Skip to content

Commit df25a57

Browse files
test: everything asking for one stage shares one tap
Two taps where a minimizer and a generator both ask for it, since a generator reads back what a minimizer wrote and cannot run in the same pass.
1 parent 0062a9f commit df25a57

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎test/stage-option.test.js‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,46 @@ describe("where work runs", () => {
307307
expect(getErrors(stats)).toEqual([]);
308308
expect(getWarnings(stats)).toEqual([]);
309309
});
310+
311+
it("should share one tap between everything asking for the same stage", async () => {
312+
const order = [];
313+
const transfer = Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER;
314+
315+
new MinimizerPlugin({
316+
parallel: false,
317+
minify: [
318+
asking(order, "first", transfer),
319+
asking(order, "second", transfer),
320+
],
321+
generate: {
322+
a: {
323+
implementation: asking(order, "a", transfer),
324+
type: "asset",
325+
filename: "[path][base].a",
326+
},
327+
b: {
328+
implementation: asking(order, "b", transfer),
329+
type: "asset",
330+
filename: "[path][base].b",
331+
},
332+
},
333+
}).apply(compiler);
334+
335+
const stages = tappedStages(compiler);
336+
const stats = await compile(compiler);
337+
338+
// Two taps for four: one for the minimizers and one for the generators,
339+
// which cannot share it — a generator reads what a minimizer wrote.
340+
expect(stages).toEqual([transfer, transfer]);
341+
expect(order).toEqual(["first", "second", "a", "b"]);
342+
expect(Object.keys(stats.compilation.assets).sort()).toEqual([
343+
"one.js",
344+
"one.js.a",
345+
"one.js.b",
346+
]);
347+
expect(getErrors(stats)).toEqual([]);
348+
expect(getWarnings(stats)).toEqual([]);
349+
});
310350
});
311351

312352
describe("a minimizer that asks for its own stage", () => {

0 commit comments

Comments
 (0)