@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
|
@@ -4,7 +4,7 @@ var _chunkMUYXNIONjs = require('./chunk-MUYXNION.js');
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkJEMJNDZOjs = require('./chunk-JEMJNDZO.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkB3NNVTA6js = require('./chunk-B3NNVTA6.js');
|
|
@@ -61,10 +61,10 @@ var SnapsStatsPlugin = class {
|
|
|
61
61
|
if (errors?.length) {
|
|
62
62
|
const formattedErrors = errors.map((statsError) => _chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _getStatsErrorMessage, getStatsErrorMessage_fn).call(this, statsError)).join("\n\n");
|
|
63
63
|
_chunkTJ2F3J6Xjs.error.call(void 0,
|
|
64
|
-
`Compiled ${modules.length} ${
|
|
64
|
+
`Compiled ${modules.length} ${_chunkJEMJNDZOjs.pluralize.call(void 0,
|
|
65
65
|
modules.length,
|
|
66
66
|
"file"
|
|
67
|
-
)} in ${time}ms with ${errors.length} ${
|
|
67
|
+
)} in ${time}ms with ${errors.length} ${_chunkJEMJNDZOjs.pluralize.call(void 0,
|
|
68
68
|
errors.length,
|
|
69
69
|
"error"
|
|
70
70
|
)}.
|
|
@@ -82,10 +82,10 @@ ${formattedErrors}
|
|
|
82
82
|
(statsWarning) => _chunkX3D3MHWFjs.__privateMethod.call(void 0, this, _getStatsErrorMessage, getStatsErrorMessage_fn).call(this, statsWarning, _chalk.yellow)
|
|
83
83
|
).join("\n\n");
|
|
84
84
|
_chunkTJ2F3J6Xjs.warn.call(void 0,
|
|
85
|
-
`Compiled ${modules.length} ${
|
|
85
|
+
`Compiled ${modules.length} ${_chunkJEMJNDZOjs.pluralize.call(void 0,
|
|
86
86
|
modules.length,
|
|
87
87
|
"file"
|
|
88
|
-
)} in ${time}ms with ${warnings.length} ${
|
|
88
|
+
)} in ${time}ms with ${warnings.length} ${_chunkJEMJNDZOjs.pluralize.call(void 0,
|
|
89
89
|
warnings.length,
|
|
90
90
|
"warning"
|
|
91
91
|
)}.
|
|
@@ -96,7 +96,7 @@ ${formattedWarnings}
|
|
|
96
96
|
);
|
|
97
97
|
} else {
|
|
98
98
|
_chunkTJ2F3J6Xjs.info.call(void 0,
|
|
99
|
-
`Compiled ${modules.length} ${
|
|
99
|
+
`Compiled ${modules.length} ${_chunkJEMJNDZOjs.pluralize.call(void 0,
|
|
100
100
|
modules.length,
|
|
101
101
|
"file"
|
|
102
102
|
)} in ${time}ms.`,
|
|
@@ -115,10 +115,10 @@ getStatsErrorMessage_fn = function(statsError, color = _chalk.red) {
|
|
|
115
115
|
const baseMessage = this.options.verbose ? _chunkB3NNVTA6js.getErrorMessage.call(void 0, statsError) : statsError.message;
|
|
116
116
|
const [first, ...rest] = baseMessage.split("\n");
|
|
117
117
|
return [
|
|
118
|
-
color(
|
|
119
|
-
...rest.map((message) =>
|
|
118
|
+
color(_chunkJEMJNDZOjs.formatText.call(void 0, `\u2022 ${first}`, 4, 2)),
|
|
119
|
+
...rest.map((message) => _chunkJEMJNDZOjs.formatText.call(void 0, color(message), 4)),
|
|
120
120
|
statsError.details && `
|
|
121
|
-
${
|
|
121
|
+
${_chunkJEMJNDZOjs.formatText.call(void 0, _chalk.dim.call(void 0, statsError.details), 6)}`
|
|
122
122
|
].filter(Boolean).join("\n");
|
|
123
123
|
};
|
|
124
124
|
var _spinner2, _safeEvaluate, safeEvaluate_fn;
|
|
@@ -343,4 +343,4 @@ checkBuffer_fn = function(compiler) {
|
|
|
343
343
|
|
|
344
344
|
|
|
345
345
|
exports.SnapsStatsPlugin = SnapsStatsPlugin; exports.SnapsWatchPlugin = SnapsWatchPlugin; exports.SnapsBuiltInResolver = SnapsBuiltInResolver; exports.SnapsBundleWarningsPlugin = SnapsBundleWarningsPlugin;
|
|
346
|
-
//# sourceMappingURL=chunk-
|
|
346
|
+
//# sourceMappingURL=chunk-HNWSVD35.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
watchHandler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FQ3HKVHQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
builders_default
|
|
6
6
|
} from "./chunk-MR44GPM3.mjs";
|
|
@@ -21,4 +21,4 @@ var watch_default = command;
|
|
|
21
21
|
export {
|
|
22
22
|
watch_default
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-IO6WNNPF.mjs.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
formatText,
|
|
6
6
|
pluralize
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OGGTU5W6.mjs";
|
|
8
8
|
import {
|
|
9
9
|
getErrorMessage
|
|
10
10
|
} from "./chunk-7RHK2YTB.mjs";
|
|
@@ -343,4 +343,4 @@ export {
|
|
|
343
343
|
SnapsBuiltInResolver,
|
|
344
344
|
SnapsBundleWarningsPlugin
|
|
345
345
|
};
|
|
346
|
-
//# sourceMappingURL=chunk-
|
|
346
|
+
//# sourceMappingURL=chunk-JBSWMUCQ.mjs.map
|
|
@@ -9,6 +9,7 @@ var _chunkPDYQXXLPjs = require('./chunk-PDYQXXLP.js');
|
|
|
9
9
|
var _chunkX3D3MHWFjs = require('./chunk-X3D3MHWF.js');
|
|
10
10
|
|
|
11
11
|
// src/webpack/utils.ts
|
|
12
|
+
var _utils = require('@metamask/utils');
|
|
12
13
|
var _chalk = require('chalk');
|
|
13
14
|
var _fs = require('fs');
|
|
14
15
|
var _module = require('module');
|
|
@@ -270,6 +271,11 @@ function formatText(text, indent, initialIndent = indent) {
|
|
|
270
271
|
return formatLine(line, indent, lineIndent);
|
|
271
272
|
}).join("\n");
|
|
272
273
|
}
|
|
274
|
+
function getImageSVG(mimeType, bytes) {
|
|
275
|
+
const dataUrl = `data:${mimeType};base64,${_utils.bytesToBase64.call(void 0, bytes)}`;
|
|
276
|
+
return `<svg xmlns="http://www.w3.org/2000/svg"><image href="${dataUrl}" /></svg>`;
|
|
277
|
+
}
|
|
278
|
+
|
|
273
279
|
|
|
274
280
|
|
|
275
281
|
|
|
@@ -283,5 +289,5 @@ function formatText(text, indent, initialIndent = indent) {
|
|
|
283
289
|
|
|
284
290
|
|
|
285
291
|
|
|
286
|
-
exports.BROWSERSLIST_FILE = BROWSERSLIST_FILE; exports.WEBPACK_FALLBACKS = WEBPACK_FALLBACKS; exports.getDefaultLoader = getDefaultLoader; exports.getDevTool = getDevTool; exports.getProgressHandler = getProgressHandler; exports.getBrowserslistTargets = getBrowserslistTargets; exports.pluralize = pluralize; exports.getFallbacks = getFallbacks; exports.getEnvironmentVariables = getEnvironmentVariables; exports.formatText = formatText; exports.browserify_default = browserify_default;
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
292
|
+
exports.BROWSERSLIST_FILE = BROWSERSLIST_FILE; exports.WEBPACK_FALLBACKS = WEBPACK_FALLBACKS; exports.getDefaultLoader = getDefaultLoader; exports.getDevTool = getDevTool; exports.getProgressHandler = getProgressHandler; exports.getBrowserslistTargets = getBrowserslistTargets; exports.pluralize = pluralize; exports.getFallbacks = getFallbacks; exports.getEnvironmentVariables = getEnvironmentVariables; exports.formatText = formatText; exports.getImageSVG = getImageSVG; exports.browserify_default = browserify_default;
|
|
293
|
+
//# sourceMappingURL=chunk-JEMJNDZO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack/utils.ts","../src/webpack/loaders/browserify.ts"],"names":["resolve"],"mappings":";;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,WAAW;AACpB,SAAS,YAAY,UAAU;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,SAAS,eAAe;AACjC,OAAO,eAAe;;;ACNtB,OAAO,gBAAgB;AACvB,SAAS,gBAAgB;AAoBzB,IAAM,SAAkD,eACtD,SACA,WACA;AACA,QAAM,SAAS,KAAK,WAAW;AAE/B,QAAM,EAAE,kBAAkB,IAAI;AAE9B,QAAM,UAAU,WAAW;AAAA,IACzB,YAAY,CAAC,OAAO,KAAK;AAAA,IACzB,OAAO,QAAQ,SAAS;AAAA,IACxB,YAAY;AAAA,EACd,CAAC;AAED,MAAI,yCAA+C;AACjD,UAAM,kBAAkB,oBAAoB,MAAM;AAKlD,YAAQ,UAAU,UAAQ,UAAU,GAAG;AAAA,MACrC,QAAQ;AAAA,MACR,YAAY,CAAC,OAAO,KAAK;AAAA,MACzB,SAAS;AAAA,QACP,UAAQ,0BAA0B;AAAA,QAClC;AAAA,UACE,UAAQ,mBAAmB;AAAA,UAC3B;AAAA,YACE,SAAS;AAAA,cACP,UAAU,MAAM,uBAAuB;AAAA,YACzC;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACP,UAAQ,iCAAiC;AAAA,QACzC,UAAQ,0CAA0C;AAAA,QAClD,UAAQ,yCAAyC;AAAA,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AC,EACA,KAAK,IAAI;AACd;AASO,SAAS,YAAY,UAAkB,OAAmB;AAC/D,QAAM,UAAU,QAAQ,QAAQ,WAAW,cAAc,KAAK,CAAC;AAC/D,SAAO,wDAAwD,OAAO;AACxE","sourcesContent":["import { bytesToBase64 } from '@metamask/utils';\nimport { dim } from 'chalk';\nimport { promises as fs } from 'fs';\nimport { builtinModules } from 'module';\nimport type { Ora } from 'ora';\nimport { dirname, resolve } from 'path';\nimport stripAnsi from 'strip-ansi';\nimport type { Configuration } from 'webpack';\n\nimport type { ProcessedWebpackConfig } from '../config';\nimport { browserify, getFunctionLoader } from './loaders';\n\nexport const BROWSERSLIST_FILE = resolve(\n dirname(\n // eslint-disable-next-line n/no-extraneous-require\n require.resolve('@metamask/snaps-cli/package.json'),\n ),\n '.browserslistrc',\n);\n\nexport const WEBPACK_FALLBACKS = {\n assert: require.resolve('assert/'),\n buffer: require.resolve('buffer/'),\n console: require.resolve('console-browserify'),\n constants: require.resolve('constants-browserify'),\n crypto: require.resolve('crypto-browserify'),\n domain: require.resolve('domain-browser'),\n events: require.resolve('events/'),\n http: require.resolve('stream-http'),\n https: require.resolve('https-browserify'),\n os: require.resolve('os-browserify/browser'),\n path: require.resolve('path-browserify'),\n punycode: require.resolve('punycode/'),\n process: require.resolve('process/browser'),\n querystring: require.resolve('querystring-es3'),\n stream: require.resolve('stream-browserify'),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: require.resolve('readable-stream/lib/_stream_duplex'),\n _stream_passthrough: require.resolve(\n 'readable-stream/lib/_stream_passthrough',\n ),\n _stream_readable: require.resolve('readable-stream/lib/_stream_readable'),\n _stream_transform: require.resolve('readable-stream/lib/_stream_transform'),\n _stream_writable: require.resolve('readable-stream/lib/_stream_writable'),\n string_decoder: require.resolve('string_decoder/'),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: require.resolve('util/'),\n timers: require.resolve('timers-browserify'),\n tty: require.resolve('tty-browserify'),\n url: require.resolve('url/'),\n util: require.resolve('util/'),\n vm: require.resolve('vm-browserify'),\n zlib: require.resolve('browserify-zlib'),\n};\n\n/**\n * Get the default loader for JavaScript and TypeScript files, based on the\n * config object.\n *\n * - If the `legacy` option is set, we use the custom `browserify` loader. This\n * uses the legacy Browserify config to transpile the code.\n * - Otherwise, we use the `swc-loader`. This is a Webpack loader that uses the\n * `SWC` compiler, which is a much faster alternative to Babel and TypeScript's\n * own compiler.\n *\n * @param config - The processed snap Webpack config.\n * @param config.legacy - The legacy config object, if any.\n * @param config.sourceMap - Whether to generate source maps.\n * @see https://swc.rs/docs/usage/swc-loader\n * @returns The default loader.\n */\nexport async function getDefaultLoader({\n legacy,\n sourceMap,\n}: ProcessedWebpackConfig) {\n if (legacy) {\n /**\n * If the snap uses the legacy config, we use the custom `browserify`\n * loader. This uses the legacy Browserify config to transpile the code.\n * This is necessary for backwards compatibility with the\n * `bundlerCustomizer` function.\n */\n return getFunctionLoader(browserify, legacy);\n }\n\n const targets = await getBrowserslistTargets();\n return {\n /**\n * We use the `swc-loader` to transpile TypeScript and JavaScript files.\n * This is a Webpack loader that uses the `SWC` compiler, which is a much\n * faster alternative to Babel and TypeScript's own compiler.\n */\n loader: require.resolve('swc-loader'),\n\n /**\n * The options for the `swc-loader`. These can be overridden in the\n * `.swcrc` file.\n *\n * @see https://swc.rs/docs/configuration/swcrc\n */\n options: {\n sync: false,\n\n /**\n * This tells SWC to generate source maps. We set it to the\n * `sourceMap` value from the config object.\n *\n * This must be enabled if source maps are enabled in the config.\n */\n sourceMaps: Boolean(getDevTool(sourceMap)),\n\n jsc: {\n parser: {\n /**\n * This tells the parser to parse TypeScript files. If you\n * don't need to support TypeScript, you can set this to\n * `ecmascript` instead, but there's no harm in leaving it\n * as `typescript`.\n *\n * @see https://swc.rs/docs/configuration/compilation#jscparser\n */\n syntax: 'typescript',\n },\n },\n\n /**\n * The module configuration. This tells SWC how to output the\n * transpiled code.\n *\n * @see https://swc.rs/docs/configuration/modules\n */\n module: {\n /**\n * This tells SWC to output ES6 modules. This will allow Webpack to\n * optimize the output code better. Snaps don't support ES6 however, so\n * the output code will be transpiled to CommonJS by Webpack later in\n * the build process.\n *\n * @see https://swc.rs/docs/configuration/modules#es6\n */\n type: 'es6',\n },\n\n env: {\n targets: targets.join(', '),\n },\n },\n };\n}\n\n/**\n * Get the Webpack devtool configuration based on the given snap config.\n *\n * - If `sourceMap` is `inline`, return `inline-source-map`.\n * - If `sourceMap` is `true`, return `source-map`.\n * - Otherwise, return `false`.\n *\n * @param sourceMap - The `sourceMap` value from the snap config.\n * @returns The Webpack devtool configuration.\n */\nexport function getDevTool(\n sourceMap: ProcessedWebpackConfig['sourceMap'],\n): Configuration['devtool'] {\n if (sourceMap === 'inline') {\n return 'inline-source-map';\n }\n\n if (sourceMap === true) {\n return 'source-map';\n }\n\n return false;\n}\n\n/**\n * Get a function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n *\n * @param spinner - The spinner to update.\n * @param spinnerText - The initial spinner text. This will be prepended to the\n * percentage.\n * @returns A function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n */\n// Note: This is extracted for testing purposes.\nexport function getProgressHandler(spinner?: Ora, spinnerText?: string) {\n return (percentage: number) => {\n if (spinner && spinnerText) {\n spinner.text = `${spinnerText} ${dim(\n `(${Math.round(percentage * 100)}%)`,\n )}`;\n }\n };\n}\n\n/**\n * Get the targets from the `.browserslistrc` file.\n *\n * @returns The browser targets as an array of strings.\n */\nexport async function getBrowserslistTargets() {\n const contents = await fs.readFile(BROWSERSLIST_FILE, 'utf8');\n return contents\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.startsWith('#'));\n}\n\n/**\n * Get a singular or plural string based on the given count. This is useful for\n * generating messages like \"1 error\" or \"2 errors\". By default, the plural\n * string is the singular string with an \"s\" appended to it.\n *\n * This assumes that the text is in English, and likely won't work for some\n * other languages.\n *\n * @param count - The count.\n * @param singular - The singular string.\n * @param plural - The plural string.\n * @returns The singular or plural string.\n * @example\n * ```typescript\n * pluralize(1, 'error'); // => 'error'\n * pluralize(2, 'error'); // => 'errors'\n * pluralize(1, 'error', 'problem'); // => 'error'\n * pluralize(2, 'error', 'problems'); // => 'problems'\n * ```\n */\nexport function pluralize(\n count: number,\n singular: string,\n plural = `${singular}s`,\n) {\n return count === 1 ? singular : plural;\n}\n\n/**\n * Get an object that can be used as fallback config for Webpack's\n * `fallback` config.\n *\n * @param polyfills - The polyfill object from the snap config.\n * @returns The webpack fallback config.\n */\nexport function getFallbacks(polyfills: ProcessedWebpackConfig['polyfills']): {\n [index: string]: string | false;\n} {\n if (polyfills === true) {\n return Object.fromEntries(\n builtinModules.map((name) => [\n name,\n WEBPACK_FALLBACKS[name as keyof typeof WEBPACK_FALLBACKS] ?? false,\n ]),\n );\n }\n\n if (polyfills === false) {\n return Object.fromEntries(builtinModules.map((name) => [name, false]));\n }\n\n return Object.fromEntries(\n builtinModules.map((name) => [\n name,\n polyfills[name as keyof ProcessedWebpackConfig['polyfills']]\n ? WEBPACK_FALLBACKS[name as keyof typeof WEBPACK_FALLBACKS]\n : false,\n ]),\n );\n}\n\n/**\n * Get an object that can be used as environment variables for Webpack's\n * `DefinePlugin`.\n *\n * @param environment - The environment object from the Snap config.\n * @param defaults - The default environment variables.\n * @returns The Webpack environment variables.\n */\nexport function getEnvironmentVariables(\n environment: Record<string, unknown>,\n defaults = {\n NODE_DEBUG: 'false',\n NODE_ENV: 'production',\n DEBUG: 'false',\n },\n) {\n return Object.fromEntries(\n Object.entries({\n ...defaults,\n ...environment,\n }).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),\n );\n}\n\n/**\n * Format the given line to fit within the terminal width.\n *\n * @param line - The line to format.\n * @param indent - The indentation to use.\n * @param initialIndent - The initial indentation to use, i.e., the indentation\n * for the first line.\n * @returns The formatted line.\n */\nfunction formatLine(line: string, indent: number, initialIndent: number) {\n const terminalWidth = process.stdout.columns;\n if (!terminalWidth) {\n return `${' '.repeat(initialIndent)}${line}`;\n }\n\n return line.split(' ').reduce(\n ({ formattedText, currentLineLength }, word, index) => {\n // `chalk` adds ANSI escape codes to the text, which are not visible\n // characters. We need to strip them to get the visible length of the\n // text.\n const visibleWord = stripAnsi(word);\n\n // Determine if a space should be added before the word.\n const spaceBeforeWord = index > 0 ? ' ' : '';\n const wordLengthWithSpace = visibleWord.length + spaceBeforeWord.length;\n\n // If the word would exceed the terminal width, start a new line.\n if (currentLineLength + wordLengthWithSpace > terminalWidth) {\n return {\n formattedText: `${formattedText}\\n${' '.repeat(indent)}${word}`,\n currentLineLength: indent + visibleWord.length,\n };\n }\n\n // Otherwise, add the word to the current line.\n return {\n formattedText: formattedText + spaceBeforeWord + word,\n currentLineLength: currentLineLength + wordLengthWithSpace,\n };\n },\n {\n formattedText: ' '.repeat(initialIndent),\n currentLineLength: initialIndent,\n },\n ).formattedText;\n}\n\n/**\n * Format the given text to fit within the terminal width.\n *\n * @param text - The text to format.\n * @param indent - The indentation to use.\n * @param initialIndent - The initial indentation to use, i.e., the indentation\n * for the first line.\n * @returns The formatted text.\n */\nexport function formatText(\n text: string,\n indent: number,\n initialIndent = indent,\n) {\n const lines = text.split('\\n');\n\n // Apply formatting to each line separately and then join them.\n return lines\n .map((line, index) => {\n const lineIndent = index === 0 ? initialIndent : indent;\n return formatLine(line, indent, lineIndent);\n })\n .join('\\n');\n}\n\n/**\n * Get an SVG from the given bytes and mime type.\n *\n * @param mimeType - The mime type of the image.\n * @param bytes - The image bytes.\n * @returns The SVG.\n */\nexport function getImageSVG(mimeType: string, bytes: Uint8Array) {\n const dataUrl = `data:${mimeType};base64,${bytesToBase64(bytes)}`;\n return `<svg xmlns=\"http://www.w3.org/2000/svg\"><image href=\"${dataUrl}\" /></svg>`;\n}\n","import browserify from 'browserify';\nimport { Readable } from 'readable-stream';\nimport type { LoaderDefinitionFunction } from 'webpack';\n\nimport { TranspilationModes } from '../../builders';\nimport type { LegacyOptions } from '../../config';\nimport { processDependencies } from '../../utils';\nimport { getBrowserslistTargets } from '../utils';\n\n/**\n * A Browserify loader for Webpack. This exists for backwards compatibility with\n * the legacy configuration format, in order to support the `bundlerCustomizer`\n * function.\n *\n * When this loader is used, the input file will be processed by Browserify, and\n * written to disk by Webpack. Most processing will be handled by Browserify, so\n * there are no benefits like tree-shaking.\n *\n * @param content - The input file contents as a string.\n * @param sourceMap - The source map of the input file.\n */\nconst loader: LoaderDefinitionFunction<LegacyOptions> = async function (\n content,\n sourceMap,\n) {\n const config = this.getOptions();\n\n const { transpilationMode } = config;\n\n const bundler = browserify({\n extensions: ['.js', '.ts'],\n debug: Boolean(sourceMap),\n standalone: '<snap>',\n });\n\n if (transpilationMode !== TranspilationModes.None) {\n const babelifyOptions = processDependencies(config);\n\n // We need to statically import all Browserify transforms, and all Babel\n // presets and plugins, and calling `require` is the sanest way to do that.\n /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n bundler.transform(require('babelify'), {\n global: transpilationMode === TranspilationModes.LocalAndDeps,\n extensions: ['.js', '.ts'],\n presets: [\n require('@babel/preset-typescript'),\n [\n require('@babel/preset-env'),\n {\n targets: {\n browsers: await getBrowserslistTargets(),\n },\n },\n ],\n ],\n plugins: [\n require('@babel/plugin-transform-runtime'),\n require('@babel/plugin-transform-class-properties'),\n require('@babel/plugin-transform-private-methods'),\n require('@babel/plugin-transform-class-static-block'),\n require('@babel/plugin-transform-private-property-in-object'),\n ],\n ...(babelifyOptions as any),\n });\n /* eslint-enable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n }\n\n config.bundlerCustomizer?.(bundler);\n\n // Browserify doesn't accept a string as an entry point, so we need to convert\n // it to a stream.\n const stream = new Readable();\n stream.push(content);\n stream.push(null);\n\n bundler.add(stream, {\n file: this.resourcePath,\n });\n\n return new Promise<Buffer>((resolve, reject) => {\n bundler.bundle((bundleError, buffer: Buffer) => {\n if (bundleError) {\n reject(bundleError);\n return;\n }\n\n // Browserify inlines the source map, so we just pass the output buffer back\n // to Webpack.\n resolve(buffer);\n });\n });\n};\n\nexport default loader;\n"]}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-R77RJHC5.mjs";
|
|
10
10
|
|
|
11
11
|
// src/webpack/utils.ts
|
|
12
|
+
import { bytesToBase64 } from "@metamask/utils";
|
|
12
13
|
import { dim } from "chalk";
|
|
13
14
|
import { promises as fs } from "fs";
|
|
14
15
|
import { builtinModules } from "module";
|
|
@@ -270,6 +271,10 @@ function formatText(text, indent, initialIndent = indent) {
|
|
|
270
271
|
return formatLine(line, indent, lineIndent);
|
|
271
272
|
}).join("\n");
|
|
272
273
|
}
|
|
274
|
+
function getImageSVG(mimeType, bytes) {
|
|
275
|
+
const dataUrl = `data:${mimeType};base64,${bytesToBase64(bytes)}`;
|
|
276
|
+
return `<svg xmlns="http://www.w3.org/2000/svg"><image href="${dataUrl}" /></svg>`;
|
|
277
|
+
}
|
|
273
278
|
|
|
274
279
|
export {
|
|
275
280
|
BROWSERSLIST_FILE,
|
|
@@ -282,6 +287,7 @@ export {
|
|
|
282
287
|
getFallbacks,
|
|
283
288
|
getEnvironmentVariables,
|
|
284
289
|
formatText,
|
|
290
|
+
getImageSVG,
|
|
285
291
|
browserify_default
|
|
286
292
|
};
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
293
|
+
//# sourceMappingURL=chunk-OGGTU5W6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack/utils.ts","../src/webpack/loaders/browserify.ts"],"sourcesContent":["import { bytesToBase64 } from '@metamask/utils';\nimport { dim } from 'chalk';\nimport { promises as fs } from 'fs';\nimport { builtinModules } from 'module';\nimport type { Ora } from 'ora';\nimport { dirname, resolve } from 'path';\nimport stripAnsi from 'strip-ansi';\nimport type { Configuration } from 'webpack';\n\nimport type { ProcessedWebpackConfig } from '../config';\nimport { browserify, getFunctionLoader } from './loaders';\n\nexport const BROWSERSLIST_FILE = resolve(\n dirname(\n // eslint-disable-next-line n/no-extraneous-require\n require.resolve('@metamask/snaps-cli/package.json'),\n ),\n '.browserslistrc',\n);\n\nexport const WEBPACK_FALLBACKS = {\n assert: require.resolve('assert/'),\n buffer: require.resolve('buffer/'),\n console: require.resolve('console-browserify'),\n constants: require.resolve('constants-browserify'),\n crypto: require.resolve('crypto-browserify'),\n domain: require.resolve('domain-browser'),\n events: require.resolve('events/'),\n http: require.resolve('stream-http'),\n https: require.resolve('https-browserify'),\n os: require.resolve('os-browserify/browser'),\n path: require.resolve('path-browserify'),\n punycode: require.resolve('punycode/'),\n process: require.resolve('process/browser'),\n querystring: require.resolve('querystring-es3'),\n stream: require.resolve('stream-browserify'),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: require.resolve('readable-stream/lib/_stream_duplex'),\n _stream_passthrough: require.resolve(\n 'readable-stream/lib/_stream_passthrough',\n ),\n _stream_readable: require.resolve('readable-stream/lib/_stream_readable'),\n _stream_transform: require.resolve('readable-stream/lib/_stream_transform'),\n _stream_writable: require.resolve('readable-stream/lib/_stream_writable'),\n string_decoder: require.resolve('string_decoder/'),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: require.resolve('util/'),\n timers: require.resolve('timers-browserify'),\n tty: require.resolve('tty-browserify'),\n url: require.resolve('url/'),\n util: require.resolve('util/'),\n vm: require.resolve('vm-browserify'),\n zlib: require.resolve('browserify-zlib'),\n};\n\n/**\n * Get the default loader for JavaScript and TypeScript files, based on the\n * config object.\n *\n * - If the `legacy` option is set, we use the custom `browserify` loader. This\n * uses the legacy Browserify config to transpile the code.\n * - Otherwise, we use the `swc-loader`. This is a Webpack loader that uses the\n * `SWC` compiler, which is a much faster alternative to Babel and TypeScript's\n * own compiler.\n *\n * @param config - The processed snap Webpack config.\n * @param config.legacy - The legacy config object, if any.\n * @param config.sourceMap - Whether to generate source maps.\n * @see https://swc.rs/docs/usage/swc-loader\n * @returns The default loader.\n */\nexport async function getDefaultLoader({\n legacy,\n sourceMap,\n}: ProcessedWebpackConfig) {\n if (legacy) {\n /**\n * If the snap uses the legacy config, we use the custom `browserify`\n * loader. This uses the legacy Browserify config to transpile the code.\n * This is necessary for backwards compatibility with the\n * `bundlerCustomizer` function.\n */\n return getFunctionLoader(browserify, legacy);\n }\n\n const targets = await getBrowserslistTargets();\n return {\n /**\n * We use the `swc-loader` to transpile TypeScript and JavaScript files.\n * This is a Webpack loader that uses the `SWC` compiler, which is a much\n * faster alternative to Babel and TypeScript's own compiler.\n */\n loader: require.resolve('swc-loader'),\n\n /**\n * The options for the `swc-loader`. These can be overridden in the\n * `.swcrc` file.\n *\n * @see https://swc.rs/docs/configuration/swcrc\n */\n options: {\n sync: false,\n\n /**\n * This tells SWC to generate source maps. We set it to the\n * `sourceMap` value from the config object.\n *\n * This must be enabled if source maps are enabled in the config.\n */\n sourceMaps: Boolean(getDevTool(sourceMap)),\n\n jsc: {\n parser: {\n /**\n * This tells the parser to parse TypeScript files. If you\n * don't need to support TypeScript, you can set this to\n * `ecmascript` instead, but there's no harm in leaving it\n * as `typescript`.\n *\n * @see https://swc.rs/docs/configuration/compilation#jscparser\n */\n syntax: 'typescript',\n },\n },\n\n /**\n * The module configuration. This tells SWC how to output the\n * transpiled code.\n *\n * @see https://swc.rs/docs/configuration/modules\n */\n module: {\n /**\n * This tells SWC to output ES6 modules. This will allow Webpack to\n * optimize the output code better. Snaps don't support ES6 however, so\n * the output code will be transpiled to CommonJS by Webpack later in\n * the build process.\n *\n * @see https://swc.rs/docs/configuration/modules#es6\n */\n type: 'es6',\n },\n\n env: {\n targets: targets.join(', '),\n },\n },\n };\n}\n\n/**\n * Get the Webpack devtool configuration based on the given snap config.\n *\n * - If `sourceMap` is `inline`, return `inline-source-map`.\n * - If `sourceMap` is `true`, return `source-map`.\n * - Otherwise, return `false`.\n *\n * @param sourceMap - The `sourceMap` value from the snap config.\n * @returns The Webpack devtool configuration.\n */\nexport function getDevTool(\n sourceMap: ProcessedWebpackConfig['sourceMap'],\n): Configuration['devtool'] {\n if (sourceMap === 'inline') {\n return 'inline-source-map';\n }\n\n if (sourceMap === true) {\n return 'source-map';\n }\n\n return false;\n}\n\n/**\n * Get a function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n *\n * @param spinner - The spinner to update.\n * @param spinnerText - The initial spinner text. This will be prepended to the\n * percentage.\n * @returns A function that can be used as handler function for Webpack's\n * `ProgressPlugin`.\n */\n// Note: This is extracted for testing purposes.\nexport function getProgressHandler(spinner?: Ora, spinnerText?: string) {\n return (percentage: number) => {\n if (spinner && spinnerText) {\n spinner.text = `${spinnerText} ${dim(\n `(${Math.round(percentage * 100)}%)`,\n )}`;\n }\n };\n}\n\n/**\n * Get the targets from the `.browserslistrc` file.\n *\n * @returns The browser targets as an array of strings.\n */\nexport async function getBrowserslistTargets() {\n const contents = await fs.readFile(BROWSERSLIST_FILE, 'utf8');\n return contents\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.startsWith('#'));\n}\n\n/**\n * Get a singular or plural string based on the given count. This is useful for\n * generating messages like \"1 error\" or \"2 errors\". By default, the plural\n * string is the singular string with an \"s\" appended to it.\n *\n * This assumes that the text is in English, and likely won't work for some\n * other languages.\n *\n * @param count - The count.\n * @param singular - The singular string.\n * @param plural - The plural string.\n * @returns The singular or plural string.\n * @example\n * ```typescript\n * pluralize(1, 'error'); // => 'error'\n * pluralize(2, 'error'); // => 'errors'\n * pluralize(1, 'error', 'problem'); // => 'error'\n * pluralize(2, 'error', 'problems'); // => 'problems'\n * ```\n */\nexport function pluralize(\n count: number,\n singular: string,\n plural = `${singular}s`,\n) {\n return count === 1 ? singular : plural;\n}\n\n/**\n * Get an object that can be used as fallback config for Webpack's\n * `fallback` config.\n *\n * @param polyfills - The polyfill object from the snap config.\n * @returns The webpack fallback config.\n */\nexport function getFallbacks(polyfills: ProcessedWebpackConfig['polyfills']): {\n [index: string]: string | false;\n} {\n if (polyfills === true) {\n return Object.fromEntries(\n builtinModules.map((name) => [\n name,\n WEBPACK_FALLBACKS[name as keyof typeof WEBPACK_FALLBACKS] ?? false,\n ]),\n );\n }\n\n if (polyfills === false) {\n return Object.fromEntries(builtinModules.map((name) => [name, false]));\n }\n\n return Object.fromEntries(\n builtinModules.map((name) => [\n name,\n polyfills[name as keyof ProcessedWebpackConfig['polyfills']]\n ? WEBPACK_FALLBACKS[name as keyof typeof WEBPACK_FALLBACKS]\n : false,\n ]),\n );\n}\n\n/**\n * Get an object that can be used as environment variables for Webpack's\n * `DefinePlugin`.\n *\n * @param environment - The environment object from the Snap config.\n * @param defaults - The default environment variables.\n * @returns The Webpack environment variables.\n */\nexport function getEnvironmentVariables(\n environment: Record<string, unknown>,\n defaults = {\n NODE_DEBUG: 'false',\n NODE_ENV: 'production',\n DEBUG: 'false',\n },\n) {\n return Object.fromEntries(\n Object.entries({\n ...defaults,\n ...environment,\n }).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),\n );\n}\n\n/**\n * Format the given line to fit within the terminal width.\n *\n * @param line - The line to format.\n * @param indent - The indentation to use.\n * @param initialIndent - The initial indentation to use, i.e., the indentation\n * for the first line.\n * @returns The formatted line.\n */\nfunction formatLine(line: string, indent: number, initialIndent: number) {\n const terminalWidth = process.stdout.columns;\n if (!terminalWidth) {\n return `${' '.repeat(initialIndent)}${line}`;\n }\n\n return line.split(' ').reduce(\n ({ formattedText, currentLineLength }, word, index) => {\n // `chalk` adds ANSI escape codes to the text, which are not visible\n // characters. We need to strip them to get the visible length of the\n // text.\n const visibleWord = stripAnsi(word);\n\n // Determine if a space should be added before the word.\n const spaceBeforeWord = index > 0 ? ' ' : '';\n const wordLengthWithSpace = visibleWord.length + spaceBeforeWord.length;\n\n // If the word would exceed the terminal width, start a new line.\n if (currentLineLength + wordLengthWithSpace > terminalWidth) {\n return {\n formattedText: `${formattedText}\\n${' '.repeat(indent)}${word}`,\n currentLineLength: indent + visibleWord.length,\n };\n }\n\n // Otherwise, add the word to the current line.\n return {\n formattedText: formattedText + spaceBeforeWord + word,\n currentLineLength: currentLineLength + wordLengthWithSpace,\n };\n },\n {\n formattedText: ' '.repeat(initialIndent),\n currentLineLength: initialIndent,\n },\n ).formattedText;\n}\n\n/**\n * Format the given text to fit within the terminal width.\n *\n * @param text - The text to format.\n * @param indent - The indentation to use.\n * @param initialIndent - The initial indentation to use, i.e., the indentation\n * for the first line.\n * @returns The formatted text.\n */\nexport function formatText(\n text: string,\n indent: number,\n initialIndent = indent,\n) {\n const lines = text.split('\\n');\n\n // Apply formatting to each line separately and then join them.\n return lines\n .map((line, index) => {\n const lineIndent = index === 0 ? initialIndent : indent;\n return formatLine(line, indent, lineIndent);\n })\n .join('\\n');\n}\n\n/**\n * Get an SVG from the given bytes and mime type.\n *\n * @param mimeType - The mime type of the image.\n * @param bytes - The image bytes.\n * @returns The SVG.\n */\nexport function getImageSVG(mimeType: string, bytes: Uint8Array) {\n const dataUrl = `data:${mimeType};base64,${bytesToBase64(bytes)}`;\n return `<svg xmlns=\"http://www.w3.org/2000/svg\"><image href=\"${dataUrl}\" /></svg>`;\n}\n","import browserify from 'browserify';\nimport { Readable } from 'readable-stream';\nimport type { LoaderDefinitionFunction } from 'webpack';\n\nimport { TranspilationModes } from '../../builders';\nimport type { LegacyOptions } from '../../config';\nimport { processDependencies } from '../../utils';\nimport { getBrowserslistTargets } from '../utils';\n\n/**\n * A Browserify loader for Webpack. This exists for backwards compatibility with\n * the legacy configuration format, in order to support the `bundlerCustomizer`\n * function.\n *\n * When this loader is used, the input file will be processed by Browserify, and\n * written to disk by Webpack. Most processing will be handled by Browserify, so\n * there are no benefits like tree-shaking.\n *\n * @param content - The input file contents as a string.\n * @param sourceMap - The source map of the input file.\n */\nconst loader: LoaderDefinitionFunction<LegacyOptions> = async function (\n content,\n sourceMap,\n) {\n const config = this.getOptions();\n\n const { transpilationMode } = config;\n\n const bundler = browserify({\n extensions: ['.js', '.ts'],\n debug: Boolean(sourceMap),\n standalone: '<snap>',\n });\n\n if (transpilationMode !== TranspilationModes.None) {\n const babelifyOptions = processDependencies(config);\n\n // We need to statically import all Browserify transforms, and all Babel\n // presets and plugins, and calling `require` is the sanest way to do that.\n /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n bundler.transform(require('babelify'), {\n global: transpilationMode === TranspilationModes.LocalAndDeps,\n extensions: ['.js', '.ts'],\n presets: [\n require('@babel/preset-typescript'),\n [\n require('@babel/preset-env'),\n {\n targets: {\n browsers: await getBrowserslistTargets(),\n },\n },\n ],\n ],\n plugins: [\n require('@babel/plugin-transform-runtime'),\n require('@babel/plugin-transform-class-properties'),\n require('@babel/plugin-transform-private-methods'),\n require('@babel/plugin-transform-class-static-block'),\n require('@babel/plugin-transform-private-property-in-object'),\n ],\n ...(babelifyOptions as any),\n });\n /* eslint-enable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */\n }\n\n config.bundlerCustomizer?.(bundler);\n\n // Browserify doesn't accept a string as an entry point, so we need to convert\n // it to a stream.\n const stream = new Readable();\n stream.push(content);\n stream.push(null);\n\n bundler.add(stream, {\n file: this.resourcePath,\n });\n\n return new Promise<Buffer>((resolve, reject) => {\n bundler.bundle((bundleError, buffer: Buffer) => {\n if (bundleError) {\n reject(bundleError);\n return;\n }\n\n // Browserify inlines the source map, so we just pass the output buffer back\n // to Webpack.\n resolve(buffer);\n });\n });\n};\n\nexport default loader;\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,WAAW;AACpB,SAAS,YAAY,UAAU;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,SAAS,eAAe;AACjC,OAAO,eAAe;;;ACNtB,OAAO,gBAAgB;AACvB,SAAS,gBAAgB;AAoBzB,IAAM,SAAkD,eACtD,SACA,WACA;AACA,QAAM,SAAS,KAAK,WAAW;AAE/B,QAAM,EAAE,kBAAkB,IAAI;AAE9B,QAAM,UAAU,WAAW;AAAA,IACzB,YAAY,CAAC,OAAO,KAAK;AAAA,IACzB,OAAO,QAAQ,SAAS;AAAA,IACxB,YA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UAC7D,mBAAmB,SAAS,YAAY;AAAA,QAC1C;AAAA,MACF;AAGA,aAAO;AAAA,QACL,eAAe,gBAAgB,kBAAkB;AAAA,QACjD,mBAAmB,oBAAoB;AAAA,MACzC;AAAA,IACF;AAAA,IACA;AAAA,MACE,eAAe,IAAI,OAAO,aAAa;AAAA,MACvC,mBAAmB;AAAA,IACrB;AAAA,EACF,EAAE;AACJ;AAWO,SAAS,WACd,MACA,QACA,gBAAgB,QAChB;AACA,QAAM,QAAQ,KAAK,MAAM,IAAI;AAG7B,SAAO,MACJ,IAAI,CAAC,MAAM,UAAU;AACpB,UAAM,aAAa,UAAU,IAAI,gBAAgB;AACjD,WAAO,WAAW,MAAM,QAAQ,UAAU;AAAA,EAC5C,CAAC,EACA,KAAK,IAAI;AACd;AASO,SAAS,YAAY,UAAkB,OAAmB;AAC/D,QAAM,UAAU,QAAQ,QAAQ,WAAW,cAAc,KAAK,CAAC;AAC/D,SAAO,wDAAwD,OAAO;AACxE;","names":["resolve"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkAKAP22ELjs = require('./chunk-AKAP22EL.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkC46KEPACjs = require('./chunk-C46KEPAC.js');
|
|
@@ -15,25 +15,16 @@ var _chunkTJ2F3J6Xjs = require('./chunk-TJ2F3J6X.js');
|
|
|
15
15
|
var _chunkS7UP2YYFjs = require('./chunk-S7UP2YYF.js');
|
|
16
16
|
|
|
17
17
|
// src/cli.ts
|
|
18
|
+
var _packagejson = require('@metamask/snaps-cli/package.json'); var _packagejson2 = _interopRequireDefault(_packagejson);
|
|
18
19
|
var _semver = require('semver'); var _semver2 = _interopRequireDefault(_semver);
|
|
19
20
|
var _yargs = require('yargs'); var _yargs2 = _interopRequireDefault(_yargs);
|
|
20
21
|
var _helpers = require('yargs/helpers');
|
|
21
|
-
var MINIMUM_NODE_16_VERSION = "16.17.0";
|
|
22
|
-
var MINIMUM_NODE_18_VERSION = "18.6.0";
|
|
23
22
|
function checkNodeVersion(nodeVersion = process.version.slice(1)) {
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
_chunkTJ2F3J6Xjs.error.call(void 0, message);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
if (majorVersion === 16 && _semver2.default.lt(nodeVersion, MINIMUM_NODE_16_VERSION)) {
|
|
31
|
-
_chunkTJ2F3J6Xjs.error.call(void 0, message);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
if (majorVersion === 18 && _semver2.default.lt(nodeVersion, MINIMUM_NODE_18_VERSION)) {
|
|
23
|
+
const versionRange = _packagejson2.default.engines.node;
|
|
24
|
+
const minimumVersion = _semver2.default.minVersion(versionRange).format();
|
|
25
|
+
if (!_semver2.default.satisfies(nodeVersion, versionRange)) {
|
|
35
26
|
_chunkTJ2F3J6Xjs.error.call(void 0,
|
|
36
|
-
`Node version ${nodeVersion} is not supported. Please use Node ${
|
|
27
|
+
`Node version ${nodeVersion} is not supported. Please use Node ${minimumVersion} or later.`
|
|
37
28
|
);
|
|
38
29
|
process.exit(1);
|
|
39
30
|
}
|
|
@@ -48,7 +39,7 @@ async function cli(argv, commands) {
|
|
|
48
39
|
`The snap input file for changes, and serve it on port 8000`
|
|
49
40
|
).example("$0 serve --port 8000", `Serve the snap bundle on port 8000`).command(commands).option("config", _chunkS7UP2YYFjs.builders_default.config).option("verboseErrors", _chunkS7UP2YYFjs.builders_default.verboseErrors).option("suppressWarnings", _chunkS7UP2YYFjs.builders_default.suppressWarnings).strict().middleware(async (args) => {
|
|
50
41
|
args.context = {
|
|
51
|
-
config: await
|
|
42
|
+
config: await _chunkAKAP22ELjs.getConfigByArgv.call(void 0, args)
|
|
52
43
|
};
|
|
53
44
|
_chunkC46KEPACjs.sanitizeInputs.call(void 0, args);
|
|
54
45
|
}, false).demandCommand(1, "You must specify at least one command.").fail((message, failure) => {
|
|
@@ -61,4 +52,4 @@ async function cli(argv, commands) {
|
|
|
61
52
|
|
|
62
53
|
|
|
63
54
|
exports.checkNodeVersion = checkNodeVersion; exports.cli = cli;
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-QXP34HW3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,OAAO,iBAAiB;AAExB,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,SAAS,eAAe;AAYjB,SAAS,iBACd,cAAsB,QAAQ,QAAQ,MAAM,CAAC,GAC7C;AACA,QAAM,eAAe,YAAY,QAAQ;AACzC,QAAM,iBAAkB,OAAO,WAAW,YAAY,EAAa,OAAO;AAE1E,MAAI,CAAC,OAAO,UAAU,aAAa,YAAY,GAAG;AAChD;AAAA,MACE,gBAAgB,WAAW,sCAAsC,cAAc;AAAA,IACjF;AAEA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AASA,eAAsB,IAAI,MAAgB,UAAe;AACvD,mBAAiB;AAEjB,QAAM,MAAM,QAAQ,IAAI,CAAC,EACtB,WAAW,SAAS,EACpB,MAAM,+BAA+B,EAErC,QAAQ,YAAY,8CAA8C,EAClE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,QAAQ,qBAAqB,6CAA6C,EAC1E;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,QAAQ,wBAAwB,oCAAoC,EAEpE,QAAQ,QAAQ,EAEhB,OAAO,UAAU,iBAAS,MAAM,EAChC,OAAO,iBAAiB,iBAAS,aAAa,EAC9C,OAAO,oBAAoB,iBAAS,gBAAgB,EAEpD,OAAO,EAEP,WAAW,OAAO,SAAc;AAE/B,SAAK,UAAU;AAAA,MACb,QAAQ,MAAM,gBAAgB,IAAI;AAAA,IACpC;AAEA,mBAAe,IAAI;AAAA,EACrB,GAAG,KAAK,EAEP,cAAc,GAAG,wCAAwC,EAEzD,KAAK,CAAC,SAAS,YAAY;AAC1B,UAAM,qBAAqB,SAAS,OAAO,CAAC;AAE5C,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC,EAEA,KAAK,EACL,MAAM,QAAQ,GAAG,EACjB,WAAW;AAChB","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport packageJson from '@metamask/snaps-cli/package.json';\nimport type { SemVer } from 'semver';\nimport semver from 'semver';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport builders from './builders';\nimport { getConfigByArgv } from './config';\nimport { error, getYargsErrorMessage, sanitizeInputs } from './utils';\n\n/**\n * Check the Node version. If the Node version is less than the minimum required\n * version, this logs an error and exits the process.\n *\n * @param nodeVersion - The Node version to check.\n */\nexport function checkNodeVersion(\n nodeVersion: string = process.version.slice(1),\n) {\n const versionRange = packageJson.engines.node;\n const minimumVersion = (semver.minVersion(versionRange) as SemVer).format();\n\n if (!semver.satisfies(nodeVersion, versionRange)) {\n error(\n `Node version ${nodeVersion} is not supported. Please use Node ${minimumVersion} or later.`,\n );\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n }\n}\n\n/**\n * The main CLI entry point function. This processes the command line args, and\n * runs the appropriate function.\n *\n * @param argv - The raw command line arguments, i.e., `process.argv`.\n * @param commands - The list of commands to use.\n */\nexport async function cli(argv: string[], commands: any) {\n checkNodeVersion();\n\n await yargs(hideBin(argv))\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 build', `Build './src/index.js' as './dist/bundle.js'`)\n .example(\n '$0 build --config ./snap.config.build.ts',\n `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`,\n )\n .example('$0 manifest --fix', `Check the snap manifest, and fix any errors`)\n .example(\n '$0 watch --port 8000',\n `The snap input file for changes, and serve it on port 8000`,\n )\n .example('$0 serve --port 8000', `Serve the snap bundle on port 8000`)\n\n .command(commands)\n\n .option('config', builders.config)\n .option('verboseErrors', builders.verboseErrors)\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n .middleware(async (args: any) => {\n // eslint-disable-next-line require-atomic-updates\n args.context = {\n config: await getConfigByArgv(args),\n };\n\n sanitizeInputs(args);\n }, false)\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .fail((message, failure) => {\n error(getYargsErrorMessage(message, failure));\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n })\n\n .help()\n .alias('help', 'h')\n .parseAsync();\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZOC4OHGMjs = require('./chunk-ZOC4OHGM.js');
|
|
4
4
|
|
|
5
5
|
// src/commands/build/implementation.ts
|
|
6
6
|
async function build(config, options) {
|
|
7
|
-
const compiler = await
|
|
7
|
+
const compiler = await _chunkZOC4OHGMjs.getCompiler.call(void 0, config, options);
|
|
8
8
|
return await new Promise((resolve, reject) => {
|
|
9
9
|
compiler.run((runError) => {
|
|
10
10
|
if (runError) {
|
|
@@ -25,4 +25,4 @@ async function build(config, options) {
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
exports.build = build;
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-RJ6IKKA2.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZOC4OHGMjs = require('./chunk-ZOC4OHGM.js');
|
|
4
4
|
|
|
5
5
|
// src/commands/watch/implementation.ts
|
|
6
6
|
var _path = require('path');
|
|
7
7
|
async function watch(config, options) {
|
|
8
|
-
const compiler = await
|
|
8
|
+
const compiler = await _chunkZOC4OHGMjs.getCompiler.call(void 0, config, {
|
|
9
9
|
evaluate: config.evaluate,
|
|
10
10
|
watch: true,
|
|
11
11
|
spinner: options?.spinner
|
|
@@ -32,4 +32,4 @@ async function watch(config, options) {
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
exports.watch = watch;
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-RM5FN3N5.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-76IQAFYR.mjs";
|
|
4
4
|
import {
|
|
5
5
|
evaluate
|
|
6
6
|
} from "./chunk-3WWFQLH4.mjs";
|
|
@@ -58,4 +58,4 @@ async function buildHandler(config) {
|
|
|
58
58
|
export {
|
|
59
59
|
buildHandler
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-SM2JEXE6.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfigByArgv
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7P7JW53B.mjs";
|
|
4
4
|
import {
|
|
5
5
|
sanitizeInputs
|
|
6
6
|
} from "./chunk-L72RLBV5.mjs";
|
|
@@ -15,25 +15,16 @@ import {
|
|
|
15
15
|
} from "./chunk-MR44GPM3.mjs";
|
|
16
16
|
|
|
17
17
|
// src/cli.ts
|
|
18
|
+
import packageJson from "@metamask/snaps-cli/package.json";
|
|
18
19
|
import semver from "semver";
|
|
19
20
|
import yargs from "yargs";
|
|
20
21
|
import { hideBin } from "yargs/helpers";
|
|
21
|
-
var MINIMUM_NODE_16_VERSION = "16.17.0";
|
|
22
|
-
var MINIMUM_NODE_18_VERSION = "18.6.0";
|
|
23
22
|
function checkNodeVersion(nodeVersion = process.version.slice(1)) {
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
error(message);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
if (majorVersion === 16 && semver.lt(nodeVersion, MINIMUM_NODE_16_VERSION)) {
|
|
31
|
-
error(message);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
if (majorVersion === 18 && semver.lt(nodeVersion, MINIMUM_NODE_18_VERSION)) {
|
|
23
|
+
const versionRange = packageJson.engines.node;
|
|
24
|
+
const minimumVersion = semver.minVersion(versionRange).format();
|
|
25
|
+
if (!semver.satisfies(nodeVersion, versionRange)) {
|
|
35
26
|
error(
|
|
36
|
-
`Node version ${nodeVersion} is not supported. Please use Node ${
|
|
27
|
+
`Node version ${nodeVersion} is not supported. Please use Node ${minimumVersion} or later.`
|
|
37
28
|
);
|
|
38
29
|
process.exit(1);
|
|
39
30
|
}
|
|
@@ -61,4 +52,4 @@ export {
|
|
|
61
52
|
checkNodeVersion,
|
|
62
53
|
cli
|
|
63
54
|
};
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-SUSC466E.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport packageJson from '@metamask/snaps-cli/package.json';\nimport type { SemVer } from 'semver';\nimport semver from 'semver';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport builders from './builders';\nimport { getConfigByArgv } from './config';\nimport { error, getYargsErrorMessage, sanitizeInputs } from './utils';\n\n/**\n * Check the Node version. If the Node version is less than the minimum required\n * version, this logs an error and exits the process.\n *\n * @param nodeVersion - The Node version to check.\n */\nexport function checkNodeVersion(\n nodeVersion: string = process.version.slice(1),\n) {\n const versionRange = packageJson.engines.node;\n const minimumVersion = (semver.minVersion(versionRange) as SemVer).format();\n\n if (!semver.satisfies(nodeVersion, versionRange)) {\n error(\n `Node version ${nodeVersion} is not supported. Please use Node ${minimumVersion} or later.`,\n );\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n }\n}\n\n/**\n * The main CLI entry point function. This processes the command line args, and\n * runs the appropriate function.\n *\n * @param argv - The raw command line arguments, i.e., `process.argv`.\n * @param commands - The list of commands to use.\n */\nexport async function cli(argv: string[], commands: any) {\n checkNodeVersion();\n\n await yargs(hideBin(argv))\n .scriptName('mm-snap')\n .usage('Usage: $0 <command> [options]')\n\n .example('$0 build', `Build './src/index.js' as './dist/bundle.js'`)\n .example(\n '$0 build --config ./snap.config.build.ts',\n `Build './src/index.js' as './dist/bundle.js' using the config in './snap.config.build.ts'`,\n )\n .example('$0 manifest --fix', `Check the snap manifest, and fix any errors`)\n .example(\n '$0 watch --port 8000',\n `The snap input file for changes, and serve it on port 8000`,\n )\n .example('$0 serve --port 8000', `Serve the snap bundle on port 8000`)\n\n .command(commands)\n\n .option('config', builders.config)\n .option('verboseErrors', builders.verboseErrors)\n .option('suppressWarnings', builders.suppressWarnings)\n\n .strict()\n\n .middleware(async (args: any) => {\n // eslint-disable-next-line require-atomic-updates\n args.context = {\n config: await getConfigByArgv(args),\n };\n\n sanitizeInputs(args);\n }, false)\n\n .demandCommand(1, 'You must specify at least one command.')\n\n .fail((message, failure) => {\n error(getYargsErrorMessage(message, failure));\n // eslint-disable-next-line n/no-process-exit\n process.exit(1);\n })\n\n .help()\n .alias('help', 'h')\n .parseAsync();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA,OAAO,iBAAiB;AAExB,OAAO,YAAY;AACnB,OAAO,WAAW;AAClB,SAAS,eAAe;AAYjB,SAAS,iBACd,cAAsB,QAAQ,QAAQ,MAAM,CAAC,GAC7C;AACA,QAAM,eAAe,YAAY,QAAQ;AACzC,QAAM,iBAAkB,OAAO,WAAW,YAAY,EAAa,OAAO;AAE1E,MAAI,CAAC,OAAO,UAAU,aAAa,YAAY,GAAG;AAChD;AAAA,MACE,gBAAgB,WAAW,sCAAsC,cAAc;AAAA,IACjF;AAEA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AASA,eAAsB,IAAI,MAAgB,UAAe;AACvD,mBAAiB;AAEjB,QAAM,MAAM,QAAQ,IAAI,CAAC,EACtB,WAAW,SAAS,EACpB,MAAM,+BAA+B,EAErC,QAAQ,YAAY,8CAA8C,EAClE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,QAAQ,qBAAqB,6CAA6C,EAC1E;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,QAAQ,wBAAwB,oCAAoC,EAEpE,QAAQ,QAAQ,EAEhB,OAAO,UAAU,iBAAS,MAAM,EAChC,OAAO,iBAAiB,iBAAS,aAAa,EAC9C,OAAO,oBAAoB,iBAAS,gBAAgB,EAEpD,OAAO,EAEP,WAAW,OAAO,SAAc;AAE/B,SAAK,UAAU;AAAA,MACb,QAAQ,MAAM,gBAAgB,IAAI;AAAA,IACpC;AAEA,mBAAe,IAAI;AAAA,EACrB,GAAG,KAAK,EAEP,cAAc,GAAG,wCAAwC,EAEzD,KAAK,CAAC,SAAS,YAAY;AAC1B,UAAM,qBAAqB,SAAS,OAAO,CAAC;AAE5C,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC,EAEA,KAAK,EACL,MAAM,QAAQ,GAAG,EACjB,WAAW;AAChB;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
watch_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IO6WNNPF.mjs";
|
|
4
4
|
import {
|
|
5
5
|
build_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AO724LXX.mjs";
|
|
7
7
|
import {
|
|
8
8
|
manifest_default
|
|
9
9
|
} from "./chunk-G3COWLG5.mjs";
|
|
@@ -27,4 +27,4 @@ var commands_default = commands;
|
|
|
27
27
|
export {
|
|
28
28
|
commands_default
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-T4CLBV7F.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkC2OMV3H5js = require('./chunk-C2OMV3H5.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS7UP2YYFjs = require('./chunk-S7UP2YYF.js');
|
|
@@ -12,11 +12,11 @@ var command = {
|
|
|
12
12
|
builder: (yarg) => {
|
|
13
13
|
yarg.option("dist", _chunkS7UP2YYFjs.builders_default.dist).option("eval", _chunkS7UP2YYFjs.builders_default.eval).option("manifest", _chunkS7UP2YYFjs.builders_default.manifest).option("outfileName", _chunkS7UP2YYFjs.builders_default.outfileName).option("sourceMaps", _chunkS7UP2YYFjs.builders_default.sourceMaps).option("src", _chunkS7UP2YYFjs.builders_default.src).option("stripComments", _chunkS7UP2YYFjs.builders_default.stripComments).option("transpilationMode", _chunkS7UP2YYFjs.builders_default.transpilationMode).option("depsToTranspile", _chunkS7UP2YYFjs.builders_default.depsToTranspile).option("writeManifest", _chunkS7UP2YYFjs.builders_default.writeManifest).implies("writeManifest", "manifest").implies("depsToTranspile", "transpilationMode");
|
|
14
14
|
},
|
|
15
|
-
handler: async (argv) =>
|
|
15
|
+
handler: async (argv) => _chunkC2OMV3H5js.buildHandler.call(void 0, argv.context.config)
|
|
16
16
|
};
|
|
17
17
|
var build_default = command;
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
exports.build_default = build_default;
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-V4UPOVEH.js.map
|
|
@@ -3,15 +3,16 @@ import {
|
|
|
3
3
|
SnapsBundleWarningsPlugin,
|
|
4
4
|
SnapsStatsPlugin,
|
|
5
5
|
SnapsWatchPlugin
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JBSWMUCQ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
BROWSERSLIST_FILE,
|
|
9
9
|
getDefaultLoader,
|
|
10
10
|
getDevTool,
|
|
11
11
|
getEnvironmentVariables,
|
|
12
12
|
getFallbacks,
|
|
13
|
+
getImageSVG,
|
|
13
14
|
getProgressHandler
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-OGGTU5W6.mjs";
|
|
15
16
|
import {
|
|
16
17
|
getFunctionLoader
|
|
17
18
|
} from "./chunk-AZMQTZXZ.mjs";
|
|
@@ -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: 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: getImageSVG.bind(null, "image/jpeg")
|
|
182
|
+
}
|
|
183
|
+
},
|
|
155
184
|
config.experimental.wasm && {
|
|
156
185
|
test: /\.wasm$/u,
|
|
157
186
|
use: getFunctionLoader(wasm_default, {})
|
|
@@ -299,4 +328,4 @@ async function getDefaultConfiguration(config, options = {
|
|
|
299
328
|
export {
|
|
300
329
|
getDefaultConfiguration
|
|
301
330
|
};
|
|
302
|
-
//# sourceMappingURL=chunk-
|
|
331
|
+
//# sourceMappingURL=chunk-VIQIUSXW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webpack/config.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,wBAAwB;AAE/B,SAAS,eAAe;AACxB,OAAO,kBAAkB;AAEzB,SAAS,cAAc,gBAAgB,qBAAqB;AAwD5D,eAAsB,wBACpB,QACA,UAA0B;AAAA,EACxB,UAAU,OAAO;AACnB,GACwB;AACxB,QAAM,cAAc,QAAQ,SAAS;AACrC,QAAM,kBACJ,OAAO,MAAM,YACb,IAAI,qBAAqB,OAAO,MAAM,UAAU,QAAQ,OAAO;AAEjE,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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 +13,4 @@ async function getCompiler(config, options) {
|
|
|
13
13
|
export {
|
|
14
14
|
getCompiler
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-WUC7DUXN.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRM5FN3N5js = require('./chunk-RM5FN3N5.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkYGEAZQSCjs = require('./chunk-YGEAZQSC.js');
|
|
@@ -40,7 +40,7 @@ var steps = [
|
|
|
40
40
|
{
|
|
41
41
|
name: "Building the snap bundle.",
|
|
42
42
|
task: async ({ config, spinner }) => {
|
|
43
|
-
await
|
|
43
|
+
await _chunkRM5FN3N5js.watch.call(void 0, config, { spinner });
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
];
|
|
@@ -51,4 +51,4 @@ async function watchHandler(config, options) {
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
exports.watchHandler = watchHandler;
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-XQGKSVFJ.js.map
|