Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle generating outputs with non-inlined dynamic imports after inlined ones #4589

Merged
merged 1 commit into from Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions .eslintrc.js
Expand Up @@ -15,11 +15,8 @@ module.exports = {
ignorePatterns: [
'node_modules',
'dist',
'/test',
'perf',
'!/test/*.js',
'!/test/*/*.js',
'/test/node_modules',
'/test/*/samples/**/*.*',
'!/test/*/samples/**/_config.js',
'!/test/*/samples/**/rollup.config.js'
],
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
6 changes: 2 additions & 4 deletions test/cli/node_modules_rename_me/bar/lib/config.js
@@ -1,11 +1,9 @@
const replace = require( '@rollup/plugin-replace' );
const replace = require('@rollup/plugin-replace');

module.exports = {
input: 'main.js',
output: {
format: 'cjs'
},
plugins: [
replace( { preventAssignment: true, ANSWER: 42 } )
]
plugins: [replace({ preventAssignment: true, ANSWER: 42 })]
};
@@ -1,11 +1,9 @@
const replace = require( '@rollup/plugin-replace' );
const replace = require('@rollup/plugin-replace');

module.exports = {
input: 'main.js',
output: {
format: 'cjs'
},
plugins: [
replace( { preventAssignment: true, ANSWER: 42 } )
]
plugins: [replace({ preventAssignment: true, ANSWER: 42 })]
};
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' });
});
});
13 changes: 7 additions & 6 deletions test/typescript/index.ts
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import * as rollup from './dist/rollup';

// Plugin API
Expand Down Expand Up @@ -32,24 +33,24 @@ const amdOutputOptions: rollup.OutputOptions['amd'][] = [
autoId: false
},
{
// @ts-expect-error
// @ts-expect-error for "basePath", "autoId" needs to be true
autoId: false,
basePath: '',
// @ts-expect-error
// @ts-expect-error cannot combine "id" and "basePath"
id: 'a'
},
{
// @ts-expect-error
// @ts-expect-error cannot combine "id" and "autoId"
autoId: true,
// @ts-expect-error
// @ts-expect-error cannot combine "id" and "autoId"
id: 'a'
},
{
basePath: '',
// @ts-expect-error
// @ts-expect-error cannot combine "id" and "basePath"
id: 'a'
},
// @ts-expect-error
// @ts-expect-error needs "autoId" for "basePath"
{
basePath: ''
}
Expand Down