From 78bf7ac1d61c97cdd83db2a1b47feadbc21f00dc Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Fri, 17 Nov 2017 22:13:07 +0100 Subject: [PATCH] importer is undefined for entry modules https://github.com/rollup/rollup/blob/master/src/Bundle.js#L116 --- types/rollup/index.d.ts | 2 +- types/rollup/rollup-tests.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/rollup/index.d.ts b/types/rollup/index.d.ts index 946b4f6786..b1a67c9fdc 100644 --- a/types/rollup/index.d.ts +++ b/types/rollup/index.d.ts @@ -135,7 +135,7 @@ export interface Plugin { * Returning null or undefined defers to other resolveId functions (and eventually the default resolution behavior); * returning any other falsy value signals that importee should be treated as an external module and not included in the bundle. */ - resolveId?(importee: string, importer: string): string | null | undefined | false | 0 | '' + resolveId?(importee: string, importer: string | undefined): string | null | undefined | false | 0 | '' /** A module transformer function */ transform?(this: TransformContext, source: string, id: string): string | { code: string, map: SourceMap } /** A bundle transformer function */ diff --git a/types/rollup/rollup-tests.ts b/types/rollup/rollup-tests.ts index 924e675373..078cdf5450 100644 --- a/types/rollup/rollup-tests.ts +++ b/types/rollup/rollup-tests.ts @@ -5,6 +5,12 @@ declare const console: { log(...messages: any[]): void, warn(message: string): v let cache: Bundle | undefined const plugin: Plugin = { name: 'test-plugin', + resolveId(importee, importer) { + if (importer === undefined) { + return 'custom/entry/point.js' + } + return importer.trim() + }, transform(source, id) { if (id === 'rxjs') { this.error(new Error(`Don't import this directly`))