Reliance on `require(esm)` in the `react-native-node-api-modules` package may cause onboarding frictions
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- node.js, react-native, typescript
- 领域
- build-system, cli, mobile
调研方向
先从 packages/react-native-node-api-modules/src/node/cli/program.ts 和 packages/react-native-node-api-modules/tsconfig.node.json 开始,然后使用 Node.js v22.11.0 重现 pod install。检查生成的 dist/node/cli/program.js,并确认 Hermes 的修补流程在没有 require(esm) 错误的情况下完成;该 issue 未指定测试文件。
由索引模型根据 Issue 内容生成。
描述
Background
I ran into a problem with require(esm) when attempting to run pod install on a React Native iOS (Expo) app that depends on react-native-node-api-modules. It seems that although I'm running an LTS version of Node, only the more recent minor releases actually support that feature.
require(esm) is supported (without --experimental-require-module) from Node.js v22.12.0+ and v23.0.0+. Although v22 is in Active LTS, versions below 22.12.0 lack this feature, and although v22.13.0 has been available for half a year already, having come out in December 2024, there's a fair chance that users won't have it installed yet. I happened to be on Node.js v22.11.0, for example 😅
We might reduce onboarding frictions by avoiding require(esm) here.
Issue
The file packages/react-native-node-api-modules/src/node/cli/program.ts writes this ESM import in TypeScript:
import { SpawnFailure } from "bufout";
Based on the config in packages/react-native-node-api-modules/tsconfig.node.json, this gets transpiled to CommonJS in packages/react-native-node-api-modules/dist/node/cli/program.js:
const bufout_1 = require("bufout");
// ... which later is accessed as `bufout_1.SpawnFailure`
This leads to the following error upon running cd ios && pod install in the latest Expo template when Node v22.11.0 is on the shell's PATH.
[Expo] Enabling modular headers for pod React-hermes
/Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js:315
undefined
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jamie/Documents/git/react-native-node-api-modules/node_modules/bufout/dist/index.js from /Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js not supported.
Instead change the require of index.js in /Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js to a dynamic import() which is available in all CommonJS modules.
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at Object.<anonymous> (/Users/jamie/Documents/git/react-native-node-api-modules/packages/react-native-node-api-modules/dist/node/cli/program.js:11:18) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v22.11.0
[!] Invalid `Podfile` file:
[!] Invalid `react-native-node-api-modules.podspec` file: Hermes patching failed. Please check the output above for errors..
# from /Users/jamie/Documents/git/react-native-node-api-modules/node_modules/react-native-node-api-modules/react-native-node-api-modules.podspec:5
# -------------------------------------------
#
> require_relative "./scripts/patch-hermes"
#
# -------------------------------------------
.
# from /Users/jamie/Documents/git/react-native-node-api-modules/apps/expo-template/ios/Podfile:32
# -------------------------------------------
#
> config = use_native_modules!(config_command)
#
# -------------------------------------------
[!] !!! PATCHING HERMES WITH NODE-API SUPPORT !!!
In one screenshot:
- 主要语言
- TypeScript
- 星标
- 188
- 派生
- 10
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 3
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
callstackincubator/react-native-node-api 的其他 Issue
-
Android 🤖
难度 2/5 1-3 小时 新手友好度 66/100
-
Sanity check of Hermes source directory via environment variable, when building Android projects 未关闭Android 🤖 good first issue
难度 2/5 1-3 小时 新手友好度 78/100
callstackincubator/react-native-node-api#163 · 1 条评论 ·
-
enhancement good first issue gyp-to-cmake
难度 2/5 1-3 小时 新手友好度 72/100
callstackincubator/react-native-node-api#161 · 3 条评论 · 1 个 reaction ·
-
enhancement Host 🏡
难度 5/5 一周以上 新手友好度 25/100
-
Automatable good first issue
难度 3/5 1-2 天 新手友好度 15/100
callstackincubator/react-native-node-api#424 · 1 条评论 ·
查看 callstackincubator/react-native-node-api 的全部 Issue
相似的 Issue
-
blocklist removal
难度 2/5 1-3 小时 新手友好度 65/100
MetaMask/eth-phishing-detect#296544 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
pastelsky/bundlephobia#1122 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100