diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3e1afdb523..3c86cc90f2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,8 +104,8 @@ jobs: - name: Install dependencies run: yarn install - - name: Build - run: yarn build:node + - name: Build Rolldown + run: yarn build - name: Type Check run: yarn type-check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47de4c8845..7baedf3920 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: include: - os: macos-latest target: x86_64-apple-darwin - build: yarn build:binding:release + build: yarn build-binding:release - os: macos-latest target: aarch64-apple-darwin @@ -26,23 +26,23 @@ jobs: SYSROOT=$(xcrun --sdk macosx --show-sdk-path); export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; export CARGO_BUILD_TARGET=aarch64-apple-darwin - yarn build:binding:release + yarn build-binding:release - os: windows-latest target: x86_64-pc-windows-msvc - build: yarn build:binding:release + build: yarn build-binding:release - os: windows-latest target: i686-pc-windows-msvc build: | export CARGO_BUILD_TARGET=i686-pc-windows-msvc - yarn build:binding:release + yarn build-binding:release - os: windows-latest target: aarch64-pc-windows-msvc build: | export CARGO_BUILD_TARGET=aarch64-pc-windows-msvc - yarn build:binding:release + yarn build-binding:release - os: ubuntu-latest target: x86_64-unknown-linux-gnu @@ -50,12 +50,12 @@ jobs: build: |- set -e && export CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu && - yarn build:binding:release + yarn build-binding:release - os: ubuntu-latest target: x86_64-unknown-linux-musl docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine - build: yarn build:binding:release + build: yarn build-binding:release - os: ubuntu-latest target: aarch64-unknown-linux-gnu @@ -64,7 +64,7 @@ jobs: set -e && export CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu && rustup target add aarch64-unknown-linux-gnu && - yarn build:binding:release + yarn build-binding:release - os: ubuntu-latest target: armv7-unknown-linux-gnueabihf @@ -72,19 +72,19 @@ jobs: sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf -y export CARGO_BUILD_TARGET=armv7-unknown-linux-gnueabihf - yarn build:binding:release --zig --zig-link-only + yarn build-binding:release --zig --zig-link-only - os: ubuntu-latest target: aarch64-linux-android build: | export CARGO_BUILD_TARGET=aarch64-linux-android - yarn build:binding:release + yarn build-binding:release - os: ubuntu-latest target: armv7-linux-androideabi build: | export CARGO_BUILD_TARGET=armv7-linux-androideabi - yarn build:binding:release + yarn build-binding:release - os: ubuntu-latest target: aarch64-unknown-linux-musl @@ -94,7 +94,7 @@ jobs: rustup target add aarch64-unknown-linux-musl && export CARGO_BUILD_TARGET=aarch64-unknown-linux-musl && export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc && - yarn build:binding:release + yarn build-binding:release name: Build ${{ matrix.target }} runs-on: ${{ matrix.os }} steps: @@ -191,7 +191,7 @@ jobs: run: yarn install - name: Build Wasm - run: yarn build:wasm:release + run: yarn build-wasm:release - name: Upload Wasm Artifact uses: actions/upload-artifact@v4 diff --git a/crates/rolldown_binding_wasm/package.json b/crates/rolldown_binding_wasm/package.json index 48592c30a2..2f58e49565 100644 --- a/crates/rolldown_binding_wasm/package.json +++ b/crates/rolldown_binding_wasm/package.json @@ -11,10 +11,10 @@ "access": "public" }, "scripts": { - "build": "npm-run-all -s build:wasm clean-wasm-build", - "build:release": "npm-run-all -s build:wasm:release clean-wasm-build", - "build:wasm": "wasm-pack build --dev --target web -d ./dist", - "build:wasm:release": "wasm-pack build --release --target web -d ./dist", + "build": "npm-run-all -s build-wasm clean-wasm-build", + "build:release": "npm-run-all -s build-wasm:release clean-wasm-build", + "build-wasm": "wasm-pack build --dev --target web -d ./dist", + "build-wasm:release": "wasm-pack build --release --target web -d ./dist", "clean-wasm-build": "rm ./dist/.gitignore" }, "files": [ @@ -33,4 +33,4 @@ "npm-run-all": "^4.1.5", "wasm-pack": "^0.12.1" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 2c42fb7b7f..efc38d4c63 100644 --- a/package.json +++ b/package.json @@ -17,13 +17,12 @@ "scripts": { "lint-code": "oxlint --ignore-path=./.oxlintignore --import-plugin --deny-warnings", "lint-filename": "ls-lint", - "watch": "yarn run build --watch", - "build": "DEBUG='rolldown:*' node ./scripts/build-node-binding.js", - "build:node": "yarn workspaces foreach -R --topological-dev --from 'rolldown' run build", - "build:binding": "yarn workspace @rolldown/node-binding run build", - "build:binding:release": "yarn workspace @rolldown/node-binding run build:release", - "build:wasm": "yarn workspace @rolldown/wasm-binding run build", - "build:wasm:release": "yarn workspace @rolldown/wasm-binding run build:release", + "build": "yarn workspace rolldown run build", + "build:release": "yarn workspace rolldown run build:release", + "build-binding": "yarn workspace rolldown run build-binding", + "build-binding:release": "yarn workspace rolldown run build-binding-release", + "build-wasm": "yarn workspace @rolldown/wasm-binding run build", + "build-wasm:release": "yarn workspace @rolldown/wasm-binding run build:release", "test": "yarn workspaces foreach --all --parallel run test", "test:update": "yarn workspaces foreach --all --parallel run test:update", "test:update-rolldown": "yarn workspace node run test:update", diff --git a/scripts/build-binding.js b/scripts/build-binding.js deleted file mode 100644 index 0402bab2cd..0000000000 --- a/scripts/build-binding.js +++ /dev/null @@ -1,15 +0,0 @@ -import 'zx/globals' -import nodePath from 'path' -import { repoRoot } from './meta/constants.js' - -$.cwd = repoRoot -// process.chdir(nodePath.join(repoRoot, 'packages/node').normalize()) -process.chdir(repoRoot) - -const manifestPath = nodePath - .join('.', 'crates/rolldown_binding/Cargo.toml') - .normalize() - -const distPath = nodePath.join('.', 'packages/node/src').normalize() - -await $`yarn napi build --manifest-path ${manifestPath} --platform -p rolldown_binding --js ${path.join(distPath, 'binding').normalize()} --dts ${path.join(distPath, 'binding.d.ts').normalize()} -o .` diff --git a/scripts/build-node-binding.js b/scripts/build-node-binding.js.bak similarity index 100% rename from scripts/build-node-binding.js rename to scripts/build-node-binding.js.bak diff --git a/web/docs/contrib-guide/build.md b/web/docs/contrib-guide/build.md index 6c27220ca7..31963ebae8 100644 --- a/web/docs/contrib-guide/build.md +++ b/web/docs/contrib-guide/build.md @@ -4,41 +4,11 @@ Rolldown is built on Rust and Node.js, so and building process includes building 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` -- `rolldown`, 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. +To build the `rolldown` package, there are two commands: -## Incremental Build +- `yarn build` +- `yarn build:release` (**important if running benchmarks**) -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`, you can run `yarn build:node`. It will topologically run the `build` command in `rolldown` and `@rolldown/node-binding` package. - -To build some specific package only: - -For `rolldown`, you could run: - -- `yarn workspace rolldown 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. - -::: +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.