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 reexports from dynamic entries across chunks #2928

Merged
merged 1 commit into from Jun 11, 2019
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
9 changes: 5 additions & 4 deletions src/Chunk.ts
Expand Up @@ -98,9 +98,7 @@ function getGlobalName(
graph.warn({
code: 'MISSING_GLOBAL_NAME',
guess: module.variableName,
message: `No name was provided for external module '${
module.id
}' in output.globals – guessing '${module.variableName}'`,
message: `No name was provided for external module '${module.id}' in output.globals – guessing '${module.variableName}'`,
source: module.id
});
return module.variableName;
Expand Down Expand Up @@ -1088,7 +1086,10 @@ export default class Chunk {
}
}
}
if (module.isEntryPoint) {
if (
module.isEntryPoint ||
module.dynamicallyImportedBy.some(importer => importer.chunk !== this)
) {
const map = module.getExportNamesByVariable();
for (const exportedVariable of map.keys()) {
this.exports.add(exportedVariable);
Expand Down
8 changes: 8 additions & 0 deletions test/function/samples/chunking-duplicate-reexport/_config.js
@@ -0,0 +1,8 @@
const assert = require('assert');

module.exports = {
description: 'handles duplicate reexports when using dynamic imports',
exports(exports) {
return exports.then(result => assert.deepStrictEqual(result, [{ answer: 42 }, { answer: 42 }]));
}
};
@@ -0,0 +1 @@
export { answer } from './lib.js';
@@ -0,0 +1 @@
export { answer } from './lib.js';
1 change: 1 addition & 0 deletions test/function/samples/chunking-duplicate-reexport/lib.js
@@ -0,0 +1 @@
export const answer = 42;
1 change: 1 addition & 0 deletions test/function/samples/chunking-duplicate-reexport/main.js
@@ -0,0 +1 @@
export default Promise.all([import('./chunk1.js'), import('./chunk2.js')]);