Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Help wanted] App broken when setting corejs=3 for '@babel/plugin-transform-runtime'

未关闭
#1,090 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
babel, javascript, react-native

调研方向

从 babel.config.js 中的 plugin 配置以及报告中显示的生成 bundle 开始。使用 React Native 0.68 和 metro-react-native-babel-preset 0.72.1 重现该故障,然后追踪生成的 core-js runtime 导入为何会使 require 未定义。应用能够完成 bundle 并在没有该异常的情况下运行,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
JavaScript
星标
5.6k
派生
702
平均合并
3 天 2 小时
30 天内合并 PR
57

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

react/metro 的其他 Issue

查看 react/metro 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。