Skip to content

Commit 17c7289

Browse files
Make it work
1 parent 7a6941c commit 17c7289

File tree

15 files changed

+158
-34
lines changed

15 files changed

+158
-34
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
node-version: ${{ matrix.node-version }}
5151
cache: 'pnpm'
5252

53+
- name: Setup WASM target
54+
run: rustup target add wasm32-wasip1-threads
55+
5356
# Cargo already skips downloading dependencies if they already exist
5457
- name: Cache cargo
5558
uses: actions/cache@v4

.github/workflows/integration-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- vite
3131
- cli
3232
- postcss
33-
- workers
33+
- oxide
3434
- webpack
3535

3636
# Exclude windows and macos from being built on feature branches
@@ -59,6 +59,9 @@ jobs:
5959
node-version: ${{ matrix.node-version }}
6060
cache: 'pnpm'
6161

62+
- name: Setup WASM target
63+
run: rustup target add wasm32-wasip1-threads
64+
6265
# Cargo already skips downloading dependencies if they already exist
6366
- name: Cache cargo
6467
uses: actions/cache@v4

Cargo.lock

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

crates/node/.gitignore

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,9 @@ Cargo.lock
199199
# Generated
200200
index.d.ts
201201
index.js
202-
203-
# wasm stuff
204202
*.wasm
205-
/browser.js
206-
/tailwindcss-oxide.wasi-browser.js
207-
/tailwindcss-oxide.wasi.cjs
208-
/wasi-worker-browser.mjs
209-
/wasi-worker.mjs
203+
browser.js
204+
tailwindcss-oxide.wasi-browser.js
205+
tailwindcss-oxide.wasi.cjs
206+
wasi-worker-browser.mjs
207+
wasi-worker.mjs

crates/node/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ crate-type = ["cdylib"]
88

99
[dependencies]
1010
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
11-
napi = { version = "2.16.16", default-features = false, features = ["napi4"] }
11+
napi = { version = "2.16.17", default-features = false, features = ["napi4"] }
1212
napi-derive = "2.16.13"
1313
tailwindcss-oxide = { path = "../oxide" }
1414
rayon = "1.10.0"
1515

1616
[build-dependencies]
17-
napi-build = "2.1.4"
17+
napi-build = "2.1.6"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

crates/node/npm/wasm32-wasi/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node-linker=hoisted

crates/node/npm/wasm32-wasi/package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tailwindcss/oxide-wasm32-wasi",
3-
"version": "4.1.2",
3+
"version": "4.1.3",
44
"cpu": [
55
"wasm32"
66
],
@@ -27,6 +27,19 @@
2727
},
2828
"browser": "tailwindcss-oxide.wasi-browser.js",
2929
"dependencies": {
30-
"@napi-rs/wasm-runtime": "^0.2.8"
31-
}
30+
"@napi-rs/wasm-runtime": "^0.2.8",
31+
"@emnapi/core": "^1.4.0",
32+
"@emnapi/runtime": "^1.4.0",
33+
"@tybys/wasm-util": "^0.9.0",
34+
"@emnapi/wasi-threads": "^1.0.1",
35+
"tslib": "^2.8.0"
36+
},
37+
"bundledDependencies": [
38+
"@napi-rs/wasm-runtime",
39+
"@emnapi/core",
40+
"@emnapi/runtime",
41+
"@tybys/wasm-util",
42+
"@emnapi/wasi-threads",
43+
"tslib"
44+
]
3245
}

crates/node/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"main": "index.js",
1010
"types": "index.d.ts",
1111
"napi": {
12-
"name": "tailwindcss-oxide",
1312
"binaryName": "tailwindcss-oxide",
1413
"packageName": "@tailwindcss/oxide",
1514
"targets": [
@@ -35,6 +34,7 @@
3534
"license": "MIT",
3635
"devDependencies": {
3736
"@napi-rs/cli": "^3.0.0-alpha.77",
37+
"@napi-rs/wasm-runtime": "^0.2.8",
3838
"emnapi": "1.3.1"
3939
},
4040
"engines": {
@@ -50,7 +50,9 @@
5050
},
5151
"scripts": {
5252
"artifacts": "napi artifacts",
53-
"build": "napi build --platform --release --no-const-enum",
53+
"build": "pnpm run build:platform && pnpm run build:wasm",
54+
"postbuild": "node ./scripts/move-artifacts.mjs",
55+
"build:platform": "napi build --platform --release --no-const-enum",
5456
"build:wasm": "napi build --release --target wasm32-wasip1-threads",
5557
"dev": "cargo watch --quiet --shell 'npm run build'",
5658
"build:debug": "napi build --platform --no-const-enum",
@@ -66,8 +68,8 @@
6668
"@tailwindcss/oxide-linux-arm64-musl": "workspace:*",
6769
"@tailwindcss/oxide-linux-x64-gnu": "workspace:*",
6870
"@tailwindcss/oxide-linux-x64-musl": "workspace:*",
71+
"@tailwindcss/oxide-wasm32-wasi": "workspace:*",
6972
"@tailwindcss/oxide-win32-arm64-msvc": "workspace:*",
70-
"@tailwindcss/oxide-win32-x64-msvc": "workspace:*",
71-
"@tailwindcss/oxide-wasm32-wasi": "workspace:*"
73+
"@tailwindcss/oxide-win32-x64-msvc": "workspace:*"
7274
}
7375
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import fs from 'node:fs/promises'
2+
import path from 'node:path'
3+
import url from 'node:url'
4+
5+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
6+
let root = path.resolve(__dirname, '..')
7+
const tailwindcssOxideRoot = path.join(root)
8+
9+
// Move napi artifacts into sub packages
10+
for (let file of await fs.readdir(tailwindcssOxideRoot)) {
11+
if (file.startsWith('tailwindcss-oxide.') && file.endsWith('.node')) {
12+
let target = file.split('.')[1]
13+
await fs.cp(
14+
path.join(tailwindcssOxideRoot, file),
15+
path.join(tailwindcssOxideRoot, 'npm', target, file),
16+
)
17+
}
18+
}
19+
20+
// Move napi wasm artifacts into sub package
21+
let wasmArtifacts = {
22+
'tailwindcss-oxide.debug.wasm': 'tailwindcss-oxide.wasm32-wasi.debug.wasm',
23+
'tailwindcss-oxide.wasm': 'tailwindcss-oxide.wasm32-wasi.wasm',
24+
'tailwindcss-oxide.wasi-browser.js': 'tailwindcss-oxide.wasi-browser.js',
25+
'tailwindcss-oxide.wasi.cjs': 'tailwindcss-oxide.wasi.cjs',
26+
'wasi-worker-browser.mjs': 'wasi-worker-browser.mjs',
27+
'wasi-worker.mjs': 'wasi-worker.mjs',
28+
}
29+
for (let file of await fs.readdir(tailwindcssOxideRoot)) {
30+
if (!wasmArtifacts[file]) continue
31+
await fs.cp(
32+
path.join(tailwindcssOxideRoot, file),
33+
path.join(tailwindcssOxideRoot, 'npm', 'wasm32-wasi', wasmArtifacts[file]),
34+
)
35+
}

0 commit comments

Comments
 (0)