UNPKG

@metamask/snaps-browserify-plugin

Version:

A Browserify plugin to build MetaMask Snaps with Browserify

63 lines 2.66 kB
/// <reference types="node" /> /// <reference types="node" /> /// <reference types="src/types/vendor/readable-stream" /> import type { PostProcessOptions } from "@metamask/snaps-utils/node"; import type { BrowserifyObject } from "browserify"; import type { TransformCallback } from "readable-stream"; import { Transform } from "readable-stream"; type PluginOptions = { eval?: boolean; manifestPath?: string; writeManifest?: boolean; }; export type Options = PluginOptions & Omit<PostProcessOptions, 'sourceMap' | 'inputSourceMap'>; /** * A transform stream which can be used in the Browserify pipeline. It accepts a * string input, which is post-processed and pushed to the output stream. */ export declare class SnapsBrowserifyTransform extends Transform { #private; /** * Construct an instance of the transform stream. * * @param options - The post-processing options. * @param options.stripComments - Whether to strip comments. Defaults to `true`. * @param options.transformHtmlComments - Whether to transform HTML comments. * Defaults to `true`. */ constructor(options?: Partial<Options>); /** * Takes a chunk of data and pushes it into an internal array, for later * processing. * * @param chunk - The chunk of data to transform. * @param _encoding - The encoding of the chunk. * @param callback - The callback to call when the chunk is processed. */ _transform(chunk: Buffer, _encoding: BufferEncoding, callback: TransformCallback): void; /** * Takes the internal array of chunks and processes them. The processed code * is pushed to the output stream. * * @param callback - The callback to call when the stream is finished. */ _flush(callback: TransformCallback): void; } /** * The Browserify plugin function. Can be passed to the Browserify `plugin` * function, or used by simply passing the package name to `plugin`. * * @param browserifyInstance - The Browserify instance. * @param options - The plugin options. * @param options.stripComments - Whether to strip comments. Defaults to `true`. * @param options.eval - Whether to evaluate the bundle to test SES * compatibility. Defaults to `true`. * @param options.manifestPath - The path to the manifest file. If provided, * the manifest will be validated. Defaults to * `process.cwd() + '/snap.manifest.json'`. * @param options.writeManifest - Whether to fix the manifest. * Defaults to `true`. */ export default function plugin(browserifyInstance: BrowserifyObject, options?: Partial<Options>): void; export {}; //# sourceMappingURL=plugin.d.mts.map