Skip to content

Commit

Permalink
Handle generating non-inlined imports after inlined ones
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jul 27, 2022
1 parent 3be1609 commit 4fce640
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
15 changes: 6 additions & 9 deletions .eslintrc.js
Expand Up @@ -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: [
{
Expand Down
1 change: 1 addition & 0 deletions src/ast/nodes/ImportExpression.ts
Expand Up @@ -102,6 +102,7 @@ export default class ImportExpression extends NodeBase {
accessedGlobalsByScope: Map<ChildScope, Set<string>>
): void {
const { format } = options;
this.inlineNamespace = null;
this.resolution = resolution;
const accessedGlobals = [...(accessedImportGlobals[format] || [])];
let helper: string | null;
Expand Down
14 changes: 14 additions & 0 deletions test/misc/misc.js
Expand Up @@ -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' });
});
});

0 comments on commit 4fce640

Please sign in to comment.