-
-
Notifications
You must be signed in to change notification settings - Fork 759
feat(binding-builder): add binding-builder cli #10876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rspack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
7c7b928
to
63b2164
Compare
@@ -31,7 +31,7 @@ runs: | |||
shell: bash | |||
run: | | |||
cd ./crates/node_binding | |||
pnpm install --ignore-workspace --no-lockfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bad part is we have to link binding-builder-cli
to crates/node_binding
. This requires the binding to fallback to workspace install instead of plain package install. cc @stormslowly
@@ -31,7 +31,7 @@ runs: | |||
shell: bash | |||
run: | | |||
cd ./crates/node_binding | |||
pnpm install --ignore-workspace --no-lockfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove --ignore-workspace
will install all workspace depenceies and slow down installation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably install the binding builder cli as a dependency (not from the current workspace) after the first release, then we can revert the workflow back.
process.exit(0); | ||
} | ||
|
||
const { NapiCli } = require("@napi-rs/cli"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's a stable public api or just an internal api, I'm afraid whether we'll miss some logic in the napi-cli/bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/napi-rs/napi-rs/blob/7e34e30b66b2c35de31a3f4386d166c2154e4e8c/cli/package.json#L26 Looks like public APIs to me
|
||
const debug = require("debug")("rspack-builder:build"); | ||
|
||
const OPTIONS_CONFIG = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this duplicate of https://github.com/napi-rs/napi-rs/blob/main/cli/src/def/build.ts#L5 or we add custom logic here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, it's a bunch of code supposed to achieve the same functionalities with napi-rs cli. I changed it to programmatic API to make our CLI output nice and clean.
If
|
@@ -0,0 +1,31 @@ | |||
{ | |||
"name": "@rspack/binding-builder-cli", | |||
"version": "1.4.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand why we need make our own cli instead of using napi-cli? can you help explain in README.md so outside contributors can understand it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being explained in #10876 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought about this in the first place. But rspack's binding heavily requires some tweaking to the |
d42471e
to
941c66c
Compare
📦 Binary Size-limit
❌ Size increased by 1150.33MB from 59.79MB to 1210.13MB (⬆️1923.89%) |
144c0f4
to
4a924a7
Compare
Summary
Introduce a new package
@rspack/binding-builder-cli
to build binding (bin:rspack-builder
).The new
@rspack/binding-builder-cli
will be utilized for bothcrates/node_binding
and projects usingrspack-binding-template
or similar.The original build script contains special environment variables and features that are specialized for
crates/node_binding
. With that being said, I kept the originalscripts/build.js
to callrspack-builder
to achieve the same effect.Rationale
This package is designed to provide a command-line interface for building custom bindings for rspack.
Rspack internally performs post-processing modifications on the generated TypeScript definition (.d.ts) files from NAPI-RS bindings. The @rspack/binding-builder-cli synchronizes these modifications, ensuring that the generated .d.ts files are complete and provide access to all type information available in @rspack/binding plus the newly added types in custom binding.
Debug
To debug
rspack-builder
, setDEBUG=rspack-builder:*
as a prefix to the command.Related links
Checklist