Skip to content

Commit

Permalink
Handle reexports from dynamic entries across chunks (#2928)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jun 11, 2019
1 parent fb4632c commit dbe4492
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
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')]);

0 comments on commit dbe4492

Please sign in to comment.