Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,22 @@ jobs:
- name: Checkout repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install just
uses: extractions/setup-just@v2

- name: Install toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
bins: wasm-bindgen-cli@0.2.105, wasm-opt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build WASM module for bundlers
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --release --scope biomejs crates/biome_wasm
run: just build-wasm-bundler
- name: Build WASM module for node.js
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --release --scope biomejs crates/biome_wasm
run: just build-wasm-node
- name: Build WASM module for the web
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --release --scope biomejs crates/biome_wasm
run: just build-wasm-web

- name: Upload WASM artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/beta_js_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ jobs:
with:
node-version: 24.11.1

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install just
uses: extractions/setup-just@v2

- name: Install wasm-bindgen-cli
run: cargo install wasm-bindgen-cli --version 0.2.105

- name: Install wasm-tools
run: cargo install wasm-tools

- name: Cache pnpm modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,27 @@ jobs:
matrix:
include:
- target: wasm-bundler
wasm-pack-target: bundler
just-recipe: build-wasm-bundler
- target: wasm-nodejs
wasm-pack-target: nodejs
just-recipe: build-wasm-node
- target: wasm-web
wasm-pack-target: web
just-recipe: build-wasm-web
steps:
- name: Checkout repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install just
uses: extractions/setup-just@v2

- name: Install toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
bins: wasm-bindgen-cli@0.2.105, wasm-opt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build WASM module ${{ matrix.target }}
run: wasm-pack build --out-dir ../../packages/@biomejs/${{ matrix.target }} --target ${{ matrix.wasm-pack-target }} --release --scope biomejs crates/biome_wasm
run: just ${{ matrix.just-recipe }}

- name: Upload WASM artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pull_request_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
with:
cache-target: release
cache-base: main
bins: wasm-bindgen-cli@0.2.105, wasm-opt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build main binary
Expand All @@ -52,8 +53,9 @@ jobs:
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Install just
uses: extractions/setup-just@v2

- name: Build TypeScript code
# We use the `*-dev` builds below because release builds take very long.
Expand Down
46 changes: 29 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,31 @@ jobs:
runs-on: depot-ubuntu-24.04-arm-16
needs: version
if: needs.version.outputs.cli-version
strategy:
matrix:
include:
- target: wasm-bundler
just-recipe: build-wasm-bundler
- target: wasm-nodejs
just-recipe: build-wasm-node
- target: wasm-web
just-recipe: build-wasm-web
steps:
- name: Checkout repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install just
uses: extractions/setup-just@v2

- name: Install toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
bins: wasm-bindgen-cli@0.2.105, wasm-opt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build WASM module for bundlers
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --release --scope biomejs crates/biome_wasm
- name: Build WASM module for node.js
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --release --scope biomejs crates/biome_wasm
- name: Build WASM module for the web
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --release --scope biomejs crates/biome_wasm
- name: Build WASM module ${{ matrix.target }}
run: just ${{ matrix.just-recipe }}

- name: Upload WASM artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
Expand Down Expand Up @@ -283,8 +295,15 @@ jobs:
with:
node-version: 24.11.1

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install just
uses: extractions/setup-just@v2

- name: Install toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
bins: wasm-bindgen-cli@0.2.105, wasm-opt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cache pnpm modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
Expand Down Expand Up @@ -358,13 +377,6 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

# The WASM job updates the package.json file, because of wasm-pack, which we need to restore
- name: Restore packages changes
run: |
git restore packages/@biomejs/wasm-bundler/package.json
git restore packages/@biomejs/wasm-nodejs/package.json
git restore packages/@biomejs/wasm-web/package.json

- name: Generate npm packages
run: node packages/@biomejs/biome/scripts/generate-packages.mjs

Expand Down
27 changes: 17 additions & 10 deletions .github/workflows/repository_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
env:
BIOME_WEBSITE_REPO: biomejs/website
BIOME_PUSH_ON_MAIN_EVENT_TYPE: biome-push-on-main-event
WASM_PACK_CACHE_KEY: wasm-pack-cache
WASM_CACHE_KEY: wasm-cache
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache key changes were mine


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -27,38 +27,45 @@ jobs:
- name: Checkout repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

- name: Warm up wasm-pack cache
- name: Warm up wasm cache
id: cache-restore
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
./target
./packages/@biomejs/wasm-web
key: ${{ env.WASM_PACK_CACHE_KEY }}
key: ${{ env.WASM_CACHE_KEY }}

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install just
uses: extractions/setup-just@v2

- name: Install toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
bins: wasm-bindgen-cli@0.2.105, wasm-opt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build WASM module for the web
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm
run: just build-wasm-web

# https://github.com/actions/cache/issues/342
- name: Clear old wasm-pack cache
- name: Clear old wasm cache
if: ${{ steps.cache-restore.outputs.cache-hit }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ env.WASM_PACK_CACHE_KEY }} --confirm
gh actions-cache delete ${{ env.WASM_CACHE_KEY }} --confirm
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true

- name: Save new wasm-pack cache
- name: Save new wasm cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
./target
./packages/@biomejs/wasm-web
key: ${{ env.WASM_PACK_CACHE_KEY }}
key: ${{ env.WASM_CACHE_KEY }}

- name: Install pnpm
# workaround for the issue https://github.com/actions/setup-node/issues/1222
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ This command will install:
- `cargo-binstall`, to install binary extensions for `cargo`.
- `cargo-insta`, a `cargo` extension to manage snapshot testing inside the repository.
- `taplo-cli`, a small tool for formatting TOML files.
- `wasm-pack` and `wasm-tools` for managing the WASM build of Biome.
- `wasm-bindgen-cli` and `wasm-opt` for managing the WASM build of Biome.

You'll also need to have `pnpm` installed on your machine, and run `pnpm install` from the root of the repository. `pnpm` is needed to [create changesets](#create-a-changeset)

Expand Down Expand Up @@ -343,7 +343,7 @@ The npm module `packages/@biomejs/biome` contains Biome's Node.js API that suppo
For testing and developing, you need to build these packages, following the steps:

1. install pnpm via [corepack](https://nodejs.org/api/corepack.html) by running `corepack enable`;
2. install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) globally;
2. install `wasm-bindgen-cli` and `wasm-opt` by running `just install-tools`;
3. run `pnpm --filter "@biomejs/backend-jsonrpc" build`;
4. run the `pnpm --filter "@biomejs/js-api" build:wasm-dev` and `pnpm --filter "@biomejs/js-api" build` commands;
5. run `pnpm i --filter "@biomejs/js-api" --frozen-lockfile` to link the WebAssembly bindings and the JSON-RPC bindings
Expand Down
3 changes: 2 additions & 1 deletion crates/biome_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ js-sys = "0.3.82"
serde = { workspace = true }
serde-wasm-bindgen = "0.6.5"
serde_json = { workspace = true }
wasm-bindgen = { version = "0.2.105", features = ["serde-serialize"] }
# IMPORTANT: if you update this package, you must update justfile and workflows so we install the same CLI version
wasm-bindgen = { version = "0.2.105", features = ["serde-serialize"] }

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
Expand Down
69 changes: 67 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ alias qt := test-quick
# Installs the tools needed to develop
install-tools:
cargo install cargo-binstall
cargo binstall cargo-insta taplo-cli wasm-pack wasm-tools
cargo binstall cargo-insta taplo-cli wasm-opt
cargo binstall wasm-bindgen-cli --version 0.2.105

# Upgrades the tools needed to develop
upgrade-tools:
cargo install cargo-binstall --force
cargo binstall cargo-insta taplo-cli wasm-pack wasm-tools --force
cargo binstall cargo-insta taplo-cli wasm-opt --force
cargo binstall wasm-bindgen-cli --version 0.2.105 --force

# Generate all files across crates and tools. You rarely want to use it locally.
gen-all:
Expand Down Expand Up @@ -69,6 +71,69 @@ gen-tw:
pnpm build
pnpm execute

# Build WASM for bundler target (development)
build-wasm-bundler-dev:
cargo build --lib --target wasm32-unknown-unknown -p biome_wasm
wasm-bindgen target/wasm32-unknown-unknown/debug/biome_wasm.wasm \
--out-dir packages/@biomejs/wasm-bundler \
--target bundler \
--typescript

# Build WASM for bundler target (release)
build-wasm-bundler:
cargo build --lib --target wasm32-unknown-unknown --release -p biome_wasm
wasm-bindgen target/wasm32-unknown-unknown/release/biome_wasm.wasm \
--out-dir packages/@biomejs/wasm-bundler \
--no-demangle \
--target bundler \
--typescript
wasm-opt packages/@biomejs/wasm-bundler/biome_wasm_bg.wasm \
-o packages/@biomejs/wasm-bundler/biome_wasm_bg.wasm \
-Os \
-g

# Build WASM for Node.js target (development)
build-wasm-node-dev:
cargo build --lib --target wasm32-unknown-unknown -p biome_wasm
wasm-bindgen target/wasm32-unknown-unknown/debug/biome_wasm.wasm \
--out-dir packages/@biomejs/wasm-nodejs \
--target nodejs \
--typescript

# Build WASM for Node.js target (release)
build-wasm-node:
cargo build --lib --target wasm32-unknown-unknown --release -p biome_wasm
wasm-bindgen target/wasm32-unknown-unknown/release/biome_wasm.wasm \
--out-dir packages/@biomejs/wasm-nodejs \
--no-demangle \
--target nodejs \
--typescript
wasm-opt packages/@biomejs/wasm-nodejs/biome_wasm_bg.wasm \
-o packages/@biomejs/wasm-nodejs/biome_wasm_bg.wasm \
-Os \
-g

# Build WASM for web target (development)
build-wasm-web-dev:
cargo build --lib --target wasm32-unknown-unknown -p biome_wasm
wasm-bindgen target/wasm32-unknown-unknown/debug/biome_wasm.wasm \
--out-dir packages/@biomejs/wasm-web \
--target web \
--typescript

# Build WASM for web target (release)
build-wasm-web:
cargo build --lib --target wasm32-unknown-unknown --release -p biome_wasm
wasm-bindgen target/wasm32-unknown-unknown/release/biome_wasm.wasm \
--out-dir packages/@biomejs/wasm-web \
--no-demangle \
--target web \
--typescript
wasm-opt packages/@biomejs/wasm-web/biome_wasm_bg.wasm \
-o packages/@biomejs/wasm-web/biome_wasm_bg.wasm \
-Os \
-g

# Generates the code of the grammars available in Biome
gen-grammar *args='':
cargo run -p xtask_codegen -- grammar {{args}}
Expand Down
12 changes: 6 additions & 6 deletions packages/@biomejs/js-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"check:apply": "cargo biome-cli-dev check --apply-unsafe .",
"build:wasm-dev": "pnpm run \"/^build:wasm-.+-dev$/\"",
"build:wasm": "pnpm run \"/^build:wasm-.+(?<!dev)$/\"",
"build:wasm-bundler-dev": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --dev --scope biomejs ../../../crates/biome_wasm",
"build:wasm-bundler": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --release --scope biomejs ../../../crates/biome_wasm",
"build:wasm-node-dev": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --dev --scope biomejs ../../../crates/biome_wasm",
"build:wasm-node": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-nodejs --target nodejs --release --scope biomejs ../../../crates/biome_wasm",
"build:wasm-web-dev": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --dev --scope biomejs ../../../crates/biome_wasm",
"build:wasm-web": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --release --scope biomejs ../../../crates/biome_wasm",
"build:wasm-bundler-dev": "just build-wasm-bundler-dev",
"build:wasm-bundler": "just build-wasm-bundler",
"build:wasm-node-dev": "just build-wasm-node-dev",
"build:wasm-node": "just build-wasm-node",
"build:wasm-web-dev": "just build-wasm-web-dev",
"build:wasm-web": "just build-wasm-web",
"test": "vitest",
"test:ci": "vitest run",
"build": "tsc"
Expand Down
5 changes: 5 additions & 0 deletions packages/@biomejs/wasm-bundler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
biome_wasm.d.ts
biome_wasm.js
biome_wasm_bg.js
biome_wasm_bg.wasm
biome_wasm_bg.wasm.d.ts
4 changes: 4 additions & 0 deletions packages/@biomejs/wasm-nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
biome_wasm.d.ts
biome_wasm.js
biome_wasm_bg.wasm
biome_wasm_bg.wasm.d.ts
4 changes: 4 additions & 0 deletions packages/@biomejs/wasm-web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
biome_wasm.d.ts
biome_wasm.js
biome_wasm_bg.wasm
biome_wasm_bg.wasm.d.ts
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# https://rust-lang.github.io/rustup/concepts/profiles.html
profile = "default"
channel = "1.91.1"
targets = ["wasm32-unknown-unknown"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude wanted us to install the target in CI lol. I suggested a different approach