question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

babel.config.js not picked up since 2.13.30 (regression)

See original GitHub issue

Description

Since updating Gatsby to 2.13.30 (or newer), I can no longer use my own custom babel.config.js. babel.config.js is the new, better way to configure Babel. See Babel config files docs.

Steps to reproduce

I’ve created a minimal repro here: https://github.com/ahfarmer/gatsby-babel-config-issue To create the repro I just ran gatsby new, then added babel.config.js and deleted some unnecessary files.

Here’s how you can reproduce easily:

git clone https://github.com/ahfarmer/gatsby-babel-config-issue
cd gatsby-babel-config-issue
yarn install
gatsby develop

Note that the console.log line that I have placed in babel.config.js does NOT print out. There are other ways you could show that babel.config.js is not being considered, but I think this is the easiest one.

Expected result

We should see this line printed to the console: "👍 babel.config.js is being used"

Actual result

babel.config.js is not used for some reason. The code within does not run and the log statement doesn’t print out.

Workaround

yarn add gatsby@2.13.27
yarn develop

With this older version of Gatsby, you will see that babel.config.js is being used.

Related Issues

Basically the same issue reported here: https://github.com/birkir/gatsby-source-graphql-universal/issues/3

I opened this issue to show that it is not an issue with gatsby-source-graphql-universal, which I am not using.

They are reporting that this change caused the issue: https://github.com/gatsbyjs/gatsby/pull/15875

Environment

  System:
    OS: macOS 10.14.5
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.3 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Languages:
    Python: 3.6.8 - /anaconda3/bin/python
  Browsers:
    Chrome: 75.0.3770.142
    Firefox: 68.0.1
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.13.39 => 2.13.39 
    gatsby-image: ^2.2.6 => 2.2.6 
    gatsby-plugin-manifest: ^2.2.4 => 2.2.4 
    gatsby-plugin-offline: ^2.2.4 => 2.2.4 
    gatsby-plugin-react-helmet: ^3.1.2 => 3.1.2 
    gatsby-source-filesystem: ^2.1.6 => 2.1.6 
  npmGlobalPackages:
    gatsby-cli: 2.7.17

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
wardpeetcommented, Jul 30, 2019

I disabled it because people should use .babelrc files instead. babel.config.js is used for library owners or in the root but shouldn’t be used on a project level.

https://babeljs.io/docs/en/config-files#project-wide-configuration

0reactions
wardpeetcommented, Aug 1, 2019

https://github.com/gatsbyjs/gatsby/pull/16205#issuecomment-516320418

Oh gatsby is always used as a “root” project and I don’t see an immediate use case to programmatically add/remove config to babel for a gatsby project. Configs are mostly static and might change depending on build (production) or develop (development).

If you want to share configs between projects you can use a babel.config.js in your root. For themes, this might be a good solution 🤔.

babeljs.io/docs/en/configuration#what-s-your-use-case

Let me revert the comment as it might not be the best idea to disable it. Thanks @m-allanson for letting me re-iterating

Read more comments on GitHub >

github_iconTop Results From Across the Web

Config Files - Babel.js
babelrc files in node_modules dependencies would be detected, even though the plugins and presets inside they were generally not installed, and may not...
Read more >
npx babel not reading configuration from babel.config.js
When running npx babel index.js from the command line, I was hoping I would see my babel configurations being applied from babel.config.js.
Read more >
ember-cli-babel - npm
js in ember-cli >= 2.13). Running non-ES6 code through the transpiler shouldn't change the code at all (likely just a format change if...
Read more >
Why You Should Replace Babel with SWC in Next.js
If a custom Babel configuration file is present within your project, Next.js will automatically switch to your existing Babel configuration. This custom Babel...
Read more >
ESLint: Parsing error: No Babel config file detected ... - YouTrack
Since moving from the deprecated babel-eslint to the recommended @babel/eslint-parser my colleagues using WebStorm and IntelliJ IDEA started getting the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found