Skip to content

Commit

Permalink
chore(rust): 使用wasm32-wasip1代替wasm32-wasi,解决编译出错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yushijie1 committed Jan 13, 2025
1 parent 2ec47d9 commit 3de9c2a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustflags = ["-C", "target-feature=+crt-static"]

[alias]
# Alias to build actual SWC plugin binary for the specified target.
build-wasi = "build --target wasm32-wasi"
build-wasi = "build --target wasm32-wasip1"
build-wasm32 = "build --target wasm32-unknown-unknown"
build-swc-plugins = "build-wasi --release -p swc_plugin_compile_mode -p swc_plugin_define_config -p swc_plugin_compile_mode_pre_process"
test-swc-plugins = "test -p swc_plugin_compile_mode -p swc_plugin_define_config -p swc_plugin_compile_mode_pre_process"
4 changes: 2 additions & 2 deletions .github/workflows/build-rust-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-wasi
targets: wasm32-wasip1
- name: Cache cargo
uses: actions/cache@v3
with:
Expand All @@ -33,5 +33,5 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: wasm-wasi-swc_plugins
path: target/wasm32-wasi/release/*.wasm
path: target/wasm32-wasip1/release/*.wasm
if-no-files-found: error
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-wasi
targets: wasm32-wasip1
- name: Cache cargo
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ $ pnpm --filter @tarojs/binding run test

#### SWC 插件

首先在项目根目录执行 `rustup target add wasm32-wasi` 命令安装 `wasm32-wasi``target`
首先在项目根目录执行 `rustup target add wasm32-wasip1` 命令安装 `wasm32-wasip1``target`

开发过程中可以使用 SWC 测试套件进行单元测试:

Expand All @@ -207,7 +207,7 @@ $ cargo build -p [package-name]

Cargo workspace 会把编译产物输出到根目录的 `target` 文件夹中。进行集成测试时,需要手动把 `.wasm` 产物软链到目标文件夹,而 Github CI 在正式发布时会自动拷贝产物到正确的文件夹中。

如对 `@taorjs/helper` 进行集成测试时,会把 `target/wasm32-wasi/release/swc_plugin_xxx.wasm` 文件的软链到 `packages/taro-helper/swc/swc_plugin_xxx.wasm`
如对 `@taorjs/helper` 进行集成测试时,会把 `target/wasm32-wasip1/release/swc_plugin_xxx.wasm` 文件的软链到 `packages/taro-helper/swc/swc_plugin_xxx.wasm`

####

Expand Down

0 comments on commit 3de9c2a

Please sign in to comment.