Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing the Plugin: On Prerequisites and Consistency Enhancements #192

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pages/docs/plugin/publishing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

If you prefer reading codes, you can refer to [the repository for official plugins](https://github.com/swc-project/plugins).

We assume that `swi_cli` was used to setup the module. See [our Getting Started guide](https://swc.rs/docs/plugin/ecmascript/getting-started).

## Creating a npm package

### Building a plugin as a wasm
Expand All @@ -13,6 +15,8 @@ cargo build-wasi --release // build wasm32-wasi target binary
cargo build-wasm32 --release // build wasm32-unknown-unknown target binary
```

Both `build-wasi` and `build-wasm32` are aliases configured in `.cargo/config` by the `swi_cli`.

It will create `target/wasm32-wasi/release/your_plugin_name.wasm` or `target/wasm32-unknown-unknown/release/your_plugin_name.wasm`, depending on your config.

### Creating a npm package for plugin
Expand All @@ -23,7 +27,7 @@ Add the following to your `package.json`:
{
"main": "your_plugin_name.wasm",
"scripts": {
"prepack": "cargo prepublish --release && cp target/wasm32-wasi/release/your_plugin_name.wasm ."
"prepack": "cargo build-wasi --release && cp target/wasm32-wasi/release/your_plugin_name.wasm ."
},
}
```
Expand Down