@metamask/snaps-cli 0.38.1-flask.1 → 1.0.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 +377 -19
- package/README.md +67 -542
- package/dist/builders.d.ts +27 -0
- package/dist/{esm/builders.js → builders.js} +51 -48
- package/dist/builders.js.map +1 -0
- package/dist/{types/cli.d.ts → cli.d.ts} +1 -1
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -0
- package/dist/cmds/build/buildHandler.d.ts +13 -0
- package/dist/cmds/build/buildHandler.js +37 -0
- package/dist/cmds/build/buildHandler.js.map +1 -0
- package/dist/cmds/build/bundle.d.ts +15 -0
- package/dist/cmds/build/bundle.js +80 -0
- package/dist/cmds/build/bundle.js.map +1 -0
- package/dist/{types/commands/serve → cmds/build}/index.d.ts +4 -4
- package/dist/cmds/build/index.js +29 -0
- package/dist/cmds/build/index.js.map +1 -0
- package/dist/cmds/build/utils.d.ts +56 -0
- package/dist/cmds/build/utils.js +100 -0
- package/dist/cmds/build/utils.js.map +1 -0
- package/dist/cmds/eval/evalHandler.d.ts +9 -0
- package/dist/cmds/eval/evalHandler.js +25 -0
- package/dist/cmds/eval/evalHandler.js.map +1 -0
- package/dist/cmds/eval/index.d.ts +9 -0
- package/dist/cmds/eval/index.js +15 -0
- package/dist/cmds/eval/index.js.map +1 -0
- package/dist/cmds/index.js +14 -0
- package/dist/cmds/index.js.map +1 -0
- package/dist/cmds/init/index.d.ts +9 -0
- package/dist/cmds/init/index.js +34 -0
- package/dist/cmds/init/index.js.map +1 -0
- package/dist/cmds/init/initHandler.d.ts +26 -0
- package/dist/cmds/init/initHandler.js +69 -0
- package/dist/cmds/init/initHandler.js.map +1 -0
- package/dist/cmds/init/initUtils.d.ts +39 -0
- package/dist/cmds/init/initUtils.js +122 -0
- package/dist/cmds/init/initUtils.js.map +1 -0
- package/dist/cmds/manifest/index.d.ts +9 -0
- package/dist/cmds/manifest/index.js +24 -0
- package/dist/cmds/manifest/index.js.map +1 -0
- package/dist/cmds/manifest/manifestHandler.d.ts +10 -0
- package/dist/cmds/manifest/manifestHandler.js +50 -0
- package/dist/cmds/manifest/manifestHandler.js.map +1 -0
- package/dist/cmds/serve/index.d.ts +9 -0
- package/dist/cmds/serve/index.js +15 -0
- package/dist/cmds/serve/index.js.map +1 -0
- package/dist/cmds/serve/serveHandler.d.ts +10 -0
- package/dist/cmds/serve/serveHandler.js +59 -0
- package/dist/cmds/serve/serveHandler.js.map +1 -0
- package/dist/cmds/serve/serveUtils.d.ts +22 -0
- package/dist/cmds/serve/serveUtils.js +39 -0
- package/dist/cmds/serve/serveUtils.js.map +1 -0
- package/dist/cmds/watch/index.d.ts +9 -0
- package/dist/cmds/watch/index.js +32 -0
- package/dist/cmds/watch/index.js.map +1 -0
- package/dist/cmds/watch/watchHandler.d.ts +14 -0
- package/dist/cmds/watch/watchHandler.js +100 -0
- package/dist/cmds/watch/watchHandler.js.map +1 -0
- package/dist/main.js +15 -0
- package/dist/main.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/misc.d.ts +53 -0
- package/dist/utils/misc.js +156 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/snap-config.d.ts +48 -0
- package/dist/utils/snap-config.js +117 -0
- package/dist/utils/snap-config.js.map +1 -0
- package/package.json +35 -54
- package/.browserslistrc +0 -3
- package/dist/cjs/builders.js +0 -148
- package/dist/cjs/builders.js.map +0 -1
- package/dist/cjs/cli.js +0 -35
- package/dist/cjs/cli.js.map +0 -1
- package/dist/cjs/commands/build/build.js +0 -54
- package/dist/cjs/commands/build/build.js.map +0 -1
- package/dist/cjs/commands/build/implementation.js +0 -31
- package/dist/cjs/commands/build/implementation.js.map +0 -1
- package/dist/cjs/commands/build/index.js +0 -45
- package/dist/cjs/commands/build/index.js.map +0 -1
- package/dist/cjs/commands/eval/eval.js +0 -57
- package/dist/cjs/commands/eval/eval.js.map +0 -1
- package/dist/cjs/commands/eval/implementation.js +0 -27
- package/dist/cjs/commands/eval/implementation.js.map +0 -1
- package/dist/cjs/commands/eval/index.js +0 -50
- package/dist/cjs/commands/eval/index.js.map +0 -1
- package/dist/cjs/commands/index.js +0 -30
- package/dist/cjs/commands/index.js.map +0 -1
- package/dist/cjs/commands/manifest/implementation.js +0 -34
- package/dist/cjs/commands/manifest/implementation.js.map +0 -1
- package/dist/cjs/commands/manifest/index.js +0 -50
- package/dist/cjs/commands/manifest/index.js.map +0 -1
- package/dist/cjs/commands/manifest/manifest.js +0 -55
- package/dist/cjs/commands/manifest/manifest.js.map +0 -1
- package/dist/cjs/commands/serve/index.js +0 -33
- package/dist/cjs/commands/serve/index.js.map +0 -1
- package/dist/cjs/commands/serve/serve.js +0 -21
- package/dist/cjs/commands/serve/serve.js.map +0 -1
- package/dist/cjs/commands/watch/implementation.js +0 -35
- package/dist/cjs/commands/watch/implementation.js.map +0 -1
- package/dist/cjs/commands/watch/index.js +0 -47
- package/dist/cjs/commands/watch/index.js.map +0 -1
- package/dist/cjs/commands/watch/watch.js +0 -51
- package/dist/cjs/commands/watch/watch.js.map +0 -1
- package/dist/cjs/config.js +0 -290
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/errors.js +0 -37
- package/dist/cjs/errors.js.map +0 -1
- package/dist/cjs/index.js +0 -77
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/main.js +0 -19
- package/dist/cjs/main.js.map +0 -1
- package/dist/cjs/utils/cli.js +0 -61
- package/dist/cjs/utils/cli.js.map +0 -1
- package/dist/cjs/utils/errors.js +0 -42
- package/dist/cjs/utils/errors.js.map +0 -1
- package/dist/cjs/utils/index.js +0 -25
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/legacy.js +0 -48
- package/dist/cjs/utils/legacy.js.map +0 -1
- package/dist/cjs/utils/logging.js +0 -46
- package/dist/cjs/utils/logging.js.map +0 -1
- package/dist/cjs/utils/path.js +0 -16
- package/dist/cjs/utils/path.js.map +0 -1
- package/dist/cjs/utils/steps.js +0 -52
- package/dist/cjs/utils/steps.js.map +0 -1
- package/dist/cjs/webpack/compiler.js +0 -96
- package/dist/cjs/webpack/compiler.js.map +0 -1
- package/dist/cjs/webpack/config.js +0 -234
- package/dist/cjs/webpack/config.js.map +0 -1
- package/dist/cjs/webpack/index.js +0 -22
- package/dist/cjs/webpack/index.js.map +0 -1
- package/dist/cjs/webpack/loaders/browserify.js +0 -97
- package/dist/cjs/webpack/loaders/browserify.js.map +0 -1
- package/dist/cjs/webpack/loaders/wasm.js +0 -36
- package/dist/cjs/webpack/loaders/wasm.js.map +0 -1
- package/dist/cjs/webpack/plugins.js +0 -340
- package/dist/cjs/webpack/plugins.js.map +0 -1
- package/dist/cjs/webpack/utils.js +0 -133
- package/dist/cjs/webpack/utils.js.map +0 -1
- package/dist/esm/builders.js.map +0 -1
- package/dist/esm/cli.js +0 -26
- package/dist/esm/cli.js.map +0 -1
- package/dist/esm/commands/build/build.js +0 -51
- package/dist/esm/commands/build/build.js.map +0 -1
- package/dist/esm/commands/build/implementation.js +0 -27
- package/dist/esm/commands/build/implementation.js.map +0 -1
- package/dist/esm/commands/build/index.js +0 -17
- package/dist/esm/commands/build/index.js.map +0 -1
- package/dist/esm/commands/eval/eval.js +0 -54
- package/dist/esm/commands/eval/eval.js.map +0 -1
- package/dist/esm/commands/eval/implementation.js +0 -24
- package/dist/esm/commands/eval/implementation.js.map +0 -1
- package/dist/esm/commands/eval/index.js +0 -22
- package/dist/esm/commands/eval/index.js.map +0 -1
- package/dist/esm/commands/index.js +0 -15
- package/dist/esm/commands/index.js.map +0 -1
- package/dist/esm/commands/manifest/implementation.js +0 -33
- package/dist/esm/commands/manifest/implementation.js.map +0 -1
- package/dist/esm/commands/manifest/index.js +0 -22
- package/dist/esm/commands/manifest/index.js.map +0 -1
- package/dist/esm/commands/manifest/manifest.js +0 -52
- package/dist/esm/commands/manifest/manifest.js.map +0 -1
- package/dist/esm/commands/serve/index.js +0 -18
- package/dist/esm/commands/serve/index.js.map +0 -1
- package/dist/esm/commands/serve/serve.js +0 -17
- package/dist/esm/commands/serve/serve.js.map +0 -1
- package/dist/esm/commands/watch/implementation.js +0 -34
- package/dist/esm/commands/watch/implementation.js.map +0 -1
- package/dist/esm/commands/watch/index.js +0 -19
- package/dist/esm/commands/watch/index.js.map +0 -1
- package/dist/esm/commands/watch/watch.js +0 -50
- package/dist/esm/commands/watch/watch.js.map +0 -1
- package/dist/esm/config.js +0 -294
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/errors.js +0 -30
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/main.js +0 -10
- package/dist/esm/main.js.map +0 -1
- package/dist/esm/utils/cli.js +0 -43
- package/dist/esm/utils/cli.js.map +0 -1
- package/dist/esm/utils/errors.js +0 -43
- package/dist/esm/utils/errors.js.map +0 -1
- package/dist/esm/utils/index.js +0 -8
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/legacy.js +0 -47
- package/dist/esm/utils/legacy.js.map +0 -1
- package/dist/esm/utils/logging.js +0 -40
- package/dist/esm/utils/logging.js.map +0 -1
- package/dist/esm/utils/path.js +0 -13
- package/dist/esm/utils/path.js.map +0 -1
- package/dist/esm/utils/steps.js +0 -43
- package/dist/esm/utils/steps.js.map +0 -1
- package/dist/esm/webpack/compiler.js +0 -89
- package/dist/esm/webpack/compiler.js.map +0 -1
- package/dist/esm/webpack/config.js +0 -236
- package/dist/esm/webpack/config.js.map +0 -1
- package/dist/esm/webpack/index.js +0 -5
- package/dist/esm/webpack/index.js.map +0 -1
- package/dist/esm/webpack/loaders/browserify.js +0 -82
- package/dist/esm/webpack/loaders/browserify.js.map +0 -1
- package/dist/esm/webpack/loaders/wasm.js +0 -26
- package/dist/esm/webpack/loaders/wasm.js.map +0 -1
- package/dist/esm/webpack/plugins.js +0 -343
- package/dist/esm/webpack/plugins.js.map +0 -1
- package/dist/esm/webpack/utils.js +0 -160
- package/dist/esm/webpack/utils.js.map +0 -1
- package/dist/types/__fixtures__/configs/cjs.d.ts +0 -1
- package/dist/types/__fixtures__/configs/esm.d.ts +0 -3
- package/dist/types/__fixtures__/configs/invalid.d.ts +0 -3
- package/dist/types/__fixtures__/configs/javascript/snap.config.d.ts +0 -0
- package/dist/types/__fixtures__/configs/typescript/snap.config.d.ts +0 -3
- package/dist/types/builders.d.ts +0 -8
- package/dist/types/commands/build/build.d.ts +0 -10
- package/dist/types/commands/build/implementation.d.ts +0 -10
- package/dist/types/commands/build/index.d.ts +0 -10
- package/dist/types/commands/eval/__test__/browserify/bad/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/browserify/good/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/webpack/bad/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/webpack/good/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/__test__/webpack/snap.config.d.ts +0 -3
- package/dist/types/commands/eval/eval.d.ts +0 -14
- package/dist/types/commands/eval/implementation.d.ts +0 -9
- package/dist/types/commands/eval/index.d.ts +0 -10
- package/dist/types/commands/manifest/implementation.d.ts +0 -12
- package/dist/types/commands/manifest/index.d.ts +0 -10
- package/dist/types/commands/manifest/manifest.d.ts +0 -14
- package/dist/types/commands/serve/serve.d.ts +0 -16
- package/dist/types/commands/watch/implementation.d.ts +0 -14
- package/dist/types/commands/watch/index.d.ts +0 -10
- package/dist/types/commands/watch/watch.d.ts +0 -19
- package/dist/types/config.d.ts +0 -626
- package/dist/types/errors.d.ts +0 -25
- package/dist/types/index.d.ts +0 -5
- package/dist/types/utils/cli.d.ts +0 -17
- package/dist/types/utils/errors.d.ts +0 -23
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/legacy.d.ts +0 -27
- package/dist/types/utils/logging.d.ts +0 -22
- package/dist/types/utils/path.d.ts +0 -9
- package/dist/types/utils/steps.d.ts +0 -17
- package/dist/types/webpack/compiler.d.ts +0 -29
- package/dist/types/webpack/config.d.ts +0 -37
- package/dist/types/webpack/index.d.ts +0 -3
- package/dist/types/webpack/loaders/browserify.d.ts +0 -16
- package/dist/types/webpack/loaders/wasm.d.ts +0 -20
- package/dist/types/webpack/plugins.d.ts +0 -147
- package/dist/types/webpack/utils.d.ts +0 -156
- /package/dist/{types/commands → cmds}/index.d.ts +0 -0
- /package/dist/{types/main.d.ts → main.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/cli.ts"],"sourcesContent":["import path from 'path';\n\nexport const CONFIG_FILE = 'snap.config.js';\nexport const TS_CONFIG_FILE = 'snap.config.ts';\n\n// CLI arguments whose values are file paths.\nconst pathArguments = new Set([\n 'src',\n 's',\n 'dist',\n 'd',\n 'bundle',\n 'b',\n 'root',\n 'r',\n]);\n\n/**\n * Sanitizes inputs. Currently normalizes \"./\" paths to \".\".\n * Yargs handles other path normalization as specified in builders.\n *\n * @param argv - Arguments as an object generated by yargs.\n */\nexport function sanitizeInputs(argv: Record<string, unknown>) {\n Object.keys(argv).forEach((key) => {\n if (typeof argv[key] === 'string') {\n // Node's path.normalize() does not do this\n if (argv[key] === './') {\n argv[key] = '.';\n }\n\n if (pathArguments.has(key)) {\n argv[key] = path.normalize(argv[key] as string);\n }\n }\n });\n}\n\n/**\n * Trims leading and trailing periods \".\" and forward slashes \"/\" from the\n * given path string.\n *\n * @param pathString - The path string to trim.\n * @returns The trimmed path string.\n */\nexport function trimPathString(pathString: string): string {\n return pathString.replace(/^[./]+|[./]+$/gu, '');\n}\n"],"names":["path","CONFIG_FILE","TS_CONFIG_FILE","pathArguments","Set","sanitizeInputs","argv","Object","keys","forEach","key","has","normalize","trimPathString","pathString","replace"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAExB,OAAO,MAAMC,cAAc,iBAAiB;AAC5C,OAAO,MAAMC,iBAAiB,iBAAiB;AAE/C,6CAA6C;AAC7C,MAAMC,gBAAgB,IAAIC,IAAI;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;;CAKC,GACD,OAAO,SAASC,eAAeC,IAA6B;IAC1DC,OAAOC,IAAI,CAACF,MAAMG,OAAO,CAAC,CAACC;QACzB,IAAI,OAAOJ,IAAI,CAACI,IAAI,KAAK,UAAU;YACjC,2CAA2C;YAC3C,IAAIJ,IAAI,CAACI,IAAI,KAAK,MAAM;gBACtBJ,IAAI,CAACI,IAAI,GAAG;YACd;YAEA,IAAIP,cAAcQ,GAAG,CAACD,MAAM;gBAC1BJ,IAAI,CAACI,IAAI,GAAGV,KAAKY,SAAS,CAACN,IAAI,CAACI,IAAI;YACtC;QACF;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,eAAeC,UAAkB;IAC/C,OAAOA,WAAWC,OAAO,CAAC,mBAAmB;AAC/C"}
|
package/dist/esm/utils/errors.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { hasProperty, isObject } from '@metamask/utils';
|
|
2
|
-
import { CLIError } from '../errors';
|
|
3
|
-
/**
|
|
4
|
-
* Get the error message from an error in a Yargs `fail` handler. If the error
|
|
5
|
-
* is not `undefined`, {@link getErrorMessage} is used to get the error message.
|
|
6
|
-
* Otherwise, the given message is returned.
|
|
7
|
-
*
|
|
8
|
-
* @param message - The error message.
|
|
9
|
-
* @param error - The error object. This may be `undefined`.
|
|
10
|
-
* @returns The error message.
|
|
11
|
-
*/ export function getYargsErrorMessage(message, error) {
|
|
12
|
-
if (error) {
|
|
13
|
-
if (error instanceof CLIError) {
|
|
14
|
-
return error.message;
|
|
15
|
-
}
|
|
16
|
-
return getErrorMessage(error);
|
|
17
|
-
}
|
|
18
|
-
return message;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get the error message from an error.
|
|
22
|
-
*
|
|
23
|
-
* - If the error is an object with a `stack` property, the `stack` property is
|
|
24
|
-
* returned.
|
|
25
|
-
* - If the error is an object with a `message` property, the `message`
|
|
26
|
-
* property is returned.
|
|
27
|
-
* - Otherwise, the error is converted to a string and returned.
|
|
28
|
-
*
|
|
29
|
-
* @param error - The error to get the message from.
|
|
30
|
-
* @returns The error message.
|
|
31
|
-
*/ export function getErrorMessage(error) {
|
|
32
|
-
if (isObject(error)) {
|
|
33
|
-
if (hasProperty(error, 'stack') && typeof error.stack === 'string') {
|
|
34
|
-
return error.stack;
|
|
35
|
-
}
|
|
36
|
-
if (hasProperty(error, 'message') && typeof error.message === 'string') {
|
|
37
|
-
return error.message;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return String(error);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/errors.ts"],"sourcesContent":["import { hasProperty, isObject } from '@metamask/utils';\n\nimport { CLIError } from '../errors';\n\n/**\n * Get the error message from an error in a Yargs `fail` handler. If the error\n * is not `undefined`, {@link getErrorMessage} is used to get the error message.\n * Otherwise, the given message is returned.\n *\n * @param message - The error message.\n * @param error - The error object. This may be `undefined`.\n * @returns The error message.\n */\nexport function getYargsErrorMessage(message: string, error?: unknown): string {\n if (error) {\n if (error instanceof CLIError) {\n return error.message;\n }\n\n return getErrorMessage(error);\n }\n\n return message;\n}\n\n/**\n * Get the error message from an error.\n *\n * - If the error is an object with a `stack` property, the `stack` property is\n * returned.\n * - If the error is an object with a `message` property, the `message`\n * property is returned.\n * - Otherwise, the error is converted to a string and returned.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n */\nexport function getErrorMessage(error: unknown): string {\n if (isObject(error)) {\n if (hasProperty(error, 'stack') && typeof error.stack === 'string') {\n return error.stack;\n }\n\n if (hasProperty(error, 'message') && typeof error.message === 'string') {\n return error.message;\n }\n }\n\n return String(error);\n}\n"],"names":["hasProperty","isObject","CLIError","getYargsErrorMessage","message","error","getErrorMessage","stack","String"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,kBAAkB;AAExD,SAASC,QAAQ,QAAQ,YAAY;AAErC;;;;;;;;CAQC,GACD,OAAO,SAASC,qBAAqBC,OAAe,EAAEC,KAAe;IACnE,IAAIA,OAAO;QACT,IAAIA,iBAAiBH,UAAU;YAC7B,OAAOG,MAAMD,OAAO;QACtB;QAEA,OAAOE,gBAAgBD;IACzB;IAEA,OAAOD;AACT;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASE,gBAAgBD,KAAc;IAC5C,IAAIJ,SAASI,QAAQ;QACnB,IAAIL,YAAYK,OAAO,YAAY,OAAOA,MAAME,KAAK,KAAK,UAAU;YAClE,OAAOF,MAAME,KAAK;QACpB;QAEA,IAAIP,YAAYK,OAAO,cAAc,OAAOA,MAAMD,OAAO,KAAK,UAAU;YACtE,OAAOC,MAAMD,OAAO;QACtB;IACF;IAEA,OAAOI,OAAOH;AAChB"}
|
package/dist/esm/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export * from './cli';\nexport * from './errors';\nexport * from './legacy';\nexport * from './logging';\nexport * from './path';\nexport * from './steps';\n"],"names":[],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,UAAU"}
|
package/dist/esm/utils/legacy.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { TranspilationModes } from '../builders';
|
|
2
|
-
/**
|
|
3
|
-
* Get the dependencies to transpile, as well as the regular input file.
|
|
4
|
-
*
|
|
5
|
-
* If `transpilationMode` is not set to `localAndDeps`, this will return an
|
|
6
|
-
* empty array.
|
|
7
|
-
*
|
|
8
|
-
* @param config - The config object.
|
|
9
|
-
* @returns An array with regular expressions of dependencies that should be
|
|
10
|
-
* transpiled.
|
|
11
|
-
*/ export function processDependencies(config) {
|
|
12
|
-
const { depsToTranspile, transpilationMode } = config;
|
|
13
|
-
if (transpilationMode === TranspilationModes.LocalAndDeps) {
|
|
14
|
-
const regex = getDependencyRegExp(depsToTranspile);
|
|
15
|
-
if (regex !== null) {
|
|
16
|
-
return [
|
|
17
|
-
regex
|
|
18
|
-
];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Processes a string of space delimited dependencies into one RegExp string.
|
|
25
|
-
*
|
|
26
|
-
* @param dependencies - An array of dependencies to add to the RegExp.
|
|
27
|
-
* @returns A RegExp object.
|
|
28
|
-
*/ export function getDependencyRegExp(dependencies) {
|
|
29
|
-
if (!dependencies || dependencies.includes('.') || !dependencies.length) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const paths = sanitizeDependencyPaths(dependencies);
|
|
33
|
-
return RegExp(`/node_modules/(?!${paths.join('|')})`, 'u');
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Helper function to remove any leading and trailing slashes from dependency
|
|
37
|
-
* list.
|
|
38
|
-
*
|
|
39
|
-
* @param dependencies - An array of dependencies to sanitize.
|
|
40
|
-
* @returns An array of sanitized paths.
|
|
41
|
-
*/ export function sanitizeDependencyPaths(dependencies) {
|
|
42
|
-
return dependencies.map((dependency)=>{
|
|
43
|
-
return dependency.replace(/^[/\\]+/u, '').replace(/[/\\]+$/u, '');
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=legacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/legacy.ts"],"sourcesContent":["import { TranspilationModes } from '../builders';\nimport type { LegacyOptions } from '../config';\n\n/**\n * Get the dependencies to transpile, as well as the regular input file.\n *\n * If `transpilationMode` is not set to `localAndDeps`, this will return an\n * empty array.\n *\n * @param config - The config object.\n * @returns An array with regular expressions of dependencies that should be\n * transpiled.\n */\nexport function processDependencies(config: LegacyOptions) {\n const { depsToTranspile, transpilationMode } = config;\n if (transpilationMode === TranspilationModes.LocalAndDeps) {\n const regex = getDependencyRegExp(depsToTranspile);\n if (regex !== null) {\n return [regex];\n }\n }\n\n return [];\n}\n\n/**\n * Processes a string of space delimited dependencies into one RegExp string.\n *\n * @param dependencies - An array of dependencies to add to the RegExp.\n * @returns A RegExp object.\n */\nexport function getDependencyRegExp(dependencies: string[]): RegExp | null {\n if (!dependencies || dependencies.includes('.') || !dependencies.length) {\n return null;\n }\n\n const paths: string[] = sanitizeDependencyPaths(dependencies);\n return RegExp(`/node_modules/(?!${paths.join('|')})`, 'u');\n}\n\n/**\n * Helper function to remove any leading and trailing slashes from dependency\n * list.\n *\n * @param dependencies - An array of dependencies to sanitize.\n * @returns An array of sanitized paths.\n */\nexport function sanitizeDependencyPaths(dependencies: string[]): string[] {\n return dependencies.map((dependency) => {\n return dependency.replace(/^[/\\\\]+/u, '').replace(/[/\\\\]+$/u, '');\n });\n}\n"],"names":["TranspilationModes","processDependencies","config","depsToTranspile","transpilationMode","LocalAndDeps","regex","getDependencyRegExp","dependencies","includes","length","paths","sanitizeDependencyPaths","RegExp","join","map","dependency","replace"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,cAAc;AAGjD;;;;;;;;;CASC,GACD,OAAO,SAASC,oBAAoBC,MAAqB;IACvD,MAAM,EAAEC,eAAe,EAAEC,iBAAiB,EAAE,GAAGF;IAC/C,IAAIE,sBAAsBJ,mBAAmBK,YAAY,EAAE;QACzD,MAAMC,QAAQC,oBAAoBJ;QAClC,IAAIG,UAAU,MAAM;YAClB,OAAO;gBAACA;aAAM;QAChB;IACF;IAEA,OAAO,EAAE;AACX;AAEA;;;;;CAKC,GACD,OAAO,SAASC,oBAAoBC,YAAsB;IACxD,IAAI,CAACA,gBAAgBA,aAAaC,QAAQ,CAAC,QAAQ,CAACD,aAAaE,MAAM,EAAE;QACvE,OAAO;IACT;IAEA,MAAMC,QAAkBC,wBAAwBJ;IAChD,OAAOK,OAAO,CAAC,iBAAiB,EAAEF,MAAMG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;AACxD;AAEA;;;;;;CAMC,GACD,OAAO,SAASF,wBAAwBJ,YAAsB;IAC5D,OAAOA,aAAaO,GAAG,CAAC,CAACC;QACvB,OAAOA,WAAWC,OAAO,CAAC,YAAY,IAAIA,OAAO,CAAC,YAAY;IAChE;AACF"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { logError, logInfo, logWarning } from '@metamask/snaps-utils';
|
|
2
|
-
import { blue, dim, red, yellow } from 'chalk';
|
|
3
|
-
/**
|
|
4
|
-
* Log a warning message. The message is prefixed with "Warning:".
|
|
5
|
-
*
|
|
6
|
-
* @param message - The message to log.
|
|
7
|
-
* @param spinner - The spinner to clear.
|
|
8
|
-
*/ export function warn(message, spinner) {
|
|
9
|
-
if (spinner) {
|
|
10
|
-
spinner.clear();
|
|
11
|
-
spinner.frame();
|
|
12
|
-
}
|
|
13
|
-
logWarning(`${yellow('⚠')} ${message}`);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Log an info message.
|
|
17
|
-
*
|
|
18
|
-
* @param message - The message to log.
|
|
19
|
-
* @param spinner - The spinner to clear.
|
|
20
|
-
*/ export function info(message, spinner) {
|
|
21
|
-
if (spinner) {
|
|
22
|
-
spinner.clear();
|
|
23
|
-
spinner.frame();
|
|
24
|
-
}
|
|
25
|
-
logInfo(`${blue('ℹ')} ${dim(message)}`);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Log an error message. The message is prefixed with "Error:".
|
|
29
|
-
*
|
|
30
|
-
* @param message - The message to log.
|
|
31
|
-
* @param spinner - The spinner to clear.
|
|
32
|
-
*/ export function error(message, spinner) {
|
|
33
|
-
if (spinner) {
|
|
34
|
-
spinner.clear();
|
|
35
|
-
spinner.frame();
|
|
36
|
-
}
|
|
37
|
-
logError(`${red('✖')} ${message}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=logging.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/logging.ts"],"sourcesContent":["import { logError, logInfo, logWarning } from '@metamask/snaps-utils';\nimport { blue, dim, red, yellow } from 'chalk';\nimport type { Ora } from 'ora';\n\n/**\n * Log a warning message. The message is prefixed with \"Warning:\".\n *\n * @param message - The message to log.\n * @param spinner - The spinner to clear.\n */\nexport function warn(message: string, spinner?: Ora) {\n if (spinner) {\n spinner.clear();\n spinner.frame();\n }\n\n logWarning(`${yellow('⚠')} ${message}`);\n}\n\n/**\n * Log an info message.\n *\n * @param message - The message to log.\n * @param spinner - The spinner to clear.\n */\nexport function info(message: string, spinner?: Ora) {\n if (spinner) {\n spinner.clear();\n spinner.frame();\n }\n\n logInfo(`${blue('ℹ')} ${dim(message)}`);\n}\n\n/**\n * Log an error message. The message is prefixed with \"Error:\".\n *\n * @param message - The message to log.\n * @param spinner - The spinner to clear.\n */\nexport function error(message: string, spinner?: Ora) {\n if (spinner) {\n spinner.clear();\n spinner.frame();\n }\n\n logError(`${red('✖')} ${message}`);\n}\n"],"names":["logError","logInfo","logWarning","blue","dim","red","yellow","warn","message","spinner","clear","frame","info","error"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,UAAU,QAAQ,wBAAwB;AACtE,SAASC,IAAI,EAAEC,GAAG,EAAEC,GAAG,EAAEC,MAAM,QAAQ,QAAQ;AAG/C;;;;;CAKC,GACD,OAAO,SAASC,KAAKC,OAAe,EAAEC,OAAa;IACjD,IAAIA,SAAS;QACXA,QAAQC,KAAK;QACbD,QAAQE,KAAK;IACf;IAEAT,WAAW,CAAC,EAAEI,OAAO,KAAK,CAAC,EAAEE,QAAQ,CAAC;AACxC;AAEA;;;;;CAKC,GACD,OAAO,SAASI,KAAKJ,OAAe,EAAEC,OAAa;IACjD,IAAIA,SAAS;QACXA,QAAQC,KAAK;QACbD,QAAQE,KAAK;IACf;IAEAV,QAAQ,CAAC,EAAEE,KAAK,KAAK,CAAC,EAAEC,IAAII,SAAS,CAAC;AACxC;AAEA;;;;;CAKC,GACD,OAAO,SAASK,MAAML,OAAe,EAAEC,OAAa;IAClD,IAAIA,SAAS;QACXA,QAAQC,KAAK;QACbD,QAAQE,KAAK;IACf;IAEAX,SAAS,CAAC,EAAEK,IAAI,KAAK,CAAC,EAAEG,QAAQ,CAAC;AACnC"}
|
package/dist/esm/utils/path.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { relative } from 'path';
|
|
2
|
-
/**
|
|
3
|
-
* Get the relative path from the current working directory to the given
|
|
4
|
-
* absolute path.
|
|
5
|
-
*
|
|
6
|
-
* @param absolutePath - The absolute path.
|
|
7
|
-
* @param cwd - The current working directory. Defaults to `process.cwd()`.
|
|
8
|
-
* @returns The relative path.
|
|
9
|
-
*/ export function getRelativePath(absolutePath, cwd = process.cwd()) {
|
|
10
|
-
return relative(cwd, absolutePath);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=path.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/path.ts"],"sourcesContent":["import { relative } from 'path';\n\n/**\n * Get the relative path from the current working directory to the given\n * absolute path.\n *\n * @param absolutePath - The absolute path.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The relative path.\n */\nexport function getRelativePath(absolutePath: string, cwd = process.cwd()) {\n return relative(cwd, absolutePath);\n}\n"],"names":["relative","getRelativePath","absolutePath","cwd","process"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,OAAO;AAEhC;;;;;;;CAOC,GACD,OAAO,SAASC,gBAAgBC,YAAoB,EAAEC,MAAMC,QAAQD,GAAG,EAAE;IACvE,OAAOH,SAASG,KAAKD;AACvB"}
|
package/dist/esm/utils/steps.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { dim } from 'chalk';
|
|
2
|
-
import createSpinner from 'ora';
|
|
3
|
-
import { getErrorMessage } from './errors';
|
|
4
|
-
import { error } from './logging';
|
|
5
|
-
/**
|
|
6
|
-
* Execute a list of steps in series. Each step receives the context object and
|
|
7
|
-
* a spinner instance.
|
|
8
|
-
*
|
|
9
|
-
* @param steps - The steps to execute.
|
|
10
|
-
* @param context - The context object that will be passed to each step.
|
|
11
|
-
*/ export async function executeSteps(steps, context) {
|
|
12
|
-
const spinner = createSpinner({
|
|
13
|
-
// Ora writes to `process.stderr` by default.
|
|
14
|
-
stream: process.stdout
|
|
15
|
-
});
|
|
16
|
-
spinner.start();
|
|
17
|
-
try {
|
|
18
|
-
for (const step of steps){
|
|
19
|
-
// If the step has a condition, and it returns false, we skip the step.
|
|
20
|
-
if (step.condition && !step.condition(context)) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
// Calling `start` here instead of setting `spinner.text` seems to work
|
|
24
|
-
// better when the process doesn't have a TTY.
|
|
25
|
-
spinner.start(dim(step.name));
|
|
26
|
-
await step.task({
|
|
27
|
-
...context,
|
|
28
|
-
spinner
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
// The spinner may have been stopped by a step, so we only succeed if it's
|
|
32
|
-
// still spinning.
|
|
33
|
-
if (spinner.isSpinning) {
|
|
34
|
-
spinner.succeed('Done!');
|
|
35
|
-
}
|
|
36
|
-
} catch (_error) {
|
|
37
|
-
error(getErrorMessage(_error), spinner);
|
|
38
|
-
spinner.stop();
|
|
39
|
-
process.exitCode = 1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=steps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/steps.ts"],"sourcesContent":["import { dim } from 'chalk';\nimport type { Ora } from 'ora';\nimport createSpinner from 'ora';\n\nimport { getErrorMessage } from './errors';\nimport { error } from './logging';\n\nexport type Step<Context extends Record<string, unknown>> = {\n name: string;\n condition?: (context: Context) => boolean;\n task: (context: Context & { spinner: Ora }) => Promise<void>;\n};\n\nexport type Steps<Context extends Record<string, unknown>> = Readonly<\n Step<Context>[]\n>;\n\n/**\n * Execute a list of steps in series. Each step receives the context object and\n * a spinner instance.\n *\n * @param steps - The steps to execute.\n * @param context - The context object that will be passed to each step.\n */\nexport async function executeSteps<Context extends Record<string, unknown>>(\n steps: Steps<Context>,\n context: Context,\n) {\n const spinner = createSpinner({\n // Ora writes to `process.stderr` by default.\n stream: process.stdout,\n });\n\n spinner.start();\n\n try {\n for (const step of steps) {\n // If the step has a condition, and it returns false, we skip the step.\n if (step.condition && !step.condition(context)) {\n continue;\n }\n\n // Calling `start` here instead of setting `spinner.text` seems to work\n // better when the process doesn't have a TTY.\n spinner.start(dim(step.name));\n\n await step.task({\n ...context,\n spinner,\n });\n }\n\n // The spinner may have been stopped by a step, so we only succeed if it's\n // still spinning.\n if (spinner.isSpinning) {\n spinner.succeed('Done!');\n }\n } catch (_error) {\n error(getErrorMessage(_error), spinner);\n spinner.stop();\n process.exitCode = 1;\n }\n}\n"],"names":["dim","createSpinner","getErrorMessage","error","executeSteps","steps","context","spinner","stream","process","stdout","start","step","condition","name","task","isSpinning","succeed","_error","stop","exitCode"],"mappings":"AAAA,SAASA,GAAG,QAAQ,QAAQ;AAE5B,OAAOC,mBAAmB,MAAM;AAEhC,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,KAAK,QAAQ,YAAY;AAYlC;;;;;;CAMC,GACD,OAAO,eAAeC,aACpBC,KAAqB,EACrBC,OAAgB;IAEhB,MAAMC,UAAUN,cAAc;QAC5B,6CAA6C;QAC7CO,QAAQC,QAAQC,MAAM;IACxB;IAEAH,QAAQI,KAAK;IAEb,IAAI;QACF,KAAK,MAAMC,QAAQP,MAAO;YACxB,uEAAuE;YACvE,IAAIO,KAAKC,SAAS,IAAI,CAACD,KAAKC,SAAS,CAACP,UAAU;gBAC9C;YACF;YAEA,uEAAuE;YACvE,8CAA8C;YAC9CC,QAAQI,KAAK,CAACX,IAAIY,KAAKE,IAAI;YAE3B,MAAMF,KAAKG,IAAI,CAAC;gBACd,GAAGT,OAAO;gBACVC;YACF;QACF;QAEA,0EAA0E;QAC1E,kBAAkB;QAClB,IAAIA,QAAQS,UAAU,EAAE;YACtBT,QAAQU,OAAO,CAAC;QAClB;IACF,EAAE,OAAOC,QAAQ;QACff,MAAMD,gBAAgBgB,SAASX;QAC/BA,QAAQY,IAAI;QACZV,QAAQW,QAAQ,GAAG;IACrB;AACF"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { createServer } from 'http';
|
|
2
|
-
import serveMiddleware from 'serve-handler';
|
|
3
|
-
import { webpack } from 'webpack';
|
|
4
|
-
import { getDefaultConfiguration } from './config';
|
|
5
|
-
/**
|
|
6
|
-
* Get a Webpack compiler for the given config.
|
|
7
|
-
*
|
|
8
|
-
* @param config - The config object.
|
|
9
|
-
* @param options - The Webpack options.
|
|
10
|
-
* @returns The Webpack compiler.
|
|
11
|
-
*/ export async function getCompiler(config, options) {
|
|
12
|
-
const baseWebpackConfig = await getDefaultConfiguration(config, options);
|
|
13
|
-
const webpackConfig = config.customizeWebpackConfig?.(baseWebpackConfig) ?? baseWebpackConfig;
|
|
14
|
-
return webpack(webpackConfig);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get a static server for development purposes.
|
|
18
|
-
*
|
|
19
|
-
* Note: We're intentionally not using `webpack-dev-server` here because it
|
|
20
|
-
* adds a lot of extra stuff to the output that we don't need, and it's
|
|
21
|
-
* difficult to customize.
|
|
22
|
-
*
|
|
23
|
-
* @param config - The config object.
|
|
24
|
-
* @returns An object with a `listen` method that returns a promise that
|
|
25
|
-
* resolves when the server is listening.
|
|
26
|
-
*/ export function getServer(config) {
|
|
27
|
-
const server = createServer((request, response)=>{
|
|
28
|
-
serveMiddleware(request, response, {
|
|
29
|
-
public: config.server.root,
|
|
30
|
-
headers: [
|
|
31
|
-
{
|
|
32
|
-
source: '**/*',
|
|
33
|
-
headers: [
|
|
34
|
-
{
|
|
35
|
-
key: 'Cache-Control',
|
|
36
|
-
value: 'no-cache'
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
key: 'Access-Control-Allow-Origin',
|
|
40
|
-
value: '*'
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
})?.catch(/* istanbul ignore next */ ()=>{
|
|
46
|
-
response.statusCode = 500;
|
|
47
|
-
response.end();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
/**
|
|
51
|
-
* Start the server on the port specified in the config.
|
|
52
|
-
*
|
|
53
|
-
* @param port - The port to listen on.
|
|
54
|
-
* @returns A promise that resolves when the server is listening. The promise
|
|
55
|
-
* resolves to an object with the port and the server instance. Note that if
|
|
56
|
-
* the `config.server.port` is `0`, the OS will choose a random port for us,
|
|
57
|
-
* so we need to get the port from the server after it starts.
|
|
58
|
-
*/ const listen = async (port = config.server.port)=>{
|
|
59
|
-
return new Promise((resolve, reject)=>{
|
|
60
|
-
try {
|
|
61
|
-
server.listen(port, ()=>{
|
|
62
|
-
const close = async ()=>{
|
|
63
|
-
await new Promise((resolveClose, rejectClose)=>{
|
|
64
|
-
server.close((closeError)=>{
|
|
65
|
-
if (closeError) {
|
|
66
|
-
return rejectClose(closeError);
|
|
67
|
-
}
|
|
68
|
-
return resolveClose();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
const address = server.address();
|
|
73
|
-
resolve({
|
|
74
|
-
port: address.port,
|
|
75
|
-
server,
|
|
76
|
-
close
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
} catch (listenError) {
|
|
80
|
-
reject(listenError);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
return {
|
|
85
|
-
listen
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//# sourceMappingURL=compiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/webpack/compiler.ts"],"sourcesContent":["import type { Server } from 'http';\nimport { createServer } from 'http';\nimport type { AddressInfo } from 'net';\nimport serveMiddleware from 'serve-handler';\nimport { webpack } from 'webpack';\n\nimport type { ProcessedConfig, ProcessedWebpackConfig } from '../config';\nimport type { WebpackOptions } from './config';\nimport { getDefaultConfiguration } from './config';\n\n/**\n * Get a Webpack compiler for the given config.\n *\n * @param config - The config object.\n * @param options - The Webpack options.\n * @returns The Webpack compiler.\n */\nexport async function getCompiler(\n config: ProcessedWebpackConfig,\n options?: WebpackOptions,\n) {\n const baseWebpackConfig = await getDefaultConfiguration(config, options);\n const webpackConfig =\n config.customizeWebpackConfig?.(baseWebpackConfig) ?? baseWebpackConfig;\n\n return webpack(webpackConfig);\n}\n\n/**\n * Get a static server for development purposes.\n *\n * Note: We're intentionally not using `webpack-dev-server` here because it\n * adds a lot of extra stuff to the output that we don't need, and it's\n * difficult to customize.\n *\n * @param config - The config object.\n * @returns An object with a `listen` method that returns a promise that\n * resolves when the server is listening.\n */\nexport function getServer(config: ProcessedConfig) {\n const server = createServer((request, response) => {\n serveMiddleware(request, response, {\n public: config.server.root,\n headers: [\n {\n source: '**/*',\n headers: [\n {\n key: 'Cache-Control',\n value: 'no-cache',\n },\n {\n key: 'Access-Control-Allow-Origin',\n value: '*',\n },\n ],\n },\n ],\n })?.catch(\n /* istanbul ignore next */ () => {\n response.statusCode = 500;\n response.end();\n },\n );\n });\n\n /**\n * Start the server on the port specified in the config.\n *\n * @param port - The port to listen on.\n * @returns A promise that resolves when the server is listening. The promise\n * resolves to an object with the port and the server instance. Note that if\n * the `config.server.port` is `0`, the OS will choose a random port for us,\n * so we need to get the port from the server after it starts.\n */\n const listen = async (port = config.server.port) => {\n return new Promise<{\n port: number;\n server: Server;\n close: () => Promise<void>;\n }>((resolve, reject) => {\n try {\n server.listen(port, () => {\n const close = async () => {\n await new Promise<void>((resolveClose, rejectClose) => {\n server.close((closeError) => {\n if (closeError) {\n return rejectClose(closeError);\n }\n\n return resolveClose();\n });\n });\n };\n\n const address = server.address() as AddressInfo;\n resolve({ port: address.port, server, close });\n });\n } catch (listenError) {\n reject(listenError);\n }\n });\n };\n\n return { listen };\n}\n"],"names":["createServer","serveMiddleware","webpack","getDefaultConfiguration","getCompiler","config","options","baseWebpackConfig","webpackConfig","customizeWebpackConfig","getServer","server","request","response","public","root","headers","source","key","value","catch","statusCode","end","listen","port","Promise","resolve","reject","close","resolveClose","rejectClose","closeError","address","listenError"],"mappings":"AACA,SAASA,YAAY,QAAQ,OAAO;AAEpC,OAAOC,qBAAqB,gBAAgB;AAC5C,SAASC,OAAO,QAAQ,UAAU;AAIlC,SAASC,uBAAuB,QAAQ,WAAW;AAEnD;;;;;;CAMC,GACD,OAAO,eAAeC,YACpBC,MAA8B,EAC9BC,OAAwB;IAExB,MAAMC,oBAAoB,MAAMJ,wBAAwBE,QAAQC;IAChE,MAAME,gBACJH,OAAOI,sBAAsB,GAAGF,sBAAsBA;IAExD,OAAOL,QAAQM;AACjB;AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASE,UAAUL,MAAuB;IAC/C,MAAMM,SAASX,aAAa,CAACY,SAASC;QACpCZ,gBAAgBW,SAASC,UAAU;YACjCC,QAAQT,OAAOM,MAAM,CAACI,IAAI;YAC1BC,SAAS;gBACP;oBACEC,QAAQ;oBACRD,SAAS;wBACP;4BACEE,KAAK;4BACLC,OAAO;wBACT;wBACA;4BACED,KAAK;4BACLC,OAAO;wBACT;qBACD;gBACH;aACD;QACH,IAAIC,MACF,wBAAwB,GAAG;YACzBP,SAASQ,UAAU,GAAG;YACtBR,SAASS,GAAG;QACd;IAEJ;IAEA;;;;;;;;GAQC,GACD,MAAMC,SAAS,OAAOC,OAAOnB,OAAOM,MAAM,CAACa,IAAI;QAC7C,OAAO,IAAIC,QAIR,CAACC,SAASC;YACX,IAAI;gBACFhB,OAAOY,MAAM,CAACC,MAAM;oBAClB,MAAMI,QAAQ;wBACZ,MAAM,IAAIH,QAAc,CAACI,cAAcC;4BACrCnB,OAAOiB,KAAK,CAAC,CAACG;gCACZ,IAAIA,YAAY;oCACd,OAAOD,YAAYC;gCACrB;gCAEA,OAAOF;4BACT;wBACF;oBACF;oBAEA,MAAMG,UAAUrB,OAAOqB,OAAO;oBAC9BN,QAAQ;wBAAEF,MAAMQ,QAAQR,IAAI;wBAAEb;wBAAQiB;oBAAM;gBAC9C;YACF,EAAE,OAAOK,aAAa;gBACpBN,OAAOM;YACT;QACF;IACF;IAEA,OAAO;QAAEV;IAAO;AAClB"}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import SnapsWebpackPlugin from '@metamask/snaps-webpack-plugin';
|
|
2
|
-
import { builtinModules } from 'module';
|
|
3
|
-
import { resolve } from 'path';
|
|
4
|
-
import TerserPlugin from 'terser-webpack-plugin';
|
|
5
|
-
import { EnvironmentPlugin, ProgressPlugin } from 'webpack';
|
|
6
|
-
import { SnapsBuiltInResolver, SnapsBundleWarningsPlugin, SnapsStatsPlugin, SnapsWatchPlugin } from './plugins';
|
|
7
|
-
import { BROWSERSLIST_FILE, getDefaultLoader, getDevTool, getProgressHandler } from './utils';
|
|
8
|
-
/**
|
|
9
|
-
* Get the default Webpack configuration. This is the configuration that will
|
|
10
|
-
* be used if the user doesn't provide a custom Webpack configuration. The
|
|
11
|
-
* configuration is based on the snap config.
|
|
12
|
-
*
|
|
13
|
-
* The default configuration includes:
|
|
14
|
-
*
|
|
15
|
-
* - `SWC` to transpile TypeScript and JavaScript files.
|
|
16
|
-
* - `TerserPlugin` to minify the bundle.
|
|
17
|
-
* - `SnapsWebpackPlugin` to validate the bundle and update the manifest.
|
|
18
|
-
*
|
|
19
|
-
* It can be customized through the `customizeWebpackConfig` function in the
|
|
20
|
-
* snap config, but in most cases, you shouldn't need to do that.
|
|
21
|
-
*
|
|
22
|
-
* @param config - The processed snap Webpack config.
|
|
23
|
-
* @param options - The Webpack options.
|
|
24
|
-
* @returns The default Webpack configuration.
|
|
25
|
-
*/ export async function getDefaultConfiguration(config, options = {
|
|
26
|
-
evaluate: config.evaluate
|
|
27
|
-
}) {
|
|
28
|
-
const spinnerText = options.spinner?.text;
|
|
29
|
-
const builtInResolver = config.stats.builtIns && new SnapsBuiltInResolver(config.stats.builtIns, options.spinner);
|
|
30
|
-
return {
|
|
31
|
-
/**
|
|
32
|
-
* The target is set to `browserslist` so that Webpack will compile the
|
|
33
|
-
* bundle to support the browsers specified in the `.browserslistrc` file.
|
|
34
|
-
* This Browserslist file contains the browsers that are supported by
|
|
35
|
-
* MetaMask Snaps.
|
|
36
|
-
*
|
|
37
|
-
* @see https://webpack.js.org/configuration/target/
|
|
38
|
-
*/ target: `browserslist:${BROWSERSLIST_FILE}`,
|
|
39
|
-
/**
|
|
40
|
-
* The mode is set to `production` by default, so that Webpack will minify
|
|
41
|
-
* and optimize the bundle.
|
|
42
|
-
*
|
|
43
|
-
* @see https://webpack.js.org/configuration/mode/
|
|
44
|
-
*/ mode: 'production',
|
|
45
|
-
/**
|
|
46
|
-
* The entry point is set to the `input` value from the config object.
|
|
47
|
-
*
|
|
48
|
-
* @see https://webpack.js.org/configuration/entry-context/
|
|
49
|
-
*/ entry: config.input,
|
|
50
|
-
/**
|
|
51
|
-
* The devtool option controls how source maps are generated. We set it to
|
|
52
|
-
* the `sourceMap` value from the config object.
|
|
53
|
-
*
|
|
54
|
-
* @see https://webpack.js.org/configuration/devtool/
|
|
55
|
-
*/ devtool: getDevTool(config.sourceMap),
|
|
56
|
-
/**
|
|
57
|
-
* The stats option controls how much information is printed to the console
|
|
58
|
-
* when Webpack is running. We set it to `none` so that we can control the
|
|
59
|
-
* output ourselves.
|
|
60
|
-
*
|
|
61
|
-
* @see https://webpack.js.org/configuration/stats/
|
|
62
|
-
*/ stats: 'none',
|
|
63
|
-
/**
|
|
64
|
-
* The output options.
|
|
65
|
-
*
|
|
66
|
-
* @see https://webpack.js.org/configuration/output/
|
|
67
|
-
*/ output: {
|
|
68
|
-
/**
|
|
69
|
-
* This indicates whether Webpack should clear the output directory
|
|
70
|
-
* before building. We set it to the `clean` value from the config
|
|
71
|
-
* object.
|
|
72
|
-
*
|
|
73
|
-
* @see https://webpack.js.org/configuration/output/#outputclean
|
|
74
|
-
*/ clean: config.output.clean,
|
|
75
|
-
/**
|
|
76
|
-
* The filename of the bundle. We set it to the `filename` value from
|
|
77
|
-
* the config object.
|
|
78
|
-
*
|
|
79
|
-
* @see https://webpack.js.org/configuration/output/#outputfilename
|
|
80
|
-
*/ filename: config.output.filename,
|
|
81
|
-
/**
|
|
82
|
-
* The path to the output directory. We set it to the `path` value from
|
|
83
|
-
* the config object.
|
|
84
|
-
*
|
|
85
|
-
* @see https://webpack.js.org/configuration/output/#outputpath
|
|
86
|
-
*/ path: config.output.path,
|
|
87
|
-
/**
|
|
88
|
-
* The public path of the bundle. We set it to `/` by default, so that
|
|
89
|
-
* the bundle can be loaded from the root of the server.
|
|
90
|
-
*
|
|
91
|
-
* @see https://webpack.js.org/configuration/output/#outputpublicpath
|
|
92
|
-
*/ publicPath: '/',
|
|
93
|
-
/**
|
|
94
|
-
* The library configuration. This tells Webpack how to export the
|
|
95
|
-
* bundle.
|
|
96
|
-
*
|
|
97
|
-
* @see https://webpack.js.org/configuration/output/#outputlibrary
|
|
98
|
-
*/ library: {
|
|
99
|
-
/**
|
|
100
|
-
* This tells Webpack to export the bundle as a CommonJS module. This
|
|
101
|
-
* is necessary for MetaMask Snaps.
|
|
102
|
-
*
|
|
103
|
-
* @see https://webpack.js.org/configuration/output/#outputlibrarytarget
|
|
104
|
-
*/ type: 'commonjs'
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
/**
|
|
108
|
-
* The module configuration. This is where we tell Webpack how to handle
|
|
109
|
-
* different types of files.
|
|
110
|
-
*
|
|
111
|
-
* @see https://webpack.js.org/configuration/module/
|
|
112
|
-
*/ module: {
|
|
113
|
-
rules: [
|
|
114
|
-
{
|
|
115
|
-
test: /\.[tj]sx?$/u,
|
|
116
|
-
exclude: /node_modules/u,
|
|
117
|
-
use: await getDefaultLoader(config)
|
|
118
|
-
},
|
|
119
|
-
config.experimental.wasm && {
|
|
120
|
-
test: /\.wasm$/u,
|
|
121
|
-
use: {
|
|
122
|
-
loader: resolve(__dirname, 'loaders', 'wasm')
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* The resolve configuration. This tells Webpack how to resolve imports.
|
|
129
|
-
* We set it to resolve `.js` and `.ts` files.
|
|
130
|
-
*
|
|
131
|
-
* @see https://webpack.js.org/configuration/resolve/
|
|
132
|
-
*/ resolve: {
|
|
133
|
-
/**
|
|
134
|
-
* The extensions to resolve. We set it to resolve `.js` and `.ts`
|
|
135
|
-
* files.
|
|
136
|
-
*/ extensions: [
|
|
137
|
-
'.js',
|
|
138
|
-
'.ts'
|
|
139
|
-
],
|
|
140
|
-
/**
|
|
141
|
-
* The fallback options. This tells Webpack how to handle imports that
|
|
142
|
-
* aren't resolved. By default, we set Node.js built-ins to `false`, so
|
|
143
|
-
* that they are ignored.
|
|
144
|
-
*/ fallback: Object.fromEntries(builtinModules.map((name)=>[
|
|
145
|
-
name,
|
|
146
|
-
false
|
|
147
|
-
])),
|
|
148
|
-
/**
|
|
149
|
-
* The plugins to use. We use the {@link SnapsBuiltInResolver} to show
|
|
150
|
-
* warnings about using Node.js built-ins, when no fallback is specified.
|
|
151
|
-
*/ plugins: [
|
|
152
|
-
builtInResolver
|
|
153
|
-
]
|
|
154
|
-
},
|
|
155
|
-
/**
|
|
156
|
-
* The plugins to use.
|
|
157
|
-
*
|
|
158
|
-
* @see https://webpack.js.org/configuration/plugins/
|
|
159
|
-
*/ plugins: [
|
|
160
|
-
/**
|
|
161
|
-
* The `SnapsWebpackPlugin` is a Webpack plugin that checks and updates
|
|
162
|
-
* the manifest file, and evaluates the bundle in SES. While not strictly
|
|
163
|
-
* required, it's highly recommended to use this plugin.
|
|
164
|
-
*/ new SnapsWebpackPlugin({
|
|
165
|
-
manifestPath: config.manifest.path,
|
|
166
|
-
writeManifest: config.manifest.update,
|
|
167
|
-
eval: !options.watch && options.evaluate
|
|
168
|
-
}),
|
|
169
|
-
/**
|
|
170
|
-
* The `SnapsStatsPlugin` is a Webpack plugin that handles the stats
|
|
171
|
-
* output. It's used to show the stats in the terminal, in a format that
|
|
172
|
-
* is easy to read.
|
|
173
|
-
*/ new SnapsStatsPlugin({
|
|
174
|
-
verbose: config.stats.verbose
|
|
175
|
-
}, options.spinner),
|
|
176
|
-
/**
|
|
177
|
-
* The `EnvironmentPlugin` is a Webpack plugin that adds environment
|
|
178
|
-
* variables to the bundle. We use it to add the `NODE_ENV` and `DEBUG`
|
|
179
|
-
* environment variables.
|
|
180
|
-
*/ new EnvironmentPlugin(config.environment),
|
|
181
|
-
/**
|
|
182
|
-
* The `ProgressPlugin` is a Webpack plugin that logs the progress of
|
|
183
|
-
* the build. We set it to log the progress to the spinner.
|
|
184
|
-
*/ new ProgressPlugin({
|
|
185
|
-
handler: getProgressHandler(options.spinner, spinnerText)
|
|
186
|
-
}),
|
|
187
|
-
/**
|
|
188
|
-
* The `SnapsBundleWarningPlugin` is a Webpack plugin that shows a
|
|
189
|
-
* warning when the bundle is potentially incompatible with MetaMask
|
|
190
|
-
* Snaps.
|
|
191
|
-
*/ new SnapsBundleWarningsPlugin({
|
|
192
|
-
builtInResolver,
|
|
193
|
-
builtIns: Boolean(config.stats.builtIns),
|
|
194
|
-
buffer: config.stats.buffer
|
|
195
|
-
}, options.spinner),
|
|
196
|
-
/**
|
|
197
|
-
* The `WatchPlugin` is a Webpack plugin that adds extra files to watch
|
|
198
|
-
* for changes. This is useful for rebuilding the bundle when the
|
|
199
|
-
* manifest file changes.
|
|
200
|
-
*/ options.watch && new SnapsWatchPlugin({
|
|
201
|
-
bundle: resolve(config.output.path, config.output.filename),
|
|
202
|
-
evaluate: options.evaluate,
|
|
203
|
-
files: [
|
|
204
|
-
config.manifest.path
|
|
205
|
-
]
|
|
206
|
-
}, options.spinner)
|
|
207
|
-
].filter(Boolean),
|
|
208
|
-
/**
|
|
209
|
-
* The optimization configuration. This tells Webpack how to optimize the
|
|
210
|
-
* bundle. Most of the time, you won't need to change this, as the default
|
|
211
|
-
* options set by the `mode` option are sufficient.
|
|
212
|
-
*/ optimization: {
|
|
213
|
-
minimize: config.output.minimize,
|
|
214
|
-
/**
|
|
215
|
-
* The minimizer to use. We set it to use the `TerserPlugin`.
|
|
216
|
-
*/ minimizer: [
|
|
217
|
-
new TerserPlugin({
|
|
218
|
-
parallel: true
|
|
219
|
-
})
|
|
220
|
-
]
|
|
221
|
-
},
|
|
222
|
-
/**
|
|
223
|
-
* The infrastructure logging configuration. This tells Webpack how to
|
|
224
|
-
* log messages.
|
|
225
|
-
*
|
|
226
|
-
* @see https://webpack.js.org/configuration/infrastructure-logging
|
|
227
|
-
*/ infrastructureLogging: {
|
|
228
|
-
/**
|
|
229
|
-
* The level of logging to use. We set it to `none`, so that we can
|
|
230
|
-
* control the output ourselves.
|
|
231
|
-
*/ level: 'none'
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/webpack/config.ts"],"sourcesContent":["import SnapsWebpackPlugin from '@metamask/snaps-webpack-plugin';\nimport { builtinModules } from 'module';\nimport type { Ora } from 'ora';\nimport { resolve } from 'path';\nimport TerserPlugin from 'terser-webpack-plugin';\nimport type { Configuration } from 'webpack';\nimport { EnvironmentPlugin, ProgressPlugin } from 'webpack';\n\nimport type { ProcessedWebpackConfig } from '../config';\nimport {\n SnapsBuiltInResolver,\n SnapsBundleWarningsPlugin,\n SnapsStatsPlugin,\n SnapsWatchPlugin,\n} from './plugins';\nimport {\n BROWSERSLIST_FILE,\n getDefaultLoader,\n getDevTool,\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 /**\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: /\\.[tj]sx?$/u,\n exclude: /node_modules/u,\n use: await getDefaultLoader(config),\n },\n\n config.experimental.wasm && {\n test: /\\.wasm$/u,\n use: {\n loader: resolve(__dirname, 'loaders', 'wasm'),\n },\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 `.js` and `.ts`\n * files.\n */\n extensions: ['.js', '.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: Object.fromEntries(builtinModules.map((name) => [name, false])),\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 `EnvironmentPlugin` is a Webpack plugin that adds environment\n * variables to the bundle. We use it to add the `NODE_ENV` and `DEBUG`\n * environment variables.\n */\n new EnvironmentPlugin(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 {\n builtInResolver,\n builtIns: Boolean(config.stats.builtIns),\n buffer: config.stats.buffer,\n },\n options.spinner,\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 ].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 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"],"names":["SnapsWebpackPlugin","builtinModules","resolve","TerserPlugin","EnvironmentPlugin","ProgressPlugin","SnapsBuiltInResolver","SnapsBundleWarningsPlugin","SnapsStatsPlugin","SnapsWatchPlugin","BROWSERSLIST_FILE","getDefaultLoader","getDevTool","getProgressHandler","getDefaultConfiguration","config","options","evaluate","spinnerText","spinner","text","builtInResolver","stats","builtIns","target","mode","entry","input","devtool","sourceMap","output","clean","filename","path","publicPath","library","type","module","rules","test","exclude","use","experimental","wasm","loader","__dirname","extensions","fallback","Object","fromEntries","map","name","plugins","manifestPath","manifest","writeManifest","update","eval","watch","verbose","environment","handler","Boolean","buffer","bundle","files","filter","optimization","minimize","minimizer","parallel","infrastructureLogging","level"],"mappings":"AAAA,OAAOA,wBAAwB,iCAAiC;AAChE,SAASC,cAAc,QAAQ,SAAS;AAExC,SAASC,OAAO,QAAQ,OAAO;AAC/B,OAAOC,kBAAkB,wBAAwB;AAEjD,SAASC,iBAAiB,EAAEC,cAAc,QAAQ,UAAU;AAG5D,SACEC,oBAAoB,EACpBC,yBAAyB,EACzBC,gBAAgB,EAChBC,gBAAgB,QACX,YAAY;AACnB,SACEC,iBAAiB,EACjBC,gBAAgB,EAChBC,UAAU,EACVC,kBAAkB,QACb,UAAU;AAoBjB;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,eAAeC,wBACpBC,MAA8B,EAC9BC,UAA0B;IACxBC,UAAUF,OAAOE,QAAQ;AAC3B,CAAC;IAED,MAAMC,cAAcF,QAAQG,OAAO,EAAEC;IACrC,MAAMC,kBACJN,OAAOO,KAAK,CAACC,QAAQ,IACrB,IAAIjB,qBAAqBS,OAAOO,KAAK,CAACC,QAAQ,EAAEP,QAAQG,OAAO;IAEjE,OAAO;QACL;;;;;;;KAOC,GACDK,QAAQ,CAAC,aAAa,EAAEd,kBAAkB,CAAC;QAE3C;;;;;KAKC,GACDe,MAAM;QAEN;;;;KAIC,GACDC,OAAOX,OAAOY,KAAK;QAEnB;;;;;KAKC,GACDC,SAAShB,WAAWG,OAAOc,SAAS;QAEpC;;;;;;KAMC,GACDP,OAAO;QAEP;;;;KAIC,GACDQ,QAAQ;YACN;;;;;;OAMC,GACDC,OAAOhB,OAAOe,MAAM,CAACC,KAAK;YAE1B;;;;;OAKC,GACDC,UAAUjB,OAAOe,MAAM,CAACE,QAAQ;YAEhC;;;;;OAKC,GACDC,MAAMlB,OAAOe,MAAM,CAACG,IAAI;YAExB;;;;;OAKC,GACDC,YAAY;YAEZ;;;;;OAKC,GACDC,SAAS;gBACP;;;;;SAKC,GACDC,MAAM;YACR;QACF;QAEA;;;;;KAKC,GACDC,QAAQ;YACNC,OAAO;gBACL;oBACEC,MAAM;oBACNC,SAAS;oBACTC,KAAK,MAAM9B,iBAAiBI;gBAC9B;gBAEAA,OAAO2B,YAAY,CAACC,IAAI,IAAI;oBAC1BJ,MAAM;oBACNE,KAAK;wBACHG,QAAQ1C,QAAQ2C,WAAW,WAAW;oBACxC;gBACF;aACD;QACH;QAEA;;;;;KAKC,GACD3C,SAAS;YACP;;;OAGC,GACD4C,YAAY;gBAAC;gBAAO;aAAM;YAE1B;;;;OAIC,GACDC,UAAUC,OAAOC,WAAW,CAAChD,eAAeiD,GAAG,CAAC,CAACC,OAAS;oBAACA;oBAAM;iBAAM;YAEvE;;;OAGC,GACDC,SAAS;gBAAC/B;aAAgB;QAC5B;QAEA;;;;KAIC,GACD+B,SAAS;YACP;;;;OAIC,GACD,IAAIpD,mBAAmB;gBACrBqD,cAActC,OAAOuC,QAAQ,CAACrB,IAAI;gBAClCsB,eAAexC,OAAOuC,QAAQ,CAACE,MAAM;gBACrCC,MAAM,CAACzC,QAAQ0C,KAAK,IAAI1C,QAAQC,QAAQ;YAC1C;YAEA;;;;OAIC,GACD,IAAIT,iBAAiB;gBAAEmD,SAAS5C,OAAOO,KAAK,CAACqC,OAAO;YAAC,GAAG3C,QAAQG,OAAO;YAEvE;;;;OAIC,GACD,IAAIf,kBAAkBW,OAAO6C,WAAW;YAExC;;;OAGC,GACD,IAAIvD,eAAe;gBACjBwD,SAAShD,mBAAmBG,QAAQG,OAAO,EAAED;YAC/C;YAEA;;;;OAIC,GACD,IAAIX,0BACF;gBACEc;gBACAE,UAAUuC,QAAQ/C,OAAOO,KAAK,CAACC,QAAQ;gBACvCwC,QAAQhD,OAAOO,KAAK,CAACyC,MAAM;YAC7B,GACA/C,QAAQG,OAAO;YAGjB;;;;OAIC,GACDH,QAAQ0C,KAAK,IACX,IAAIjD,iBACF;gBACEuD,QAAQ9D,QAAQa,OAAOe,MAAM,CAACG,IAAI,EAAElB,OAAOe,MAAM,CAACE,QAAQ;gBAC1Df,UAAUD,QAAQC,QAAQ;gBAC1BgD,OAAO;oBAAClD,OAAOuC,QAAQ,CAACrB,IAAI;iBAAC;YAC/B,GACAjB,QAAQG,OAAO;SAEpB,CAAC+C,MAAM,CAACJ;QAET;;;;KAIC,GACDK,cAAc;YACZC,UAAUrD,OAAOe,MAAM,CAACsC,QAAQ;YAEhC;;OAEC,GACDC,WAAW;gBACT,IAAIlE,aAAa;oBACfmE,UAAU;gBACZ;aACD;QACH;QAEA;;;;;KAKC,GACDC,uBAAuB;YACrB;;;OAGC,GACDC,OAAO;QACT;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/webpack/index.ts"],"sourcesContent":["export * from './compiler';\nexport * from './config';\nexport * from './plugins';\n"],"names":[],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,YAAY"}
|