Package specific configuration (for apps and libraries)

未关闭
#368 9 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
nodejs, react-native, typescript

调研方向

没有指定实现文件或测试。首先解决此处提出的配置模式、查找行为、依赖项扫描规则以及平台特定的路径处理;当项目拥有经过同意并记录在案的配置设计,且每个选项的行为都明确时,即可视为完成。

由索引模型根据 Issue 内容生成。

描述

enhancement Host 🏡 Linking 🔗

We've actively worked towards putting as few restrictions on the packages bringing Node-API modules as possible, to make it more likely to migrate / re-use existing packages intended for Node.js and we would like to continue to support packages providing Node-API modules without requiring package-specific configuration.

How to configure

We could rely on cosmiconfig (which is also used by the React Native Community CLI):

By default, Cosmiconfig will check the current directory for the following:

  • a package.json property
  • a JSON or YAML, extensionless "rc file"
  • an "rc file" with the extensions .json, .yaml, .yml, .js, .ts, .mjs, or .cjs
  • any of the above two inside a .config subdirectory
  • a .config.js, .config.ts, .config.mjs, or .config.cjs file

We could load this config starting from the "app" and then look for it in all direct dependencies of the app package and all transitive dependencies explicitly enumerated - see below.

What to configure

Possible configuration options which could optimise the experience:

Library name mapping to paths

We could allow library authors to provide explicit paths for the Node-API prebuilds bundled with their package:

{
  // Alternative names for this property could be "addons" or "modules"? 🤔
  "prebuilds": [
    // Provide a path for a prebuild
    "./build/Release/somthing.node",
    // Which would be an alias for an object with the same path
    { "path": "./build/Release/somthing.node" },
    // Allow overriding the name (default would be "my-lib--addon") used for the library files when linked into the app
    { "name": "addon", "path": "./build/Release/addon.node" },
    // Allow specifying platform-specific paths
    {
      "name": "addon",
      "path": {
        "android": "./build/Release/addon.android.node",
        "ios": "./build/Debug/addon.apple.node"
      },
    },
  ]
}
Control scanning

We could group options related to scanning for Node-API modules, either under a "scanning" (or simply "scan") key.

We could enable scanning of specific transitive dependencies (see #367 for use-case)

{
  "scanning": {
    "dependencies": ["name-of-lib-with-node-api-module"]
  }
}

We could provide lists of glob patterns to include and exclude when scanning for modules

{
  "scanning": {
    "include": ["./build"],
    "exclude": ["./node_modules"],
  }
}

Or disable scanning all together:

{
  "scanning": {
    "disabled": true
  }
}
主要语言
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 摘要。