fix: add missed __webpack_require__.e runtime while importing exist module with context

This commit is contained in:
mc-zone 2019-01-20 19:39:51 +08:00 committed by Tobias Koppers
parent 87a3046eb7
commit 7edcc480db
3 changed files with 17 additions and 1 deletions

View File

@ -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.

View File

@ -0,0 +1 @@
export default "initialModuleDefault";

View File

@ -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);
});