Skip to content

[@babel/preset-env] Provides broken warnings on compile with useBuiltIns #9751

@bradennapier

Description

@bradennapier

Bug Report

Current Behavior

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

When using useBuiltIns it is giving this warning. So I changed and used core-js 3.0.0 since it seemed like that was an option based on it saying i could run that.

I added corejs to the config stating 3.0.0, but then it just errors and no longer works:

Error: Cannot find module 'core-js/modules/es7.symbol.async-iterator'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/Shared/Development/projects/idex-server-v2/node_modules/@auroradao/logger/dist/constants.js:9:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/Users/Shared/Development/projects/idex-server-v2/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/Users/Shared/Development/projects/idex-server-v2/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)

Note that installing and using corejs 2 does work - so this is just reporting about the fact its confusing it seems to indicate support of 3.0.0 when it doesnt have it

Expected behavior/code

be more clear that i should not use core-js@3 if it is not supported / remove that entire set of yarn commands to not confuse people.

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

module.exports = function getBabelConfiguration(api) {
  api.cache.never();
  return {
    presets: [
      [
        '@babel/preset-env',
        {
          useBuiltIns: 'usage',
          corejs: '3.0.0',
          shippedProposals: true,
          targets: {
            node: '10.15',
          },
        },
      ],
    ],
    plugins: [
      [
        'module-resolver',
        {
          root: ['./src/shared'],
        },
      ],
      '@babel/plugin-transform-flow-strip-types',
      '@babel/proposal-class-properties',
      '@babel/proposal-optional-chaining',
      'dynamic-import-node',
      'lodash',
    ],
  };
};

Environment

  • Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34] See below
  • Node/npm version: [e.g. Node 8/npm 5] Node 10.15
  • OS: [e.g. OSX 10.13.4, Windows 10] OSX
  • Monorepo: [e.g. yes/no/Lerna] no
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.4.0",
    "@babel/node": "^7.2.2",
    "@babel/plugin-proposal-class-properties": "^7.4.0",
    "@babel/plugin-proposal-optional-chaining": "^7.2.0",
    "@babel/preset-env": "^7.4.2",
    "@babel/preset-flow": "^7.0.0",

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: invalidoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions