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

Cannot use `useBuiltIns` with core-js v3 when project used node_modules does't upgrade their babel related modules to v7 #10036

Open
satsuya0114 opened this issue May 29, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@satsuya0114
Copy link

commented May 29, 2019

v7 Regression

Describe the regression
When I want to upgrade my project to use Babel V7 with suggest way, my project can't upgrade successfully with some error code.

my Babel Configuration :

{
  "presets": [
    ["@babel/preset-env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      },
      "useBuiltIns": "usage",
      "corejs": 3,
    }],
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-transform-runtime",
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose" : true }],
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-syntax-dynamic-import",
    "react-hot-loader/babel"
  ]
}

package.json:

  "devDependencies": {
    "@babel/core": "^7.4.5",
    "@babel/plugin-proposal-class-properties": "^7.4.4",
    "@babel/plugin-proposal-decorators": "^7.4.4",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.0.0",
    "@babel/preset-env": "^7.4.5",
    "@babel/preset-react": "^7.0.0",
    "autoprefixer": "^8.6.1",
    "babel-eslint": "^9.0.0",
    "babel-loader": "^8.0.6",
    "babel-plugin-module-resolver": "^3.1.1",
    "core-js": "^3.1.3",
    "css-loader": "^2.1.1",
    "html-webpack-plugin": "^3.2.0",
    "less": "^3.0.4",
    "less-loader": "^4.1.0",
    "mini-css-extract-plugin": "^0.4.2",
    "node-sass": "^4.9.0",
    "optimize-css-assets-webpack-plugin": "^5.0.1",
    "postcss-loader": "^2.1.5",
    "react-hot-loader": "^4.3.12",
    "react-loadable": "^5.5.0",
    "style-loader": "^0.21.0",
    "uglifyjs-webpack-plugin": "^1.2.5",
    "webpack": "^4.18.0",
    "webpack-cli": "^3.0.2",
    "webpack-dev-middleware": "^3.3.0",
    "webpack-dev-server": "^3.1.14",
    "webpack-merge": "^4.1.2"
  },
  "dependencies": {
    "@babel/polyfill": "^7.4.4",
    "@babel/runtime": "^7.0.0",
    "@material-ui/core": "^3.9.1",
    "@material-ui/icons": "^3.0.1",
    "antd": "^3.19.1",
    "browserslist": "^4.4.2",
    "classnames": "^2.2.6",
    "detect-browser": "^4.1.0",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "normalize.css": "^8.0.0",
    "prop-types": "^15.6.2",
    "react": "^16.5.0",
    "react-dom": "^16.5.0",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "redux": "^4.0.0",
    "styled-components": "^3.4.6"
  }
}

Because I want to use the useBuiltIns feature, so I fallowed the terminal console suggestion to install the core-js@3

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

error code:

ERROR in ./node_modules/babel-runtime/core-js/array/from.js
Module not found: Error: Can't resolve 'core-js/library/fn/array/from' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/array'
 @ ./node_modules/babel-runtime/core-js/array/from.js 1:30-70
 @ ./node_modules/babel-runtime/helpers/toConsumableArray.js
 @ ./node_modules/rc-slider/es/Range.js
 @ ./node_modules/antd/es/slider/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/object/assign.js
Module not found: Error: Can't resolve 'core-js/library/fn/object/assign' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/object'
 @ ./node_modules/babel-runtime/core-js/object/assign.js 1:30-73
 @ ./node_modules/babel-runtime/helpers/extends.js
 @ ./node_modules/omit.js/es/index.js
 @ ./node_modules/antd/es/affix/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/object/create.js
Module not found: Error: Can't resolve 'core-js/library/fn/object/create' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/object'
 @ ./node_modules/babel-runtime/core-js/object/create.js 1:30-73
 @ ./node_modules/babel-runtime/helpers/inherits.js
 @ ./node_modules/rc-tooltip/es/Tooltip.js
 @ ./node_modules/rc-tooltip/es/index.js
 @ ./node_modules/antd/es/tooltip/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/object/define-property.js
Module not found: Error: Can't resolve 'core-js/library/fn/object/define-property' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/object'
 @ ./node_modules/babel-runtime/core-js/object/define-property.js 1:30-82
 @ ./node_modules/babel-runtime/helpers/defineProperty.js
 @ ./node_modules/rc-animate/es/Animate.js
 @ ./node_modules/antd/es/upload/UploadList.js
 @ ./node_modules/antd/es/upload/Upload.js
 @ ./node_modules/antd/es/upload/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/object/get-own-property-descriptor.js
Module not found: Error: Can't resolve 'core-js/library/fn/object/get-own-property-descriptor' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/object'
 @ ./node_modules/babel-runtime/core-js/object/get-own-property-descriptor.js 1:30-94
 @ ./node_modules/babel-runtime/helpers/get.js
 @ ./node_modules/rc-slider/es/common/createSlider.js
 @ ./node_modules/rc-slider/es/Range.js
 @ ./node_modules/antd/es/slider/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/object/get-prototype-of.js
Module not found: Error: Can't resolve 'core-js/library/fn/object/get-prototype-of' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/object'
 @ ./node_modules/babel-runtime/core-js/object/get-prototype-of.js 1:30-83
 @ ./node_modules/babel-runtime/helpers/get.js
 @ ./node_modules/rc-slider/es/common/createSlider.js
 @ ./node_modules/rc-slider/es/Range.js
 @ ./node_modules/antd/es/slider/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/object/set-prototype-of.js
Module not found: Error: Can't resolve 'core-js/library/fn/object/set-prototype-of' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/object'
 @ ./node_modules/babel-runtime/core-js/object/set-prototype-of.js 1:30-83
 @ ./node_modules/babel-runtime/helpers/inherits.js
 @ ./node_modules/rc-tooltip/es/Tooltip.js
 @ ./node_modules/rc-tooltip/es/index.js
 @ ./node_modules/antd/es/tooltip/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/symbol.js
Module not found: Error: Can't resolve 'core-js/library/fn/symbol' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js'
 @ ./node_modules/babel-runtime/core-js/symbol.js 1:30-66
 @ ./node_modules/babel-runtime/helpers/typeof.js
 @ ./node_modules/babel-runtime/helpers/inherits.js
 @ ./node_modules/rc-tooltip/es/Tooltip.js
 @ ./node_modules/rc-tooltip/es/index.js
 @ ./node_modules/antd/es/tooltip/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js

ERROR in ./node_modules/babel-runtime/core-js/symbol/iterator.js
Module not found: Error: Can't resolve 'core-js/library/fn/symbol/iterator' in '/Users/neinei/project/wistron/T1-project/wiBioWeb/node_modules/babel-runtime/core-js/symbol'
 @ ./node_modules/babel-runtime/core-js/symbol/iterator.js 1:30-75
 @ ./node_modules/babel-runtime/helpers/typeof.js
 @ ./node_modules/babel-runtime/helpers/inherits.js
 @ ./node_modules/rc-tooltip/es/Tooltip.js
 @ ./node_modules/rc-tooltip/es/index.js
 @ ./node_modules/antd/es/tooltip/index.js
 @ ./node_modules/antd/es/index.js
 @ ./src/containers/Admin/AdminHome/AdminHome.js
 @ ./src/containers/Main/Main.js
 @ ./src/App.js
 @ ./src/index.js
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
    [LvDl] ./node_modules/lodash/lodash.js 527 KiB {0} [built]
    [MFLM] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 939 bytes {0} [built]
    [YuTi] (webpack)/buildin/module.js 497 bytes {0} [built]
    [yLpj] (webpack)/buildin/global.js 472 bytes {0} [built]
ℹ 「wdm」: Failed to compile.

find other node_modules - antd use babel-runtime v6.x that use core-js v2
antd package.json
babel-runtime v6.X package.json

Maybe the error is the antd's babel-runtime v6.x (use core-js V2) and babel 7 useBuiltIns I choose core-js 3 caused.

So I installed core-js@2 into my project, then fixed this error. Compiled successfully.

I'm just speculating for that you cannot use useBuiltIns with core-js v3 when project used node_modules does't upgrade their babel to v7 OR You have to check all of used node_modules don't use any core-js v2 when you want to installed core-js v3 in your project

Environment

  • Babel version(s): v7.4.5
  • Node/npm version: Node v10.13.0 / npm v6.4.1
  • OS: Mojave 10.14
  • Monorepo no
  • How you are using Babel: loader

PS. I have create a new repo to duplicate this issue.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented May 29, 2019

Hey @satsuya0114! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@satsuya0114 satsuya0114 changed the title Cannot use `useBuiltIns` with core-js v3 when project used node_modules does't upgrade their babel to v7 Cannot use `useBuiltIns` with core-js v3 when project used node_modules does't upgrade their babel related modules to v7 May 29, 2019

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented May 29, 2019

As you can see in the package.json you linked, Babel runtime explicitly depends on core-js@2: your package manager should install v3 in your top-level node_modules folder, and v2 in node_modules/babel-runtime/node_modules.
Can you try to delete and reinstall node_modes? Also, what is the generated lockfile?

@satsuya0114

This comment has been minimized.

Copy link
Author

commented May 29, 2019

@nicolo-ribaudo

I have fixed this error by downgrade my core-js version (to v2).

As you say, reinstall node_modules when project has antd (babel-runtime 6.X) and core-js v3 at the same time.
I have tried, but it's still show Failed to compile.

I have create a new repo to duplicate this issue.

and the package-lock.json is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.