From 0a1ceb0e94f36423726bf788c15ef663f7c2e1c3 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 2 Feb 2019 20:07:54 -0500 Subject: [PATCH] only mark dynamic import as replaced if it was completely overwritten --- src/ast/nodes/Import.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ast/nodes/Import.ts b/src/ast/nodes/Import.ts index 779e77c2cff..7f743f21708 100644 --- a/src/ast/nodes/Import.ts +++ b/src/ast/nodes/Import.ts @@ -47,7 +47,7 @@ export default class Import extends NodeBase { private resolutionNamespace: string; private resolutionInterop: boolean; - private rendered: boolean; + private replaced: boolean; include() { this.included = true; @@ -56,14 +56,14 @@ export default class Import extends NodeBase { initialise() { this.included = false; - this.rendered = false; + this.replaced = false; this.resolutionNamespace = undefined; this.resolutionInterop = false; this.context.addDynamicImport(this); } renderFinalResolution(code: MagicString, resolution: string) { - if (this.included && !this.rendered) { + if (this.included && !this.replaced) { code.overwrite(this.parent.arguments[0].start, this.parent.arguments[0].end, resolution); } } @@ -78,7 +78,7 @@ export default class Import extends NodeBase { `Promise.resolve().then(function${_}()${_}{${_}return ${this.resolutionNamespace}${s}${_}})` ); - this.rendered = true; + this.replaced = true; return; } @@ -91,8 +91,6 @@ export default class Import extends NodeBase { const rightMechanism = (this.resolutionInterop && importMechanism.interopRight) || importMechanism.right; code.overwrite(this.parent.arguments[0].end, this.parent.end, rightMechanism); - - this.rendered = true; } }