Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making babel node_modules transpilation better #15213

Closed
wardpeet opened this issue Jun 28, 2019 · 5 comments
Closed

Making babel node_modules transpilation better #15213

wardpeet opened this issue Jun 28, 2019 · 5 comments
Assignees
Labels
topic: webpack/babel Webpack or babel

Comments

@wardpeet
Copy link
Contributor

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.

@angeloashmore
Copy link
Contributor

angeloashmore commented Sep 19, 2019

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. 👍

@jasonsoden
Copy link

jasonsoden commented Oct 22, 2019

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?

@thomasMary
Copy link

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

@manekinekko
Copy link

@thomasMary this seems to be a workaround: #15190 (comment)

@danabrit danabrit added topic: webpack/babel Webpack or babel and removed effort: low labels May 28, 2020
@wardpeet
Copy link
Contributor Author

wardpeet commented Sep 8, 2020

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

```shell
npm install gatsby-plugin-remove-dependency-transpilation
```

## Configure

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: webpack/babel Webpack or babel
Projects
None yet
Development

No branches or pull requests

7 participants