Skip to content

Commit 1b617c2

Browse files
perf(defer): gather the started async dependencies with a filter
1 parent 6dd1d33 commit 1b617c2

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

‎lib/runtime/MakeDeferredNamespaceObjectRuntime.js‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -290,24 +290,17 @@ class MakeOptimizedDeferredNamespaceObjectRuntimeModule extends HelperRuntimeMod
290290
]),
291291
"};",
292292
hasAsync
293-
? Template.asString([
294-
"if(isAsync) {",
295-
Template.indent([
296-
// `GatherAsynchronousTransitiveDependencies` skips a module
297-
// that is already evaluating, and evaluates the rest here.
298-
`${cst} started = [];`,
299-
"for (var j = 0; j < asyncDeps.length; j++) {",
300-
Template.indent([
301-
`${cst} dep = __webpack_module_cache__[asyncDeps[j]];`,
302-
"if (dep && (dep.evaluating || dep.evaluatingAsync)) continue;",
303-
"r(asyncDeps[j]);",
304-
"started.push(asyncDeps[j]);"
305-
]),
306-
"}",
307-
`obj[${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}] = started;`
308-
]),
309-
"}"
310-
])
293+
? // `GatherAsynchronousTransitiveDependencies` skips a module that is
294+
// already evaluating, and evaluates the rest right here.
295+
`if(isAsync) obj[${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}] = asyncDeps.filter(${runtimeTemplate.basicFunction(
296+
"id",
297+
[
298+
`${cst} dep = __webpack_module_cache__[id];`,
299+
"if (dep && (dep.evaluating || dep.evaluatingAsync)) return false;",
300+
"r(id);",
301+
"return true;"
302+
]
303+
)});`
311304
: "",
312305
"return obj;"
313306
]),

0 commit comments

Comments
 (0)