Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tanhauhau
Copy link
Contributor

Fixes #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.

@stephencookdev
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when used with html-webpack-plugin@v4
2 participants