Skip to content

Commit a06e08f

Browse files
test: make the deferred priority case require the priority queue
The case passes a priority to `__webpack_require__.O` but never asked for `hasChunkPriority`, so it was served the insertion-order queue and its assertion held either way. It now requests the flag and defers a loaded odd priority behind a blocked lower one, which insertion order runs instead.
1 parent 0f305fd commit a06e08f

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎test/configCases/runtime/on-chunks-loaded-priority/DeferredPriorityRuntimeModule.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class DeferredPriorityRuntimeModule extends RuntimeModule {
1919
return [
2020
`${order} = [];`,
2121
`${RuntimeGlobals.onChunksLoaded}(0, ["__never_loaded__"], function() { ${order}.push("blocked"); }, 0);`,
22+
`${RuntimeGlobals.onChunksLoaded}(0, [${JSON.stringify(
23+
chunk.id
24+
)}], function() { ${order}.push("odd"); }, 1);`,
2225
`${RuntimeGlobals.onChunksLoaded}(0, [${JSON.stringify(
2326
chunk.id
2427
)}], function() { ${order}.push("even"); }, 2);`

‎test/configCases/runtime/on-chunks-loaded-priority/index.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
if (global.__neverLoaded) import("./lazy");
44

55
it("should run an even-priority deferred handler without waiting for a blocked lower-priority one", () => {
6+
// The odd-priority handler is loaded but must stay deferred behind the blocked
7+
// priority 0; keeping insertion order instead would run it and record "odd".
68
expect(global.__onChunksLoadedOrder).toEqual(["even"]);
79
});

‎test/configCases/runtime/on-chunks-loaded-priority/webpack.config.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module.exports = {
1616
(chunk, set) => {
1717
set.add(RuntimeGlobals.global);
1818
set.add(RuntimeGlobals.onChunksLoaded);
19+
// Without this the queue keeps insertion order and drops the
20+
// priority these handlers pass.
21+
set.add(RuntimeGlobals.hasChunkPriority);
1922
compilation.addLazyRuntimeModule(
2023
chunk,
2124
() =>

0 commit comments

Comments
 (0)