Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Refactor `requireNodeAddon` to take the package name and extension-less path of an addon

未關閉
#222 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
重構
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
node.js, react-native, typescript

研究方向

先定位範例中的 requireNodeAddon 進入點,以及由 index.js 和 index.d.ts 表示的公開宣告。將要求的 packageName 與無副檔名路徑 API,和各平台的實作進行比較,包括 Node.js process.dlopen 路徑與 node 匯出條件;當相同的呼叫引數能在所述平台上運作時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

Host 🏡

This is a suggestion which is subtly different from the one proposed in https://github.com/callstackincubator/react-native-node-api/issues/91.

Goals

  • Removing the requirement for the Babel plugin, for use-cases where a library author "controls" the code calling into the host package.
  • Give more control to the host package when deciding what library files to loads (at runtime).
  • Supporting multiple platforms (including Node.js) with source-code calling into the host package with the same call arguments

Example library

Imagine a library ("my-lib") with a single index.js entrypoint calling into our host package:

// node_modules/my-lib/index.js
import { requireNodeAddon } from "react-native-node-api";
const addon = requireNodeAddon({
  packageName: "my-lib", // The name from the package.json
  path: "build/Release/hello" // Path to the addon, relative to the package root, stripped from its ".*.node" file extensions.
});
export const sum = addon.sum;

and the following directory structure:

index.js
index.d.ts
build/Release
├── hello.android.node
│   ├── arm64-v8a
│   │   └── libhello.so
│   ├── armeabi-v7a
│   │   └── libhello.so
│   ├── react-native-node-api-module
│   ├── x86
│   │   └── libhello.so
│   └── x86_64
│       └── libhello.so
├── hello.apple.node
│   ├── Info.plist
│   ├── ios-arm64
│   │   └── hello.framework
│   │       ├── Headers
│   │       ├── hello
│   │       └── Info.plist
│   ├── ios-arm64-simulator
│   │   └── hello.framework
│   │       ├── Headers
│   │       ├── hello
│   │       └── Info.plist
│   ├── macos-arm64_x86_64
│   │   └── hello.framework
│   │       ├── Headers
│   │       ├── hello
│   │       └── Info.plist
│   ├── react-native-node-api-module
│   ├── tvos-arm64
│   │   └── hello.framework
│   │       ├── Headers
│   │       ├── hello
│   │       └── Info.plist
│   ├── tvos-arm64-simulator
│   │   └── hello.framework
│   │       ├── Headers
│   │       ├── hello
│   │       └── Info.plist
│   ├── xros-arm64
│   │   └── hello.framework
│   │       ├── Headers
│   │       ├── hello
│   │       └── Info.plist
│   └── xros-arm64-simulator
│       └── hello.framework
│           ├── Headers
│           ├── hello
│           └── Info.plist
└── hello.nodejs.node
    ├── darwin-arm64
    │   └── hello.node
    └── react-native-node-api-module
主要語言
TypeScript
星號
188
分支
10
平均合併
2 天 17 小時
30 天內合併 PR
3

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

callstackincubator/react-native-node-api 的其他 Issue

查看 callstackincubator/react-native-node-api 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。