gatsby icon indicating copy to clipboard operation
gatsby copied to clipboard

Browserslist config not working for old versions browsers

Open lararthur opened this issue 2 years ago โ€ข 1 comments

Preliminary Checks

  • [X] This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
  • [X] This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions

Description

Our team has been trying to achieve a maximum range of browsers support through polyfills, generated by babel and configurated by browserslist in .babelrc file, when using babel-preset-gatsby.

The goal is to make our application not break or accuse errors when using rest/spread operators. But the outcome is always an Unexpected token ... in the console when using an old Chrome (v 50.0).

The config at .babelrc follows:

{
  "presets": [
    [
      "babel-preset-gatsby",
      {
        "targets": {
          "browsers": ["cover 100% in BR"]
        }
      }
    ]
  ]
}

Although trying different approaches of configuration like:

  • "browserslist": ["cover 100% in BR"] on package.json
  • cover 100% in BR in a .browserslistrc file
  • each config separately, combining two of each possible combinations, or all together.

Seaching in the application, we still have some remaining reference to this [">0.25%", "not dead"] browserslist config such as:

  • getBrowsersList function, on /node_modules/gatsby/dist/utils/browserslist.js
  • browserslist.js.map file on /node_modules/gatsby/dist/utils/browserslist.js.map

It seems that there is a problem with the fallbacks when setting a custom range of browsers, since the default config always remains.

Reproduction Link

https://codesandbox.io/s/cranky-fire-lv2fre

Steps to Reproduce

  1. install babel-preset-gatsby as a dev dependency
  2. create .babelrc file
  3. modify target.browsers to ["cover 100% in BR"]
  4. perform a gatsby build
  5. serve the public folder ...

Expected Result

Application running in Chrome v50.0 without console errors.

Actual Result

Chrome still pointing an Unexpected token ... error due to usage of the spread operator.

Most likely, polyfills are still being generated considering the [">0.25%", "not dead"] config.

Environment

System:
    OS: macOS 12.6
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Shell: 3.2.57 - /bin/sh
  Binaries:
    Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v14.15.4/bin/yarn
    npm: 8.1.4 - ~/.nvm/versions/node/v14.15.4/bin/npm
  Browsers:
    Chrome: 106.0.5249.119
    Firefox: 104.0.2
    Safari: 16.0
  npmPackages:
    gatsby: ^4.24.4 => 4.24.4 
  npmGlobalPackages:
    gatsby-cli: 4.24.0

Config Flags

no flags

lararthur avatar Oct 24 '22 15:10 lararthur

If you will use opera gx

Malatisahoo avatar Oct 25 '22 14:10 Malatisahoo

Please try this again with the latest Gatsby (npm install gatsby@next)

LekoArts avatar Jan 17 '23 14:01 LekoArts

Hiya!

This issue has gone quiet. Spooky quiet. ๐Ÿ‘ป

We get a lot of issues, so we currently close issues after 60 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. 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] avatar Feb 07 '23 00:02 github-actions[bot]

@lararthur , were you able to find a fix for this? The issue still exists Unexpected token .... Looks like transpilation issue due to spread operator.

mrahils avatar Feb 13 '23 08:02 mrahils

Hiya!

This issue has gone quiet. Spooky quiet. ๐Ÿ‘ป

We get a lot of issues, so we currently close issues after 60 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. 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] avatar Mar 06 '23 00:03 github-actions[bot]

@mrahils i have nothing new on that, sorry :(

Still hoping for a good soul to come and help us

lararthur avatar Mar 30 '23 18:03 lararthur

Hiya!

This issue has gone quiet. Spooky quiet. ๐Ÿ‘ป

We get a lot of issues, so we currently close issues after 60 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. 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] avatar Apr 20 '23 12:04 github-actions[bot]

We are experiencing this issue as well, using latest version of gatsby (5.10.0). We have tried the same approach as @lararthur, varisous combinations of .babelrc, .browserslistrc and package.json.

Let me know if there is anything that I can add to make this issue easier to track down. It is currently a rather problematic issue for us.

gustavlarson avatar May 23 '23 07:05 gustavlarson

https://babeljs.io/docs/babel-plugin-transform-object-rest-spread I think this is relevant here . image

like @lararthur mentioned polyfill is not kicking in (evident from the error ).

please check if babel has the plugin installed and configured . this is the only lead I have for you guys .

808vita avatar Jun 10 '23 07:06 808vita

image

https://www.npmjs.com/package/babel-preset-gatsby

not sure if spread related package is bundled in this . (it is not listed so..)

808vita avatar Jun 10 '23 08:06 808vita

Hiya!

This issue has gone quiet. Spooky quiet. ๐Ÿ‘ป

We get a lot of issues, so we currently close issues after 60 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. 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] avatar Jun 30 '23 12:06 github-actions[bot]

Hey again!

Itโ€™s been 60 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 comment on 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! ๐Ÿ’ช๐Ÿ’œ

github-actions[bot] avatar Aug 09 '23 12:08 github-actions[bot]

Sadly this problem still persists. Although @babel/plugin-transform-object-rest-spread is not listed under babel-preset-gatsby, then @babel/preset-env is listed and it contains @babel/plugin-transform-object-rest-spread in it.

kristerlooga-bolt avatar Aug 11 '23 13:08 kristerlooga-bolt