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

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

Đang mở
#222 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, react-native, typescript

Hướng nghiên cứu

Bắt đầu bằng cách xác định điểm vào requireNodeAddon và các khai báo công khai được biểu diễn bởi index.js và index.d.ts trong ví dụ. So sánh API packageName và đường dẫn không có phần mở rộng được yêu cầu với các triển khai trên nền tảng, bao gồm đường dẫn Node.js process.dlopen và điều kiện export node; hoàn tất khi cùng các đối số gọi hoạt động trên các nền tảng đã nêu.

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

Mô tả

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
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.