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

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

Closed
andrewagain opened this issue Jul 26, 2019 · 6 comments · Fixed by #16205
Closed

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

andrewagain opened this issue Jul 26, 2019 · 6 comments · Fixed by #16205
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@andrewagain
Copy link
Contributor

andrewagain commented Jul 26, 2019

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: birkir/gatsby-source-graphql-universal#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: #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
@andrewagain andrewagain changed the title babel.config.js not picked up since 2.13.27 (regression) babel.config.js not picked up since 2.13.30 (regression) Jul 26, 2019
@andrewagain
Copy link
Contributor Author

andrewagain commented Jul 26, 2019

I tested a few different Gatsby versions to see when the problem was introduced:

2.13.29: working
2.13.30: not working
2.13.39: not working

So looks like something in 2.13.30 caused this issue.

@pieh
Copy link
Contributor

pieh commented Jul 26, 2019

/cc @wardpeet

Did this stop working only for babel.config.js file, or for .babelrc as well?

@pieh
Copy link
Contributor

pieh commented Jul 26, 2019

It does seem like

loaders.js({
...options,
configFile: false,
compact: true,
}),
( configFile: false part ) is most likely reason for this.

@wardpeet Was this setting explicitly needed?

@pieh pieh added the type: bug An issue or pull request relating to a bug in Gatsby label Jul 26, 2019
@wardpeet
Copy link
Contributor

wardpeet commented 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

@andrewagain
Copy link
Contributor Author

Let's be clear: babel.config.js is referred to in the docs as a "project-wide config". It is definitely meant to be used at the project level.

I haven't seen anything saying babel.config.js is for library owners only. Can you provide a source @wardpeet?

@wardpeet
Copy link
Contributor

wardpeet commented Aug 1, 2019

#16205 (comment)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants