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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: @babel/helper-compilation-targets: 'opera_mobile' is not a valid target when upgrading babel/core to 7.23.6 #16171

Closed
1 task
zuyetawarmatik opened this issue Dec 12, 2023 · 11 comments

Comments

@zuyetawarmatik
Copy link

馃捇

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

The problem happens when only upgrading @babel/core from 7.23.5 to 7.23.6. I'm using babel-loader for react

@babel/helper-compilation-targets: 'opera_mobile' is not a valid target

Did you mean 'opera'? (While processing: "/Users/dbui/git/ui/node_modules/babel-preset-react-app/dependencies.js$0$43")
    at validateTargetNames (/Users/dbui/git/ui/node_modules/@babel/helper-define-polyfill-provider/node_modules/@babel/helper-compilation-targets/lib/index.js:60:13)
    at getTargets (/Users/dbui/git/ui/node_modules/@babel/helper-define-polyfill-provider/node_modules/@babel/helper-compilation-targets/lib/index.js:167:17)
    at resolveOptions (/Users/dbui/git/ui/node_modules/@babel/helper-define-polyfill-provider/lib/index.js:87:15)
    at instantiateProvider (/Users/dbui/git/ui/node_modules/@babel/helper-define-polyfill-provider/lib/index.js:115:7)
    at /Users/dbui/git/ui/node_modules/@babel/helper-define-polyfill-provider/lib/index.js:235:9
    at /Users/dbui/git/ui/node_modules/@babel/helper-define-polyfill-provider/node_modules/@babel/helper-plugin-utils/lib/index.js:31:12
    at async (/Users/dbui/git/ui/node_modules/@babel/core/lib/gensync-utils/async.js:35:33)
    at async (/Users/dbui/git/ui/node_modules/gensync/index.js:186:15)
    at /Users/dbui/git/ui/node_modules/gensync/index.js:216:13
    at Generator.next (<anonymous>)
    at /Users/dbui/git/ui/node_modules/@babel/core/lib/config/full.js:180:21
    at Generator.next (<anonymous>)
    at Function.<anonymous> (/Users/dbui/git/ui/node_modules/@babel/core/lib/gensync-utils/async.js:21:3)
    at Generator.next (<anonymous>)
    at step (/Users/dbui/git/ui/node_modules/gensync/index.js:269:25)
    at evaluateAsync (/Users/dbui/git/ui/node_modules/gensync/index.js:291:5)
    at Function.errback (/Users/dbui/git/ui/node_modules/gensync/index.js:113:7)
    at errback (/Users/dbui/git/ui/node_modules/@babel/core/lib/gensync-utils/async.js:65:18)
    at async (/Users/dbui/git/ui/node_modules/gensync/index.js:188:17)
    at onFirstPause (/Users/dbui/git/ui/node_modules/gensync/index.js:216:13)
    at Generator.next (<anonymous>)
    at cachedFunction (/Users/dbui/git/ui/node_modules/@babel/core/lib/config/caching.js:52:46)
    at cachedFunction.next (<anonymous>)
    at loadPluginDescriptor (/Users/dbui/git/ui/node_modules/@babel/core/lib/config/full.js:259:42)
    at loadPluginDescriptor.next (<anonymous>)
    at loadPluginDescriptors (/Users/dbui/git/ui/node_modules/@babel/core/lib/config/full.js:129:33)
    at loadPluginDescriptors.next (<anonymous>)
    at /Users/dbui/git/ui/node_modules/@babel/core/lib/config/full.js:156:21
    at Generator.next (<anonymous>)
    at loadFullConfig (/Users/dbui/git/ui/node_modules/@babel/core/lib/config/full.js:141:5)
    at loadFullConfig.next (<anonymous>)
    at transform (/Users/dbui/git/ui/node_modules/@babel/core/lib/transform.js:20:44)
    at transform.next (<anonymous>)
    at step (/Users/dbui/git/ui/node_modules/gensync/index.js:269:25)
    at /Users/dbui/git/ui/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/dbui/git/ui/node_modules/gensync/index.js:223:11)
    at /Users/dbui/git/ui/node_modules/gensync/index.js:189:28
    at /Users/dbui/git/ui/node_modules/@babel/core/lib/gensync-utils/async.js:67:7
    at /Users/dbui/git/ui/node_modules/gensync/index.js:113:33
    at step (/Users/dbui/git/ui/node_modules/gensync/index.js:287:14)
    at /Users/dbui/git/ui/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/dbui/git/ui/node_modules/gensync/index.js:223:11)

Configuration file name

No response

Configuration

No response

Current and expected behavior

Should not break the build

Environment

"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.6",
"@babel/eslint-parser": "^7.23.3",
"@babel/plugin-transform-react-constant-elements": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"@babel/preset-react": "^7.23.3",

"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"babel-preset-react-app": "^10.0.1",

"webpack": "^5.89.0",

node: 20.10.0

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @zuyetawarmatik! 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.

@liuxingbaoyu
Copy link
Member

If you delete your node_modules and package-lock.json and re-run npm i will it work?

@sumanbh
Copy link

sumanbh commented Dec 12, 2023

You might have multiple versions of helper-compilation-targets in your project.

An alternative to deleting lockfile would be to dedupe (or override) your dependency tree so it all points to 7.23.6:

yarn dedupe
# or
pnpm dedupe

@zuyetawarmatik
Copy link
Author

You might have multiple versions of helper-compilation-targets in your project.

An alternative to deleting lockfile would be to dedupe (or override) your dependency tree so it all points to 7.23.6:

yarn dedupe
# or
pnpm dedupe

yarn install will do dedupe automatically, and this is not working.
Putting into resolutions like this isn't working too.

resolutions: {
  @babel/helper-compilation-targets: 7.2.6
}

@zuyetawarmatik
Copy link
Author

If you delete your node_modules and package-lock.json and re-run npm i will it work?

I use yarn and yarn cache clean, and it's not working

@liuxingbaoyu
Copy link
Member

yarn install will do dedupe automatically, and this is not working.

I remember not dedupe automatically, but resolutions should work.
Can you provide a repository to reproduce?

@KlavierCat
Copy link

Do you happen to have a browserslist config somewhere? If you do, what happens if you delete this or make its value empty?

@zuyetawarmatik
Copy link
Author

zuyetawarmatik commented Dec 18, 2023

Do you happen to have a browserslist config somewhere? If you do, what happens if you delete this or make its value empty?

our browserlist is:

  "browserslist": [
    ">0.2%",
    "not dead",
    "not android > 0",
    "not op_mini all"
  ]

We can't remove that browserslist in package.json as browserlist lib will terminate the build. I search through node_modules and find that keyword opera_mobile is used a lot in many packages.

@zuyetawarmatik
Copy link
Author

OK I figured out the culprit: This is due to some library is using an old version of @babel/helper-compilation-targets:

  • @babel/helper-compilation-targets (old version, targets don't contain opera_mobile => crash)
    => @babel/helper-define-polyfill-provider (yarn resolves to 0.3.3, but not 0.4.4)
    => babel-plugin-polyfill-corejs3/babel-plugin-polyfill-corejs2 (old versions)
    => @babel/plugin-transform-runtime (old ver 7.16.4)
    => babel-preset-react-app 10.0.1 (very old, not maintained by FB since 2021) (But I can't get rid of it in near future).

@zuyetawarmatik
Copy link
Author

I will close this issue

@jasrhoyt
Copy link

jasrhoyt commented Mar 22, 2024

Anyone who finds themselves here looking for a solution, ignoring operah_mobile in your browserslist config solved my problem:
"browerslist": [
">0.2%",
"not dead",
"not op_mini all",
"not op_mob >= 1" -- add this line
],

voisinhugo added a commit to pass-culture/pass-culture-app-native that referenced this issue Apr 16, 2024
as it breaks the build, due to the use of an old version of Babel
babel/babel#16171 (comment)
voisinhugo added a commit to pass-culture/pass-culture-app-native that referenced this issue Apr 16, 2024
as it breaks the build, due to the use of an old version of Babel
babel/babel#16171 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants