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

Dynamic `import()` of a Node-API addon doesn't work on Android

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

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
52/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
android, babel, react-native, typescript
Lĩnh vực
build-system, mobile

Hướng nghiên cứu

Bắt đầu với TODO trong apps/test-app/App.tsx và tái hiện lỗi import động trên Android, ghi lại xem nó bị reject hay throw và thông báo của nó. Sau đó, kiểm tra packages/host/src/node/babel-plugin/plugin.ts để so sánh cách xử lý require() và import(). Hoàn thành có nghĩa là import động hoạt động trên Android, hoặc giới hạn và nguyên nhân của nó được ghi lại, bao gồm giải thích có ý nghĩa cho eslint-disable.

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

Mô tả

Android 🤖 Host 🏡

Tracking the TODO in apps/test-app/App.tsx.

The ferric-example test has to use require() — with an ESLint disable for @typescript-eslint/no-require-imports — because a dynamic import() of the same addon does not work on Android:

https://github.com/callstackincubator/react-native-node-api/blob/29a527d87fa8cb965b0048b1b4c1cff2b0eab281/apps/test-app/App.tsx#L78-L83

Nobody has established why. It matters beyond the test app: consumers writing modern ESM will reach for await import("some-addon") first, and if that silently fails on Android while working on iOS, it is a confusing first-run experience for exactly the audience this project targets.

Worth checking, roughly in order of likelihood:

  • Whether the Babel plugin in packages/host/src/node/babel-plugin/plugin.ts rewrites require("./addon.node") but leaves import("./addon.node") untransformed — the plugin matches require call expressions, so a dynamic import may simply never be turned into a requireNodeAddon() call.
  • Whether Metro's async-import handling on Android (inline requires / RAM bundles) defers the module in a way that breaks the TurboModule lookup.
  • Whether the failure is a rejected promise or a hard error, and what it actually says — the current comment records the symptom without the message.

Outcome should be either a fix (most likely: handle import() in the Babel plugin alongside require()) or a documented limitation, so the eslint-disable can carry a real explanation instead of an open question.

Ngôn ngữ chính
TypeScript
Star
188
Fork
10
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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 callstackincubator/react-native-node-api

Tất cả issue của callstackincubator/react-native-node-api

Issue tương tự

Thêm issue về TypeScript

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.