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; } }