Gatsby: Making babel node_modules transpilation better

Created on 28 Jun 2019  路  5Comments  路  Source: gatsbyjs/gatsby

Summary

Improve how we handle node_modules with babel.

We have a few options to explore.
1) Use a smaller babelrc file for node_modules
We currently use our babel-preset-gatsby which does lots of things which are probably not needed on node_modules. We probably want to run babel-preset-env to make bundles compatible.
2) only run babel on build-javascript stage. Currently, we run it also in node land, which is probably something we don't need. We want our web bundle to be working with IE11, ...
3) allow disable of node_modules with a plugin, gatsby-plugin-babel-no-nodemodules. This plugin will remove our node_modules runner from gatsby.

Motivation

It seems like people are having issues with our latest Gatsby change. Transpiling node_modules with babel. It may cause slow builds or memory issues.

webpacbabel

Most helpful comment

Any progress on this? Transpiling node_modules makes sense to perform by default, but having a way to opt out completely would be helpful. Something like Option 3 seems like the best option.

As evident in other issues, build times have more than doubled as a result of this change (~5 minutes to ~12 minutes our case). In addition to higher costs for those paying by the second, we're actually seeing builds time out on Netlify occasionally.

I'm happy to help given some direction. 馃憤

All 5 comments

Any progress on this? Transpiling node_modules makes sense to perform by default, but having a way to opt out completely would be helpful. Something like Option 3 seems like the best option.

As evident in other issues, build times have more than doubled as a result of this change (~5 minutes to ~12 minutes our case). In addition to higher costs for those paying by the second, we're actually seeing builds time out on Netlify occasionally.

I'm happy to help given some direction. 馃憤

I'd also like an update on this. We're stuck on gatsby v2.10.5 because 2.11 "enabled babel-loader for all dependencies" which completely killed our build times. Gatsby used to build so fast. How do we opt-out of the new bug feature?

Any update or workaround? We're too stuck on Gatsby v2.10.5

@thomasMary this seems to be a workaround: https://github.com/gatsbyjs/gatsby/issues/15190#issuecomment-506489552

I've created gatsby-plugin-remove-dependency-transpilation so you can disable the step. Note that we made the step a little bit better from 2.24.0 but if you want to omit it as a whole you can use my plugin. Note this could break your node_modules if they aren't transpiled correctly

````

gatsby-plugin-remove-dependency-transpilation

Removes the dependency transpilation step from Gatsby.

Install

npm install gatsby-plugin-remove-dependency-transpilation

Configure

// In your gatsby-config.js
plugins: [`gatsby-plugin-remove-dependency-transpilation`];

````

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andykais picture andykais  路  3Comments

signalwerk picture signalwerk  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

totsteps picture totsteps  路  3Comments

dustinhorton picture dustinhorton  路  3Comments