speed-measure-webpack-plugin icon indicating copy to clipboard operation
speed-measure-webpack-plugin copied to clipboard

fix make sure maintain the same referential equality even after using proxy

Open tanhauhau opened this issue 5 years ago • 1 comments

Fixes https://github.com/stephencookdev/speed-measure-webpack-plugin/issues/118

html-webpack-plugin's hook relies on referential equality of compilation instance. (see https://github.com/jantimon/html-webpack-plugin/blob/master/lib/hooks.js#L77-L85)

Currently, creating a new proxy every time breaks that referential equality.

This fix uses WeakMap to make sure to reuse the same proxy when passing the same compilation instance.

tanhauhau avatar Nov 26 '20 07:11 tanhauhau

Thanks for raising this @tanhauhau!

I've just checked this out locally — unfortunately I don't think it works fully as expected :( You can see it's breaking some of the functional-tests, e.g. v3-stats

The reason why is because the way this sets up a global wrap of each object, it means e.g. once a Compiler is wrapped for e.g. StatsPlugin, the same Compiler proxy gets used for e.g. DefinePlugin, and any work at all done by the Compiler is then attributed to the StatsPlugin, even if it's being done by DefinePlugin

This is a bit of an interesting problem 🤔 I'm not entirely sure off the top of my head how to fix. I'll give it some thought, but let me know if you have any ideas!

stephencookdev avatar Jan 23 '21 15:01 stephencookdev