Skip to content

构建和运行

¥Building and running

继续之前,请确保已完成 设置过程 的配置。

¥Make sure you have gone through the setup process before continuing.

什么是 just

¥What is just?

justrolldown 仓库的命令运行器。它只需一条命令即可构建、测试和 lint 项目。

¥just is a command runner for the rolldown repository. It could build, test, and lint the project with a single command.

用法

¥Usage

你可以通过仅运行命令 just 来获取可用命令列表。

¥You could get a list of available commands by running the command just only.

重要命令

¥Important Commands

  • just roll - 从头构建 rolldown 并运行所有测试和检查。

    ¥just roll - Build rolldown from scratch and run all the tests and checks.

  • just test - 运行所有测试。

    ¥just test - Runs all tests.

  • just lint - 格式化并检查代码库。

    ¥just lint - Format and lint the codebase.

  • just fix - 修复格式和 linting 问题。

    ¥just fix - Fix formatting and linting issues.

  • just build - 构建 rolldown 节点包(和 @rolldown/pluginutils 节点包)。

    ¥just build - Build the rolldown node package (and @rolldown/pluginutils node package).

  • just run - 使用 node 运行 rolldown cli。

    ¥just run - Run the rolldown cli using node.

大多数命令会同时运行 Rust 和 Node.js 脚本。如果只针对一个环境,请在刚才的命令后附加 -rust-node。例如,just lint-rustjust test-node

¥Most of commands will run both Rust and Node.js scripts. To only target one, append -rust or -node to the just command. For example, just lint-rust or just test-node.

提示

just roll 将是你开发工作流程中最常用的命令。它将帮助你毫不费力地检查所做的任何更改是否一切正常。

¥just roll would be the most used command in your development workflow. It will help you, without any thinking, to check if everything is working correctly for any changes you made.

它将帮助你在本地捕获错误,而不是将你的更改推送到 GitHub 并等待 CI。

¥It will help you catch errors locally rather than pushing your changes to GitHub and waiting for the CI.

  • just roll-rust - 仅运行 Rust 检查。

    ¥just roll-rust - Run only Rust checks.

  • just roll-node - 仅运行 Node.js 检查。

    ¥just roll-node - Run only Node.js checks.

  • just roll-repo - 检查与代码无关的问题,例如文件名。

    ¥just roll-repo - Checks for non-code related issues, like file name.

构建

¥Building

Rolldown 基于 Rust 和 Node.js 构建,因此构建过程包括构建 Rust crate、Node.js 包以及将它们绑定在一起的胶水部分。glue 部分也是一个 Node.js 包,但构建它也会触发 Rust crate 的构建。

¥Rolldown is built on Rust and Node.js, so a 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.

幸运的是,NAPI-RS 封装了构建粘合部分的过程,我们无需担心细节。

¥Luckily, NAPI-RS has encapsulated the process of building the glue part, we don't need to worry about the details.

rolldown

要构建 rolldown 软件包,有两个命令:

¥To build the rolldown package, there are two commands:

  • just build/just build-rolldown

  • just build-rolldown-release(如果运行基准测试)

    ¥just build-rolldown-release (important if running benchmarks)

它们将自动构建 Rust 包和 Node.js 包。因此,无论你做了哪些更改,你都可以随时运行以下命令来构建最新的 rolldown 包。

¥They will automatically build the Rust crates and the Node.js package. So no matter what changes you made, you can always run these commands to build the latest rolldown package.

WASI

Rolldown 将 WASI 视为一个特殊平台,从而支持 WASI。因此,我们仍然使用 rolldown 包来分发 WASI 版本的 Rolldown。

¥Rolldown supports WASI by considering is as a special platform. So we still use the rolldown package to distribute the WASI version of Rolldown.

要构建 WASI 版本,你可以运行以下命令:

¥To build the WASI version, you can run the following command:

  • just build-browser

  • just build-browser-release(如果运行基准测试)

    ¥just build-browser-release (important if running benchmarks)

构建 WASI 版本将移除 Rolldown 的原生版本。我们特意设计了本地构建流程,即你要么构建原生版本,要么构建 WASI 版本。你不能将它们混合使用,但 NAPI-RS 支持这样做。

¥Building the WASI version will remove the native version of Rolldown. We designed the local build process on purpose that is you either build the native version or the WASI version. You can't mix them together, though NAPI-RS supports it.

正在运行

¥Running

你可以使用 just run 来通过 Node 运行 rolldown 命令行工具。

¥You could use just run to run the rolldown cli with node.

rolldown 包通过 pnpm 工作区自动链接到 node_modules,因此你可以使用以下命令运行它:

¥The rolldown package is linked to node_modules via pnpm workspace automatically, so you can run it with the following command:

sh
pnpm rolldown

just run 只是上述命令的别名。

¥just run is just an alias for the above command.

警告

运行 rolldown 包之前,请确保已使用 just build 构建。

¥Make sure you have built the rolldown package using just build before running it.