forked from rolldown/rolldown
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: improve guide for setup and building (rolldown#536)
<!-- Thank you for contributing! --> ### Description <!-- Please insert your description here and provide especially info about the "what" this PR is solving --> ### Test Plan <!-- e.g. is there anything you'd like reviewers to focus on? --> ---
- Loading branch information
Showing
6 changed files
with
109 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
# Building Bindings | ||
# Building | ||
|
||
For the NAPI-RS based Node packages to work, and for their tests and benchmarks to run, they must be built first. This is done by running `yarn build` in the root directory. This will spin up a process that builds the Node/WASM binding crates (with Cargo), and then builds the rolldown npm package. The `yarn build` script is also smart enough to only re-build if it detects changes since the last time it was run. | ||
Rolldown is built on Rust and Node.js, so and building process includes building Rust crates, Node.js packages and the glue part that binds them together. The glue part is also a Node.js package, but building it will also trigger building the Rust crates. | ||
|
||
Luckily, NAPI-RS has encapsulated the process of building the glue part, we don't need to worry about the details. | ||
|
||
Typically, rolldown has two main packages: | ||
|
||
- `@rolldown/node`, which is the final npm package that users will install directly. | ||
- `@rolldown/node-binding`, which is the glue part that binds Rust and Node.js together. | ||
|
||
## Incremental Build | ||
|
||
For the NAPI-RS based Node packages to work, and for their tests and benchmarks to run, they must be built first. This is done by running `yarn build` in the root directory. This will spin up a process that builds the Node/WASM binding crates (with Cargo), and then builds the rolldown npm package. | ||
|
||
The `yarn build` script is also smart enough to only re-build if it detects changes since the last time it was run. | ||
|
||
`yarn build` accepts two flags: | ||
|
||
- `--no-wasm` | ||
- `--release` (**important if running benchmarks**) | ||
|
||
In addition, the `yarn watch` script can be used to watch the file system for changes, and re-build the bindings and npm package when changes are detected (using the same process as `yarn build`). This is useful for development when you're constantly making changes and re-running tests. | ||
|
||
## Fresh Build | ||
|
||
If you want to force a fresh build on `@rolldown/node`, you can run `yarn build:node`. It will topologically run the `build` command in `@rolldown/node` and `@rolldown/node-binding` package. | ||
|
||
To build some specific package only: | ||
|
||
For `@rolldown/node`, you could run: | ||
|
||
- `yarn workspace @rolldown/node build`. | ||
|
||
For `@rolldown/node-binding`, you could run: | ||
|
||
- `yarn workspace @rolldown/node-binding build` | ||
- `yarn workspace @rolldown/node-binding build:release` (**important if running benchmarks**) | ||
|
||
:::warning | ||
|
||
Due to the boundary between Rust and Node.js, once you changed the Rust code, you need to rebuild the `@rolldown/node-binding` package to see the changes while executing in Node.js. | ||
|
||
::: |
This file contains 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