Open moretti opened 8 years ago
Do you have any examples of projects that are structured this way that we can look at?
I created the following example:
https://github.com/moretti/webpack-polyfills-on-demand
If you clone it and run npm start
you will notice that polyfills for fetch
and Promise
are loaded on demand.
For example, Safari 8 will request 2.bundle.js
because it doesn't have a native window.fetch
implementation.
It would be nice if we could optionally avoid to polyfill
Promise
andwindow.fetch
. The latest versions of Firefox, Chrome and Opera natively support Promises andwindow.fetch
, so it seems unnecessary. I recently started loading polyfills on demand with webpack in order to reduce the size of the main bundle.I'm proposing the following structure
marty.js
(or maybemarty-without-polyfills.js
): equivalent to the current file, but without polyfillspolyfills.js
: a file containing all polyfillsindex.js
(or maybemarty-with-polyfills.js
): the entry point of the project with the old behaviorIn this way it would be possible not to load polyfills by creating an alias. With webpack:
With browserify: