From 4fce640b83f0dc3268cddb07e42377e1bfdfd750 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Wed, 27 Jul 2022 06:08:53 +0200 Subject: [PATCH] Handle generating non-inlined imports after inlined ones --- .eslintrc.js | 15 ++++++--------- src/ast/nodes/ImportExpression.ts | 1 + test/misc/misc.js | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 6061d199bdd..b3639f49986 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,15 +13,12 @@ module.exports = { 'plugin:import/typescript' ], ignorePatterns: [ - 'node_modules', - 'dist', - '/test', - 'perf', - '!/test/*.js', - '!/test/*/*.js', - '/test/node_modules', - '!/test/*/samples/**/_config.js', - '!/test/*/samples/**/rollup.config.js' + 'node_modules/*', + 'dist/*', + '/perf/*', + '/test/**/samples/*', + '!/test/**/samples/**/_config.js', + '!/test/**/samples/**/rollup.config.js' ], overrides: [ { diff --git a/src/ast/nodes/ImportExpression.ts b/src/ast/nodes/ImportExpression.ts index 6f9d8ae4e05..8f9121ea603 100644 --- a/src/ast/nodes/ImportExpression.ts +++ b/src/ast/nodes/ImportExpression.ts @@ -102,6 +102,7 @@ export default class ImportExpression extends NodeBase { accessedGlobalsByScope: Map> ): void { const { format } = options; + this.inlineNamespace = null; this.resolution = resolution; const accessedGlobals = [...(accessedImportGlobals[format] || [])]; let helper: string | null; diff --git a/test/misc/misc.js b/test/misc/misc.js index 76132722719..6f2f27dae36 100644 --- a/test/misc/misc.js +++ b/test/misc/misc.js @@ -274,4 +274,18 @@ console.log(x); assert.strictEqual(err.name, 'Error'); } }); + + it('supports rendering es after rendering iife with inlined dynamic imports', async () => { + const bundle = await rollup.rollup({ + input: 'main.js', + plugins: [ + loader({ + 'main.js': "import('other.js');", + 'other.js': "export const foo = 'bar';" + }) + ] + }); + const first = await bundle.generate({ format: 'iife', inlineDynamicImports: true }); + const second = await bundle.generate({ format: 'es', exports: 'auto' }); + }); });