Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,090 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
babel, javascript, react-native
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

Bắt đầu với cấu hình plugin trong babel.config.js và bundle được tạo như trong báo cáo. Tái hiện lỗi bằng React Native 0.68 và metro-react-native-babel-preset 0.72.1, sau đó truy tìm lý do các import runtime core-js được tạo ra khiến require không được định nghĩa. Hoàn thành khi ứng dụng được bundle và chạy mà không gặp exception đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
5.6k
Fork
702
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
59

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của react/metro

Tất cả issue của react/metro

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.