From 59cfa8f17b956fea1e787faaf86d8e94afcd7ff2 Mon Sep 17 00:00:00 2001 From: Luca Schneider Date: Fri, 10 Jan 2025 08:58:56 +0100 Subject: [PATCH] Update wasm target --- .changeset/new-news-smile.md | 5 +++++ .github/workflows/codspeed.yml | 4 ++-- .github/workflows/docs.yml | 4 ++-- .github/workflows/example.yml | 4 ++-- .github/workflows/node.js.yml | 4 ++-- CONTRIBUTION.md | 4 ++-- packages/docs/app/api/transform/route.ts | 6 +++--- packages/docs/next.config.mjs | 8 ++++---- packages/yak-swc/package.json | 4 ++-- packages/yak-swc/yak_swc/.cargo/config | 2 +- 10 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 .changeset/new-news-smile.md diff --git a/.changeset/new-news-smile.md b/.changeset/new-news-smile.md new file mode 100644 index 00000000..8fb3dc00 --- /dev/null +++ b/.changeset/new-news-smile.md @@ -0,0 +1,5 @@ +--- +"yak-swc": patch +--- + +Update wasm target to wasm-wasip1 diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index d623a75a..14f3f557 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -42,8 +42,8 @@ jobs: profile: minimal override: true - - name: Add wasm32-wasi target - run: rustup target add wasm32-wasi + - name: Add wasm32-wasip1 target + run: rustup target add wasm32-wasip1 - name: Enable caching uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c3f68efb..ddf06dc8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -50,8 +50,8 @@ jobs: profile: minimal override: true - - name: Add wasm32-wasi target - run: rustup target add wasm32-wasi + - name: Add wasm32-wasip1 target + run: rustup target add wasm32-wasip1 - name: Enable caching uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 2f4df540..269dd2ff 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -44,8 +44,8 @@ jobs: toolchain: stable profile: minimal override: true - - name: Add wasm32-wasi target - run: rustup target add wasm32-wasi + - name: Add wasm32-wasip1 target + run: rustup target add wasm32-wasip1 - name: Enable caching uses: Swatinem/rust-cache@v2 with: diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index fb6c8ad9..e95c0bb6 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -41,8 +41,8 @@ jobs: toolchain: stable profile: minimal override: true - - name: Add wasm32-wasi target - run: rustup target add wasm32-wasi + - name: Add wasm32-wasip1 target + run: rustup target add wasm32-wasip1 - name: Enable caching uses: Swatinem/rust-cache@v2 with: diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index 92a0ad49..5af82946 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -31,7 +31,7 @@ Before you begin Install Rust from [rust-lang.org](https://www.rust-lang.org/tools/install), following the official instructions for your platform - Add the Rust WebAssembly target, execute ```bash - rustup target add wasm32-wasi + rustup target add wasm32-wasip1 ``` ### Initial setup @@ -183,7 +183,7 @@ export default withYak({ ### Rust setup issues - **Permission problems with Rust**: Make sure to install Rust from [rust-lang.org](https://www.rust-lang.org/tools/install) and not through package managers -- **Missing wasm32-wasi target**: Run `rustup target add wasm32-wasi` +- **Missing wasm32-wasip1 target**: Run `rustup target add wasm32-wasip1` - **Cargo build failures**: Ensure you have the latest stable Rust toolchain with `rustup update stable` ### Build issues diff --git a/packages/docs/app/api/transform/route.ts b/packages/docs/app/api/transform/route.ts index 5ef87c34..2e4aef09 100644 --- a/packages/docs/app/api/transform/route.ts +++ b/packages/docs/app/api/transform/route.ts @@ -1,17 +1,17 @@ +import * as swc from "@swc/core"; import { NextRequest, NextResponse } from "next/server"; +import path from "path"; import { type Compilation } from "webpack"; -import * as swc from "@swc/core"; // had to update package exports // @ts-ignore import cssLoader = require("next-yak/loaders/css-loader"); -import path from "path"; export const maxDuration = 60; const wasmPath = path.resolve( process.cwd(), "./node_modules", - "yak-swc/target/wasm32-wasi/release/yak_swc.wasm", + "yak-swc/target/wasm32-wasip1/release/yak_swc.wasm", ); export async function POST(request: NextRequest) { diff --git a/packages/docs/next.config.mjs b/packages/docs/next.config.mjs index a5fb581b..1404c595 100644 --- a/packages/docs/next.config.mjs +++ b/packages/docs/next.config.mjs @@ -1,5 +1,5 @@ import { createMDX } from "fumadocs-mdx/next"; -import {withYak} from "next-yak/withYak"; +import { withYak } from "next-yak/withYak"; const withMDX = createMDX(); @@ -16,11 +16,11 @@ const config = { }, outputFileTracingIncludes: { // add yak-swc as a dependency for the /api/transform route - '/api/transform': ['./node_modules/yak-swc/*'], - '/api/transform': ['./node_modules/yak-swc/target/wasm32-wasi/release/*'], + "/api/transform": ["./node_modules/yak-swc/*"], + "/api/transform": ["./node_modules/yak-swc/target/wasm32-wasip1/release/*"], }, outputFileTracingExcludes: { - '/api/transform': ['../../node_modules/yak-swc/**/*'], + "/api/transform": ["../../node_modules/yak-swc/**/*"], }, // use the raw-loader for .d.ts files (used by the playground) webpack: (config) => { diff --git a/packages/yak-swc/package.json b/packages/yak-swc/package.json index 80739f0d..10cefdf1 100644 --- a/packages/yak-swc/package.json +++ b/packages/yak-swc/package.json @@ -18,9 +18,9 @@ "react", "typescript" ], - "main": "target/wasm32-wasi/release/yak_swc.wasm", + "main": "target/wasm32-wasip1/release/yak_swc.wasm", "scripts": { - "build": "cargo build --release --target=wasm32-wasi", + "build": "cargo build --release --target=wasm32-wasip1", "prepublishOnly": "node ../../scripts/check-pnpm.js && npm run build", "prettier": "cargo fmt --all", "test": "cargo test", diff --git a/packages/yak-swc/yak_swc/.cargo/config b/packages/yak-swc/yak_swc/.cargo/config index eaa0fee6..5e9878a1 100644 --- a/packages/yak-swc/yak_swc/.cargo/config +++ b/packages/yak-swc/yak_swc/.cargo/config @@ -1,5 +1,5 @@ # These command aliases are not final, may change [alias] # Alias to build actual plugin binary for the specified target. -build-wasi = "build --target wasm32-wasi" +build-wasip1 = "build --target wasm32-wasip1" build-wasm32 = "build --target wasm32-unknown-unknown"