Skip to content

Commit

Permalink
Add other targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrunyon committed Jul 15, 2024
1 parent 89c615f commit e7c5bf1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/publish-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,24 @@ jobs:
permissions:
contents: read
id-token: write
strategy:
matrix:
target: [web, node, bundler, deno]
steps:
- uses: actions/checkout@v4
- name: "Install Rust toolchain"
run: rustup target add wasm32-unknown-unknown
- uses: jetli/[email protected]
- uses: jetli/[email protected]
- name: "Run wasm-pack build"
run: wasm-pack build --target web --scope astral-sh crates/ruff_wasm
run: wasm-pack build --target ${{ matrix.target }} crates/ruff_wasm
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: "Rename generated package"
run: | # Replace the package name w/ jq
jq '.name="@astral-sh/ruff-api-web"' crates/ruff_wasm/pkg/package.json > /tmp/package.json
jq '.name="@astral-sh/ruff-wasm-${{ matrix.target }}"' crates/ruff_wasm/pkg/package.json > /tmp/package.json
mv /tmp/package.json crates/ruff_wasm/pkg
- run: cp LICENSE crates/ruff_wasm/pkg # wasm-pack does not put the LICENSE file in the pkg
- name: "Publish"
Expand Down
14 changes: 11 additions & 3 deletions crates/ruff_wasm/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Ruff API
# Ruff WASM

> [!WARNING]
> This API is experimental and may change at any time
### ⚠️ WARNING: This API is experimental and may change at any time

[**Docs**](https://docs.astral.sh/ruff/) | [**Playground**](https://play.ruff.rs/)

An extremely fast Python linter and code formatter, written in Rust.

This is a WASM version of the Ruff API which can be used to lint/format Python in a browser environment.

There are multiple versions for the different wasm-pack targets. See [here](https://rustwasm.github.io/docs/wasm-bindgen/reference/deployment.html) for more info on targets.

- [Bundler](https://www.npmjs.com/package/@astral-sh/ruff-wasm-bundler)
- [Web](https://www.npmjs.com/package/@astral-sh/ruff-wasm-web)
- [Node.js](https://www.npmjs.com/package/@astral-sh/ruff-wasm-nodejs)
- [Deno](https://www.npmjs.com/package/@astral-sh/ruff-wasm-deno)

## Usage

This example uses the wasm-pack web target and is known to work with Vite.

```ts
import init, { Workspace, type Diagnostic } from '@astral-sh/ruff-api';

Expand Down

0 comments on commit e7c5bf1

Please sign in to comment.