# Source: https://swc.rs/docs/plugin/publishing

# Publishing plugins
If you prefer reading codes, you can refer to [the repository for official plugins ].
## Creating a npm package []
### Building a plugin as a wasm []
You can run your plugin as a wasm file by running
```cargo build-wasi --release // build wasm32-wasi target binary cargo build-wasm32 --release // build wasm32-unknown-unknown target binary ```
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 []
Add the following to your `package.json `:
package.json ```{ "main" : "your_plugin_name.wasm" , "scripts" : { "prepack" : "cargo prepublish --release && cp target/wasm32-wasi/release/your_plugin_name.wasm ." }, } ```
## Advanced: Improving your plugin []
### Adjusting configuration for smaller binary []
You can reduce the size of the plugin by configuring cargo.
In your `Cargo.toml `file, you can add the following lines.
Cargo.toml ```[ profile . release ] # This removes more dead code codegen-units = 1 lto = true # Optimize for size opt-level = "s" # Optimize for performance, this is default so you don't need to specify it # opt-level = "z" # Strip debug symbols strip = "symbols" ```
### Removing log for release mode []
If logging of your crate is too much, you can remove it by enabling `release_max_level_* `of `tracing `, like
```tracing = { version= "0.1" , features = [ "release_max_level_info" ] } ```