Merge pull request #15536 from webpack/fix/issue-15518

fix allDeps list
This commit is contained in:
Tobias Koppers 2022-03-28 09:52:38 +02:00 committed by GitHub
commit 129477d11d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View File

@ -1104,9 +1104,13 @@ module.exports = webpackEmptyAsyncContext;`;
)
);
const set = new Set();
const allDeps = /** @type {ContextElementDependency[]} */ (
this.dependencies.concat(this.blocks.map(b => b.dependencies[0]))
);
const allDeps =
this.dependencies.length > 0
? /** @type {ContextElementDependency[]} */ (this.dependencies).slice()
: [];
for (const block of this.blocks)
for (const dep of block.dependencies)
allDeps.push(/** @type {ContextElementDependency} */ (dep));
set.add(RuntimeGlobals.module);
set.add(RuntimeGlobals.hasOwnProperty);
if (allDeps.length > 0) {

View File

@ -0,0 +1 @@
export const log = 1;

View File

@ -0,0 +1,13 @@
async function dynamic_import(dir, name) {
if (dir === "a") {
return import(
/* webpackChunkName: "a" */
/* webpackMode: "lazy-once" */
`./dynamic_a/${name}.js`);
}
throw new Error();
}
it("should compile and run", async () => {
await dynamic_import("a", "module_a1");
});