Open theKashey opened 3 years ago
Thanks for doing such a thorough investigation @theKashey!
FWIW the preset is less effective when applied per-module because it can't apply cross-module knowledge when removing polyfills or helper functions. It does produce useless error stacks though, that's for sure.
The early exit issue is actually just because you're applying this to a non-module file - switching Babel-loader's options to include sourceType:'unambiguous'
would fix that.
I'll try to look into the per-library errors you uncovered. Rough edges like these are why I sat on this code for so long :P
Trying to apply this preset in different forms and it throws different errors.
The configuration which works:
Trying to compile on "result bundles" results in not very replicable errors (firstly in remove-polyfills), so I've ended applying this preset via webpack loader per every file. Just a few caused an error.
react-router-dom@5.2.0 - react-router-dom/esm/react-router-dom.js
react-redux@7.1.0 - react-redux/es/connect/selectorFactory.js
connected-react-router@6.5.2 - connected-react-router/esm/selectors.js
lodash-es@4.17.15
core-js@2.6.10
react-helmet-async@0.2.0
interesting failure found at intersection-observer@0.7.0 the code
caused an error
After fixing all problems (removing plugins causing errors and changing some scripts) 28kb were removed from a total 1.5mb bundle. Size comparison can be found at https://gist.github.com/theKashey/45050f6fc341e0e324ac4fbee46a5c72