Add napiDependencies field support for package.json#367
Open
owl352 wants to merge 3 commits intocallstackincubator:mainfrom
Open
Add napiDependencies field support for package.json#367owl352 wants to merge 3 commits intocallstackincubator:mainfrom
napiDependencies field support for package.json#367owl352 wants to merge 3 commits intocallstackincubator:mainfrom
Conversation
Collaborator
|
Overall - I agree this is a problem worth solving 👍 and it seems related to #54. As a first, we're consciously using "Node-API" / |
Collaborator
|
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. I do however see value in (optional) package-specific configuration intended for our tooling with linking efficiently - wrote down a few thoughts that I'd love your input on #368 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
At the moment, we cannot import Node-API dependencies unless they are explicitly declared in package.json #366. However, there are valid use cases where a user installs a package that depends on an Node-API module. For example, it could be an SDK that includes the Node-API module.
Right now, there is only 2 workaround: manually adding that package to dependencies or manually linking. This is far from ideal, as it complicates the migration flow between versions of the dependency that relies on this package.
I see only two potential solutions at the moment: scan the entire
node_modulesdirectory, or get a “hint” from somewhere about which modules require auto-linking. I consider the first option to be bad, as it requires a lot of resources.The goal of this PR is to introduce a separate configuration field in
package.jsonthat allows specifying package names for auto-linking, without interacting with the package manager in any way.Things done
package-lock.jsonnapiDependenciesfield reading from rootpackage.jsonnew
package.jsonexample{ "name": "expo-pshenmic-dpp-test", "version": "1.0.0", "main": "index.ts", "scripts": { "start": "expo start", "android": "expo run:android", "ios": "expo run:ios" }, "dependencies": { "babel-preset-expo": "^54.0.6", "expo": "~54.0.22", "expo-build-properties": "~1.0.9", "expo-status-bar": "~3.0.8", "dash-platform-sdk": "https://github.com/pshenmic/dash-platform-sdk#a6687586eff35faa0a35409be7a97294640cf95f", "react": "19.1.0", "react-native": "0.81.4", "react-native-node-api": "1.0.1" }, "napiDependencies": [ "pshenmic-dpp" ], "devDependencies": { "@react-native-community/cli": "latest", "@babel/core": "^7.25.2", "@types/react": "~19.1.0", "typescript": "~5.9.2" }, "private": true }Here we specify
dash-platform-sdkas a dependency, and it contains the dependencypshenmic-dpp, which contains the Node-API module.