Skip to content

Commit

Permalink
Update snap build tools docs (MetaMask#482)
Browse files Browse the repository at this point in the history
* Change build tools docs

* Fix linting

* Add tip about TypeScript
  • Loading branch information
FrederikBolding authored Jun 2, 2022
1 parent 7b5bc2f commit 5740c2f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions docs/guide/snaps-development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ In this section, we'll review the major components of a snap: the source code, t

### The Snap Source Code

::: tip TypeScript Support
This guide currently covers writing snaps in JavaScript, but TypeScript is also supported. See this [example](https://github.com/MetaMask/snaps-skunkworks/tree/main/packages/examples/examples/typescript) for more information.
:::

If you're familiar with JavaScript or TypeScript development of any kind, developing a snap should feel quite familiar to you.
Consider this trivial snap, which we'll call `hello-snap`:

Expand Down Expand Up @@ -336,10 +340,15 @@ If you run into a build or eval issue that you can't solve on your own, please c
#### Using Other Build Tools
If `mm-snap build` isn't enough to bundle your snap — if you are using TypeScript, for example — you will have to compose `mm-snap build` with the rest of your build process.
If you have to complete any build steps before running `mm-snap build`, simply put your intermediate build files in a temporary directory and use the main entry point there as your `--src` argument to `mm-snap build`.
If you prefer building your snap with a build system you are more comfortable with, we have released severals plugins for other build systems that you can use. We currently support:
- [Webpack](https://www.npmjs.com/package/@metamask/snaps-webpack-plugin)
- [Rollup](https://www.npmjs.com/package/@metamask/rollup-plugin-snaps)
- [Browserify](https://www.npmjs.com/package/@metamask/snaps-browserify-plugin)
For examples on how to set up these build systems yourself, please visit our [examples](https://github.com/MetaMask/snaps-skunkworks/tree/main/packages/examples/examples).
If you have to run any build steps after `mm-snap build`, remember that the file you ship must be a single `.js` file, and that you must run `mm-snap manifest --fix` to ensure that the manifest `shasum` value is correct.
We still recommend using our CLI `mm-snap` to make sure your manifest `shasum` value is correct by running `mm-snap manifest --fix` after creating your bundle. You may also benefit from running `mm-snap eval` to detect any SES issues up front.
### Testing Your Snap
Expand Down

0 comments on commit 5740c2f

Please sign in to comment.