importer is undefined for entry modules

https://github.com/rollup/rollup/blob/master/src/Bundle.js#L116
This commit is contained in:
Christian Svensson
2017-11-17 22:13:07 +01:00
parent 51208357b1
commit 78bf7ac1d6
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -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 */
+6
View File
@@ -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`))