react-with-moxy
react-with-moxy copied to clipboard
feat: compile all node_modules
The future is to run babel through every code, including node_modules:
- Many authors are publishing uncompiled code into npm
- It doesn't make sense to compile at the lib level because we don't know in which context it will be used. For instance, we might compile a library down to ES5 but it might be used in app that only targets green browsers, making the bundle unnecessary larger (or vice-versa).
You may read more here: https://github.com/parcel-bundler/parcel/pull/559#discussion_r161926651
The babel-loader has a very good cache for sometime now, making compiling everything really fast.
create-react-app will be compiling everything in their next major version too.
Here are some benchmarks:
Compile just src/:
- Cold cache: ~4.6sec
- Cached: ~3.8sec
- HMR: ~0.4sec
Compile everything:
- Cold cache: ~15.2sec
- Cached: ~4.7sec
- HMR: ~0.4sec
Compile everything + thread-loader:
- Cold cache: ~11.8sec
- Cached: ~4.7sec
- HMR: ~1.4sec
Based on these results, I've chosen to go without thread-loader because HMR becomes much slower.
Compile everything + thread-loader:
Cold cache: ~11.8sec Cached: ~4.7sec HMR: ~1.4ms
HMR is seconds right?
Yes, I will fix it.
After merging this, we should work on our babel config to reduce the scope of it to just transpile non-standard JS stuff, like jsx.
Actually, let's wait for babel 7 to come to merge this as well as the necessary babel changes to our modules!
Reminder: add babelrc: false, to babel-loader's options