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

Support disabling NodeSourcePlugin for web target #4976

Closed
jchip opened this issue May 31, 2017 · 4 comments
Closed

Support disabling NodeSourcePlugin for web target #4976

jchip opened this issue May 31, 2017 · 4 comments

Comments

@jchip
Copy link
Contributor

jchip commented May 31, 2017

Do you want to request a feature or report a bug?

request a feature

What is the current behavior?

The default target web automatically apply the internal NodeSourcePlugin

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

If this is a feature request, what is motivation or use case for changing the behavior?

I just found out that due to some other module we use that has something like this:

var Crypto = canUseDom ? null : require("crypto");

This cause the internal NodeSourcePlugin to include a few very large files like asn1.js and bn.js.

To make things like this surface ASAP, I'd like to be able to disable the NodeSourcePlugin completely.

First thing I tried was to set target as a function to do custom target, but the internal plugin FunctionModulePlugin is not exported. I could directly require that, but not ideal.

It'd be nice if webpack can provide a new target that's basically web without the NodeSourcePlugin.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

@sokra
Copy link
Member

sokra commented Jun 1, 2017

It's supported. See node option

@sokra sokra closed this as completed Jun 1, 2017
@jchip
Copy link
Contributor Author

jchip commented Jun 1, 2017

In that case, I think the plugin should honor the single kill switch.

I could not get this https://github.com/webpack/webpack/blob/master/lib/node/NodeSourcePlugin.js#L40 to trigger even if I set config.node.node to false.

This is looking at each lib https://github.com/webpack/webpack/blob/master/lib/node/NodeSourcePlugin.js#L74

@jchip
Copy link
Contributor Author

jchip commented Jun 1, 2017

would you like me to open a new issue for the plugin? I am happy to make the changes if we can come to an approach.

@jchip
Copy link
Contributor Author

jchip commented Jun 1, 2017

@sokra would something like this work?

updated: jchip@e8688a5

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

No branches or pull requests

2 participants