Question on cargo-cp-artifact
amarjanica opened this issue · 1 comments
amarjanica commented
Hi, first of all, great project!
I recently published a node package https://www.npmjs.com/package/node-el-slugify?activeTab=explore,
my first native module for node, and I have a couple of questions:
- When I install the package from npm, the module builds on my system.
That means people who use my module should also have Rust installed if they want to use it, right? - If that's true, then there's no need to include index.node in the build, as package can
be a couple of kB, instead of MB? - Is there a way to prebuild and publish? I'd want to avoid the Rust requirement and build for users of my package.
Sorry, maybe I'm using it all wrong :) Thanks!
kjvalencik commented
Yes, built in this way it will require Rust and the index.node
doesn't need to be included. As of now, Neon does not have an official recommendation for delivering prebuilt binaries; however, there are several ways.
Method | Advantage | Disadvantage |
---|---|---|
Bundle index.nod for all platforms. Dynamically require the correct one. |
Simple | Makes the native package very large |
Publish platform specific versions of the module (e.g., node-el-slugify-macos-x86_64 ). These become optionalDependencies with a postinstall script that installs the correct one. |
Small bundle. | Publishing lots of modules instead of one. |
node-pre-gyp or similar to download the correct artifact from some store like S3 or Github releases. |
Small bundle, flexible and one package. | Complicated. |
Some of those are documented in #117. I am going to close this issue since I believe your request is covered by that, but feel free to ask more questions or we can re-open if I misunderstood.