Skip to content

Commit

Permalink
fix: add missed __webpack_require__.e runtime while importing exist m…
Browse files Browse the repository at this point in the history
…odule with context
  • Loading branch information
mc-zone authored and sokra committed Feb 6, 2019
1 parent 87a3046 commit 7edcc48
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/MainTemplate.js
Expand Up @@ -250,7 +250,14 @@ module.exports = class MainTemplate extends Tapable {
} else if (
chunk.hasModuleInGraph(m =>
m.blocks.some(b => b.chunkGroup && b.chunkGroup.chunks.length > 0)
)
) ||
chunk
.getModules()
.some(m =>
m.dependencies.some(
dep => dep.type && dep.type.startsWith("import()")
)
)
) {
// There async blocks in the graph, so we need to add an empty requireEnsure
// function anyway. This can happen with multiple entrypoints.
Expand Down
@@ -0,0 +1 @@
export default "initialModuleDefault";
8 changes: 8 additions & 0 deletions test/cases/chunks/import-context-exist-chunk/index.js
@@ -0,0 +1,8 @@
it("should resolve when import existed chunk (#8626)", function(done) {
require.context("./dir-initial/");
const fileName = "initialModule";
import(`./dir-initial/${fileName}`).then(({default:m}) => {
expect(m).toBe("initialModuleDefault");
done();
}).catch(done);
});

0 comments on commit 7edcc48

Please sign in to comment.