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

Making this package compatible with Webpack v5 #194

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rising-entropy
Copy link

This PR resolves the deprecation warning with regards to the normal-module-loader, invoking the loader from it's new location.

Also, adding an option of passing an array of strings of names of all the plugins that it should refrain from tracking.
A little background about this:

So the basic way of SMP plugin to measure plugin-timings is that it wraps each plugin into a Wrapper Plugin which has hooks to measure time before and after completion.
Since plugins like the MiniCSSExtractPlugin throw can exception when the invoker is not from the main MiniCSSExtractPlugin class, we need to exclude it from wrapping within the plugin.

Now here's how you can do this with this PR.
Alongside just sending the parameter of config in smp.wrap(config), you now also share the names of the plugins that usually fail the build or start of the dev server (Example: ReactRefreshPlugin while we are using SMP plugin in react dev server).
So the syntax would be: smp.wrap(config, ['MiniCSSExtractPlugin', 'ReactRefreshPlugin'])

And voila!
You can now use the package in your code without worrying that it would fail the builds or blow the code at runtime.

I don't know if and when this would be integrated in the package, so I'll also be making a separate package of this soon.

Hope it helps :)

@@ -149,7 +149,9 @@ const wrapHooks = (orig, pluginName, smp, type) => {
};

const wrapped = Object.keys(hooks).reduce((acc, method) => {
acc[method] = genProxy(method);
if (method != "normalModuleLoader")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is too hardcoded, now it is arguing with additionalChunkAssets
so I changed it to be like

if (hooks[method])
  acc[method] = genProxy(method);

@jlaustill
Copy link

It would be super helpful to get this merged for me today :)

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.

None yet

3 participants