Skip to content

Commit 2985bf3

Browse files
committed
ci(wasm): check wasm32-wasip1-threads build (oxc-project#9569)
Duplicate of oxc-project#9555, but just stacked on top of oxc-project#9566. `napi-rs` for some reason omits the `export * from '@oxc-project/types';` line from `index.d.ts` when building for WASM. I don't know how to fix that, so added a hacky script to fix up `index.d.ts` manually. This is not at all ideal, but at least it now compiles and CI passes.
1 parent 91c9932 commit 2985bf3

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292

9393
test-wasm32-wasip1-threads:
9494
name: Test wasm32-wasip1-threads
95-
if: ${{ github.ref_name == 'main' }}
95+
# if: ${{ github.ref_name == 'main' }}
9696
runs-on: ubuntu-latest
9797
env:
9898
RUSTFLAGS: "--cfg tokio_unstable -C target-feature=+atomics,+bulk-memory,+mutable-globals,+simd128 -C link-args=--max-memory=67108864"
@@ -105,8 +105,14 @@ jobs:
105105
with:
106106
cache-key: wasi
107107
save-cache: ${{ github.ref_name == 'main' }}
108+
- uses: ./.github/actions/pnpm
108109
- run: rustup target add wasm32-wasip1-threads
109110
- uses: bytecodealliance/actions/wasmtime/setup@3b93676295fd6f7eaa7af2c2785539e052fa8349 # v1.1.1
111+
- run: pnpm napi build --target wasm32-wasip1-threads --manifest-path ./napi/parser/Cargo.toml
112+
- run: pnpm napi build --target wasm32-wasip1-threads --manifest-path ./napi/transform/Cargo.toml
113+
- run: pnpm napi build --target wasm32-wasip1-threads --manifest-path ./napi/minify/Cargo.toml
114+
# Fix `index.d.ts`
115+
- run: node napi/parser/scripts/fix-wasm-dts.mjs
110116
- run: cargo test --target wasm32-wasip1-threads ${TEST_FLAGS}
111117
- run: git diff --exit-code # Must commit everything
112118

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { readFileSync, writeFileSync } from 'node:fs';
2+
import { join as pathJoin } from 'node:path';
3+
4+
// Add missing `export * from '@oxc-project/types';` line to `index.d.ts`
5+
const path = pathJoin(import.meta.dirname, '../index.d.ts');
6+
let dts = readFileSync(path, 'utf8');
7+
const lines = dts.split('\n');
8+
lines.splice(2, 0, '', "export * from '@oxc-project/types';");
9+
dts = lines.join('\n');
10+
writeFileSync(path, dts);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"devDependencies": {
1414
"@napi-rs/cli": "catalog:",
15+
"emnapi": "1.3.1",
1516
"typescript": "catalog:",
1617
"vitest": "catalog:"
1718
}

pnpm-lock.yaml

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)