@metamask/snaps-cli 6.3.2 → 6.3.4

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 CHANGED
@@ -1,4 +1,5 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -6,39 +7,66 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
7
 
7
8
  ## [Unreleased]
8
9
 
10
+ ## [6.3.4]
11
+
12
+ ### Changed
13
+
14
+ - Bump `@metamask/snaps-sdk` to `^6.7.0` ([#2770](https://github.com/MetaMask/snaps/pull/2770))
15
+ - Bump `@metamask/snaps-utils` to `^8.3.0` ([#2770](https://github.com/MetaMask/snaps/pull/2770))
16
+
17
+ ## [6.3.3]
18
+
19
+ ### Fixed
20
+
21
+ - Fix invalid types in type declaration in some cases ([#2714](https://github.com/MetaMask/snaps/pull/2714))
22
+
9
23
  ## [6.3.2]
24
+
10
25
  ### Fixed
26
+
11
27
  - Fix ESM version of the package ([#2682](https://github.com/MetaMask/snaps/pull/2682))
12
28
  - This fixes the ESM version of the package to be fully compliant with the ESM
13
29
  standard.
14
30
  - Bump `@metamask/utils` from `^9.1.0` to `^9.2.1` ([#2680](https://github.com/MetaMask/snaps/pull/2680))
15
31
 
16
32
  ## [6.3.1]
33
+
17
34
  ### Fixed
35
+
18
36
  - Hide browserlist warning where applicable ([#2664](https://github.com/MetaMask/snaps/pull/2664))
19
37
 
20
38
  ## [6.3.0]
39
+
21
40
  ### Changed
41
+
22
42
  - Improve manifest validation output ([#2572](https://github.com/MetaMask/snaps/pull/2572))
23
43
  - Replace `superstruct` with ESM-compatible fork `@metamask/superstruct` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
24
44
 
25
45
  ## [6.2.1]
46
+
26
47
  ### Fixed
48
+
27
49
  - Improve validation of `endowment:rpc` ([#2512](https://github.com/MetaMask/snaps/pull/2512))
28
50
 
29
51
  ## [6.2.0]
52
+
30
53
  ### Added
54
+
31
55
  - Add support for building Snaps with JSX ([#2258](https://github.com/MetaMask/snaps/pull/2258))
32
56
  - It's now possible to use JSX components from `@metamask/snaps-sdk` to build
33
57
  user interfaces for Snaps.
34
58
 
35
59
  ## [6.1.1]
60
+
36
61
  ### Fixed
62
+
37
63
  - Disable `topLevelAwait` configuration option ([#2358](https://github.com/MetaMask/snaps/pull/2358))
38
64
  - Before this the CLI would produce invalid builds when using top-level await.
39
65
 
40
66
  ## [6.1.0]
67
+
41
68
  ### Added
69
+
42
70
  - Add support for importing SVG, PNG, and JPEG files directly ([#2284](https://github.com/MetaMask/snaps/pull/2284))
43
71
  - You can now import these files using a regular import declaration when using the Webpack-based config.
44
72
  - To opt out of this feature (i.e., to use custom image loading logic), add the following to your config:
@@ -51,116 +79,164 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
51
79
  ```
52
80
 
53
81
  ### Changed
82
+
54
83
  - Update CLI docs link ([#2294](https://github.com/MetaMask/snaps/pull/2294))
55
84
 
56
85
  ### Fixed
86
+
57
87
  - Fix detection of minimum Node.js version ([#2292](https://github.com/MetaMask/snaps/pull/2292))
58
88
 
59
89
  ## [6.0.2]
90
+
60
91
  ### Fixed
92
+
61
93
  - Publish `.browserslistrc` ([#2227](https://github.com/MetaMask/snaps/pull/2227))
62
94
 
63
95
  ## [6.0.1]
96
+
64
97
  ### Fixed
98
+
65
99
  - Fix minor build configuration problems ([#2220](https://github.com/MetaMask/snaps/pull/2220))
66
100
 
67
101
  ## [6.0.0]
102
+
68
103
  ### Changed
104
+
69
105
  - **BREAKING:** Update ESM build to be fully compliant with the ESM standard ([#2210](https://github.com/MetaMask/snaps/pull/2210))
70
106
  - **BREAKING:** Change config to use Webpack by default ([#2214](https://github.com/MetaMask/snaps/pull/2214))
71
107
  - You can still use Browserify by specifying `bundler: 'browserify'`.
72
108
 
73
109
  ## [5.1.1]
110
+
74
111
  ### Fixed
112
+
75
113
  - Support new lines in CLI message formatting ([#2194](https://github.com/MetaMask/snaps/pull/2194))
76
114
 
77
115
  ## [5.1.0]
116
+
78
117
  ### Changed
118
+
79
119
  - Optimize CLI Webpack configuration ([#2175](https://github.com/MetaMask/snaps/pull/2175))
80
120
  - This can reduce the size of Snaps in certain cases.
81
121
  - Show Webpack compilation warnings in CLI ([#2186](https://github.com/MetaMask/snaps/pull/2186), [#2192](https://github.com/MetaMask/snaps/pull/2192))
82
122
  - Add a warning when no icon is found and when icon is not square ([#2185](https://github.com/MetaMask/snaps/pull/2185))
83
123
 
84
124
  ## [5.0.0]
125
+
85
126
  ### Changed
127
+
86
128
  - **BREAKING:** Disable source maps by default ([#2166](https://github.com/MetaMask/snaps/pull/2166))
87
129
  - This slightly speeds up the build process.
88
130
  - You can enable source maps again by setting `sourceMap: true` in your Snap config.
89
131
  - Set `output.chunkFormat` to `commonjs` by default ([#2136](https://github.com/MetaMask/snaps/pull/2136))
90
132
 
91
133
  ## [4.0.1]
134
+
92
135
  ### Fixed
136
+
93
137
  - Fix missing `global` during snap evaluation ([#2072](https://github.com/MetaMask/snaps/pull/2072))
94
138
 
95
139
  ## [4.0.0]
140
+
96
141
  ### Changed
142
+
97
143
  - **BREAKING:** Synchronously initialize WASM modules ([#2024](https://github.com/MetaMask/snaps/pull/2024))
98
144
  - When the `experimental.wasm` flag in the Snaps CLI is enabled, the WASM module will now be synchronously initialized, rather than being inlined as a Uint8Array.
99
145
 
100
146
  ## [3.0.5]
147
+
101
148
  ### Fixed
149
+
102
150
  - Include Snap icon in allowed server paths ([#2003](https://github.com/MetaMask/snaps/pull/2003))
103
151
 
104
152
  ## [3.0.4]
153
+
105
154
  ### Fixed
155
+
106
156
  - Only serve Snap files from CLI ([#1979](https://github.com/MetaMask/snaps/pull/1979))
107
157
 
108
158
  ## [3.0.3]
159
+
109
160
  ### Changed
161
+
110
162
  - Bump several MetaMask dependencies ([#1964](https://github.com/MetaMask/snaps/pull/1964))
111
163
 
112
164
  ### Fixed
165
+
113
166
  - Fix issues generating checksum with binary auxiliary files ([#1975](https://github.com/MetaMask/snaps/pull/1975))
114
167
 
115
168
  ## [3.0.2]
169
+
116
170
  ### Changed
171
+
117
172
  - Use `@metamask/snaps-sdk` package ([#1951](https://github.com/MetaMask/snaps/pull/1951))
118
173
  - This package replaces the `@metamask/snaps-types` and
119
174
  `@metamask/snaps-ui` packages.
120
175
 
121
176
  ## [3.0.1]
177
+
122
178
  ### Changed
179
+
123
180
  - Bump Babel packages from `^7.20.12` to `^7.23.2` ([#1862](https://github.com/MetaMask/snaps/pull/1862))
124
181
  - Update multiple MetaMask dependencies ([#1841](https://github.com/MetaMask/snaps/pull/1841))
125
182
 
126
183
  ## [3.0.0]
184
+
127
185
  ### Changed
186
+
128
187
  - **BREAKING:** Bump minimum Node.js version to `^18.16.0` ([#1741](https://github.com/MetaMask/snaps/pull/1741))
129
188
 
130
189
  ## [2.0.2]
190
+
131
191
  ### Fixed
192
+
132
193
  - Fix Webpack being unable to find `swc-loader` in some cases ([#1798](https://github.com/MetaMask/snaps/pull/1798))
133
194
  - Check minimum Node version in CLI ([#1797](https://github.com/MetaMask/snaps/pull/1797))
134
195
 
135
196
  ## [2.0.1]
197
+
136
198
  ### Fixed
199
+
137
200
  - Disable the `fullySpecified` rule for `.js` imports in the default Webpack config ([#1780](https://github.com/MetaMask/snaps/pull/1780))
138
201
 
139
202
  ## [2.0.0]
203
+
140
204
  ### Changed
205
+
141
206
  - Initial stable release from main branch ([#1757](https://github.com/MetaMask/snaps/pull/1757))
142
207
 
143
208
  ## [0.38.4-flask.1]
209
+
144
210
  ### Changed
211
+
145
212
  - Bump `metamask/utils` and `metamask/snaps-registry` ([#1738](https://github.com/MetaMask/snaps/pull/1738), [#1694](https://github.com/MetaMask/snaps/pull/1694))
146
213
 
147
214
  ## [0.38.3-flask.1]
215
+
148
216
  ### Fixed
217
+
149
218
  - Remove unused dependencies ([#1680](https://github.com/MetaMask/snaps/pull/1680))
150
219
 
151
220
  ## [0.38.2-flask.1]
221
+
152
222
  ### Added
223
+
153
224
  - Add `polyfills` option to Webpack configuration ([#1650](https://github.com/MetaMask/snaps/pull/1650))
154
225
 
155
226
  ### Fixed
227
+
156
228
  - Fix breaking change to SWC causing the CLI to break ([#1677](https://github.com/MetaMask/snaps/pull/1677))
157
229
 
158
230
  ## [0.38.1-flask.1]
231
+
159
232
  ### Changed
233
+
160
234
  - Update all examples to use Webpack ([#1632](https://github.com/MetaMask/snaps/pull/1632))
161
235
 
162
236
  ## [0.38.0-flask.1]
237
+
163
238
  ### Added
239
+
164
240
  - Add support for bundling with Webpack ([#1521](https://github.com/MetaMask/snaps/pull/1521))
165
241
  - For backwards compatibility, the Webpack bundler is opt-in. To use it, add
166
242
  `"bundler": "webpack"` to your snap configuration file, and follow the new
@@ -173,11 +249,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
173
249
  - Support TypeScript snap configuration files ([#1521](https://github.com/MetaMask/snaps/pull/1521))
174
250
 
175
251
  ### Changed
252
+
176
253
  - Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
177
254
  - The version of the package no longer needs to match the version of all other
178
255
  MetaMask Snaps packages.
179
256
 
180
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.3.2...HEAD
257
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.3.4...HEAD
258
+ [6.3.4]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.3.3...@metamask/snaps-cli@6.3.4
259
+ [6.3.3]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.3.2...@metamask/snaps-cli@6.3.3
181
260
  [6.3.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.3.1...@metamask/snaps-cli@6.3.2
182
261
  [6.3.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.3.0...@metamask/snaps-cli@6.3.1
183
262
  [6.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-cli@6.2.1...@metamask/snaps-cli@6.3.0
@@ -1,8 +1,26 @@
1
+ function $__filename(fileUrl) {
2
+ const url = new URL(fileUrl);
3
+ return url.pathname.replace(/^\/([a-zA-Z]:)/u, "$1");
4
+ }
5
+ function $getDirname(path) {
6
+ const sanitisedPath = path.toString().replace(/\\/gu, "/").replace(/\/$/u, "");
7
+ const index = sanitisedPath.lastIndexOf("/");
8
+ if (index === -1) {
9
+ return path;
10
+ }
11
+ if (index === 0) {
12
+ return "/";
13
+ }
14
+ return sanitisedPath.slice(0, index);
15
+ }
16
+ function $__dirname(url) {
17
+ return $getDirname($__filename(url));
18
+ }
1
19
  const config = {
2
20
  bundler: 'webpack',
3
21
  input: 'src/index.ts',
4
22
  output: {
5
- path: __dirname,
23
+ path: $__dirname(import.meta.url),
6
24
  filename: 'eval.js',
7
25
  },
8
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"snap.config.mjs","sourceRoot":"","sources":["../../../../../../src/commands/eval/__test__/webpack/bad/snap.config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAe;IACzB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,SAAS;KACpB;CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import type { SnapConfig } from '../../../../../config';\n\nconst config: SnapConfig = {\n bundler: 'webpack',\n input: 'src/index.ts',\n output: {\n path: __dirname,\n filename: 'eval.js',\n },\n};\n\nexport default config;\n"]}
1
+ {"version":3,"file":"snap.config.mjs","sourceRoot":"","sources":["../../../../../../src/commands/eval/__test__/webpack/bad/snap.config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,MAAM,MAAM,GAAe;IACzB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE;QACN,IAAI,6BAAW;QACf,QAAQ,EAAE,SAAS;KACpB;CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import type { SnapConfig } from '../../../../../config';\n\nconst config: SnapConfig = {\n bundler: 'webpack',\n input: 'src/index.ts',\n output: {\n path: __dirname,\n filename: 'eval.js',\n },\n};\n\nexport default config;\n"]}
@@ -1,8 +1,26 @@
1
+ function $__filename(fileUrl) {
2
+ const url = new URL(fileUrl);
3
+ return url.pathname.replace(/^\/([a-zA-Z]:)/u, "$1");
4
+ }
5
+ function $getDirname(path) {
6
+ const sanitisedPath = path.toString().replace(/\\/gu, "/").replace(/\/$/u, "");
7
+ const index = sanitisedPath.lastIndexOf("/");
8
+ if (index === -1) {
9
+ return path;
10
+ }
11
+ if (index === 0) {
12
+ return "/";
13
+ }
14
+ return sanitisedPath.slice(0, index);
15
+ }
16
+ function $__dirname(url) {
17
+ return $getDirname($__filename(url));
18
+ }
1
19
  const config = {
2
20
  bundler: 'webpack',
3
21
  input: 'src/index.ts',
4
22
  output: {
5
- path: __dirname,
23
+ path: $__dirname(import.meta.url),
6
24
  filename: 'eval.js',
7
25
  },
8
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"snap.config.mjs","sourceRoot":"","sources":["../../../../../../src/commands/eval/__test__/webpack/good/snap.config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAe;IACzB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,SAAS;KACpB;CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import type { SnapConfig } from '../../../../../config';\n\nconst config: SnapConfig = {\n bundler: 'webpack',\n input: 'src/index.ts',\n output: {\n path: __dirname,\n filename: 'eval.js',\n },\n};\n\nexport default config;\n"]}
1
+ {"version":3,"file":"snap.config.mjs","sourceRoot":"","sources":["../../../../../../src/commands/eval/__test__/webpack/good/snap.config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,MAAM,MAAM,GAAe;IACzB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE;QACN,IAAI,6BAAW;QACf,QAAQ,EAAE,SAAS;KACpB;CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import type { SnapConfig } from '../../../../../config';\n\nconst config: SnapConfig = {\n bundler: 'webpack',\n input: 'src/index.ts',\n output: {\n path: __dirname,\n filename: 'eval.js',\n },\n};\n\nexport default config;\n"]}
@@ -3,7 +3,7 @@ declare const commands: {
3
3
  command: string[];
4
4
  desc: string;
5
5
  builder: (yarg: import("yargs").Argv<{}>) => void;
6
- handler: (argv: import("../types/yargs").YargsArgs) => Promise<void>;
6
+ handler: (argv: import("../types/yargs.d.cjs").YargsArgs) => Promise<void>;
7
7
  }[];
8
8
  export default commands;
9
9
  //# sourceMappingURL=index.d.cts.map
@@ -3,7 +3,7 @@ declare const commands: {
3
3
  command: string[];
4
4
  desc: string;
5
5
  builder: (yarg: import("yargs").Argv<{}>) => void;
6
- handler: (argv: import("../types/yargs").YargsArgs) => Promise<void>;
6
+ handler: (argv: import("../types/yargs.d.mjs").YargsArgs) => Promise<void>;
7
7
  }[];
8
8
  export default commands;
9
9
  //# sourceMappingURL=index.d.mts.map
@@ -34,13 +34,13 @@ const loader = async function (content, sourceMap) {
34
34
  // We need to statically import all Browserify transforms, and all Babel
35
35
  // presets and plugins, and calling `require` is the sanest way to do that.
36
36
  /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */
37
- bundler.transform(require('babelify'), {
37
+ bundler.transform(require("babelify/index.js"), {
38
38
  global: transpilationMode === builders_1.TranspilationModes.LocalAndDeps,
39
39
  extensions: ['.js', '.jsx', '.ts', '.tsx'],
40
40
  presets: [
41
- require('@babel/preset-typescript'),
41
+ require("@babel/preset-typescript"),
42
42
  [
43
- require('@babel/preset-env'),
43
+ require("@babel/preset-env"),
44
44
  {
45
45
  targets: {
46
46
  browsers: await (0, utils_2.getBrowserslistTargets)(),
@@ -49,11 +49,11 @@ const loader = async function (content, sourceMap) {
49
49
  ],
50
50
  ],
51
51
  plugins: [
52
- require('@babel/plugin-transform-runtime'),
53
- require('@babel/plugin-transform-class-properties'),
54
- require('@babel/plugin-transform-private-methods'),
55
- require('@babel/plugin-transform-class-static-block'),
56
- require('@babel/plugin-transform-private-property-in-object'),
52
+ require("@babel/plugin-transform-runtime"),
53
+ require("@babel/plugin-transform-class-properties"),
54
+ require("@babel/plugin-transform-private-methods"),
55
+ require("@babel/plugin-transform-class-static-block"),
56
+ require("@babel/plugin-transform-private-property-in-object"),
57
57
  ],
58
58
  ...babelifyOptions,
59
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"browserify.cjs","sourceRoot":"","sources":["../../../src/webpack/loaders/browserify.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AACpC,qDAA2C;AAG3C,iDAAoD;AAEpD,iDAAkD;AAClD,wCAAkD;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,GAA4C,KAAK,WAC3D,OAAO,EACP,SAAS;IAET,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAEjC,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;IAErC,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC;QACzB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;QAC1C,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC;QACzB,UAAU,EAAE,QAAQ;KACrB,CAAC,CAAC;IAEH,IAAI,iBAAiB,KAAK,6BAAkB,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,eAAe,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC,CAAC;QAEpD,wEAAwE;QACxE,2EAA2E;QAC3E,gHAAgH;QAChH,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YACrC,MAAM,EA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AAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["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 * @returns The Browserify loader.\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', '.jsx', '.ts', '.tsx'],\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', '.jsx', '.ts', '.tsx'],\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"]}
1
+ {"version":3,"file":"browserify.cjs","sourceRoot":"","sources":["../../../src/webpack/loaders/browserify.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AACpC,qDAA2C;AAG3C,iDAAoD;AAEpD,iDAAkD;AAClD,wCAAkD;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,GAA4C,KAAK,WAC3D,OAAO,EACP,SAAS;IAET,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAEjC,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;IAErC,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC;QACzB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;QAC1C,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC;QACzB,UAAU,EAAE,QAAQ;KACrB,CAAC,CAAC;IAEH,IAAI,iBAAiB,KAAK,6BAAkB,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,eAAe,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC,CAAC;QAEpD,wEAAwE;QACxE,2EAA2E;QAC3E,gHAAgH;QAChH,OAAO,CAAC,SAAS,CAAC,OAAO,qBAAY,EAAE;YACrC,MAAM,EAAE,iBAAiB,KAAK,6BAAkB,CAAC,YAAY;YAC7D,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;YAC1C,OAAO,EAAE;gBACP,OAAO,4BAA4B;gBACnC;oBACE,OAAO,qBAAqB;oBAC5B;wBACE,OAAO,EAAE;4BACP,QAAQ,EAAE,MAAM,IAAA,8BAAsB,GAAE;yBACzC;qBACF;iBACF;aACF;YACD,OAAO,EAAE;gBACP,OAAO,mCAAmC;gBAC1C,OAAO,4CAA4C;gBACnD,OAAO,2CAA2C;gBAClD,OAAO,8CAA8C;gBACrD,OAAO,sDAAsD;aAC9D;YACD,GAAI,eAAuB;SAC5B,CAAC,CAAC;QACH,+GAA+G;IACjH,CAAC;IAED,MAAM,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,CAAC;IAEpC,8EAA8E;IAC9E,kBAAkB;IAClB,MAAM,MAAM,GAAG,IAAI,0BAAQ,EAAE,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;QAClB,IAAI,EAAE,IAAI,CAAC,YAAY;KACxB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,MAAc,EAAE,EAAE;YAC7C,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,WAAW,CAAC,CAAC;gBACpB,OAAO;YACT,CAAC;YAED,4EAA4E;YAC5E,cAAc;YACd,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC","sourcesContent":["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 * @returns The Browserify loader.\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', '.jsx', '.ts', '.tsx'],\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', '.jsx', '.ts', '.tsx'],\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"]}
@@ -1,3 +1,5 @@
1
+ import { createRequire as $createRequire } from "module";
2
+ const $require = $createRequire(import.meta.url);
1
3
  function $importDefault(module) {
2
4
  if (module?.__esModule) {
3
5
  return module.default;
@@ -36,13 +38,13 @@ const loader = async function (content, sourceMap) {
36
38
  // We need to statically import all Browserify transforms, and all Babel
37
39
  // presets and plugins, and calling `require` is the sanest way to do that.
38
40
  /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, n/global-require */
39
- bundler.transform(require('babelify'), {
41
+ bundler.transform($require("babelify/index.js"), {
40
42
  global: transpilationMode === TranspilationModes.LocalAndDeps,
41
43
  extensions: ['.js', '.jsx', '.ts', '.tsx'],
42
44
  presets: [
43
- require('@babel/preset-typescript'),
45
+ $require("@babel/preset-typescript"),
44
46
  [
45
- require('@babel/preset-env'),
47
+ $require("@babel/preset-env"),
46
48
  {
47
49
  targets: {
48
50
  browsers: await getBrowserslistTargets(),
@@ -51,11 +53,11 @@ const loader = async function (content, sourceMap) {
51
53
  ],
52
54
  ],
53
55
  plugins: [
54
- require('@babel/plugin-transform-runtime'),
55
- require('@babel/plugin-transform-class-properties'),
56
- require('@babel/plugin-transform-private-methods'),
57
- require('@babel/plugin-transform-class-static-block'),
58
- require('@babel/plugin-transform-private-property-in-object'),
56
+ $require("@babel/plugin-transform-runtime"),
57
+ $require("@babel/plugin-transform-class-properties"),
58
+ $require("@babel/plugin-transform-private-methods"),
59
+ $require("@babel/plugin-transform-class-static-block"),
60
+ $require("@babel/plugin-transform-private-property-in-object"),
59
61
  ],
60
62
  ...babelifyOptions,
61
63
  });
@@ -1 +1 @@
1
- {"version":3,"file":"browserify.mjs","sourceRoot":"","sources":["../../../src/webpack/loaders/browserify.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,WAAU,mBAAmB;;AACpC,OAAO,EAAE,QAAQ,EAAE,wBAAwB;AAG3C,OAAO,EAAE,kBAAkB,EAAE,2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,+GAA+G;IACjH,CAAC;IAED,MAAM,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,CAAC;IAEpC,8EAA8E;IAC9E,kBAAkB;IAClB,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;QAClB,IAAI,EAAE,IAAI,CAAC,YAAY;KACxB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,MAAc,EAAE,EAAE;YAC7C,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,WAAW,CAAC,CAAC;gBACpB,OAAO;YACT,CAAC;YAED,4EAA4E;YAC5E,cAAc;YACd,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["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 * @returns The Browserify loader.\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', '.jsx', '.ts', '.tsx'],\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', '.jsx', '.ts', '.tsx'],\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"]}
1
+ {"version":3,"file":"browserify.mjs","sourceRoot":"","sources":["../../../src/webpack/loaders/browserify.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,WAAU,mBAAmB;;AACpC,OAAO,EAAE,QAAQ,EAAE,wBAAwB;AAG3C,OAAO,EAAE,kBAAkB,EAAE,2BAAuB;AAEpD,OAAO,EAAE,mBAAmB,EAAE,8BAAoB;AACl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,EAAE,IAAI,CAAC,YAAY;KACxB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,MAAc,EAAE,EAAE;YAC7C,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,WAAW,CAAC,CAAC;gBACpB,OAAO;YACT,CAAC;YAED,4EAA4E;YAC5E,cAAc;YACd,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["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 * @returns The Browserify loader.\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', '.jsx', '.ts', '.tsx'],\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', '.jsx', '.ts', '.tsx'],\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"]}
@@ -1,3 +1,7 @@
1
+ function $__filename(fileUrl) {
2
+ const url = new URL(fileUrl);
3
+ return url.pathname.replace(/^\/([a-zA-Z]:)/u, "$1");
4
+ }
1
5
  /**
2
6
  * A loader that executes a function. See {@link getFunctionLoader} for more
3
7
  * information.
@@ -22,7 +26,7 @@ export function getFunctionLoader(fn, options) {
22
26
  return {
23
27
  // We use `__filename` as the loader, so Webpack will execute the loader in
24
28
  // this file, with the actual function in the options.
25
- loader: __filename,
29
+ loader: $__filename(import.meta.url),
26
30
  options: {
27
31
  fn,
28
32
  ...options,
@@ -1 +1 @@
1
- {"version":3,"file":"function.mjs","sourceRoot":"","sources":["../../../src/webpack/loaders/function.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,MAAM,MAAM,GAAoD,UAC9D,OAAO;IAEP,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IACjC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC;AAEtB;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAqC,EACrC,OAAgB;IAEhB,OAAO;QACL,2EAA2E;QAC3E,sDAAsD;QACtD,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE;YACP,EAAE;YACF,GAAG,OAAO;SACX;KACF,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,yCAAyC;AACzC,yBAAyB;AACzB,4CAA4C;AAC5C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,MAAM,EAAE,CAAC;IACvE,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,OAAO,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IACrD,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import type { LoaderDefinitionFunction } from 'webpack';\n\n/**\n * Options for the function loader.\n */\nexport type FunctionLoaderOptions = {\n /**\n * The function to execute. This is bound to the loader context, so it can\n * access the loader options and other properties.\n */\n fn: LoaderDefinitionFunction;\n};\n\n/**\n * A loader that executes a function. See {@link getFunctionLoader} for more\n * information.\n *\n * @param content - The input file contents as a `Uint8Array`.\n * @returns The output of the function.\n */\nconst loader: LoaderDefinitionFunction<FunctionLoaderOptions> = function (\n content,\n) {\n const { fn } = this.getOptions();\n return fn.bind(this)(content);\n};\n\nexport default loader;\n\n/**\n * Get a loader that executes the given function. This is useful for executing\n * loaders without needing to pass a file to Webpack.\n *\n * @param fn - The function to execute.\n * @param options - The options to pass to the loader.\n * @returns The loader definition.\n */\nexport function getFunctionLoader<Options>(\n fn: LoaderDefinitionFunction<Options>,\n options: Options,\n) {\n return {\n // We use `__filename` as the loader, so Webpack will execute the loader in\n // this file, with the actual function in the options.\n loader: __filename,\n options: {\n fn,\n ...options,\n },\n };\n}\n\n// When running as CJS, we need to export the loader as a default export, since\n// `tsup` exports it as `loader_default`.\n// istanbul ignore next 3\n// eslint-disable-next-line n/no-process-env\nif (typeof module !== 'undefined' && process?.env?.NODE_ENV !== 'test') {\n module.exports = loader;\n module.exports.getFunctionLoader = getFunctionLoader;\n module.exports.raw = true;\n}\n"]}
1
+ {"version":3,"file":"function.mjs","sourceRoot":"","sources":["../../../src/webpack/loaders/function.ts"],"names":[],"mappings":";;;;AAaA;;;;;;GAMG;AACH,MAAM,MAAM,GAAoD,UAC9D,OAAO;IAEP,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IACjC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC;AAEtB;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAqC,EACrC,OAAgB;IAEhB,OAAO;QACL,2EAA2E;QAC3E,sDAAsD;QACtD,MAAM,8BAAY;QAClB,OAAO,EAAE;YACP,EAAE;YACF,GAAG,OAAO;SACX;KACF,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,yCAAyC;AACzC,yBAAyB;AACzB,4CAA4C;AAC5C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,MAAM,EAAE,CAAC;IACvE,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,OAAO,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IACrD,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import type { LoaderDefinitionFunction } from 'webpack';\n\n/**\n * Options for the function loader.\n */\nexport type FunctionLoaderOptions = {\n /**\n * The function to execute. This is bound to the loader context, so it can\n * access the loader options and other properties.\n */\n fn: LoaderDefinitionFunction;\n};\n\n/**\n * A loader that executes a function. See {@link getFunctionLoader} for more\n * information.\n *\n * @param content - The input file contents as a `Uint8Array`.\n * @returns The output of the function.\n */\nconst loader: LoaderDefinitionFunction<FunctionLoaderOptions> = function (\n content,\n) {\n const { fn } = this.getOptions();\n return fn.bind(this)(content);\n};\n\nexport default loader;\n\n/**\n * Get a loader that executes the given function. This is useful for executing\n * loaders without needing to pass a file to Webpack.\n *\n * @param fn - The function to execute.\n * @param options - The options to pass to the loader.\n * @returns The loader definition.\n */\nexport function getFunctionLoader<Options>(\n fn: LoaderDefinitionFunction<Options>,\n options: Options,\n) {\n return {\n // We use `__filename` as the loader, so Webpack will execute the loader in\n // this file, with the actual function in the options.\n loader: __filename,\n options: {\n fn,\n ...options,\n },\n };\n}\n\n// When running as CJS, we need to export the loader as a default export, since\n// `tsup` exports it as `loader_default`.\n// istanbul ignore next 3\n// eslint-disable-next-line n/no-process-env\nif (typeof module !== 'undefined' && process?.env?.NODE_ENV !== 'test') {\n module.exports = loader;\n module.exports.getFunctionLoader = getFunctionLoader;\n module.exports.raw = true;\n}\n"]}
@@ -53,23 +53,23 @@ export declare function getDefaultLoader({ legacy, sourceMap, }: ProcessedWebpac
53
53
  loader: string;
54
54
  options: {
55
55
  fn: import("webpack").LoaderDefinitionFunction<{
56
- transpilationMode: import("../builders").TranspilationModes.LocalAndDeps;
56
+ transpilationMode: import("../builders.cjs").TranspilationModes.LocalAndDeps;
57
57
  depsToTranspile: string[];
58
58
  writeManifest: boolean;
59
59
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
60
60
  } | {
61
- transpilationMode: import("../builders").TranspilationModes.LocalOnly | import("../builders").TranspilationModes.None;
61
+ transpilationMode: import("../builders.cjs").TranspilationModes.LocalOnly | import("../builders.cjs").TranspilationModes.None;
62
62
  depsToTranspile: unknown[];
63
63
  writeManifest: boolean;
64
64
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
65
65
  }, {}>;
66
66
  } & ({
67
- transpilationMode: import("../builders").TranspilationModes.LocalAndDeps;
67
+ transpilationMode: import("../builders.cjs").TranspilationModes.LocalAndDeps;
68
68
  depsToTranspile: string[];
69
69
  writeManifest: boolean;
70
70
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
71
71
  } | {
72
- transpilationMode: import("../builders").TranspilationModes.LocalOnly | import("../builders").TranspilationModes.None;
72
+ transpilationMode: import("../builders.cjs").TranspilationModes.LocalOnly | import("../builders.cjs").TranspilationModes.None;
73
73
  depsToTranspile: unknown[];
74
74
  writeManifest: boolean;
75
75
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
@@ -53,23 +53,23 @@ export declare function getDefaultLoader({ legacy, sourceMap, }: ProcessedWebpac
53
53
  loader: string;
54
54
  options: {
55
55
  fn: import("webpack").LoaderDefinitionFunction<{
56
- transpilationMode: import("../builders").TranspilationModes.LocalAndDeps;
56
+ transpilationMode: import("../builders.mjs").TranspilationModes.LocalAndDeps;
57
57
  depsToTranspile: string[];
58
58
  writeManifest: boolean;
59
59
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
60
60
  } | {
61
- transpilationMode: import("../builders").TranspilationModes.LocalOnly | import("../builders").TranspilationModes.None;
61
+ transpilationMode: import("../builders.mjs").TranspilationModes.LocalOnly | import("../builders.mjs").TranspilationModes.None;
62
62
  depsToTranspile: unknown[];
63
63
  writeManifest: boolean;
64
64
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
65
65
  }, {}>;
66
66
  } & ({
67
- transpilationMode: import("../builders").TranspilationModes.LocalAndDeps;
67
+ transpilationMode: import("../builders.mjs").TranspilationModes.LocalAndDeps;
68
68
  depsToTranspile: string[];
69
69
  writeManifest: boolean;
70
70
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
71
71
  } | {
72
- transpilationMode: import("../builders").TranspilationModes.LocalOnly | import("../builders").TranspilationModes.None;
72
+ transpilationMode: import("../builders.mjs").TranspilationModes.LocalOnly | import("../builders.mjs").TranspilationModes.None;
73
73
  depsToTranspile: unknown[];
74
74
  writeManifest: boolean;
75
75
  bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
@@ -1,3 +1,5 @@
1
+ import { createRequire as $createRequire } from "module";
2
+ const $require = $createRequire(import.meta.url);
1
3
  function $importDefault(module) {
2
4
  if (module?.__esModule) {
3
5
  return module.default;
@@ -13,40 +15,38 @@ import { dirname, resolve } from "path";
13
15
  import $stripAnsi from "strip-ansi/index.js";
14
16
  const stripAnsi = $importDefault($stripAnsi);
15
17
  import { browserify, getFunctionLoader } from "./loaders/index.mjs";
16
- export const BROWSERSLIST_FILE = resolve(dirname(
17
- // eslint-disable-next-line n/no-extraneous-require
18
- require.resolve('@metamask/snaps-cli/package.json')), '.browserslistrc');
18
+ export const BROWSERSLIST_FILE = resolve(dirname($require.resolve('@metamask/snaps-cli/package.json')), '.browserslistrc');
19
19
  export const WEBPACK_FALLBACKS = {
20
- assert: require.resolve('assert/'),
21
- buffer: require.resolve('buffer/'),
22
- console: require.resolve('console-browserify'),
23
- constants: require.resolve('constants-browserify'),
24
- crypto: require.resolve('crypto-browserify'),
25
- domain: require.resolve('domain-browser'),
26
- events: require.resolve('events/'),
27
- http: require.resolve('stream-http'),
28
- https: require.resolve('https-browserify'),
29
- os: require.resolve('os-browserify/browser'),
30
- path: require.resolve('path-browserify'),
31
- punycode: require.resolve('punycode/'),
32
- process: require.resolve('process/browser'),
33
- querystring: require.resolve('querystring-es3'),
34
- stream: require.resolve('stream-browserify'),
20
+ assert: $require.resolve('assert/'),
21
+ buffer: $require.resolve('buffer/'),
22
+ console: $require.resolve('console-browserify'),
23
+ constants: $require.resolve('constants-browserify'),
24
+ crypto: $require.resolve('crypto-browserify'),
25
+ domain: $require.resolve('domain-browser'),
26
+ events: $require.resolve('events/'),
27
+ http: $require.resolve('stream-http'),
28
+ https: $require.resolve('https-browserify'),
29
+ os: $require.resolve('os-browserify/browser'),
30
+ path: $require.resolve('path-browserify'),
31
+ punycode: $require.resolve('punycode/'),
32
+ process: $require.resolve('process/browser'),
33
+ querystring: $require.resolve('querystring-es3'),
34
+ stream: $require.resolve('stream-browserify'),
35
35
  /* eslint-disable @typescript-eslint/naming-convention */
36
- _stream_duplex: require.resolve('readable-stream/lib/_stream_duplex'),
37
- _stream_passthrough: require.resolve('readable-stream/lib/_stream_passthrough'),
38
- _stream_readable: require.resolve('readable-stream/lib/_stream_readable'),
39
- _stream_transform: require.resolve('readable-stream/lib/_stream_transform'),
40
- _stream_writable: require.resolve('readable-stream/lib/_stream_writable'),
41
- string_decoder: require.resolve('string_decoder/'),
36
+ _stream_duplex: $require.resolve('readable-stream/lib/_stream_duplex'),
37
+ _stream_passthrough: $require.resolve('readable-stream/lib/_stream_passthrough'),
38
+ _stream_readable: $require.resolve('readable-stream/lib/_stream_readable'),
39
+ _stream_transform: $require.resolve('readable-stream/lib/_stream_transform'),
40
+ _stream_writable: $require.resolve('readable-stream/lib/_stream_writable'),
41
+ string_decoder: $require.resolve('string_decoder/'),
42
42
  /* eslint-enable @typescript-eslint/naming-convention */
43
- sys: require.resolve('util/'),
44
- timers: require.resolve('timers-browserify'),
45
- tty: require.resolve('tty-browserify'),
46
- url: require.resolve('url/'),
47
- util: require.resolve('util/'),
48
- vm: require.resolve('vm-browserify'),
49
- zlib: require.resolve('browserify-zlib'),
43
+ sys: $require.resolve('util/'),
44
+ timers: $require.resolve('timers-browserify'),
45
+ tty: $require.resolve('tty-browserify'),
46
+ url: $require.resolve('url/'),
47
+ util: $require.resolve('util/'),
48
+ vm: $require.resolve('vm-browserify'),
49
+ zlib: $require.resolve('browserify-zlib'),
50
50
  };
51
51
  /**
52
52
  * Get the default loader for JavaScript and TypeScript files, based on the
@@ -81,7 +81,7 @@ export async function getDefaultLoader({ legacy, sourceMap, }) {
81
81
  * This is a Webpack loader that uses the `SWC` compiler, which is a much
82
82
  * faster alternative to Babel and TypeScript's own compiler.
83
83
  */
84
- loader: require.resolve('swc-loader'),
84
+ loader: $require.resolve('swc-loader'),
85
85
  /**
86
86
  * The options for the `swc-loader`. These can be overridden in the
87
87
  * `.swcrc` file.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../src/webpack/utils.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,wBAAwB;;;AAEhD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,WAAW;AACpC,OAAO,EAAE,cAAc,EAAE,eAAe;AAExC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa;AACxC,OAAO,UAAS,4BAAmB;;AAInC,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,4BAAkB;AAE1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CACtC,OAAO;AACL,mDAAmD;AACnD,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CACpD,EACD,iBAAiB,CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAClC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC;IAC9C,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC;IAClD,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC;IAC5C,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACzC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAClC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC;IACpC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;IAC1C,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,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,KAAiB;IAC7D,MAAM,OAAO,GAAG,QAAQ,QAAQ,WAAW,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;IAClE,OAAO,wDAAwD,OAAO,YAAY,CAAC;AACrF,CAAC","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 * This tells the parser to transpile JSX.\n *\n * @see https://swc.rs/docs/configuration/compilation#jscparser\n * @see https://swc.rs/docs/configuration/compilation#jscparserjsx\n */\n tsx: true,\n },\n\n transform: {\n react: {\n /**\n * This tells SWC to use the JSX runtime, instead of the\n * `createElement` function.\n *\n * @see https://swc.rs/docs/configuration/compilation#jsctransformreact\n */\n runtime: 'automatic',\n\n /**\n * This tells SWC to import the JSX runtime from the\n * `@metamask/snaps-sdk` package, instead of the default React\n * package.\n *\n * @see https://swc.rs/docs/configuration/compilation#jsctransformreact\n */\n importSource: '@metamask/snaps-sdk',\n\n /**\n * This tells SWC to use `Object.assign` and `Object.create` for\n * JSX spread attributes, instead of the default behavior.\n *\n * @see https://swc.rs/docs/configuration/compilation#jsctransformreact\n */\n useBuiltins: true,\n },\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"]}
1
+ {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../src/webpack/utils.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,wBAAwB;;;AAEhD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,WAAW;AACpC,OAAO,EAAE,cAAc,EAAE,eAAe;AAExC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa;AACxC,OAAO,UAAS,4BAAmB;;AAInC,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,4BAAkB;AAE1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CACtC,OAAO,kBAEW,kCAAkC,EACnD,EACD,iBAAiB,CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,mBAAkB,SAAS,CAAC;IAClC,MAAM,mBAAkB,SAAS,CAAC;IAClC,OAAO,mBAAkB,oBAAoB,CAAC;IAC9C,SAAS,mBAAkB,sBAAsB,CAAC;IAClD,MAAM,mBAAkB,mBAAmB,CAAC;IAC5C,MAAM,mBAAkB,gBAAgB,CAAC;IACzC,MAAM,mBAAkB,SAAS,CAAC;IAClC,IAAI,mBAAkB,aAAa,CAAC;IACpC,KAAK,mBAAkB,kBAAkB,CAAC;IAC1C,EAAE,mBAAkB,uBAAuB,CAAC;IAC5C,IAAI,mBAAkB,iBAAiB,CAAC;IAC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,aAAa,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI;YACrD,iBAAiB,EAAE,iBAAiB,GAAG,mBAAmB;SAC3D,CAAC;IACJ,CAAC,EACD;QACE,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;QACxC,iBAAiB,EAAE,aAAa;KACjC,CACF,CAAC,aAAa,CAAC;AAClB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,MAAc,EACd,aAAa,GAAG,MAAM;IAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,+DAA+D;IAC/D,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACnB,MAAM,UAAU,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;QACxD,OAAO,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,KAAiB;IAC7D,MAAM,OAAO,GAAG,QAAQ,QAAQ,WAAW,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;IAClE,OAAO,wDAAwD,OAAO,YAAY,CAAC;AACrF,CAAC","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 * This tells the parser to transpile JSX.\n *\n * @see https://swc.rs/docs/configuration/compilation#jscparser\n * @see https://swc.rs/docs/configuration/compilation#jscparserjsx\n */\n tsx: true,\n },\n\n transform: {\n react: {\n /**\n * This tells SWC to use the JSX runtime, instead of the\n * `createElement` function.\n *\n * @see https://swc.rs/docs/configuration/compilation#jsctransformreact\n */\n runtime: 'automatic',\n\n /**\n * This tells SWC to import the JSX runtime from the\n * `@metamask/snaps-sdk` package, instead of the default React\n * package.\n *\n * @see https://swc.rs/docs/configuration/compilation#jsctransformreact\n */\n importSource: '@metamask/snaps-sdk',\n\n /**\n * This tells SWC to use `Object.assign` and `Object.create` for\n * JSX spread attributes, instead of the default behavior.\n *\n * @see https://swc.rs/docs/configuration/compilation#jsctransformreact\n */\n useBuiltins: true,\n },\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"]}
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@metamask/snaps-cli",
3
- "version": "6.3.2",
4
- "description": "A CLI for developing MetaMask Snaps.",
3
+ "version": "6.3.4",
4
+ "description": "A CLI for developing MetaMask Snaps",
5
+ "keywords": [
6
+ "MetaMask",
7
+ "Snaps",
8
+ "Ethereum"
9
+ ],
10
+ "homepage": "https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/MetaMask/snaps/issues"
13
+ },
5
14
  "repository": {
6
15
  "type": "git",
7
16
  "url": "https://github.com/MetaMask/snaps.git"
@@ -33,22 +42,26 @@
33
42
  ".browserslistrc"
34
43
  ],
35
44
  "scripts": {
36
- "build": "ts-bridge --project tsconfig.build.json --verbose --no-references && yarn build:chmod && yarn build:readme",
45
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
37
46
  "build:chmod": "chmod +x ./dist/main.mjs && chmod +x ./dist/main.js",
47
+ "build:post": "yarn build:chmod && yarn build:readme",
38
48
  "build:readme": "node ./scripts/updateReadme.js",
39
49
  "build:watch": "tsc-watch --onSuccess 'yarn build:chmod'",
40
- "test": "jest --runInBand && yarn posttest",
41
- "posttest": "jest-it-up",
42
- "test:watch": "yarn test --watch",
43
- "test:ci": "yarn test",
44
- "lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-cli",
50
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/snaps-cli",
51
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/snaps-cli",
52
+ "lint": "yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies",
53
+ "lint:ci": "yarn lint",
54
+ "lint:dependencies": "depcheck",
45
55
  "lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
46
- "lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
47
- "lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies",
48
56
  "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
57
+ "lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
49
58
  "publish:preview": "yarn npm publish --tag preview",
50
- "lint:ci": "yarn lint",
51
- "lint:dependencies": "depcheck"
59
+ "since-latest-release": "../../scripts/since-latest-release.sh",
60
+ "test": "jest --reporters=jest-silent-reporter",
61
+ "test:clean": "jest --clearCache",
62
+ "test:post": "jest-it-up",
63
+ "test:verbose": "jest --verbose",
64
+ "test:watch": "jest --watch"
52
65
  },
53
66
  "dependencies": {
54
67
  "@babel/core": "^7.23.2",
@@ -59,9 +72,9 @@
59
72
  "@babel/plugin-transform-runtime": "^7.13.2",
60
73
  "@babel/preset-env": "^7.23.2",
61
74
  "@babel/preset-typescript": "^7.23.2",
62
- "@metamask/snaps-sdk": "^6.4.0",
63
- "@metamask/snaps-utils": "^8.1.0",
64
- "@metamask/snaps-webpack-plugin": "^4.1.1",
75
+ "@metamask/snaps-sdk": "^6.7.0",
76
+ "@metamask/snaps-utils": "^8.3.0",
77
+ "@metamask/snaps-webpack-plugin": "^4.1.2",
65
78
  "@metamask/superstruct": "^3.1.0",
66
79
  "@metamask/utils": "^9.2.1",
67
80
  "@swc/core": "1.3.78",
@@ -109,7 +122,7 @@
109
122
  "@metamask/eslint-config-nodejs": "^12.1.0",
110
123
  "@metamask/eslint-config-typescript": "^12.1.0",
111
124
  "@swc/jest": "^0.2.26",
112
- "@ts-bridge/cli": "^0.4.4",
125
+ "@ts-bridge/cli": "^0.5.1",
113
126
  "@types/browserify": "^12.0.37",
114
127
  "@types/jest": "^27.5.1",
115
128
  "@types/node": "18.14.2",
@@ -131,9 +144,10 @@
131
144
  "execa": "^5.1.1",
132
145
  "jest": "^29.0.2",
133
146
  "jest-it-up": "^2.0.0",
147
+ "jest-silent-reporter": "^0.6.0",
134
148
  "memfs": "^3.4.13",
135
- "prettier": "^2.7.1",
136
- "prettier-plugin-packagejson": "^2.2.11",
149
+ "prettier": "^2.8.8",
150
+ "prettier-plugin-packagejson": "^2.5.2",
137
151
  "ts-node": "^10.9.1",
138
152
  "tsc-watch": "^4.5.0",
139
153
  "typescript": "~5.3.3"