Package specific configuration (for apps and libraries)

Ouverte
#368 9 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
25/100
Type d'issue
Fonctionnalité
Clarté
À clarifier
Activité
À l'abandon
Stack technique
nodejs, react-native, typescript

Piste de recherche

Aucun fichier d’implémentation ni test n’est nommé. Commencez par clarifier le schéma de configuration, le comportement de recherche, les règles d’analyse des dépendances et la gestion des chemins spécifique à chaque plateforme proposés ici ; le travail est terminé lorsque le projet dispose d’une conception de configuration approuvée et documentée, ainsi que d’un comportement clair pour chaque option.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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
  }
}
Langage dominant
TypeScript
Étoiles
188
Forks
10
Merge moyen
2 j 17 h
PR mergées (30 j)
3

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de callstackincubator/react-native-node-api

Toutes les issues de callstackincubator/react-native-node-api

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.