Reliance on `require(esm)` in the `react-native-node-api-modules` package may cause onboarding frictions
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 58/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- node.js, react-native, typescript
- Bereich
- build-system, cli, mobile
Rechercherichtung
Beginne mit packages/react-native-node-api-modules/src/node/cli/program.ts und packages/react-native-node-api-modules/tsconfig.node.json und reproduziere dann pod install mit Node.js v22.11.0. Überprüfe die generierte dist/node/cli/program.js und bestätige, dass der Hermes-Patching-Ablauf ohne den require(esm)-Fehler abgeschlossen wird; im Issue wird keine Testdatei genannt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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:
- Vorherrschende Sprache
- TypeScript
- Sterne
- 188
- Forks
- 10
- Ø Merge
- 2 T. 17 Std.
- Gemergte PRs (30 T.)
- 3
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus callstackincubator/react-native-node-api
-
Android 🤖
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
-
Sanity check of Hermes source directory via environment variable, when building Android projects OffenAndroid 🤖 good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
callstackincubator/react-native-node-api#163 · 1 Kommentar ·
-
enhancement good first issue gyp-to-cmake
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
callstackincubator/react-native-node-api#161 · 3 Kommentare · 1 Reaktion ·
-
enhancement Host 🏡
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
-
Automatable good first issue
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 15/100
callstackincubator/react-native-node-api#424 · 1 Kommentar ·
Alle Issues in callstackincubator/react-native-node-api
Ähnliche Issues
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
Mend: dependency security vulnerability untriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100