You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,14 @@ module.exports = binding
71
71
An added benefit of this approach is that your native modules will work across multiple node and electron versions without having the user
72
72
need to reinstall or recompile them - as long as you produce prebuilds for all versions. With Node-API you only have to produce prebuilds for every runtime.
73
73
74
-
When publishing your module to npm remember to include the `./prebuilds` folder.
74
+
75
+
## Platform-specific Packages
76
+
As an alternate to including all prebuilds directly in your published package, you can use `--optional-packages` to setup the prebuilds for publishing as separate platform-specific packages. Using this option, each prebuild directory will also include a package.json that specifies the target platform and architectures along with some basic package files. Each of these prebuild directories can then be published as separate packages in NPM. In addition,
77
+
the main package should specify all the platform packages as `optionalDependencies`. When installed, NPM (or Yarn, etc.) will then only install the optional dependency with the platform/architecture matching the target machine.
78
+
79
+
This provides both the efficiency of only needing to download/install the binary (or binaries) needed for the current platform, but also the key benefit of the prebuildify system in that binaries are downloaded and available as part of the normal NPM install process (no install scripts for extra downloads are necessary). When using this method, you should omit the prebuilds folder when publishing your package (since they will be separately downloaded).
80
+
81
+
If you do not use this option, when publishing your module to npm, remember to include the `./prebuilds` folder.
75
82
76
83
That's it! Happy native hacking.
77
84
@@ -94,6 +101,7 @@ Options can be provided via (in order of precedence) the programmatic API, the C
94
101
| `--tag-uv` | - | `false` | Tag prebuild with `uv`\*\*\*
95
102
| `--tag-armv` | - | `false` | Tag prebuild with `armv`\*\*\*
96
103
| `--tag-libc` | - | `false` | Tag prebuild with `libc`\*\*\*
104
+
| `--optional-dependencies`| - | `false` | Add package.json and basic files for package publishing
97
105
| `--preinstall` | - | - | Command to run before build
98
106
| `--postinstall` | - | - | Command to run after build
99
107
| `--shell` | `PREBUILD_SHELL` | `'sh'` on Android | Shell to spawn commands in
0 commit comments