@metamask/snaps-cli 6.0.2 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -1
- package/dist/{chunk-WYDHPUWV.mjs → chunk-76IQAFYR.mjs} +2 -2
- package/dist/{chunk-X7VYAL2L.mjs → chunk-7P7JW53B.mjs} +8 -3
- package/dist/chunk-7P7JW53B.mjs.map +1 -0
- package/dist/{chunk-BVPYLBE5.js → chunk-AKAP22EL.js} +8 -3
- package/dist/chunk-AKAP22EL.js.map +1 -0
- package/dist/{chunk-K5QMGTQL.mjs → chunk-AO724LXX.mjs} +2 -2
- package/dist/{chunk-XUYXKO4F.js → chunk-BFX2RH3M.js} +43 -14
- package/dist/chunk-BFX2RH3M.js.map +1 -0
- package/dist/{chunk-7NQQGJZJ.mjs → chunk-BVPROOGE.mjs} +2 -2
- package/dist/{chunk-SVYNCWMH.js → chunk-C2OMV3H5.js} +3 -3
- package/dist/{chunk-JI3B665Z.js → chunk-CQZ2AXMG.js} +3 -3
- package/dist/{chunk-CIYE263O.js → chunk-EHJPVBQU.js} +5 -5
- package/dist/{chunk-HQBA5RU6.mjs → chunk-FQ3HKVHQ.mjs} +2 -2
- package/dist/{chunk-OKDY7C7S.js → chunk-HNWSVD35.js} +10 -10
- package/dist/{chunk-OPE2PGM6.mjs → chunk-IO6WNNPF.mjs} +2 -2
- package/dist/{chunk-5KQNAW4C.mjs → chunk-JBSWMUCQ.mjs} +2 -2
- package/dist/{chunk-MDHJ5HLM.js → chunk-JEMJNDZO.js} +8 -2
- package/dist/chunk-JEMJNDZO.js.map +1 -0
- package/dist/{chunk-26C34AS7.mjs → chunk-OGGTU5W6.mjs} +7 -1
- package/dist/chunk-OGGTU5W6.mjs.map +1 -0
- package/dist/{chunk-KUSHMQXD.js → chunk-QXP34HW3.js} +8 -17
- package/dist/chunk-QXP34HW3.js.map +1 -0
- package/dist/{chunk-CGJKCIHP.js → chunk-RJ6IKKA2.js} +3 -3
- package/dist/{chunk-EDEA4QTA.js → chunk-RM5FN3N5.js} +3 -3
- package/dist/{chunk-T7NEPTM5.mjs → chunk-SM2JEXE6.mjs} +2 -2
- package/dist/{chunk-XZJLYKES.mjs → chunk-SUSC466E.mjs} +7 -16
- package/dist/chunk-SUSC466E.mjs.map +1 -0
- package/dist/{chunk-GKRRE4WN.mjs → chunk-T4CLBV7F.mjs} +3 -3
- package/dist/{chunk-YQVCFM6L.js → chunk-V4UPOVEH.js} +3 -3
- package/dist/{chunk-YWCNJELN.mjs → chunk-VIQIUSXW.mjs} +33 -4
- package/dist/chunk-VIQIUSXW.mjs.map +1 -0
- package/dist/{chunk-WO7DMSQU.mjs → chunk-WUC7DUXN.mjs} +2 -2
- package/dist/{chunk-5CLEKHXE.js → chunk-XQGKSVFJ.js} +3 -3
- package/dist/{chunk-R6NBQKVH.js → chunk-ZOC4OHGM.js} +3 -3
- package/dist/cli.js +3 -3
- package/dist/cli.mjs +2 -2
- package/dist/commands/build/build.js +7 -7
- package/dist/commands/build/build.mjs +6 -6
- package/dist/commands/build/implementation.js +6 -6
- package/dist/commands/build/implementation.mjs +5 -5
- package/dist/commands/build/index.js +8 -8
- package/dist/commands/build/index.mjs +7 -7
- package/dist/commands/index.js +12 -12
- package/dist/commands/index.mjs +11 -11
- package/dist/commands/serve/index.js +4 -4
- package/dist/commands/serve/index.mjs +4 -4
- package/dist/commands/serve/serve.js +4 -4
- package/dist/commands/serve/serve.mjs +4 -4
- package/dist/commands/watch/implementation.js +6 -6
- package/dist/commands/watch/implementation.mjs +5 -5
- package/dist/commands/watch/index.js +8 -8
- package/dist/commands/watch/index.mjs +7 -7
- package/dist/commands/watch/watch.js +7 -7
- package/dist/commands/watch/watch.mjs +6 -6
- package/dist/config.js +2 -2
- package/dist/config.mjs +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/dist/main.js +14 -14
- package/dist/main.mjs +13 -13
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +28 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/webpack/utils.d.ts +8 -0
- package/dist/webpack/compiler.js +5 -5
- package/dist/webpack/compiler.mjs +4 -4
- package/dist/webpack/config.js +4 -4
- package/dist/webpack/config.mjs +3 -3
- package/dist/webpack/index.js +5 -5
- package/dist/webpack/index.mjs +4 -4
- package/dist/webpack/loaders/browserify.js +2 -2
- package/dist/webpack/loaders/browserify.mjs +1 -1
- package/dist/webpack/loaders/index.js +2 -2
- package/dist/webpack/loaders/index.mjs +1 -1
- package/dist/webpack/plugins.js +3 -3
- package/dist/webpack/plugins.mjs +2 -2
- package/dist/webpack/utils.js +4 -2
- package/dist/webpack/utils.mjs +3 -1
- package/package.json +4 -4
- package/dist/chunk-26C34AS7.mjs.map +0 -1
- package/dist/chunk-BVPYLBE5.js.map +0 -1
- package/dist/chunk-KUSHMQXD.js.map +0 -1
- package/dist/chunk-MDHJ5HLM.js.map +0 -1
- package/dist/chunk-X7VYAL2L.mjs.map +0 -1
- package/dist/chunk-XUYXKO4F.js.map +0 -1
- package/dist/chunk-XZJLYKES.mjs.map +0 -1
- package/dist/chunk-YWCNJELN.mjs.map +0 -1
- /package/dist/{chunk-WYDHPUWV.mjs.map → chunk-76IQAFYR.mjs.map} +0 -0
- /package/dist/{chunk-K5QMGTQL.mjs.map → chunk-AO724LXX.mjs.map} +0 -0
- /package/dist/{chunk-7NQQGJZJ.mjs.map → chunk-BVPROOGE.mjs.map} +0 -0
- /package/dist/{chunk-SVYNCWMH.js.map → chunk-C2OMV3H5.js.map} +0 -0
- /package/dist/{chunk-JI3B665Z.js.map → chunk-CQZ2AXMG.js.map} +0 -0
- /package/dist/{chunk-CIYE263O.js.map → chunk-EHJPVBQU.js.map} +0 -0
- /package/dist/{chunk-HQBA5RU6.mjs.map → chunk-FQ3HKVHQ.mjs.map} +0 -0
- /package/dist/{chunk-OKDY7C7S.js.map → chunk-HNWSVD35.js.map} +0 -0
- /package/dist/{chunk-OPE2PGM6.mjs.map → chunk-IO6WNNPF.mjs.map} +0 -0
- /package/dist/{chunk-5KQNAW4C.mjs.map → chunk-JBSWMUCQ.mjs.map} +0 -0
- /package/dist/{chunk-CGJKCIHP.js.map → chunk-RJ6IKKA2.js.map} +0 -0
- /package/dist/{chunk-EDEA4QTA.js.map → chunk-RM5FN3N5.js.map} +0 -0
- /package/dist/{chunk-T7NEPTM5.mjs.map → chunk-SM2JEXE6.mjs.map} +0 -0
- /package/dist/{chunk-GKRRE4WN.mjs.map → chunk-T4CLBV7F.mjs.map} +0 -0
- /package/dist/{chunk-YQVCFM6L.js.map → chunk-V4UPOVEH.js.map} +0 -0
- /package/dist/{chunk-WO7DMSQU.mjs.map → chunk-WUC7DUXN.mjs.map} +0 -0
- /package/dist/{chunk-5CLEKHXE.js.map → chunk-XQGKSVFJ.js.map} +0 -0
- /package/dist/{chunk-R6NBQKVH.js.map → chunk-ZOC4OHGM.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [6.1.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add support for importing SVG, PNG, and JPEG files directly ([#2284](https://github.com/MetaMask/snaps/pull/2284))
|
|
12
|
+
- You can now import these files using a regular import declaration when using the Webpack-based config.
|
|
13
|
+
- To opt out of this feature (i.e., to use custom image loading logic), add the following to your config:
|
|
14
|
+
```ts
|
|
15
|
+
{
|
|
16
|
+
features: {
|
|
17
|
+
images: false,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Update CLI docs link ([#2294](https://github.com/MetaMask/snaps/pull/2294))
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
- Fix detection of minimum Node.js version ([#2292](https://github.com/MetaMask/snaps/pull/2292))
|
|
27
|
+
|
|
9
28
|
## [6.0.2]
|
|
10
29
|
### Fixed
|
|
11
30
|
- Publish `.browserslistrc` ([#2227](https://github.com/MetaMask/snaps/pull/2227))
|
|
@@ -127,7 +146,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
127
146
|
- The version of the package no longer needs to match the version of all other
|
|
128
147
|
MetaMask Snaps packages.
|
|
129
148
|
|
|
130
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.0
|
|
149
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.1.0...HEAD
|
|
150
|
+
[6.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.0.2...@metamask/snaps-cli@6.1.0
|
|
131
151
|
[6.0.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.0.1...@metamask/snaps-cli@6.0.2
|
|
132
152
|
[6.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.0.0...@metamask/snaps-cli@6.0.1
|
|
133
153
|
[6.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@5.1.1...@metamask/snaps-cli@6.0.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCompiler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WUC7DUXN.mjs";
|
|
4
4
|
|
|
5
5
|
// src/commands/build/implementation.ts
|
|
6
6
|
async function build(config, options) {
|
|
@@ -25,4 +25,4 @@ async function build(config, options) {
|
|
|
25
25
|
export {
|
|
26
26
|
build
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-76IQAFYR.mjs.map
|
|
@@ -159,6 +159,12 @@ var SnapsWebpackConfigStruct = object({
|
|
|
159
159
|
]),
|
|
160
160
|
false
|
|
161
161
|
),
|
|
162
|
+
features: defaulted(
|
|
163
|
+
object({
|
|
164
|
+
images: defaulted(boolean(), true)
|
|
165
|
+
}),
|
|
166
|
+
{}
|
|
167
|
+
),
|
|
162
168
|
customizeWebpackConfig: optional(
|
|
163
169
|
SnapsWebpackCustomizeWebpackConfigFunctionStruct
|
|
164
170
|
),
|
|
@@ -205,8 +211,7 @@ var LegacyOptionsStruct = union([
|
|
|
205
211
|
function getConfig(config, argv) {
|
|
206
212
|
const prefix = "The snap config file is invalid";
|
|
207
213
|
const suffix = dim(
|
|
208
|
-
|
|
209
|
-
"Refer to the documentation for more information: https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli/"
|
|
214
|
+
"Refer to the documentation for more information: https://docs.metamask.io/snaps/reference/cli/options/"
|
|
210
215
|
);
|
|
211
216
|
const { bundler } = createFromStruct(
|
|
212
217
|
config,
|
|
@@ -362,4 +367,4 @@ export {
|
|
|
362
367
|
mergeLegacyOptions,
|
|
363
368
|
getWebpackConfig
|
|
364
369
|
};
|
|
365
|
-
//# sourceMappingURL=chunk-
|
|
370
|
+
//# sourceMappingURL=chunk-7P7JW53B.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { literal, union } from '@metamask/snaps-sdk';\nimport {\n createFromStruct,\n indent,\n isFile,\n SnapsStructError,\n named,\n} from '@metamask/snaps-utils/node';\nimport { hasProperty } from '@metamask/utils';\nimport { transform } from '@swc/core';\nimport type { BrowserifyObject } from 'browserify';\nimport { dim } from 'chalk';\nimport { readFile } from 'fs/promises';\nimport Module from 'module';\nimport { basename, dirname, resolve } from 'path';\nimport {\n array,\n boolean,\n create,\n defaulted,\n define,\n func,\n number,\n object,\n optional,\n record,\n string,\n type,\n unknown,\n empty,\n} from 'superstruct';\nimport type { Infer } from 'superstruct';\nimport type { Configuration as WebpackConfiguration } from 'webpack';\n\nimport { TranspilationModes } from './builders';\nimport { ConfigError } from './errors';\nimport { file } from './structs';\nimport type { YargsArgs } from './types/yargs';\nimport { CONFIG_FILE, TS_CONFIG_FILE } from './utils';\n\nconst CONFIG_FILES = [CONFIG_FILE, TS_CONFIG_FILE];\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\nexport type SnapBrowserifyConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler: 'browserify';\n\n /**\n * The options for the Snaps CLI. These are merged with the options passed to\n * the CLI, with the CLI options taking precedence.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n cliOptions?: {\n /**\n * The path to the snap bundle file.\n *\n * @default 'dist/bundle.js'\n */\n bundle?: string;\n\n /**\n * The directory to output the snap to. This is only used if `bundle` is\n * not specified.\n *\n * @default 'dist'\n */\n dist?: string;\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n eval?: boolean;\n\n /**\n * Whether to validate the snap manifest.\n *\n * @default true\n */\n manifest?: boolean;\n\n /**\n * The name of the bundle file. This is only used if `bundle` is not\n * specified.\n *\n * @default 'bundle.js'\n */\n outfileName?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n\n /**\n * The root directory to serve the snap from.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * Whether to generate source maps for the snap bundle.\n *\n * @default false\n */\n sourceMaps?: boolean;\n\n /**\n * The path to the snap entry point.\n *\n * @default 'src/index.js'\n */\n src?: string;\n\n /**\n * Whether to remove comments from the bundle.\n *\n * @default true\n */\n stripComments?: boolean;\n\n /**\n * Whether to suppress warnings.\n *\n * @default false\n */\n suppressWarnings?: boolean;\n\n /**\n * The transpilation mode to use, which determines which files are\n * transpiled.\n *\n * - `'localAndDeps'`: Transpile the snap entry point and all dependencies.\n * - `'localOnly'`: Transpile only the snap entry point.\n * - `'none'`: Don't transpile any files.\n *\n * @default 'localOnly'\n */\n transpilationMode?: 'localAndDeps' | 'localOnly' | 'none';\n\n /**\n * The dependencies to transpile when `transpilationMode` is set to\n * `'localAndDeps'`. If not specified, all dependencies will be transpiled.\n */\n depsToTranspile?: string[];\n\n /**\n * Whether to show original errors.\n *\n * @default true\n */\n verboseErrors?: boolean;\n\n /**\n * Whether to write the updated manifest to disk.\n *\n * @default true\n */\n writeManifest?: boolean;\n\n /**\n * Whether to serve the snap locally.\n *\n * @default true\n */\n serve?: boolean;\n };\n\n /**\n * A function that can be used to customize the Browserify instance used to\n * build the snap.\n *\n * @param bundler - The Browserify instance.\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n bundlerCustomizer?: (bundler: BrowserifyObject) => void;\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapWebpackConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler?: 'webpack';\n\n /**\n * The path to the snap entry point. This should be a JavaScript or TypeScript\n * file.\n */\n input: string;\n\n /**\n * Whether to generate source maps for the snap. If `true`, source maps will\n * be generated as separate files. If `'inline'`, source maps will be\n * inlined in the generated JavaScript bundle.\n *\n * @default true\n */\n sourceMap?: boolean | 'inline';\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n evaluate?: boolean;\n\n output?: {\n /**\n * The path to the directory where the snap will be built. This directory\n * will be created if it doesn't exist.\n *\n * If the path is relative, it will be resolved relative to the current\n * working directory.\n *\n * @default 'dist'\n */\n path?: string;\n\n /**\n * The name of the JavaScript bundle file.\n *\n * @default 'bundle.js'\n */\n filename?: string;\n\n /**\n * Whether to clean the output directory before building the snap. If\n * `true`, the output directory will be deleted and recreated. Otherwise,\n * the output directory will be left as-is.\n *\n * @default false\n */\n clean?: boolean;\n\n /**\n * Whether to minimize the snap bundle. If `true`, the bundle will be\n * minified. Otherwise, the bundle will be left as-is.\n *\n * @default true\n */\n minimize?: boolean;\n };\n\n manifest?: {\n /**\n * The path to the snap manifest file. If the path is relative, it will be\n * resolved relative to the current working directory.\n *\n * @default 'snap.manifest.json'\n */\n path?: string;\n\n /**\n * Whether to automatically update the manifest. If `true`, the manifest\n * will be updated with the latest shasum of the snap bundle, and some\n * common fields will be updated if they are missing or incorrect. If\n * `false`, the manifest will be left as-is.\n *\n * @default true\n */\n update?: boolean;\n };\n\n server?: {\n /**\n * Whether to enable the local server. If `true`, the snap will be served\n * from a local server, when running the `watch` command. If `false`, the\n * snap will not be served.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * The root directory to serve the snap from. If the path is relative, it\n * will be resolved relative to the current working directory.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n };\n\n /**\n * The environment variables to set when building the snap. These will be\n * available in the snap as `process.env`. In addition to these environment\n * variables, the following environment variables will always be set:\n *\n * - `NODE_DEBUG`: `false`\n * - `NODE_ENV`: `'production'`\n * - `DEBUG`: `false`\n *\n * Any environment variables specified here will override these defaults. You\n * can also override any variables here by setting them in your shell when\n * running the CLI.\n */\n environment?: Record<string, unknown>;\n\n /**\n * Options that control the logging output of the CLI.\n */\n stats?: {\n /**\n * Whether to enable verbose logging.\n *\n * @default false\n */\n verbose?: boolean;\n\n /**\n * Whether to log warnings about unresolved built-in modules. If `false`,\n * warnings will not be logged.\n */\n builtIns?:\n | {\n /**\n * The built-in modules to ignore when resolving modules. If a module\n * is ignored, no warning will be logged if it is not resolved.\n */\n ignore?: string[];\n }\n | false;\n\n /**\n * Whether to log warnings about the use of the `Buffer` global. If `false`,\n * warnings will not be logged. If `true`, the CLI will warn if the `Buffer`\n * global is used, but not provided by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n };\n\n /**\n * Whether to provide polyfills for node builtins. If `true`, all the available\n * polyfills will be provided. If `false` no polyfills will be provided. If a\n * configuration object is passed only the polyfills set to `true` will be provided.\n *\n * @default false\n * @example\n * ```ts\n * polyfills: true\n *\n * // or\n *\n * polyfills: {\n * assert: true,\n * buffer: true\n * }\n * ```\n */\n polyfills?:\n | boolean\n | {\n assert?: boolean;\n buffer?: boolean;\n console?: boolean;\n constants?: boolean;\n crypto?: boolean;\n domain?: boolean;\n events?: boolean;\n http?: boolean;\n https?: boolean;\n os?: boolean;\n path?: boolean;\n punycode?: boolean;\n process?: boolean;\n querystring?: boolean;\n stream?: boolean;\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex?: boolean;\n _stream_passthrough?: boolean;\n _stream_readable?: boolean;\n _stream_transform?: boolean;\n _stream_writable?: boolean;\n string_decoder?: boolean;\n /* eslint-enable @typescript-eslint/naming-convention */\n sys?: boolean;\n timers?: boolean;\n tty?: boolean;\n url?: boolean;\n util?: boolean;\n vm?: boolean;\n zlib?: boolean;\n };\n\n /**\n * Optional features to enable in the CLI.\n *\n * @example\n * {\n * features: {\n * images: true,\n * }\n * }\n */\n features?: {\n /**\n * Whether to enable support for images. If `true`, the Webpack\n * configuration will be modified to support images. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default true\n */\n images?: boolean;\n };\n\n /**\n * A function to customize the Webpack configuration used to build the snap.\n * This function will be called with the default Webpack configuration, and\n * should return the modified configuration. If not specified, the default\n * configuration will be used.\n *\n * It's recommended to use the `webpack-merge` package to merge the default\n * configuration with your customizations. The merge function is exported as\n * `merge` from the `@metamask/snaps-cli` package.\n *\n * @example\n * ```ts\n * import type { SnapsConfig } from '@metamask/snaps-cli';\n * import { merge } from '@metamask/snaps-cli';\n *\n * const config: SnapsConfig = {\n * bundler: 'webpack',\n * entry: 'src/index.ts',\n * customizeWebpackConfig: (config) => merge(config, {\n * module: {\n * rules: [\n * {\n * test: /\\.wasm$/,\n * type: 'assets/resource',\n * },\n * ],\n * },\n * }),\n * };\n *\n * export default config;\n * ```\n */\n customizeWebpackConfig?: (\n config: WebpackConfiguration,\n ) => WebpackConfiguration;\n\n /**\n * Experimental features that can be enabled. These features are not\n * guaranteed to be stable, and may be removed or changed in a future release.\n */\n experimental?: {\n /**\n * Whether to enable WebAssembly support. If `true`, the Webpack\n * configuration will be modified to support WebAssembly. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default false\n */\n wasm?: boolean;\n };\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapConfig = SnapBrowserifyConfig | SnapWebpackConfig;\n\ntype SnapsBrowserifyBundlerCustomizerFunction = (\n bundler: BrowserifyObject,\n) => void;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsBrowserifyBundlerCustomizerFunctionStruct =\n define<SnapsBrowserifyBundlerCustomizerFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsBrowserifyConfigStruct = object({\n bundler: literal('browserify'),\n cliOptions: defaulted(\n object({\n bundle: optional(file()),\n dist: defaulted(file(), 'dist'),\n eval: defaulted(boolean(), true),\n manifest: defaulted(boolean(), true),\n port: defaulted(number(), 8081),\n outfileName: defaulted(string(), 'bundle.js'),\n root: defaulted(file(), process.cwd()),\n sourceMaps: defaulted(boolean(), false),\n src: defaulted(file(), 'src/index.js'),\n stripComments: defaulted(boolean(), true),\n suppressWarnings: defaulted(boolean(), false),\n transpilationMode: defaulted(\n union([literal('localAndDeps'), literal('localOnly'), literal('none')]),\n 'localOnly',\n ),\n depsToTranspile: defaulted(array(string()), []),\n verboseErrors: defaulted(boolean(), true),\n writeManifest: defaulted(boolean(), true),\n serve: defaulted(boolean(), true),\n }),\n {},\n ),\n bundlerCustomizer: optional(SnapsBrowserifyBundlerCustomizerFunctionStruct),\n});\n\ntype SnapsWebpackCustomizeWebpackConfigFunction = (\n config: WebpackConfiguration,\n) => WebpackConfiguration;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsWebpackCustomizeWebpackConfigFunctionStruct =\n define<SnapsWebpackCustomizeWebpackConfigFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsWebpackConfigStruct = object({\n bundler: defaulted(literal('webpack'), 'webpack'),\n input: defaulted(file(), resolve(process.cwd(), 'src/index.js')),\n sourceMap: defaulted(union([boolean(), literal('inline')]), false),\n evaluate: defaulted(boolean(), true),\n\n output: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'dist')),\n filename: defaulted(string(), 'bundle.js'),\n clean: defaulted(boolean(), false),\n minimize: defaulted(boolean(), true),\n }),\n {},\n ),\n\n manifest: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'snap.manifest.json')),\n update: defaulted(boolean(), true),\n }),\n {},\n ),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n root: defaulted(file(), process.cwd()),\n port: defaulted(number(), 8081),\n }),\n {},\n ),\n\n environment: defaulted(record(string(), unknown()), {}),\n\n stats: defaulted(\n object({\n verbose: defaulted(boolean(), false),\n builtIns: defaulted(\n union([\n object({ ignore: defaulted(array(string()), []) }),\n literal(false),\n ]),\n {},\n ),\n buffer: defaulted(boolean(), true),\n }),\n {},\n ),\n\n polyfills: defaulted(\n union([\n boolean(),\n object({\n assert: defaulted(boolean(), false),\n buffer: defaulted(boolean(), false),\n console: defaulted(boolean(), false),\n constants: defaulted(boolean(), false),\n crypto: defaulted(boolean(), false),\n domain: defaulted(boolean(), false),\n events: defaulted(boolean(), false),\n http: defaulted(boolean(), false),\n https: defaulted(boolean(), false),\n os: defaulted(boolean(), false),\n path: defaulted(boolean(), false),\n punycode: defaulted(boolean(), false),\n process: defaulted(boolean(), false),\n querystring: defaulted(boolean(), false),\n stream: defaulted(boolean(), false),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: defaulted(boolean(), false),\n _stream_passthrough: defaulted(boolean(), false),\n _stream_readable: defaulted(boolean(), false),\n _stream_transform: defaulted(boolean(), false),\n _stream_writable: defaulted(boolean(), false),\n string_decoder: defaulted(boolean(), false),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: defaulted(boolean(), false),\n timers: defaulted(boolean(), false),\n tty: defaulted(boolean(), false),\n url: defaulted(boolean(), false),\n util: defaulted(boolean(), false),\n vm: defaulted(boolean(), false),\n zlib: defaulted(boolean(), false),\n }),\n ]),\n false,\n ),\n\n features: defaulted(\n object({\n images: defaulted(boolean(), true),\n }),\n {},\n ),\n\n customizeWebpackConfig: optional(\n SnapsWebpackCustomizeWebpackConfigFunctionStruct,\n ),\n\n experimental: defaulted(\n object({\n wasm: defaulted(boolean(), false),\n }),\n {},\n ),\n});\n\nexport const SnapsConfigStruct = type({\n bundler: defaulted(\n union([literal('browserify'), literal('webpack')]),\n 'webpack',\n ),\n});\n\nexport const LegacyOptionsStruct = union([\n named(\n 'object with `transpilationMode` set to `localAndDeps` and `depsToTranspile` set to an array of strings',\n type({\n depsToTranspile: array(string()),\n transpilationMode: literal(TranspilationModes.LocalAndDeps),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n named(\n 'object without `depsToTranspile`',\n type({\n depsToTranspile: named('empty array', empty(array())),\n transpilationMode: union([\n literal(TranspilationModes.LocalOnly),\n literal(TranspilationModes.None),\n ]),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n]);\n\nexport type LegacyOptions = Infer<typeof LegacyOptionsStruct>;\n\nexport type ProcessedBrowserifyConfig = Infer<\n typeof SnapsBrowserifyConfigStruct\n>;\n\nexport type ProcessedWebpackConfig = Infer<typeof SnapsWebpackConfigStruct> & {\n /**\n * The legacy Browserify config, if the bundler is Browserify. This is used\n * to support the legacy config format.\n */\n legacy?: LegacyOptions;\n};\n\nexport type ProcessedConfig = ProcessedWebpackConfig;\n\n/**\n * Get a validated snap config. This validates the config and adds default\n * values for any missing properties.\n *\n * @param config - The config to validate.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n */\nexport function getConfig(config: unknown, argv: YargsArgs): ProcessedConfig {\n const prefix = 'The snap config file is invalid';\n const suffix = dim(\n 'Refer to the documentation for more information: https://docs.metamask.io/snaps/reference/cli/options/',\n );\n\n const { bundler } = createFromStruct(\n config,\n SnapsConfigStruct,\n prefix,\n suffix,\n );\n\n if (bundler === 'browserify') {\n const legacyConfig = createFromStruct(\n config,\n SnapsBrowserifyConfigStruct,\n prefix,\n suffix,\n );\n\n return getWebpackConfig(mergeLegacyOptions(argv, legacyConfig));\n }\n\n return createFromStruct(config, SnapsWebpackConfigStruct, prefix, suffix);\n}\n\n/**\n * Load a snap config from a file. This supports both JavaScript and TypeScript\n * config files, in the CommonJS module format and the ES module format.\n *\n * This assumes that the config file exports a default object, either through\n * `module.exports` or `export default`.\n *\n * @param path - The full path to the config file.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n * @throws If the config file is invalid, or if the config file does not have a\n * default export.\n */\nexport async function loadConfig(path: string, argv: YargsArgs) {\n try {\n const contents = await readFile(path, 'utf8');\n const source = await transform(contents, {\n swcrc: false,\n jsc: {\n parser: {\n syntax: 'typescript',\n },\n },\n module: {\n type: 'commonjs',\n },\n });\n\n const config = new Module(path);\n\n // @ts-expect-error - This function is not typed.\n config.paths = Module._nodeModulePaths(dirname(path));\n\n // @ts-expect-error - This function is not typed.\n config._compile(source.code, path);\n\n if (!hasProperty(config.exports, 'default')) {\n return getConfig(config.exports, argv);\n }\n\n return getConfig(config.exports.default, argv);\n } catch (error) {\n if (error instanceof SnapsStructError) {\n throw new ConfigError(error.message);\n }\n\n throw new ConfigError(\n `Unable to load snap config file at \"${path}\".\\n\\n${indent(\n error.message,\n )}`,\n );\n }\n}\n\n/**\n * Resolve a snap config. This function will look for a `snap.config.js` or\n * `snap.config.ts` file in the current or specified directory.\n *\n * @param path - The path to resolve the snap config from. Defaults to the\n * current working directory.\n * @param argv - The CLI arguments.\n * @returns The resolved and validated snap config.\n * @throws If a snap config could not be found.\n */\nexport async function resolveConfig(path: string, argv: YargsArgs) {\n for (const configFile of CONFIG_FILES) {\n const filePath = resolve(path, configFile);\n if (await isFile(filePath)) {\n return await loadConfig(filePath, argv);\n }\n }\n\n throw new ConfigError(\n `Could not find a \"snap.config.js\" or \"snap.config.ts\" file in the current or specified directory (\"${path}\").`,\n );\n}\n\n/**\n * Get a snap config from the CLI arguments. This will either load the config\n * from the specified config file, or resolve the config from the current\n * working directory.\n *\n * @param argv - The CLI arguments.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The resolved and validated snap config.\n */\nexport async function getConfigByArgv(\n argv: YargsArgs,\n cwd: string = process.cwd(),\n) {\n if (argv.config) {\n if (!(await isFile(argv.config))) {\n throw new ConfigError(\n `Could not find a config file at \"${argv.config}\". Make sure that the path is correct.`,\n );\n }\n\n return await loadConfig(argv.config, argv);\n }\n\n return await resolveConfig(cwd, argv);\n}\n\n/**\n * Merge legacy CLI options into the config. This is used to support the legacy\n * config format, where options can be specified both in the config file and\n * through CLI flags.\n *\n * @param argv - The CLI arguments.\n * @param config - The config to merge the CLI options into.\n * @returns The config with the CLI options merged in.\n * @deprecated This function is only used to support the legacy config format.\n */\nexport function mergeLegacyOptions(\n argv: YargsArgs,\n config: ProcessedBrowserifyConfig,\n) {\n const cliOptions = Object.keys(config.cliOptions).reduce<\n ProcessedBrowserifyConfig['cliOptions']\n >((accumulator, key) => {\n if (argv[key] !== undefined) {\n return {\n ...accumulator,\n [key]: argv[key],\n };\n }\n\n return accumulator;\n }, config.cliOptions);\n\n return {\n ...config,\n cliOptions,\n };\n}\n\n/**\n * Get a Webpack config from a legacy browserify config. This is used to\n * support the legacy config format, and convert it to the new format.\n *\n * @param legacyConfig - The legacy browserify config.\n * @returns The Webpack config.\n */\nexport function getWebpackConfig(\n legacyConfig: ProcessedBrowserifyConfig,\n): ProcessedWebpackConfig {\n const defaultConfig = create(\n { bundler: 'webpack' },\n SnapsWebpackConfigStruct,\n );\n\n // The legacy config has two options for specifying the output path and\n // filename: `bundle`, and `dist` + `outfileName`. If `bundle` is specified,\n // we use that as the output path and filename. Otherwise, we use `dist` and\n // `outfileName`.\n const path = legacyConfig.cliOptions.bundle\n ? dirname(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.dist;\n\n const filename = legacyConfig.cliOptions.bundle\n ? basename(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.outfileName;\n\n return {\n ...defaultConfig,\n input: legacyConfig.cliOptions.src,\n evaluate: legacyConfig.cliOptions.eval,\n sourceMap: legacyConfig.cliOptions.sourceMaps,\n output: {\n path,\n filename,\n\n // The legacy config has an option to remove comments from the bundle, but\n // the terser plugin does this by default, so we only enable the terser if\n // the legacy config has `stripComments` set to `true`. This is not a\n // perfect solution, but it's the best we can do without breaking the\n // legacy config.\n minimize: legacyConfig.cliOptions.stripComments,\n\n // The legacy config does not have a `clean` option, so we default to\n // `false` here.\n clean: false,\n },\n manifest: {\n // The legacy config does not have a `manifest` option, so we default to\n // `process.cwd()/snap.manifest.json`.\n path: resolve(process.cwd(), 'snap.manifest.json'),\n update: legacyConfig.cliOptions.writeManifest,\n },\n server: {\n enabled: legacyConfig.cliOptions.serve,\n port: legacyConfig.cliOptions.port,\n root: legacyConfig.cliOptions.root,\n },\n stats: {\n verbose: false,\n\n // These plugins are designed to be used with the modern config format, so\n // we disable them for the legacy config format.\n builtIns: false,\n buffer: false,\n },\n legacy: createFromStruct(\n {\n ...legacyConfig.cliOptions,\n bundlerCustomizer: legacyConfig.bundlerCustomizer,\n },\n LegacyOptionsStruct,\n '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AA,EACF;AACF;AASO,SAAS,iBACd,cACwB;AACxB,QAAM,gBAAgB;AAAA,IACpB,EAAE,SAAS,UAAU;AAAA,IACrB;AAAA,EACF;AAMA,QAAM,OAAO,aAAa,WAAW,SACjC,QAAQ,aAAa,WAAW,MAAM,IACtC,aAAa,WAAW;AAE5B,QAAM,WAAW,aAAa,WAAW,SACrC,SAAS,aAAa,WAAW,MAAM,IACvC,aAAa,WAAW;AAE5B,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,aAAa,WAAW;AAAA,IAC/B,UAAU,aAAa,WAAW;AAAA,IAClC,WAAW,aAAa,WAAW;AAAA,IACnC,QAAQ;AAAA,MACN;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOA,UAAU,aAAa,WAAW;AAAA;AAAA;AAAA,MAIlC,OAAO;AAAA,IACT;AAAA,IACA,UAAU;AAAA;AAAA;AAAA,MAGR,MAAM,QAAQ,QAAQ,IAAI,GAAG,oBAAoB;AAAA,MACjD,QAAQ,aAAa,WAAW;AAAA,IAClC;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,aAAa,WAAW;AAAA,MACjC,MAAM,aAAa,WAAW;AAAA,MAC9B,MAAM,aAAa,WAAW;AAAA,IAChC;AAAA,IACA,OAAO;AAAA,MACL,SAAS;AAAA;AAAA;AAAA,MAIT,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,QACE,GAAG,aAAa;AAAA,QAChB,mBAAmB,aAAa;AAAA,MAClC;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -159,6 +159,12 @@ var SnapsWebpackConfigStruct = _superstruct.object.call(void 0, {
|
|
|
159
159
|
]),
|
|
160
160
|
false
|
|
161
161
|
),
|
|
162
|
+
features: _superstruct.defaulted.call(void 0,
|
|
163
|
+
_superstruct.object.call(void 0, {
|
|
164
|
+
images: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true)
|
|
165
|
+
}),
|
|
166
|
+
{}
|
|
167
|
+
),
|
|
162
168
|
customizeWebpackConfig: _superstruct.optional.call(void 0,
|
|
163
169
|
SnapsWebpackCustomizeWebpackConfigFunctionStruct
|
|
164
170
|
),
|
|
@@ -205,8 +211,7 @@ var LegacyOptionsStruct = _snapssdk.union.call(void 0, [
|
|
|
205
211
|
function getConfig(config, argv) {
|
|
206
212
|
const prefix = "The snap config file is invalid";
|
|
207
213
|
const suffix = _chalk.dim.call(void 0,
|
|
208
|
-
|
|
209
|
-
"Refer to the documentation for more information: https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli/"
|
|
214
|
+
"Refer to the documentation for more information: https://docs.metamask.io/snaps/reference/cli/options/"
|
|
210
215
|
);
|
|
211
216
|
const { bundler } = _node.createFromStruct.call(void 0,
|
|
212
217
|
config,
|
|
@@ -362,4 +367,4 @@ function getWebpackConfig(legacyConfig) {
|
|
|
362
367
|
|
|
363
368
|
|
|
364
369
|
exports.SnapsBrowserifyConfigStruct = SnapsBrowserifyConfigStruct; exports.SnapsWebpackConfigStruct = SnapsWebpackConfigStruct; exports.SnapsConfigStruct = SnapsConfigStruct; exports.LegacyOptionsStruct = LegacyOptionsStruct; exports.getConfig = getConfig; exports.loadConfig = loadConfig; exports.resolveConfig = resolveConfig; exports.getConfigByArgv = getConfigByArgv; exports.mergeLegacyOptions = mergeLegacyOptions; exports.getWebpackConfig = getWebpackConfig;
|
|
365
|
-
//# sourceMappingURL=chunk-
|
|
370
|
+
//# sourceMappingURL=chunk-AKAP22EL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,SAAS,SAAS,aAAa;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAE1B,SAAS,WAAW;AACpB,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WAAW,SACrC,SAAS,aAAa,WAAW,MAAM,IACvC,aAAa,WAAW;AAE5B,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,aAAa,WAAW;AAAA,IAC/B,UAAU,aAAa,WAAW;AAAA,IAClC,WAAW,aAAa,WAAW;AAAA,IACnC,QAAQ;AAAA,MACN;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOA,UAAU,aAAa,WAAW;AAAA;AAAA;AAAA,MAIlC,OAAO;AAAA,IACT;AAAA,IACA,UAAU;AAAA;AAAA;AAAA,MAGR,MAAM,QAAQ,QAAQ,IAAI,GAAG,oBAAoB;AAAA,MACjD,QAAQ,aAAa,WAAW;AAAA,IAClC;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,aAAa,WAAW;AAAA,MACjC,MAAM,aAAa,WAAW;AAAA,MAC9B,MAAM,aAAa,WAAW;AAAA,IAChC;AAAA,IACA,OAAO;AAAA,MACL,SAAS;AAAA;AAAA;AAAA,MAIT,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,QACE,GAAG,aAAa;AAAA,QAChB,mBAAmB,aAAa;AAAA,MAClC;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["import { literal, union } from '@metamask/snaps-sdk';\nimport {\n createFromStruct,\n indent,\n isFile,\n SnapsStructError,\n named,\n} from '@metamask/snaps-utils/node';\nimport { hasProperty } from '@metamask/utils';\nimport { transform } from '@swc/core';\nimport type { BrowserifyObject } from 'browserify';\nimport { dim } from 'chalk';\nimport { readFile } from 'fs/promises';\nimport Module from 'module';\nimport { basename, dirname, resolve } from 'path';\nimport {\n array,\n boolean,\n create,\n defaulted,\n define,\n func,\n number,\n object,\n optional,\n record,\n string,\n type,\n unknown,\n empty,\n} from 'superstruct';\nimport type { Infer } from 'superstruct';\nimport type { Configuration as WebpackConfiguration } from 'webpack';\n\nimport { TranspilationModes } from './builders';\nimport { ConfigError } from './errors';\nimport { file } from './structs';\nimport type { YargsArgs } from './types/yargs';\nimport { CONFIG_FILE, TS_CONFIG_FILE } from './utils';\n\nconst CONFIG_FILES = [CONFIG_FILE, TS_CONFIG_FILE];\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\nexport type SnapBrowserifyConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler: 'browserify';\n\n /**\n * The options for the Snaps CLI. These are merged with the options passed to\n * the CLI, with the CLI options taking precedence.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n cliOptions?: {\n /**\n * The path to the snap bundle file.\n *\n * @default 'dist/bundle.js'\n */\n bundle?: string;\n\n /**\n * The directory to output the snap to. This is only used if `bundle` is\n * not specified.\n *\n * @default 'dist'\n */\n dist?: string;\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n eval?: boolean;\n\n /**\n * Whether to validate the snap manifest.\n *\n * @default true\n */\n manifest?: boolean;\n\n /**\n * The name of the bundle file. This is only used if `bundle` is not\n * specified.\n *\n * @default 'bundle.js'\n */\n outfileName?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n\n /**\n * The root directory to serve the snap from.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * Whether to generate source maps for the snap bundle.\n *\n * @default false\n */\n sourceMaps?: boolean;\n\n /**\n * The path to the snap entry point.\n *\n * @default 'src/index.js'\n */\n src?: string;\n\n /**\n * Whether to remove comments from the bundle.\n *\n * @default true\n */\n stripComments?: boolean;\n\n /**\n * Whether to suppress warnings.\n *\n * @default false\n */\n suppressWarnings?: boolean;\n\n /**\n * The transpilation mode to use, which determines which files are\n * transpiled.\n *\n * - `'localAndDeps'`: Transpile the snap entry point and all dependencies.\n * - `'localOnly'`: Transpile only the snap entry point.\n * - `'none'`: Don't transpile any files.\n *\n * @default 'localOnly'\n */\n transpilationMode?: 'localAndDeps' | 'localOnly' | 'none';\n\n /**\n * The dependencies to transpile when `transpilationMode` is set to\n * `'localAndDeps'`. If not specified, all dependencies will be transpiled.\n */\n depsToTranspile?: string[];\n\n /**\n * Whether to show original errors.\n *\n * @default true\n */\n verboseErrors?: boolean;\n\n /**\n * Whether to write the updated manifest to disk.\n *\n * @default true\n */\n writeManifest?: boolean;\n\n /**\n * Whether to serve the snap locally.\n *\n * @default true\n */\n serve?: boolean;\n };\n\n /**\n * A function that can be used to customize the Browserify instance used to\n * build the snap.\n *\n * @param bundler - The Browserify instance.\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n bundlerCustomizer?: (bundler: BrowserifyObject) => void;\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapWebpackConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler?: 'webpack';\n\n /**\n * The path to the snap entry point. This should be a JavaScript or TypeScript\n * file.\n */\n input: string;\n\n /**\n * Whether to generate source maps for the snap. If `true`, source maps will\n * be generated as separate files. If `'inline'`, source maps will be\n * inlined in the generated JavaScript bundle.\n *\n * @default true\n */\n sourceMap?: boolean | 'inline';\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n evaluate?: boolean;\n\n output?: {\n /**\n * The path to the directory where the snap will be built. This directory\n * will be created if it doesn't exist.\n *\n * If the path is relative, it will be resolved relative to the current\n * working directory.\n *\n * @default 'dist'\n */\n path?: string;\n\n /**\n * The name of the JavaScript bundle file.\n *\n * @default 'bundle.js'\n */\n filename?: string;\n\n /**\n * Whether to clean the output directory before building the snap. If\n * `true`, the output directory will be deleted and recreated. Otherwise,\n * the output directory will be left as-is.\n *\n * @default false\n */\n clean?: boolean;\n\n /**\n * Whether to minimize the snap bundle. If `true`, the bundle will be\n * minified. Otherwise, the bundle will be left as-is.\n *\n * @default true\n */\n minimize?: boolean;\n };\n\n manifest?: {\n /**\n * The path to the snap manifest file. If the path is relative, it will be\n * resolved relative to the current working directory.\n *\n * @default 'snap.manifest.json'\n */\n path?: string;\n\n /**\n * Whether to automatically update the manifest. If `true`, the manifest\n * will be updated with the latest shasum of the snap bundle, and some\n * common fields will be updated if they are missing or incorrect. If\n * `false`, the manifest will be left as-is.\n *\n * @default true\n */\n update?: boolean;\n };\n\n server?: {\n /**\n * Whether to enable the local server. If `true`, the snap will be served\n * from a local server, when running the `watch` command. If `false`, the\n * snap will not be served.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * The root directory to serve the snap from. If the path is relative, it\n * will be resolved relative to the current working directory.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n };\n\n /**\n * The environment variables to set when building the snap. These will be\n * available in the snap as `process.env`. In addition to these environment\n * variables, the following environment variables will always be set:\n *\n * - `NODE_DEBUG`: `false`\n * - `NODE_ENV`: `'production'`\n * - `DEBUG`: `false`\n *\n * Any environment variables specified here will override these defaults. You\n * can also override any variables here by setting them in your shell when\n * running the CLI.\n */\n environment?: Record<string, unknown>;\n\n /**\n * Options that control the logging output of the CLI.\n */\n stats?: {\n /**\n * Whether to enable verbose logging.\n *\n * @default false\n */\n verbose?: boolean;\n\n /**\n * Whether to log warnings about unresolved built-in modules. If `false`,\n * warnings will not be logged.\n */\n builtIns?:\n | {\n /**\n * The built-in modules to ignore when resolving modules. If a module\n * is ignored, no warning will be logged if it is not resolved.\n */\n ignore?: string[];\n }\n | false;\n\n /**\n * Whether to log warnings about the use of the `Buffer` global. If `false`,\n * warnings will not be logged. If `true`, the CLI will warn if the `Buffer`\n * global is used, but not provided by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n };\n\n /**\n * Whether to provide polyfills for node builtins. If `true`, all the available\n * polyfills will be provided. If `false` no polyfills will be provided. If a\n * configuration object is passed only the polyfills set to `true` will be provided.\n *\n * @default false\n * @example\n * ```ts\n * polyfills: true\n *\n * // or\n *\n * polyfills: {\n * assert: true,\n * buffer: true\n * }\n * ```\n */\n polyfills?:\n | boolean\n | {\n assert?: boolean;\n buffer?: boolean;\n console?: boolean;\n constants?: boolean;\n crypto?: boolean;\n domain?: boolean;\n events?: boolean;\n http?: boolean;\n https?: boolean;\n os?: boolean;\n path?: boolean;\n punycode?: boolean;\n process?: boolean;\n querystring?: boolean;\n stream?: boolean;\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex?: boolean;\n _stream_passthrough?: boolean;\n _stream_readable?: boolean;\n _stream_transform?: boolean;\n _stream_writable?: boolean;\n string_decoder?: boolean;\n /* eslint-enable @typescript-eslint/naming-convention */\n sys?: boolean;\n timers?: boolean;\n tty?: boolean;\n url?: boolean;\n util?: boolean;\n vm?: boolean;\n zlib?: boolean;\n };\n\n /**\n * Optional features to enable in the CLI.\n *\n * @example\n * {\n * features: {\n * images: true,\n * }\n * }\n */\n features?: {\n /**\n * Whether to enable support for images. If `true`, the Webpack\n * configuration will be modified to support images. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default true\n */\n images?: boolean;\n };\n\n /**\n * A function to customize the Webpack configuration used to build the snap.\n * This function will be called with the default Webpack configuration, and\n * should return the modified configuration. If not specified, the default\n * configuration will be used.\n *\n * It's recommended to use the `webpack-merge` package to merge the default\n * configuration with your customizations. The merge function is exported as\n * `merge` from the `@metamask/snaps-cli` package.\n *\n * @example\n * ```ts\n * import type { SnapsConfig } from '@metamask/snaps-cli';\n * import { merge } from '@metamask/snaps-cli';\n *\n * const config: SnapsConfig = {\n * bundler: 'webpack',\n * entry: 'src/index.ts',\n * customizeWebpackConfig: (config) => merge(config, {\n * module: {\n * rules: [\n * {\n * test: /\\.wasm$/,\n * type: 'assets/resource',\n * },\n * ],\n * },\n * }),\n * };\n *\n * export default config;\n * ```\n */\n customizeWebpackConfig?: (\n config: WebpackConfiguration,\n ) => WebpackConfiguration;\n\n /**\n * Experimental features that can be enabled. These features are not\n * guaranteed to be stable, and may be removed or changed in a future release.\n */\n experimental?: {\n /**\n * Whether to enable WebAssembly support. If `true`, the Webpack\n * configuration will be modified to support WebAssembly. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default false\n */\n wasm?: boolean;\n };\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapConfig = SnapBrowserifyConfig | SnapWebpackConfig;\n\ntype SnapsBrowserifyBundlerCustomizerFunction = (\n bundler: BrowserifyObject,\n) => void;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsBrowserifyBundlerCustomizerFunctionStruct =\n define<SnapsBrowserifyBundlerCustomizerFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsBrowserifyConfigStruct = object({\n bundler: literal('browserify'),\n cliOptions: defaulted(\n object({\n bundle: optional(file()),\n dist: defaulted(file(), 'dist'),\n eval: defaulted(boolean(), true),\n manifest: defaulted(boolean(), true),\n port: defaulted(number(), 8081),\n outfileName: defaulted(string(), 'bundle.js'),\n root: defaulted(file(), process.cwd()),\n sourceMaps: defaulted(boolean(), false),\n src: defaulted(file(), 'src/index.js'),\n stripComments: defaulted(boolean(), true),\n suppressWarnings: defaulted(boolean(), false),\n transpilationMode: defaulted(\n union([literal('localAndDeps'), literal('localOnly'), literal('none')]),\n 'localOnly',\n ),\n depsToTranspile: defaulted(array(string()), []),\n verboseErrors: defaulted(boolean(), true),\n writeManifest: defaulted(boolean(), true),\n serve: defaulted(boolean(), true),\n }),\n {},\n ),\n bundlerCustomizer: optional(SnapsBrowserifyBundlerCustomizerFunctionStruct),\n});\n\ntype SnapsWebpackCustomizeWebpackConfigFunction = (\n config: WebpackConfiguration,\n) => WebpackConfiguration;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsWebpackCustomizeWebpackConfigFunctionStruct =\n define<SnapsWebpackCustomizeWebpackConfigFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsWebpackConfigStruct = object({\n bundler: defaulted(literal('webpack'), 'webpack'),\n input: defaulted(file(), resolve(process.cwd(), 'src/index.js')),\n sourceMap: defaulted(union([boolean(), literal('inline')]), false),\n evaluate: defaulted(boolean(), true),\n\n output: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'dist')),\n filename: defaulted(string(), 'bundle.js'),\n clean: defaulted(boolean(), false),\n minimize: defaulted(boolean(), true),\n }),\n {},\n ),\n\n manifest: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'snap.manifest.json')),\n update: defaulted(boolean(), true),\n }),\n {},\n ),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n root: defaulted(file(), process.cwd()),\n port: defaulted(number(), 8081),\n }),\n {},\n ),\n\n environment: defaulted(record(string(), unknown()), {}),\n\n stats: defaulted(\n object({\n verbose: defaulted(boolean(), false),\n builtIns: defaulted(\n union([\n object({ ignore: defaulted(array(string()), []) }),\n literal(false),\n ]),\n {},\n ),\n buffer: defaulted(boolean(), true),\n }),\n {},\n ),\n\n polyfills: defaulted(\n union([\n boolean(),\n object({\n assert: defaulted(boolean(), false),\n buffer: defaulted(boolean(), false),\n console: defaulted(boolean(), false),\n constants: defaulted(boolean(), false),\n crypto: defaulted(boolean(), false),\n domain: defaulted(boolean(), false),\n events: defaulted(boolean(), false),\n http: defaulted(boolean(), false),\n https: defaulted(boolean(), false),\n os: defaulted(boolean(), false),\n path: defaulted(boolean(), false),\n punycode: defaulted(boolean(), false),\n process: defaulted(boolean(), false),\n querystring: defaulted(boolean(), false),\n stream: defaulted(boolean(), false),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: defaulted(boolean(), false),\n _stream_passthrough: defaulted(boolean(), false),\n _stream_readable: defaulted(boolean(), false),\n _stream_transform: defaulted(boolean(), false),\n _stream_writable: defaulted(boolean(), false),\n string_decoder: defaulted(boolean(), false),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: defaulted(boolean(), false),\n timers: defaulted(boolean(), false),\n tty: defaulted(boolean(), false),\n url: defaulted(boolean(), false),\n util: defaulted(boolean(), false),\n vm: defaulted(boolean(), false),\n zlib: defaulted(boolean(), false),\n }),\n ]),\n false,\n ),\n\n features: defaulted(\n object({\n images: defaulted(boolean(), true),\n }),\n {},\n ),\n\n customizeWebpackConfig: optional(\n SnapsWebpackCustomizeWebpackConfigFunctionStruct,\n ),\n\n experimental: defaulted(\n object({\n wasm: defaulted(boolean(), false),\n }),\n {},\n ),\n});\n\nexport const SnapsConfigStruct = type({\n bundler: defaulted(\n union([literal('browserify'), literal('webpack')]),\n 'webpack',\n ),\n});\n\nexport const LegacyOptionsStruct = union([\n named(\n 'object with `transpilationMode` set to `localAndDeps` and `depsToTranspile` set to an array of strings',\n type({\n depsToTranspile: array(string()),\n transpilationMode: literal(TranspilationModes.LocalAndDeps),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n named(\n 'object without `depsToTranspile`',\n type({\n depsToTranspile: named('empty array', empty(array())),\n transpilationMode: union([\n literal(TranspilationModes.LocalOnly),\n literal(TranspilationModes.None),\n ]),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n]);\n\nexport type LegacyOptions = Infer<typeof LegacyOptionsStruct>;\n\nexport type ProcessedBrowserifyConfig = Infer<\n typeof SnapsBrowserifyConfigStruct\n>;\n\nexport type ProcessedWebpackConfig = Infer<typeof SnapsWebpackConfigStruct> & {\n /**\n * The legacy Browserify config, if the bundler is Browserify. This is used\n * to support the legacy config format.\n */\n legacy?: LegacyOptions;\n};\n\nexport type ProcessedConfig = ProcessedWebpackConfig;\n\n/**\n * Get a validated snap config. This validates the config and adds default\n * values for any missing properties.\n *\n * @param config - The config to validate.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n */\nexport function getConfig(config: unknown, argv: YargsArgs): ProcessedConfig {\n const prefix = 'The snap config file is invalid';\n const suffix = dim(\n 'Refer to the documentation for more information: https://docs.metamask.io/snaps/reference/cli/options/',\n );\n\n const { bundler } = createFromStruct(\n config,\n SnapsConfigStruct,\n prefix,\n suffix,\n );\n\n if (bundler === 'browserify') {\n const legacyConfig = createFromStruct(\n config,\n SnapsBrowserifyConfigStruct,\n prefix,\n suffix,\n );\n\n return getWebpackConfig(mergeLegacyOptions(argv, legacyConfig));\n }\n\n return createFromStruct(config, SnapsWebpackConfigStruct, prefix, suffix);\n}\n\n/**\n * Load a snap config from a file. This supports both JavaScript and TypeScript\n * config files, in the CommonJS module format and the ES module format.\n *\n * This assumes that the config file exports a default object, either through\n * `module.exports` or `export default`.\n *\n * @param path - The full path to the config file.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n * @throws If the config file is invalid, or if the config file does not have a\n * default export.\n */\nexport async function loadConfig(path: string, argv: YargsArgs) {\n try {\n const contents = await readFile(path, 'utf8');\n const source = await transform(contents, {\n swcrc: false,\n jsc: {\n parser: {\n syntax: 'typescript',\n },\n },\n module: {\n type: 'commonjs',\n },\n });\n\n const config = new Module(path);\n\n // @ts-expect-error - This function is not typed.\n config.paths = Module._nodeModulePaths(dirname(path));\n\n // @ts-expect-error - This function is not typed.\n config._compile(source.code, path);\n\n if (!hasProperty(config.exports, 'default')) {\n return getConfig(config.exports, argv);\n }\n\n return getConfig(config.exports.default, argv);\n } catch (error) {\n if (error instanceof SnapsStructError) {\n throw new ConfigError(error.message);\n }\n\n throw new ConfigError(\n `Unable to load snap config file at \"${path}\".\\n\\n${indent(\n error.message,\n )}`,\n );\n }\n}\n\n/**\n * Resolve a snap config. This function will look for a `snap.config.js` or\n * `snap.config.ts` file in the current or specified directory.\n *\n * @param path - The path to resolve the snap config from. Defaults to the\n * current working directory.\n * @param argv - The CLI arguments.\n * @returns The resolved and validated snap config.\n * @throws If a snap config could not be found.\n */\nexport async function resolveConfig(path: string, argv: YargsArgs) {\n for (const configFile of CONFIG_FILES) {\n const filePath = resolve(path, configFile);\n if (await isFile(filePath)) {\n return await loadConfig(filePath, argv);\n }\n }\n\n throw new ConfigError(\n `Could not find a \"snap.config.js\" or \"snap.config.ts\" file in the current or specified directory (\"${path}\").`,\n );\n}\n\n/**\n * Get a snap config from the CLI arguments. This will either load the config\n * from the specified config file, or resolve the config from the current\n * working directory.\n *\n * @param argv - The CLI arguments.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The resolved and validated snap config.\n */\nexport async function getConfigByArgv(\n argv: YargsArgs,\n cwd: string = process.cwd(),\n) {\n if (argv.config) {\n if (!(await isFile(argv.config))) {\n throw new ConfigError(\n `Could not find a config file at \"${argv.config}\". Make sure that the path is correct.`,\n );\n }\n\n return await loadConfig(argv.config, argv);\n }\n\n return await resolveConfig(cwd, argv);\n}\n\n/**\n * Merge legacy CLI options into the config. This is used to support the legacy\n * config format, where options can be specified both in the config file and\n * through CLI flags.\n *\n * @param argv - The CLI arguments.\n * @param config - The config to merge the CLI options into.\n * @returns The config with the CLI options merged in.\n * @deprecated This function is only used to support the legacy config format.\n */\nexport function mergeLegacyOptions(\n argv: YargsArgs,\n config: ProcessedBrowserifyConfig,\n) {\n const cliOptions = Object.keys(config.cliOptions).reduce<\n ProcessedBrowserifyConfig['cliOptions']\n >((accumulator, key) => {\n if (argv[key] !== undefined) {\n return {\n ...accumulator,\n [key]: argv[key],\n };\n }\n\n return accumulator;\n }, config.cliOptions);\n\n return {\n ...config,\n cliOptions,\n };\n}\n\n/**\n * Get a Webpack config from a legacy browserify config. This is used to\n * support the legacy config format, and convert it to the new format.\n *\n * @param legacyConfig - The legacy browserify config.\n * @returns The Webpack config.\n */\nexport function getWebpackConfig(\n legacyConfig: ProcessedBrowserifyConfig,\n): ProcessedWebpackConfig {\n const defaultConfig = create(\n { bundler: 'webpack' },\n SnapsWebpackConfigStruct,\n );\n\n // The legacy config has two options for specifying the output path and\n // filename: `bundle`, and `dist` + `outfileName`. If `bundle` is specified,\n // we use that as the output path and filename. Otherwise, we use `dist` and\n // `outfileName`.\n const path = legacyConfig.cliOptions.bundle\n ? dirname(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.dist;\n\n const filename = legacyConfig.cliOptions.bundle\n ? basename(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.outfileName;\n\n return {\n ...defaultConfig,\n input: legacyConfig.cliOptions.src,\n evaluate: legacyConfig.cliOptions.eval,\n sourceMap: legacyConfig.cliOptions.sourceMaps,\n output: {\n path,\n filename,\n\n // The legacy config has an option to remove comments from the bundle, but\n // the terser plugin does this by default, so we only enable the terser if\n // the legacy config has `stripComments` set to `true`. This is not a\n // perfect solution, but it's the best we can do without breaking the\n // legacy config.\n minimize: legacyConfig.cliOptions.stripComments,\n\n // The legacy config does not have a `clean` option, so we default to\n // `false` here.\n clean: false,\n },\n manifest: {\n // The legacy config does not have a `manifest` option, so we default to\n // `process.cwd()/snap.manifest.json`.\n path: resolve(process.cwd(), 'snap.manifest.json'),\n update: legacyConfig.cliOptions.writeManifest,\n },\n server: {\n enabled: legacyConfig.cliOptions.serve,\n port: legacyConfig.cliOptions.port,\n root: legacyConfig.cliOptions.root,\n },\n stats: {\n verbose: false,\n\n // These plugins are designed to be used with the modern config format, so\n // we disable them for the legacy config format.\n builtIns: false,\n buffer: false,\n },\n legacy: createFromStruct(\n {\n ...legacyConfig.cliOptions,\n bundlerCustomizer: legacyConfig.bundlerCustomizer,\n },\n LegacyOptionsStruct,\n 'Invalid Browserify CLI options',\n ),\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildHandler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SM2JEXE6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
builders_default
|
|
6
6
|
} from "./chunk-MR44GPM3.mjs";
|
|
@@ -19,4 +19,4 @@ var build_default = command;
|
|
|
19
19
|
export {
|
|
20
20
|
build_default
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-AO724LXX.mjs.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkHNWSVD35js = require('./chunk-HNWSVD35.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -11,7 +11,8 @@ var _chunkOKDY7C7Sjs = require('./chunk-OKDY7C7S.js');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
var _chunkJEMJNDZOjs = require('./chunk-JEMJNDZO.js');
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
var _chunkQHCKVO3Pjs = require('./chunk-QHCKVO3P.js');
|
|
@@ -28,7 +29,7 @@ async function getDefaultConfiguration(config, options = {
|
|
|
28
29
|
evaluate: config.evaluate
|
|
29
30
|
}) {
|
|
30
31
|
const spinnerText = options.spinner?.text;
|
|
31
|
-
const builtInResolver = config.stats.builtIns && new (0,
|
|
32
|
+
const builtInResolver = config.stats.builtIns && new (0, _chunkHNWSVD35js.SnapsBuiltInResolver)(config.stats.builtIns, options.spinner);
|
|
32
33
|
return {
|
|
33
34
|
/**
|
|
34
35
|
* The target is set to `browserslist` so that Webpack will compile the
|
|
@@ -38,7 +39,7 @@ async function getDefaultConfiguration(config, options = {
|
|
|
38
39
|
*
|
|
39
40
|
* @see https://webpack.js.org/configuration/target/
|
|
40
41
|
*/
|
|
41
|
-
target: `browserslist:${
|
|
42
|
+
target: `browserslist:${_chunkJEMJNDZOjs.BROWSERSLIST_FILE}`,
|
|
42
43
|
/**
|
|
43
44
|
* The mode is set to `production` by default, so that Webpack will minify
|
|
44
45
|
* and optimize the bundle.
|
|
@@ -58,7 +59,7 @@ async function getDefaultConfiguration(config, options = {
|
|
|
58
59
|
*
|
|
59
60
|
* @see https://webpack.js.org/configuration/devtool/
|
|
60
61
|
*/
|
|
61
|
-
devtool:
|
|
62
|
+
devtool: _chunkJEMJNDZOjs.getDevTool.call(void 0, config.sourceMap),
|
|
62
63
|
/**
|
|
63
64
|
* The stats option controls how much information is printed to the console
|
|
64
65
|
* when Webpack is running. We set it to `none` so that we can control the
|
|
@@ -138,7 +139,7 @@ async function getDefaultConfiguration(config, options = {
|
|
|
138
139
|
{
|
|
139
140
|
test: /\.(js|mjs|cjs|ts)$/u,
|
|
140
141
|
exclude: /node_modules/u,
|
|
141
|
-
use: await
|
|
142
|
+
use: await _chunkJEMJNDZOjs.getDefaultLoader.call(void 0, config)
|
|
142
143
|
},
|
|
143
144
|
/**
|
|
144
145
|
* This allows importing modules that uses `.js` and not `.mjs` for the
|
|
@@ -147,11 +148,39 @@ async function getDefaultConfiguration(config, options = {
|
|
|
147
148
|
* @see https://webpack.js.org/configuration/module/#resolvefullyspecified
|
|
148
149
|
*/
|
|
149
150
|
{
|
|
150
|
-
test: /\.m?js
|
|
151
|
+
test: /\.m?js$/u,
|
|
151
152
|
resolve: {
|
|
152
153
|
fullySpecified: false
|
|
153
154
|
}
|
|
154
155
|
},
|
|
156
|
+
/**
|
|
157
|
+
* This allows importing `.svg` files as a string.
|
|
158
|
+
*/
|
|
159
|
+
config.features.images && {
|
|
160
|
+
test: /\.svg$/u,
|
|
161
|
+
// `asset/source` returns the source as a UTF-8 string.
|
|
162
|
+
type: "asset/source"
|
|
163
|
+
},
|
|
164
|
+
/**
|
|
165
|
+
* This allows importing `.png` files as a data URL.
|
|
166
|
+
*/
|
|
167
|
+
config.features.images && {
|
|
168
|
+
test: /\.png$/u,
|
|
169
|
+
type: "asset/inline",
|
|
170
|
+
generator: {
|
|
171
|
+
dataUrl: _chunkJEMJNDZOjs.getImageSVG.bind(null, "image/png")
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* This allows importing `.jpe?g` files as a data URL.
|
|
176
|
+
*/
|
|
177
|
+
config.features.images && {
|
|
178
|
+
test: /\.jpe?g$/u,
|
|
179
|
+
type: "asset/inline",
|
|
180
|
+
generator: {
|
|
181
|
+
dataUrl: _chunkJEMJNDZOjs.getImageSVG.bind(null, "image/jpeg")
|
|
182
|
+
}
|
|
183
|
+
},
|
|
155
184
|
config.experimental.wasm && {
|
|
156
185
|
test: /\.wasm$/u,
|
|
157
186
|
use: _chunkQHCKVO3Pjs.getFunctionLoader.call(void 0, _chunkYQ2E7NEAjs.wasm_default, {})
|
|
@@ -175,7 +204,7 @@ async function getDefaultConfiguration(config, options = {
|
|
|
175
204
|
* aren't resolved. By default, we set Node.js built-ins to `false`, so
|
|
176
205
|
* that they are ignored.
|
|
177
206
|
*/
|
|
178
|
-
fallback:
|
|
207
|
+
fallback: _chunkJEMJNDZOjs.getFallbacks.call(void 0, config.polyfills),
|
|
179
208
|
/**
|
|
180
209
|
* The plugins to use. We use the {@link SnapsBuiltInResolver} to show
|
|
181
210
|
* warnings about using Node.js built-ins, when no fallback is specified.
|
|
@@ -203,27 +232,27 @@ async function getDefaultConfiguration(config, options = {
|
|
|
203
232
|
* output. It's used to show the stats in the terminal, in a format that
|
|
204
233
|
* is easy to read.
|
|
205
234
|
*/
|
|
206
|
-
new (0,
|
|
235
|
+
new (0, _chunkHNWSVD35js.SnapsStatsPlugin)({ verbose: config.stats.verbose }, options.spinner),
|
|
207
236
|
/**
|
|
208
237
|
* The `DefinePlugin` is a Webpack plugin that adds static values to the
|
|
209
238
|
* bundle. We use it to add the `NODE_DEBUG`, `NODE_ENV`, and `DEBUG`
|
|
210
239
|
* environment variables, as well as any custom environment
|
|
211
240
|
* variables (as `process.env`).
|
|
212
241
|
*/
|
|
213
|
-
new (0, _webpack.DefinePlugin)(
|
|
242
|
+
new (0, _webpack.DefinePlugin)(_chunkJEMJNDZOjs.getEnvironmentVariables.call(void 0, config.environment)),
|
|
214
243
|
/**
|
|
215
244
|
* The `ProgressPlugin` is a Webpack plugin that logs the progress of
|
|
216
245
|
* the build. We set it to log the progress to the spinner.
|
|
217
246
|
*/
|
|
218
247
|
new (0, _webpack.ProgressPlugin)({
|
|
219
|
-
handler:
|
|
248
|
+
handler: _chunkJEMJNDZOjs.getProgressHandler.call(void 0, options.spinner, spinnerText)
|
|
220
249
|
}),
|
|
221
250
|
/**
|
|
222
251
|
* The `SnapsBundleWarningPlugin` is a Webpack plugin that shows a
|
|
223
252
|
* warning when the bundle is potentially incompatible with MetaMask
|
|
224
253
|
* Snaps.
|
|
225
254
|
*/
|
|
226
|
-
new (0,
|
|
255
|
+
new (0, _chunkHNWSVD35js.SnapsBundleWarningsPlugin)({
|
|
227
256
|
builtInResolver,
|
|
228
257
|
builtIns: Boolean(config.stats.builtIns),
|
|
229
258
|
buffer: config.stats.buffer
|
|
@@ -233,7 +262,7 @@ async function getDefaultConfiguration(config, options = {
|
|
|
233
262
|
* for changes. This is useful for rebuilding the bundle when the
|
|
234
263
|
* manifest file changes.
|
|
235
264
|
*/
|
|
236
|
-
options.watch && new (0,
|
|
265
|
+
options.watch && new (0, _chunkHNWSVD35js.SnapsWatchPlugin)(
|
|
237
266
|
{
|
|
238
267
|
bundle: _path.resolve.call(void 0, config.output.path, config.output.filename),
|
|
239
268
|
evaluate: options.evaluate,
|
|
@@ -299,4 +328,4 @@ async function getDefaultConfiguration(config, options = {
|
|
|
299
328
|
|
|
300
329
|
|
|
301
330
|
exports.getDefaultConfiguration = getDefaultConfiguration;
|
|
302
|
-
//# sourceMappingURL=chunk-
|
|
331
|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MACH;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOX,OAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,MAKrB,OAAO;AAAA,IACT;AAAA,EACF;AACF","sourcesContent":["import SnapsWebpackPlugin from '@metamask/snaps-webpack-plugin';\nimport type { Ora } from 'ora';\nimport { resolve } from 'path';\nimport TerserPlugin from 'terser-webpack-plugin';\nimport type { Configuration } from 'webpack';\nimport { DefinePlugin, ProgressPlugin, ProvidePlugin } from 'webpack';\n\nimport type { ProcessedWebpackConfig } from '../config';\nimport { getFunctionLoader, wasm } from './loaders';\nimport {\n SnapsBuiltInResolver,\n SnapsBundleWarningsPlugin,\n SnapsStatsPlugin,\n SnapsWatchPlugin,\n} from './plugins';\nimport {\n BROWSERSLIST_FILE,\n getDefaultLoader,\n getDevTool,\n getEnvironmentVariables,\n getFallbacks,\n getImageSVG,\n getProgressHandler,\n} from './utils';\n\nexport type WebpackOptions = {\n /**\n * Whether to watch for changes.\n */\n watch?: boolean;\n\n /**\n * Whether to evaluate the bundle. If this is set, it will override the\n * `evaluate` option in the config object.\n */\n evaluate?: boolean;\n\n /**\n * The spinner to use for logging.\n */\n spinner?: Ora;\n};\n\n/**\n * Get the default Webpack configuration. This is the configuration that will\n * be used if the user doesn't provide a custom Webpack configuration. The\n * configuration is based on the snap config.\n *\n * The default configuration includes:\n *\n * - `SWC` to transpile TypeScript and JavaScript files.\n * - `TerserPlugin` to minify the bundle.\n * - `SnapsWebpackPlugin` to validate the bundle and update the manifest.\n *\n * It can be customized through the `customizeWebpackConfig` function in the\n * snap config, but in most cases, you shouldn't need to do that.\n *\n * @param config - The processed snap Webpack config.\n * @param options - The Webpack options.\n * @returns The default Webpack configuration.\n */\nexport async function getDefaultConfiguration(\n config: ProcessedWebpackConfig,\n options: WebpackOptions = {\n evaluate: config.evaluate,\n },\n): Promise<Configuration> {\n const spinnerText = options.spinner?.text;\n const builtInResolver =\n config.stats.builtIns &&\n new SnapsBuiltInResolver(config.stats.builtIns, options.spinner);\n\n return {\n /**\n * The target is set to `browserslist` so that Webpack will compile the\n * bundle to support the browsers specified in the `.browserslistrc` file.\n * This Browserslist file contains the browsers that are supported by\n * MetaMask Snaps.\n *\n * @see https://webpack.js.org/configuration/target/\n */\n target: `browserslist:${BROWSERSLIST_FILE}`,\n\n /**\n * The mode is set to `production` by default, so that Webpack will minify\n * and optimize the bundle.\n *\n * @see https://webpack.js.org/configuration/mode/\n */\n mode: 'production',\n\n /**\n * The entry point is set to the `input` value from the config object.\n *\n * @see https://webpack.js.org/configuration/entry-context/\n */\n entry: config.input,\n\n /**\n * The devtool option controls how source maps are generated. We set it to\n * the `sourceMap` value from the config object.\n *\n * @see https://webpack.js.org/configuration/devtool/\n */\n devtool: getDevTool(config.sourceMap),\n\n /**\n * The stats option controls how much information is printed to the console\n * when Webpack is running. We set it to `none` so that we can control the\n * output ourselves.\n *\n * @see https://webpack.js.org/configuration/stats/\n */\n stats: 'none',\n\n /**\n * The output options.\n *\n * @see https://webpack.js.org/configuration/output/\n */\n output: {\n /**\n * This indicates whether Webpack should clear the output directory\n * before building. We set it to the `clean` value from the config\n * object.\n *\n * @see https://webpack.js.org/configuration/output/#outputclean\n */\n clean: config.output.clean,\n\n /**\n * The filename of the bundle. We set it to the `filename` value from\n * the config object.\n *\n * @see https://webpack.js.org/configuration/output/#outputfilename\n */\n filename: config.output.filename,\n\n /**\n * The path to the output directory. We set it to the `path` value from\n * the config object.\n *\n * @see https://webpack.js.org/configuration/output/#outputpath\n */\n path: config.output.path,\n\n /**\n * The public path of the bundle. We set it to `/` by default, so that\n * the bundle can be loaded from the root of the server.\n *\n * @see https://webpack.js.org/configuration/output/#outputpublicpath\n */\n publicPath: '/',\n\n /**\n * The library configuration. This tells Webpack how to export the\n * bundle.\n *\n * @see https://webpack.js.org/configuration/output/#outputlibrary\n */\n library: {\n /**\n * This tells Webpack to export the bundle as a CommonJS module. This\n * is necessary for MetaMask Snaps.\n *\n * @see https://webpack.js.org/configuration/output/#outputlibrarytarget\n */\n type: 'commonjs',\n },\n\n /**\n * The chunk format. This tells Webpack how to export chunks. This is\n * required because we use browserslist to target browsers, but Snaps are\n * not fully compatible with browser APIs (such as `window` and\n * `document`).\n *\n * @see https://webpack.js.org/configuration/output/#outputchunkformat\n */\n chunkFormat: 'commonjs',\n },\n\n /**\n * The module configuration. This is where we tell Webpack how to handle\n * different types of files.\n *\n * @see https://webpack.js.org/configuration/module/\n */\n module: {\n rules: [\n {\n test: /\\.(js|mjs|cjs|ts)$/u,\n exclude: /node_modules/u,\n use: await getDefaultLoader(config),\n },\n\n /**\n * This allows importing modules that uses `.js` and not `.mjs` for the\n * ES build.\n *\n * @see https://webpack.js.org/configuration/module/#resolvefullyspecified\n */\n {\n test: /\\.m?js$/u,\n resolve: {\n fullySpecified: false,\n },\n },\n\n /**\n * This allows importing `.svg` files as a string.\n */\n config.features.images && {\n test: /\\.svg$/u,\n // `asset/source` returns the source as a UTF-8 string.\n type: 'asset/source',\n },\n\n /**\n * This allows importing `.png` files as a data URL.\n */\n config.features.images && {\n test: /\\.png$/u,\n type: 'asset/inline',\n generator: {\n dataUrl: getImageSVG.bind(null, 'image/png'),\n },\n },\n\n /**\n * This allows importing `.jpe?g` files as a data URL.\n */\n config.features.images && {\n test: /\\.jpe?g$/u,\n type: 'asset/inline',\n generator: {\n dataUrl: getImageSVG.bind(null, 'image/jpeg'),\n },\n },\n\n config.experimental.wasm && {\n test: /\\.wasm$/u,\n use: getFunctionLoader(wasm, {}),\n },\n ],\n },\n\n /**\n * The resolve configuration. This tells Webpack how to resolve imports.\n * We set it to resolve `.js` and `.ts` files.\n *\n * @see https://webpack.js.org/configuration/resolve/\n */\n resolve: {\n /**\n * The extensions to resolve. We set it to resolve `.(c|m)?js` and `.ts`\n * files.\n */\n extensions: ['.js', '.mjs', '.cjs', '.ts'],\n\n /**\n * The fallback options. This tells Webpack how to handle imports that\n * aren't resolved. By default, we set Node.js built-ins to `false`, so\n * that they are ignored.\n */\n fallback: getFallbacks(config.polyfills),\n\n /**\n * The plugins to use. We use the {@link SnapsBuiltInResolver} to show\n * warnings about using Node.js built-ins, when no fallback is specified.\n */\n plugins: [builtInResolver],\n },\n\n /**\n * The plugins to use.\n *\n * @see https://webpack.js.org/configuration/plugins/\n */\n plugins: [\n /**\n * The `SnapsWebpackPlugin` is a Webpack plugin that checks and updates\n * the manifest file, and evaluates the bundle in SES. While not strictly\n * required, it's highly recommended to use this plugin.\n */\n new SnapsWebpackPlugin({\n manifestPath: config.manifest.path,\n writeManifest: config.manifest.update,\n eval: !options.watch && options.evaluate,\n }),\n\n /**\n * The `SnapsStatsPlugin` is a Webpack plugin that handles the stats\n * output. It's used to show the stats in the terminal, in a format that\n * is easy to read.\n */\n new SnapsStatsPlugin({ verbose: config.stats.verbose }, options.spinner),\n\n /**\n * The `DefinePlugin` is a Webpack plugin that adds static values to the\n * bundle. We use it to add the `NODE_DEBUG`, `NODE_ENV`, and `DEBUG`\n * environment variables, as well as any custom environment\n * variables (as `process.env`).\n */\n new DefinePlugin(getEnvironmentVariables(config.environment)),\n\n /**\n * The `ProgressPlugin` is a Webpack plugin that logs the progress of\n * the build. We set it to log the progress to the spinner.\n */\n new ProgressPlugin({\n handler: getProgressHandler(options.spinner, spinnerText),\n }),\n\n /**\n * The `SnapsBundleWarningPlugin` is a Webpack plugin that shows a\n * warning when the bundle is potentially incompatible with MetaMask\n * Snaps.\n */\n new SnapsBundleWarningsPlugin({\n builtInResolver,\n builtIns: Boolean(config.stats.builtIns),\n buffer: config.stats.buffer,\n }),\n\n /**\n * The `WatchPlugin` is a Webpack plugin that adds extra files to watch\n * for changes. This is useful for rebuilding the bundle when the\n * manifest file changes.\n */\n options.watch &&\n new SnapsWatchPlugin(\n {\n bundle: resolve(config.output.path, config.output.filename),\n evaluate: options.evaluate,\n files: [config.manifest.path],\n },\n options.spinner,\n ),\n\n /**\n * The `ProviderPlugin` is a Webpack plugin that automatically load\n * modules instead of having to import or require them everywhere.\n */\n (config.polyfills === true ||\n (config.polyfills !== false && config.polyfills.buffer)) &&\n new ProvidePlugin({\n Buffer: ['buffer', 'Buffer'],\n }),\n ].filter(Boolean),\n\n /**\n * The optimization configuration. This tells Webpack how to optimize the\n * bundle. Most of the time, you won't need to change this, as the default\n * options set by the `mode` option are sufficient.\n */\n optimization: {\n minimize: config.output.minimize,\n\n /**\n * The minimizer to use. We set it to use the `TerserPlugin`.\n */\n minimizer: [\n new TerserPlugin({\n parallel: true,\n }),\n ],\n },\n\n /**\n * The performance configuration. This tells Webpack how to handle\n * performance hints.\n *\n * @see https://webpack.js.org/configuration/performance/\n */\n performance: {\n /**\n * The hints to show. We set it to `false`, so that we don't get\n * performance hints, as they are not relevant for Snaps.\n *\n * @see https://webpack.js.org/configuration/performance/#performancehints\n */\n hints: false,\n },\n\n /**\n * The infrastructure logging configuration. This tells Webpack how to\n * log messages.\n *\n * @see https://webpack.js.org/configuration/infrastructure-logging\n */\n infrastructureLogging: {\n /**\n * The level of logging to use. We set it to `none`, so that we can\n * control the output ourselves.\n */\n level: 'none',\n },\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCompiler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WUC7DUXN.mjs";
|
|
4
4
|
|
|
5
5
|
// src/commands/watch/implementation.ts
|
|
6
6
|
import { basename } from "path";
|
|
@@ -32,4 +32,4 @@ async function watch(config, options) {
|
|
|
32
32
|
export {
|
|
33
33
|
watch
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-BVPROOGE.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRJ6IKKA2js = require('./chunk-RJ6IKKA2.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkMUYXNIONjs = require('./chunk-MUYXNION.js');
|
|
@@ -32,7 +32,7 @@ var steps = [
|
|
|
32
32
|
{
|
|
33
33
|
name: "Building the snap bundle.",
|
|
34
34
|
task: async ({ config, spinner }) => {
|
|
35
|
-
return await
|
|
35
|
+
return await _chunkRJ6IKKA2js.build.call(void 0, config, { evaluate: false, spinner });
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
{
|
|
@@ -58,4 +58,4 @@ async function buildHandler(config) {
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
exports.buildHandler = buildHandler;
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-C2OMV3H5.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkXQGKSVFJjs = require('./chunk-XQGKSVFJ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS7UP2YYFjs = require('./chunk-S7UP2YYF.js');
|
|
@@ -12,7 +12,7 @@ var command = {
|
|
|
12
12
|
builder: (yarg) => {
|
|
13
13
|
yarg.option("src", _chunkS7UP2YYFjs.builders_default.src).option("eval", _chunkS7UP2YYFjs.builders_default.eval).option("dist", _chunkS7UP2YYFjs.builders_default.dist).option("outfileName", _chunkS7UP2YYFjs.builders_default.outfileName).option("sourceMaps", _chunkS7UP2YYFjs.builders_default.sourceMaps).option("stripComments", _chunkS7UP2YYFjs.builders_default.stripComments).option("transpilationMode", _chunkS7UP2YYFjs.builders_default.transpilationMode).option("depsToTranspile", _chunkS7UP2YYFjs.builders_default.depsToTranspile).option("manifest", _chunkS7UP2YYFjs.builders_default.manifest).option("writeManifest", _chunkS7UP2YYFjs.builders_default.writeManifest).option("serve", _chunkS7UP2YYFjs.builders_default.serve).option("root", _chunkS7UP2YYFjs.builders_default.root).option("port", _chunkS7UP2YYFjs.builders_default.port).implies("writeManifest", "manifest").implies("depsToTranspile", "transpilationMode");
|
|
14
14
|
},
|
|
15
|
-
handler: async (argv) =>
|
|
15
|
+
handler: async (argv) => _chunkXQGKSVFJjs.watchHandler.call(void 0, argv.context.config, {
|
|
16
16
|
port: argv.port
|
|
17
17
|
})
|
|
18
18
|
};
|
|
@@ -21,4 +21,4 @@ var watch_default = command;
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
exports.watch_default = watch_default;
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-CQZ2AXMG.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkCQZ2AXMGjs = require('./chunk-CQZ2AXMG.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkV4UPOVEHjs = require('./chunk-V4UPOVEH.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkS76EZ6HYjs = require('./chunk-S76EZ6HY.js');
|
|
@@ -16,15 +16,15 @@ var _chunk6EEZHGF5js = require('./chunk-6EEZHGF5.js');
|
|
|
16
16
|
|
|
17
17
|
// src/commands/index.ts
|
|
18
18
|
var commands = [
|
|
19
|
-
|
|
19
|
+
_chunkV4UPOVEHjs.build_default,
|
|
20
20
|
_chunk6EEZHGF5js.eval_default,
|
|
21
21
|
_chunkS76EZ6HYjs.manifest_default,
|
|
22
22
|
_chunkU4VFMIGOjs.serve_default,
|
|
23
|
-
|
|
23
|
+
_chunkCQZ2AXMGjs.watch_default
|
|
24
24
|
];
|
|
25
25
|
var commands_default = commands;
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
exports.commands_default = commands_default;
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-EHJPVBQU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
watch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BVPROOGE.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getServer
|
|
6
6
|
} from "./chunk-SYRWT2KT.mjs";
|
|
@@ -51,4 +51,4 @@ async function watchHandler(config, options) {
|
|
|
51
51
|
export {
|
|
52
52
|
watchHandler
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-FQ3HKVHQ.mjs.map
|