Skip to content

Commit 4aed273

Browse files
committed
Returns 'null' from resolve id hook rather than undefined to fix compatibility issue with newest Rollup version
1 parent 29b60cb commit 4aed273

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"@wessberg/scaffold": "^1.0.18",
5353
"@wessberg/ts-config": "^0.0.41",
5454
"standard-changelog": "^2.0.11",
55-
"@wessberg/rollup-plugin-ts": "^1.1.56",
55+
"@wessberg/rollup-plugin-ts": "^1.1.57",
5656
"tslint": "^5.17.0",
5757
"prettier": "^1.18.2",
5858
"pretty-quick": "^1.11.1",

src/plugin/typescript-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,11 @@ export default function typescriptRollupPlugin(pluginInputOptions: Partial<Types
345345
* Attempts to resolve the given id via the LanguageServiceHost
346346
* @param {string} id
347347
* @param {string} parent
348-
* @returns {string | void}
348+
* @returns {string | null}
349349
*/
350-
resolveId(this: PluginContext, id: string, parent: string | undefined): string | undefined {
350+
resolveId(this: PluginContext, id: string, parent: string | undefined): string | null {
351351
// Don't proceed if there is no parent (in which case this is an entry module)
352-
if (parent == null) return undefined;
352+
if (parent == null) return null;
353353

354354
return resolveId({id, parent, cwd, options: parsedCommandLineResult.parsedCommandLine.options, moduleResolutionHost, resolveCache});
355355
},

src/util/resolve-id/resolve-id.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import {isBuiltInModule} from "../module/module-util";
44
/**
55
* Resolves an id from the given parent
66
* @param {IResolveModuleOptions} opts
7-
* @returns {string?}
7+
* @returns {string|null}
88
*/
9-
export function resolveId({id, parent, options, cwd, moduleResolutionHost, resolveCache}: IResolveModuleOptions): string | undefined {
9+
export function resolveId({id, parent, options, cwd, moduleResolutionHost, resolveCache}: IResolveModuleOptions): string | null {
1010
// Don't proceed if there is no parent (in which case this is an entry module)
11-
if (parent == null) return undefined;
11+
if (parent == null) return null;
1212

1313
// Don't attempt to load built-in modules
14-
if (isBuiltInModule(id)) return undefined;
14+
if (isBuiltInModule(id)) return null;
1515

16-
const resolveMatch = resolveCache.get({id, parent, cwd, options, moduleResolutionHost});
17-
return resolveMatch == null ? undefined : resolveMatch;
16+
return resolveCache.get({id, parent, cwd, options, moduleResolutionHost});
1817
}

0 commit comments

Comments
 (0)