添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

What does this error mean? With `useBuiltIns` option, required direct setting of `corejs` option

Ask Question

Getting the same issue. Resolved it by installing core-js as a top level dependency and then adding it as an option to .babelrc

npm install --save core-js@3

Then updated my .babelrc file to include it as an option:

"presets": [ [ "@babel/preset-env", { "useBuiltIns": "entry", "corejs": 3 "plugins": [ "@babel/plugin-syntax-dynamic-import", "@babel/plugin-syntax-import-meta", ["@babel/plugin-proposal-class-properties", { "loose": false }], "@babel/plugin-proposal-json-strings"

I referenced the docs here to figure it out https://babeljs.io/docs/en/babel-preset-env#usebuiltins

there's always a possibility of issues with major releases, of course. Here's a blog post by one of babel's authors, written at the time of babel 7.4.0 release a few days ago, with some migration guides and info: babeljs.io/blog/2019/03/19/7.4.0#migration-from-core-js-2 – T-G Mar 22, 2019 at 5:54

This has been reported to parcel.js: https://github.com/parcel-bundler/parcel/issues/2819

This is due to a soft change in the newly released @babel/core 7.4 and seems to require a parcel.js change.

The solution so far is to either:

  • lock @babel/core to ~7.3: "@babel/core": "~7.3"
  • not upgrade the dependencies at all if they are locked
  • After reading through related discussions on github and the solutions proposed here, the following seems to be the way to go for now:

  • Add core-js@2 to your dependencies npm i core-js@2

  • Ignore the warnings when building

  • When playing around with the babel config modifying targets I ran into errors either when building or when serving the project.

    The documentation says "You may need to specify core-js@2 as a top level dependency in your application". https://babeljs.io/docs/en/babel-preset-env#usebuiltins

    This worked for me:

    npm i core-js@2
    

    Then in babel.config.js:

    presets: [ "@babel/env", // or others like "@vue/app" "useBuiltIns": "usage", "corejs": "core-js@2", // ...

    You don't need to have core-js as a dependency necessarily. Just set core-js version in your babel config file (babel.config.js) @babel/env preset as follows:

    '@babel/env', targets: { corejs: 'core-js@2'

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.