parcel: Unexpected "With `useBuiltins` option, required direct setting of `corejs` option" with default configuration

🐛 bug report

Calling parcel build <entry point> with all default configuration results in a warning from @babel/preset-env.

🎛 Configuration (.babelrc, package.json, cli command)

  • .babelrc: none
  • package.json:
{
  "name": "test",
  "version": "1.0.0",
  "license": "MIT",
  "devDependencies": {
    "parcel-bundler": "^1.12.2"
  }
}
  • CLI command: yarn run parcel build src/index.html

🤔 Expected Behavior

The build should complete with no errors or warnings

😯 Current Behavior

The build completes, but it emits the following warning: With `useBuiltIns` option, required direct setting of `corejs` option

💁 Possible Solution

This warning appears to come from @babel/preset-env. It seems like it might be possible to avoid by specifying corejs appropriately in transforms/babel.js

🔦 Context

I’m trying to bootstrap a project which requires no extra configuration than what Parcel comes with out of the box. It would be helpful for this warning to be resolved without having to add extra non-functional Babel configuration (several attempts at configuring correctly have failed).

💻 Code Sample

The following files with the addition of the above configuration should be enough to reproduce the issue.

  • src/index.html:
<!DOCTYPE html>
<html>
  <body>
    <div id="root">test</div>
    <script src="./index.js"></script>
  </body>
</html>
  • src/index.js:
document.getElementById('root').append('more test')

🌍 Your Environment

Software Version(s)
Parcel 1.12.2
Node 11.9.0
npm/Yarn 1.13.0
Operating System macOS 10.14.3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 28
  • Comments: 46 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I’m not sure about the core-js thing. It’s a warning, but people tend to freak out about warnings, and perhaps other bugs in babel 7.4 are getting conflated with this warning.

Ok, let me explain the current situation: @babel/preset-env generates imports to core-js. Let’s assume that it only generates imports to core-js@2, that it doesn’t know about core-js@3. We can make this assumption because core-js@2 is the default behavior.

The fact that it generates those imports means that users need to have "core-js": "^2.0.0" in their package.json’s dependencies. Since almost every node project which uses npm already has core-js as a dependency of a dependency (it has three times the downlaods of react or of webpack), and npm hoist packages to the top when possible, so node_modules/core-js always existed even if it wasn’t defined as a dependency: even if it was documented, people didn’t notice that they where depending on a package which they hadn’t specified.

Yesterday core-js@3 was released. If any package in your dependency tree (for example, as you noted in https://github.com/parcel-bundler/parcel/issues/2819#issuecomment-474982867, Babel), your app will have both core-js@2 and core-js@3 in your dependencies three and npm can choose which to hoist. If it decides to hoist core-js@3, all the imports pointing to core-js@2 will be broken. It is a major version of the package, so it isn’t unexpected that it breaks something. For this reason, users must have core-js@2 in their dependencies: if they are relying on a package, it needs to be explicit or major updates will be done when any of the dependencies updates its subdependency.

Even if the necessity to npm install --save core-js has been documented since Babel 6, users didn’t do it. We needed to do something to make them aware about it, so we asked them not to rely on the default behavior but to be explicit about it: corejs: 2 is a way of saying “I know I’m using core-js@2”. I know, the warning message doesn’t explain it and we will soon update it (https://github.com/babel/babel/pull/9716).

An example of a project which relied on core-js without it being installed is angular-cli: https://github.com/angular/angular-cli/issues/13954#issuecomment-474827906

Relying on npm hoisting won’t work anymore, and we need to make people aware of the presence of core-js in their project.


I don’t know if parcel does analyse node_modules, but if it does the only way to proper fix this issue is to set the corejs option you pass to preset env based on what will be bundled: corejs: require("core-js/package.json").version.


Thanks for reporting the other issue, I’m looking at it.

I downgraded all babel packages to < 7.4 in https://github.com/parcel-bundler/parcel/commit/53c09b3cfa3a14bc0dc9875950b31e43d4a9a2e4 while we get this figured out. Published parcel v1.12.3.

See this stackoverflow question for some solutions/approaches.

Confirmed that this issue is solved with 1.12.3 of parcel

'@babel/plugin-transform-runtime’can’t have the corejs configuration option, although the source code in its version 7.4.0 has this option, but setting it will make an error!!!

Can you show an example which explains the problem? It should work.

@Maximilianos Doesn’t Babel 7.4.0 work if you do not upgrade to core-js@3?

I only installed version 3.0.0 of “core-js”.(npm i -g core-js) No “core-js@2”!!!

My version of “core-js” in “package.json”: “core-js”: “^3.0.0” , “core-js-compat”: “^3.0.0” , “core-js-pure”: “^3.0.0”

and, My Babel configuration has the following information: ‘@babel/preset-env’, { targets: { browsers: [ ‘>= 10%’, ‘cover 95%’, ‘since 2017-01-01’, ‘iOS >= 10’, ‘Safari >= 10’, ‘Edge >= 16’, ‘Opera >= 47’, ‘Android >= 56’, ‘Chrome >= 56’, ‘ChromeAndroid >= 56’, ‘Firefox ESR’, ‘Firefox >= 54’, ‘FirefoxAndroid >= 54’, ‘last 2 Baidu major versions’, ‘last 2 OperaMini major versions’, ‘last 2 QQAndroid major versions’, ‘last 2 UCAndroid major versions’, ‘last 2 OperaMobile major versions’, ‘last 2 Samsung major versions’, ‘last 2 BlackBerry major versions’, ‘last 2 major versions’, ‘last 2 versions’, ‘not ie <= 11’, ‘not ie_mob <= 11’, ‘not dead’ ], safari: ‘tp’, esmodules: false }, modules: false, spec: false, loose: true, shippedProposals: true, useBuiltIns: ‘usage’ } ‘@babel/plugin-transform-runtime’, { helpers: true, regenerator: true, useESModules: true }

When the @babel/preset-env and @babel/plugin-transform-runtime options are set the “corejs” option, the value is: corejs: { version: 3, proposals: true } Report wrong!!! The error message is as follows: error1 1.txt

If only the “corejs” option of “@babel/plugin-transform-runtime” is set, and the value is: corejs: { version: 3, proposals: true } And there is no “corejs” option for “@babel/preset-env”!!! However, the value of the “useBuiltIns” option of “@babel/preset-env” is “usage”. It will go wrong.!!! The error message is as follows: 只启用transform1 只启用transform2 只启用transform.txt

But if me just set the “corejs” option of “@babel/preset-env”, the value is: corejs: { version: 3, proposals: true } No “corejs” option is set for “@babel/plugin-transform-runtime”! Then my project will compile successfully!!!

Also, 53c09b3 will only work until some other dependency will depend on core-js@3. As you can see in https://github.com/parcel-bundler/parcel/issues/2819#issuecomment-474898805, it’s not a problem specific of v7.4.

Sorry, just realized that 1.12.3 only rolled back the version of babel. I think I should keep this open until there is a definitive solution.

I just use these. you can also try update parcel,it maybe deal this bug image

I believe that is probably a separate issue with babel 7.4, unrelated to the warning.

(btw this overriding behavior is bad and it’s going away in parcel 2, but it’s what we have right now)

Did you try to npm install --save core-js@2?

useBuiltIns now requires direct setting of corejs version option, without it will be used 2 by default and shown deprecation warning.” merged 3 hours ago at the time of writing.

Didn’t realize the change was so recent. Looks like Babel is making a soft API change in 7.4.0. I doubt they’ll turn back on that, so unfortunately I think it has become a Parcel issue.