react-with-moxy icon indicating copy to clipboard operation
react-with-moxy copied to clipboard

feat: compile all node_modules

Open satazor opened this issue 7 years ago • 5 comments

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.

satazor avatar May 05 '18 13:05 satazor

Compile everything + thread-loader:

Cold cache: ~11.8sec Cached: ~4.7sec HMR: ~1.4ms

HMR is seconds right?

hugomrdias avatar May 30 '18 15:05 hugomrdias

Yes, I will fix it.

satazor avatar May 30 '18 16:05 satazor

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.

satazor avatar May 30 '18 16:05 satazor

Actually, let's wait for babel 7 to come to merge this as well as the necessary babel changes to our modules!

satazor avatar Jul 26 '18 13:07 satazor

Reminder: add babelrc: false, to babel-loader's options

satazor avatar Sep 19 '18 10:09 satazor