Skip to content

Commit

Permalink
fix allDeps list
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop committed Mar 16, 2022
1 parent aca885c commit b56aac4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/ContextModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions test/cases/runtime/issue-15518/dynamic_a/module_a1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

let printLog = () => console.log("module_a1");

export const log = printLog;

3 changes: 3 additions & 0 deletions test/cases/runtime/issue-15518/dynamic_a/module_a2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let printLog = async () => {
console.log("module_a2");
};
13 changes: 13 additions & 0 deletions test/cases/runtime/issue-15518/index.js
Original file line number Diff line number Diff line change
@@ -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(`${dir} directory not found`);
}

it("should compile and run", async () => {
await dynamic_import("a", "module_a1");
});

0 comments on commit b56aac4

Please sign in to comment.