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.

Invalid warning for not declaring 'corejs' option when using 'useBuiltIns': 'false'

See original GitHub issue

Bug Report

  • I would like to work on a fix!

Current Behavior When using @babel/preset-env and setting useBuiltIns: 'false' and not declaring a corejs option, the following warning occurs:

WARNING: We noticed you’re using the useBuiltIns option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the corejs option.\n" + You should also be sure that the version you pass to the corejs option matches the version specified in your package.json’s dependencies section. If it doesn’t, you need to run one of the following commands: npm install --save core-js@2 npm install --save core-js@3 yarn add core-js@2 yarn add core-js@3

First, I don’t know if this should be considered a bug, because the problem occurs only when setting the useBuiltIns option to the string 'false' and not false. But if you set it accidentaly to a string value I think It should behave the same as when setting it to a boolean one.

Expected behavior/code The warning should not occur.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  presets: [
    "@babel/env",
    {
      useBuiltIns: "false"
    }
  ]
}

Environment

  • Babel version: 7.9.0
  • Babel preset-env version: 7.9.0
  • Node/npm version: 10.17.0
  • OS: Ubuntu 18.04.3 LTS
  • Monorepo: [e.g. yes/no/Lerna]
  • How you are using Babel: [loader]

Possible Solution Upon inspecting the @babel/preset-env source code, in the file normalize-options.js in the function normalizeCoreJSOption the following check is used

if (useBuiltIns && corejs === undefined) {

Using a more thorough check for useBuiltIns will fix the warning.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JMarkoskicommented, Apr 3, 2020

@JLHwung Yes, I will submit a PR. Also, the same thing should be done with https://github.com/babel/babel/blob/94447135c75a19da867f2e6a8906ce0a7e8f1ed4/packages/babel-preset-env/src/normalize-options.js#L171

I will add a fix for that in the PR as well. Thanks.

1reaction
nicolo-ribaudocommented, Mar 29, 2020

We should throw an error about "false" not being a valid value instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does this error mean? With `useBuiltIns` option ...
Getting the same issue. Resolved it by installing core-js as a top level dependency and then adding it as an option to .babelrc...
Read more >
babel/preset-env
Enable transformation of ES module syntax to another module type. Note that cjs is just an alias for commonjs . Setting this to...
Read more >
Error in using Cornerstone 3.4.1 starting local webserver ...
WARNING : We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is...
Read more >
WARNING: We noticed you're using the `useBuiltIns` option ...
WARNING (@babel/preset-env): We noticed you're using the `useBuiltIns` option without declaring a core-js version.
Read more >
babel-loader
You can pass options to the loader by using the options property: ... of the loader in the webpack config (which is not...
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