@metamask/snaps-rollup-plugin
TypeScript icon, indicating that this package has built-in type declarations

4.2.0 • Public • Published

@metamask/snaps-rollup-plugin

A plugin for developing MetaMask Snaps using Rollup. This can be used as alternative to the mm-snap CLI build command. It transforms the bundle to fix common issues with SES. For a list of changes the plugin makes, you can refer to the source code.

Installation

Use Node.js 16.0.0 or later. We recommend using nvm for managing Node.js versions.

Install a dependency in your snap project using yarn or npm:

  • npm install @metamask/snaps-rollup-plugin
  • yarn add @metamask/snaps-rollup-plugin

Usage

Add the plugin to the plugins array in your Rollup configuration:

// rollup.config.js

import snaps from '@metamask/snaps-rollup-plugin';

export default {
  plugins: [snaps(options)],
};

Options

All options are optional, and default to true.

import { Options } from '@metamask/snaps-rollup-plugin';

const options: Options = {
  /**
   * Whether to strip all comments from the bundle.
   */
  stripComments: true,

  /**
   * Whether to evaluate the bundle with SES, to ensure SES compatibility.
   */
  eval: true,

  /**
   * The path to the Snap manifest file. If set, it will be checked and automatically updated with
   * the bundle's hash, if `writeManifest` is enabled. Defaults to `snap/manifest.json` in the
   * current working directory.
   */
  manifestPath: './snap.manifest.json',

  /**
   * Whether to write the updated Snap manifest file to disk. If `manifestPath` is not set, this
   * option has no effect. If this is disabled, an error will be thrown if the manifest file is
   * invalid.
   */
  writeManifest: true,
};

/@metamask/snaps-rollup-plugin/

    Package Sidebar

    Install

    npm i @metamask/snaps-rollup-plugin

    Weekly Downloads

    0

    Version

    4.2.0

    License

    ISC

    Unpacked Size

    35.8 kB

    Total Files

    28

    Last publish

    Collaborators

    • danfinlay
    • kumavis
    • mcmire
    • rekmarks
    • metamaskbot
    • gudahtt
    • nicholasellul
    • sethkfman
    • naugtur