Feature request
We need package.json
option to disable webpack’s polyfills. Something like browser
but for node
options.
I am JS library author. I have this code in my library:
if (typeof setImmediate !== 'undefined') {
setImmediate(action);
} else {
setTimeout(action, 1);
}
Most of my users will use Webpack and it will insert unnecessary 2 KB polyfill.
What is the expected behavior?
I see two options:
- Do not insert
setImmediate
polyfill ontypeof setImmediate !== 'undefined'
wrap. - Or read
node
config from library’spackage.json
What is motivation or use case for adding/changing the behavior?
Performance is important.
How should this be implemented in your opinion?
Have no idea
Are you willing to work on this yourself?
I can try
You can disable this behavior by adding this to your config:
We don’t have such option. Actually in my opinion library developers should not take care of polyfills. That’s a job for the application developer. They can decide if a polyfill is needed, but you can add a note to your documentation.
But if you still want to opt-out. webpack only cares about free-vars. If you access the property from the global object it won’t include a polyfill: