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

Fix babel useBuiltIns core-js warning #1471

Closed
1 task done
sullivanpt opened this issue Mar 22, 2019 · 12 comments
Closed
1 task done

Fix babel useBuiltIns core-js warning #1471

sullivanpt opened this issue Mar 22, 2019 · 12 comments

Comments

@sullivanpt
Copy link

  • I confirm that this is an issue rather than a question.

Bug report

When running 'vanilla' build see the following warning in the console

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.


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

Version

@vuepress/core@1.0.0-alpha.44

Steps to reproduce

$ mkdir test; cd test; npm init # accept defaults
$ npm install vuepress@next
$ echo '# Hello VuePress' > README.md
$ ./node_modules/.bin/vuepress build

What is expected?

no warnings about useBuiltIns

What is actually happening?

scary warning ;-)

actually, some additional information on how I stumbled across this. In my case adding nuxt@2.5.0 (used core-js 3) caused the "vupress build" to fail. Whereas adding nuxt@2.5.1 (uses core-js 2) makes the vuepress build error and warning go away. Related to nuxt/nuxt#5313

Other relevant information

  • Your OS: Windows 10
  • Node.js version: 8.15.1
  • Browser version: n/a
  • Is this a global or local install? local
  • Which package manager did you use for the install? npm 6.4.1
  • Does this issue occur when all plugins are disabled? unsure, only using defaults
@ghenry
Copy link

ghenry commented Mar 22, 2019 via email

@fengchenzhihun1
Copy link

how to fix this ques

@DaniG2k
Copy link

DaniG2k commented Mar 27, 2019

Got the same warning here when running RAILS_ENV=test bundle exec rake webpacker:compile in a Rails project with Vuejs. Not sure if it's best to add core-js@2 or core-js@3 🤔

@junwatu
Copy link

junwatu commented Mar 27, 2019

well i already add core-js@3 but still has the same warning

@miltonkowalewski
Copy link

Try npm install --save core-js@2 probably your project core are not compatible with current core-js@3, but even if the same warning are keep, it will still work fine until you have a solution:


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.

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

webpackbar 12:59:10 ✔ Client: Compiled successfully in 58.40s
webpackbar 12:59:10 ℹ Compiling Server
12:59:10
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.

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

webpackbar 12:59:20 ✔ Server: Compiled successfully in 9.66s

@manigandham
Copy link

core-js@3 is a big new release with tighter integration into babel, worth reading the blog post: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md

Since @babel/preset-env now supports core-js@2 and core-js@3, useBuiltIns requires setting a new option, corejs, which specifies the used version (corejs: 2 or corejs: 3). If it isn't directly set, corejs: 2 will be used by default and it will show a warning.

@dig412
Copy link

dig412 commented Mar 29, 2019

Thanks @manigandham, that gave me the clue that corejs:2 needs to be set in babel config. I thought the warning was just saying that adding core-js to package.json would resolve the error, which it does not.

I think the fix for this for nuxt is to allow https://github.com/nuxt/nuxt.js/tree/dev/packages/babel-preset-app to pass the corejs option through from our nuxt.config.js files to the babel config it creates.

@sidwaseem
Copy link

sidwaseem commented Mar 31, 2019

Adding "corejs": "3.0.0" in the .babelrc file turned off the warnings.

"presets": [
        [
            "@babel/preset-env",
            {
                "useBuiltIns": "usage", // "usage" | "entry" | false, defaults to false.
                "corejs": "3.0.0",
                "targets": {
                    "esmodules": true,
                    "ie": "11"
                }
            }
        ]
    ],

@jaredbeck
Copy link

Documentation for the corejs option: https://babeljs.io/docs/en/next/babel-preset-env#corejs

@micas06gua
Copy link

Adding "corejs": "3.0.0" in the .babelrc file turned off the warnings.

"presets": [
        [
            "@babel/preset-env",
            {
                "useBuiltIns": "usage", // "usage" | "entry" | false, defaults to false.
                "corejs": "3.0.0",
                "targets": {
                    "esmodules": true,
                    "ie": "11"
                }
            }
        ]
    ],

worked perfectly!

@flozero
Copy link
Collaborator

flozero commented Sep 5, 2019

The issue is fix with the merge so i am closing the issue thank's for your comments all !

@GSto
Copy link

GSto commented Sep 4, 2020

@sidwaseem 's solutions worked for me. Also worth noting that the core-js version is a string, not an integer. I banged my head against the wall too long wondering why I was still getting the error even though I added the version to my .bablrc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests