-
Couldn't load subscription status.
- Fork 6
Description
Specification
As js-quic is a native package, it has much more complicated packaging procedure making it similar to js-db. However this is different because it uses Rust instead of C++, therefore the entire toolchain is different from js-db.
Rather than tsc, node, node-gyp, napi-macros and node-gyp-build. This is just tsc, node and napi-rs.
What needs to be done is:
- Remove initial experimental scaffolding that was using
neon. For example theneon-clipackage is no longer needed andcargo-cp-artifactis also not required. - Remove initial experimental scaffolding that was using
napi-macrosandnode-addon-apiandnode-gyp. All of these packages and related configuration is no longer needed. This includes removingnode-gyp-buildtoo. - We are only using
napi-rsand the related rust and cargo tools are brought in from theshell.nix. - Unrelated and useless packages should be removed like
threads. - The
npm run napi-buildandnpm run napi-build-prodshould be integrated into thenpm run prebuildscript located insrc/scripts/prebuild.js. - The entire
prebuild.jswas ported fromjs-dbwhich usesnode-gyp. This does not usenode-gypat all, and instead needs to usenapi buildcommand instead. All relevant flags and options should be adapted tonapi buildwhich comes from the@napi-rs/clipackage. - The purpose of
prebuild.jsis be able to build binaries and put them into aprebuilddirectory. This directory is packaged as part of the npm distribution, and so binary compiled artifacts are "prebuilt" before they are downloaded by downstream users. We should maintain this structure. - There is some work on native packages that spread their binary artifacts into different NPM pacakges, and for the npm to install the ones that are required, thus reducing the final closure size. Haven't experimented with this yet, but I see some other native packages making use of this pattern.
- Currently the
napi buildends up putting the artifact intoquic.linux-x64-gnu.nodeon the project root. This should be put into the equivalent prebuild directories that js-db does. - If we do use the same
prebuilddirectories... we might recover the ability to usenode-gyp-buildto look it up. But right now all that logic is written intosrc/native/quiche.ts. Alternatively we give up onnode-gyp-buildentirely and just use our own script to find the right bindings.
Note that on MacOS and Windows we are using homebrew and chocolatey respectively. This means the rust toolchain would come from those 2 areas instead of Nix. No way to use Nix on MacOS just yet, so it's just a good idea to ensure that we are in fact building with the same Rust version.
Additional context
- Clean up superfluous compilation flags js-db#43 - superfluous compilation flags are no longer a thing with the Rust toolchain, alot more efficient
- Cross-Compilation for linux-arm64 and win-arm64 TypeScript-Demo-Lib-Native#3
- MacOS Runner Nix Integration for Platform-Specific Build TypeScript-Demo-Lib-Native#1
- Follow how js-db looks and feels at the end, just knowing that rust toolchain is more streamlined
- Darwin universal architecture napi-rs/napi-rs#1397 - How to build universal binaries with
napi.
Tasks
- 1. Remove initial experimental scaffolding that was using
neon. For example theneon-clipackage is no longer needed andcargo-cp-artifactis also not required. - 2. Remove initial experimental scaffolding that was using
napi-macrosandnode-addon-apiandnode-gyp. All of these packages and related configuration is no longer needed. This includes removingnode-gyp-buildtoo. - 3. We are only using
napi-rsand the related rust and cargo tools are brought in from theshell.nix. - 4. Unrelated and useless packages should be removed like
threads. - 6. The
npm run napi-buildandnpm run napi-build-prodshould be integrated into thenpm run prebuildscript located insrc/scripts/prebuild.js. - 7. The entire
prebuild.jswas ported fromjs-dbwhich usesnode-gyp. This does not usenode-gypat all, and instead needs to usenapi buildcommand instead. All relevant flags and options should be adapted tonapi buildwhich comes from the@napi-rs/clipackage. - 8. The purpose of
prebuild.jsis be able to build binaries and put them into aprebuilddirectory. This directory is packaged as part of the npm distribution, and so binary compiled artifacts are "prebuilt" before they are downloaded by downstream users. We should maintain this structure. - 9. There is some work on native packages that spread their binary artifacts into different NPM pacakges, and for the npm to install the ones that are required, thus reducing the final closure size. Haven't experimented with this yet, but I see some other native packages making use of this pattern.
- 10. Currently the
napi buildends up putting the artifact intoquic.linux-x64-gnu.nodeon the project root. This should be put into the equivalent prebuild directories that js-db does. - 11. If we do use the same
prebuilddirectories... we might recover the ability to usenode-gyp-buildto look it up. But right now all that logic is written intosrc/native/quiche.ts. Alternatively we give up onnode-gyp-buildentirely and just use our own script to find the right bindings. - Test on CI/CD