Pass all attributes of old tap with only overidden fn

This commit is contained in:
Mark Molinaro 2022-02-12 17:18:29 -08:00
parent 2279c5a210
commit f63045c686
2 changed files with 25 additions and 5 deletions

View File

@ -343,7 +343,8 @@ const interceptAllJavascriptModulesPluginHooks = (compilation, tracer) => {
};
const makeInterceptorFor = (instance, tracer) => hookName => ({
register: ({ name, type, context, fn }) => {
register: tapInfo => {
const { name, type, fn } = tapInfo;
const newFn =
// Don't tap our own hooks to ensure stream can close cleanly
name === pluginName
@ -354,9 +355,7 @@ const makeInterceptorFor = (instance, tracer) => hookName => ({
fn
});
return {
name,
type,
context,
...tapInfo,
fn: newFn
};
}

View File

@ -13,6 +13,7 @@ describe("Profiling Plugin", function () {
const webpack = require("../");
const outputPath = path.join(__dirname, "js/profilingPath");
const finalPath = path.join(outputPath, "events.json");
let counter = 0;
rimraf(outputPath, () => {
const startTime = process.hrtime();
const compiler = webpack({
@ -24,7 +25,27 @@ describe("Profiling Plugin", function () {
plugins: [
new webpack.debug.ProfilingPlugin({
outputPath: finalPath
})
}),
{
apply(compiler) {
const hook = compiler.hooks.make;
[
{ stage: 0, order: 1 },
{ stage: 1, order: 2 },
{ stage: -1, order: 0 }
].forEach(({ stage, order }) => {
hook.tap(
{
name: "RespectStageCheckerPlugin",
stage
},
() => {
expect(counter++).toBe(order);
}
);
});
}
}
],
experiments: {
backCompat: false