From 3f5612d6274873ce567403e68ee4e77cf9b6d82f Mon Sep 17 00:00:00 2001 From: Alexandra Tran Date: Mon, 31 Mar 2025 21:15:26 -0700 Subject: [PATCH 1/5] Document Snaps bundle analyzer option --- docs/whats-new.md | 5 +++++ snaps/reference/cli/subcommands.md | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/docs/whats-new.md b/docs/whats-new.md index 5394bd87651..4bff3255d1a 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -9,6 +9,11 @@ The latest major MetaMask documentation updates are listed by the month they wer For a comprehensive list of recent product changes, visit the "Release Notes" section at the bottom of the [MetaMask developer page](https://metamask.io/developer/). +## April 2025 + +- Documented [Snaps bundle analyzer option](/snaps/reference/cli/subcommands/#analyze). + ([#1955](https://github.com/MetaMask/metamask-docs/pull/1955)) + ## March 2025 - Added a tutorial for [sending a transaction using Viem](/services/tutorials/ethereum/send-a-transaction/send-a-transaction-viem). ([#1920](https://github.com/MetaMask/metamask-docs/pull/1920)) diff --git a/snaps/reference/cli/subcommands.md b/snaps/reference/cli/subcommands.md index 717dec526b2..7bdb51da36e 100644 --- a/snaps/reference/cli/subcommands.md +++ b/snaps/reference/cli/subcommands.md @@ -29,6 +29,32 @@ Builds a Snap from source. `b` is an alias for `build`. +#### `analyze` + + + + +```bash +yarn mm-snap build --analyze +``` + + + + +```bash +yarn mm-snap build --analyze false +``` + + + + +Enables or disables analyzing the Snap bundle. +This uses [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer) under the hood. + +:::info +This option requires [`@metamask/create-snap`](https://github.com/MetaMask/snaps/tree/main/packages/create-snap) version 4.0.4 or later. +::: + #### `c`, `config` From 36ab0c687048d539cdd9729a9475d3da754c0403 Mon Sep 17 00:00:00 2001 From: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> Date: Tue, 1 Apr 2025 09:00:09 -0700 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Maarten Zuidhoorn --- snaps/reference/cli/subcommands.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snaps/reference/cli/subcommands.md b/snaps/reference/cli/subcommands.md index 7bdb51da36e..dc7fbcac294 100644 --- a/snaps/reference/cli/subcommands.md +++ b/snaps/reference/cli/subcommands.md @@ -35,7 +35,7 @@ Builds a Snap from source. ```bash -yarn mm-snap build --analyze +yarn mm-snap build --analyze ``` @@ -48,11 +48,11 @@ yarn mm-snap build --analyze false -Enables or disables analyzing the Snap bundle. +Enables analyzing the Snap bundle. This uses [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer) under the hood. :::info -This option requires [`@metamask/create-snap`](https://github.com/MetaMask/snaps/tree/main/packages/create-snap) version 4.0.4 or later. +This option requires [`@metamask/snaps-cli`](https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli) version 6.7.0 or later. ::: #### `c`, `config` From 08aaa6edd31459559bdabd4707fdb30c39e6fdfb Mon Sep 17 00:00:00 2001 From: Alexandra Tran Date: Tue, 1 Apr 2025 09:23:52 -0700 Subject: [PATCH 3/5] edits --- snaps/reference/cli/subcommands.md | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/snaps/reference/cli/subcommands.md b/snaps/reference/cli/subcommands.md index dc7fbcac294..566d9517174 100644 --- a/snaps/reference/cli/subcommands.md +++ b/snaps/reference/cli/subcommands.md @@ -38,13 +38,6 @@ Builds a Snap from source. yarn mm-snap build --analyze ``` - - - -```bash -yarn mm-snap build --analyze false -``` - @@ -105,21 +98,13 @@ Validates the Snap [manifest file](../../learn/about-snaps/files.md#manifest-fil ```bash -yarn mm-snap manifest --fix -``` - - - - -```bash -yarn mm-snap manifest --fix false +yarn mm-snap manifest --fix ``` -Enables or disables making any changes to fix the manifest file. -The default is `true`. +Enables making any changes to fix the manifest file. ### `s`, `serve` From 778dc9a98ca0a8d3c141fbccde8b939d017bcaec Mon Sep 17 00:00:00 2001 From: Alexandra Tran Date: Wed, 2 Apr 2025 11:20:53 -0700 Subject: [PATCH 4/5] add more context --- snaps/learn/about-snaps/files.md | 2 +- snaps/reference/cli/subcommands.md | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/snaps/learn/about-snaps/files.md b/snaps/learn/about-snaps/files.md index fc9eab02f1c..599bc4d3066 100644 --- a/snaps/learn/about-snaps/files.md +++ b/snaps/learn/about-snaps/files.md @@ -164,6 +164,6 @@ built-ins must be bundled along with the Snap. Running `yarn start` bundles your Snap for you. You can also run [`yarn mm-snap build`](../../reference/cli/subcommands.md#b-build) to bundle your -Snap using [webpack](https://webpack.js.org/) or [Browserify](https://browserify.org). +Snap using [webpack](https://webpack.js.org/). This command finds all dependencies using your specified main entry point and outputs a bundle file to your specified output path. diff --git a/snaps/reference/cli/subcommands.md b/snaps/reference/cli/subcommands.md index 566d9517174..e059c7cf97e 100644 --- a/snaps/reference/cli/subcommands.md +++ b/snaps/reference/cli/subcommands.md @@ -41,8 +41,10 @@ yarn mm-snap build --analyze -Enables analyzing the Snap bundle. -This uses [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer) under the hood. +Enables analyzing the Snap [bundle](../../learn/about-snaps/files.md#bundle-file). +This uses [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer) under the hood, +which creates an interactive visualization of the contents of your bundle. +The visualization is located at the port displayed in the command line output. :::info This option requires [`@metamask/snaps-cli`](https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli) version 6.7.0 or later. @@ -67,7 +69,8 @@ yarn mm-snap build --config ./snap.config.build.ts -Path to the [configuration file](../../learn/about-snaps/files.md#configuration-file). +Path to the [configuration file](../../learn/about-snaps/files.md#configuration-file), +which specifies [options](options.md) with which to the build the Snap. `-c` is an alias for `--config`. From 631482c0193005109b3a32cdc194fb9de76c79e3 Mon Sep 17 00:00:00 2001 From: Alexandra Tran Date: Wed, 2 Apr 2025 13:36:11 -0700 Subject: [PATCH 5/5] clarify analyzer url --- snaps/reference/cli/subcommands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snaps/reference/cli/subcommands.md b/snaps/reference/cli/subcommands.md index e059c7cf97e..2f56a5809ec 100644 --- a/snaps/reference/cli/subcommands.md +++ b/snaps/reference/cli/subcommands.md @@ -44,7 +44,7 @@ yarn mm-snap build --analyze Enables analyzing the Snap [bundle](../../learn/about-snaps/files.md#bundle-file). This uses [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer) under the hood, which creates an interactive visualization of the contents of your bundle. -The visualization is located at the port displayed in the command line output. +The visualization is located at the URL displayed in the command line output (for example, `http://localhost:8888`). :::info This option requires [`@metamask/snaps-cli`](https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli) version 6.7.0 or later.