Skip to content

Commit 7edcc48

Browse files
mc-zonesokra
authored andcommitted
fix: add missed __webpack_require__.e runtime while importing exist module with context
1 parent 87a3046 commit 7edcc48

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

lib/MainTemplate.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,14 @@ module.exports = class MainTemplate extends Tapable {
250250
} else if (
251251
chunk.hasModuleInGraph(m =>
252252
m.blocks.some(b => b.chunkGroup && b.chunkGroup.chunks.length > 0)
253-
)
253+
) ||
254+
chunk
255+
.getModules()
256+
.some(m =>
257+
m.dependencies.some(
258+
dep => dep.type && dep.type.startsWith("import()")
259+
)
260+
)
254261
) {
255262
// There async blocks in the graph, so we need to add an empty requireEnsure
256263
// function anyway. This can happen with multiple entrypoints.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default "initialModuleDefault";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
it("should resolve when import existed chunk (#8626)", function(done) {
2+
require.context("./dir-initial/");
3+
const fileName = "initialModule";
4+
import(`./dir-initial/${fileName}`).then(({default:m}) => {
5+
expect(m).toBe("initialModuleDefault");
6+
done();
7+
}).catch(done);
8+
});

0 commit comments

Comments
 (0)