Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

feat: compile all node_modules #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

satazor
Copy link
Contributor

@satazor satazor commented May 5, 2018

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: parcel-bundler/parcel#559 (comment)

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.

The future is to run babel through every code, including node_modules. You may read more here: parcel-bundler/parcel#559 (comment)
The `babel-loader` has a very good cache for sometime now, making compiling everything really fast.
`create-react-app` will be doing the same in their next major version.
@@ -76,8 +75,6 @@ module.exports = ({ minify } = {}) => {
plugins: [
// Necessary for import() to work
require.resolve('babel-plugin-dynamic-import-node'),
// <3 hot module reload
isDev ? require.resolve('react-hot-loader/babel') : null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react-hot-loader is not necessary on the server 😓

@hugomrdias
Copy link

Compile everything + thread-loader:

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

HMR is seconds right?

@satazor
Copy link
Contributor Author

satazor commented May 30, 2018

Yes, I will fix it.

@satazor
Copy link
Contributor Author

satazor commented May 30, 2018

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
Copy link
Contributor Author

satazor commented Jul 26, 2018

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

@satazor
Copy link
Contributor Author

satazor commented Sep 19, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants