Skip to content

Commit 55ca2e9

Browse files
authored
feat: Add wasm module build (#1)
1 parent 339d1f8 commit 55ca2e9

File tree

13 files changed

+440
-146
lines changed

13 files changed

+440
-146
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CI
2-
on: [push]
2+
on: [push, pull_request]
33
env:
44
CARGO_TERM_COLOR: always
55
RUST_VERSION: 1.84.1
@@ -14,6 +14,10 @@ jobs:
1414
run: rustup toolchain install ${{ env.RUST_VERSION }} --component clippy --component rustfmt && rustup default ${{ env.RUST_VERSION }}
1515
- name: Cache
1616
uses: Swatinem/rust-cache@v2
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version-file: 'package.json'
1721
- name: Build
1822
run: cargo build --all
1923
- name: Run tests
@@ -22,6 +26,8 @@ jobs:
2226
run: cargo clippy --all -- -D warnings
2327
- name: Run fmt
2428
run: cargo fmt --all -- --check
29+
- name: Build and Test wasm
30+
run: npm install && npm run build && npm test
2531
- name: Install license tool
2632
run: cargo install dd-rust-license-tool
2733
- name: Run license tool

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
^target/
33
target
44
tests/*/instrumented.*
5+
pkg/
6+
node_modules/
7+
package-lock.json

Cargo.lock

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

Cargo.toml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,31 @@ rust-version = "1.84.1"
66
license = "Apache-2.0"
77

88
[lib]
9-
# crate-type = ["cdylib"]
10-
# This was originally set as above, but commented to run tests in tests folder.
9+
crate-type = ["cdylib", "rlib"]
1110

12-
[profile.release]
13-
lto = true
11+
[features]
12+
serde = ["serde/derive"]
13+
wasm = ['serde', "wasm-bindgen", "tsify", "getrandom"]
1414

1515
[dependencies]
16-
nodejs-semver = "4"
16+
nodejs-semver = { version = "4", features = ["serde"] }
1717
swc = "21"
1818
swc_core = { version = "22", features = ["ecma_plugin_transform","ecma_quote"] }
1919
swc_ecma_parser = "11"
2020
swc_ecma_visit = { version = "8", features = ["path"] }
2121

22+
# serde feature
23+
serde = { version = "1", features = ["derive"], optional = true }
24+
25+
# wasm feature
26+
wasm-bindgen = { version = "0.2", optional = true }
27+
tsify = { version='0.5', features = ["js"], optional = true}
28+
# we need this to enable the js feature
29+
getrandom = { version = "*", features = ["js"], optional = true }
30+
2231
[dev-dependencies]
2332
assert_cmd = "2"
33+
34+
[profile.release]
35+
lto = true
36+
opt-level = "s"

0 commit comments

Comments
 (0)