Skip to content

Commit a12b63a

Browse files
authored
Merge pull request #15379 from markjm/markjm/fix-15378
Pass all attributes of old tap with only overidden fn
2 parents 89c92bf + f63045c commit a12b63a

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

lib/debug/ProfilingPlugin.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ const interceptAllJavascriptModulesPluginHooks = (compilation, tracer) => {
343343
};
344344

345345
const makeInterceptorFor = (instance, tracer) => hookName => ({
346-
register: ({ name, type, context, fn }) => {
346+
register: tapInfo => {
347+
const { name, type, fn } = tapInfo;
347348
const newFn =
348349
// Don't tap our own hooks to ensure stream can close cleanly
349350
name === pluginName
@@ -354,9 +355,7 @@ const makeInterceptorFor = (instance, tracer) => hookName => ({
354355
fn
355356
});
356357
return {
357-
name,
358-
type,
359-
context,
358+
...tapInfo,
360359
fn: newFn
361360
};
362361
}

test/ProfilingPlugin.test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("Profiling Plugin", function () {
1313
const webpack = require("../");
1414
const outputPath = path.join(__dirname, "js/profilingPath");
1515
const finalPath = path.join(outputPath, "events.json");
16+
let counter = 0;
1617
rimraf(outputPath, () => {
1718
const startTime = process.hrtime();
1819
const compiler = webpack({
@@ -24,7 +25,27 @@ describe("Profiling Plugin", function () {
2425
plugins: [
2526
new webpack.debug.ProfilingPlugin({
2627
outputPath: finalPath
27-
})
28+
}),
29+
{
30+
apply(compiler) {
31+
const hook = compiler.hooks.make;
32+
[
33+
{ stage: 0, order: 1 },
34+
{ stage: 1, order: 2 },
35+
{ stage: -1, order: 0 }
36+
].forEach(({ stage, order }) => {
37+
hook.tap(
38+
{
39+
name: "RespectStageCheckerPlugin",
40+
stage
41+
},
42+
() => {
43+
expect(counter++).toBe(order);
44+
}
45+
);
46+
});
47+
}
48+
}
2849
],
2950
experiments: {
3051
backCompat: false

0 commit comments

Comments
 (0)