gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

Gatsby should merge .babelrc / babel.config.js to his preset config? #21157

Closed slorber closed 4 years ago

slorber commented 4 years ago

Description

This is a potential bug that I reported on Twitter for which @sidharthachatterjee told me to open an issue: https://twitter.com/chatsidhartha/status/1224192160464982016

Adding an empty .babelrc or babel.config.js at the root of the project makes everything fail, like if the babel plugin wasn't applied property.

I noticed that on my website, based on Novela theme, which is a bit particular, as it is both a Gatsby/Expo app to simplify cross-platform code sharing (didn't want to create a monorepo as RN bundler does not follow symlinks)

https://github.com/slorber/sebastienlorber.com/tree/gatsby-rnw-v3-expo

Was able to reproduce in the official blog theme too.

Steps to reproduce

gatsby new my-themed-blog https://github.com/gatsbyjs/gatsby-starter-blog-theme
cd my-themed-blog
yarn install
echo "{}" > .babelrc
yarn start

Expected result

It should work fine, gatsby babel preset should still be applied

Actual result

Various errors

In theme blog, it's basic transpilation errors.

In my website I don't get transpilation errors (because the Expo plugin does transpile the Gatsby code) but it seems like there are query/data problems.

image

Environment

 ~/Desktop/projects/my-themed-blog  master ?  yarn gatsby info --clipboard                                                                                                       130 ↵  4139  11:39:32
yarn run v1.21.1
$ /Users/sebastienlorber/Desktop/projects/my-themed-blog/node_modules/.bin/gatsby info --clipboard

  System:
    OS: macOS 10.15.2
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.0 - /var/folders/x0/4p0fybvn02d290vrr9qw5wyh0000gn/T/yarn--1580726374658-0.12296792029289838/node
    Yarn: 1.21.1 - /var/folders/x0/4p0fybvn02d290vrr9qw5wyh0000gn/T/yarn--1580726374658-0.12296792029289838/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 79.0.3945.130
    Firefox: 68.0.1
    Safari: 13.0.4
  npmPackages:
    gatsby: ^2.19.7 => 2.19.7
    gatsby-theme-blog: ^1.2.35 => 1.2.35
  npmGlobalPackages:
    gatsby: 2.13.41

✨  Done in 2.99s.
github-actions[bot] commented 4 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

github-actions[bot] commented 4 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

wardpeet commented 4 years ago

@slorber I don't immediately see how we can fix this. We don't know if you want to merge or want to override. You can include our babel-preset-gatsby yourself.

slorber commented 4 years ago

sure, I do this, just reported because @sidharthachatterjee asked me on twitter :)

slorber commented 4 years ago

@wardpeet @sidharthachatterjee I'd like to reopen this issue.

I've tried to add this on an existing site that worked (based on Novela theme)

module.exports = function(api) {
  return {
    presets: [
      [
        'babel-preset-gatsby',
        {
          targets: {
            browsers: ['>0.25%', 'not dead'],
          },
        },
      ],
    ],
  };
};

Is this normal it breaks my site?

image

Does it mean that plugin babel configs are not applied anymore?

What's the purpose of having a local babel config? Who uses this and how exactly?


I really need a .babelrc at the root of my project, yet when I have one, I'm unable to make my siote work.

Is there an option to tell gatsby to not use the babel config file, even if there is one? Or an ability to configure the configFile path? I would be very interested to have that.

github-actions[bot] commented 4 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

github-actions[bot] commented 4 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

wardpeet commented 4 years ago

@slorber sorry I didn't see this message. have you installed the preset locally as well?

slorber commented 4 years ago

Hi,

Honnestly I don't remember, I've found a workaround to achieve my goal since then :)

LekoArts commented 4 years ago

@slorber Are you fine with closing this then? :)