[Help wanted] App broken when setting corejs=3 for '@babel/plugin-transform-runtime'
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
In the file babel.config.js, I wrote the following code:
plugins: ['@babel/plugin-transform-runtime', { helpers: true, corejs: 3 }]
And the bundle code is as shown:
!(function(e){"use strict";var r=require("@babel/runtime-corejs3/core-js-stable/object/create"),t=(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"),require("@babel/runtime-corejs3/core-js-stable/instance/map"),require("@babel/runtime-corejs3/core-js-stable/instance/slice"),require("@babel/runtime-corejs3/core-js-stable/map")),i=require("@babel/runtime-corejs3/core-js-stable/instance/for-each");require("@babel/runtime-corejs3/core-js-stable/set"),require("@babel/runtime-corejs3/core-js-stable/instance/reverse"),require("@babel/runtime-corejs3/core-js-stable/set-timeout"),require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");e.__r=u,e[__METRO_GLOBAL_PREFIX__+"__d"]=function(e,r,t){if(null!=o[r])return;
And the app went broken, showing exception info like "require is undefined"
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
- react-native: 0.68
- metro-react-native-babel-preset: 0.72.1
What is the expected behavior?
The babel plugin can import core-js normaly as before.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
yarn
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the babel.config.js plugin configuration and the generated bundle shown in the report. Reproduce the failure using React Native 0.68 and metro-react-native-babel-preset 0.72.1, then trace why the generated core-js runtime imports leave require undefined. Done means the app bundles and runs without that exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript, react-native
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100