@metamask/snaps-cli 6.3.0 → 6.3.2

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.
Files changed (636) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/__fixtures__/configs/cjs.cjs +9 -0
  3. package/dist/__fixtures__/configs/cjs.cjs.map +1 -0
  4. package/dist/__fixtures__/configs/cjs.d.cts +2 -0
  5. package/dist/__fixtures__/configs/cjs.d.cts.map +1 -0
  6. package/dist/__fixtures__/configs/cjs.d.mts +2 -0
  7. package/dist/__fixtures__/configs/cjs.d.mts.map +1 -0
  8. package/dist/__fixtures__/configs/cjs.mjs +8 -0
  9. package/dist/__fixtures__/configs/cjs.mjs.map +1 -0
  10. package/dist/__fixtures__/configs/esm.cjs +7 -0
  11. package/dist/__fixtures__/configs/esm.cjs.map +1 -0
  12. package/dist/__fixtures__/configs/esm.d.cts +4 -0
  13. package/dist/__fixtures__/configs/esm.d.cts.map +1 -0
  14. package/dist/__fixtures__/configs/esm.d.mts +4 -0
  15. package/dist/__fixtures__/configs/esm.d.mts.map +1 -0
  16. package/dist/__fixtures__/configs/esm.mjs +5 -0
  17. package/dist/__fixtures__/configs/esm.mjs.map +1 -0
  18. package/dist/__fixtures__/configs/invalid.cjs +8 -0
  19. package/dist/__fixtures__/configs/invalid.cjs.map +1 -0
  20. package/dist/__fixtures__/configs/invalid.d.cts +4 -0
  21. package/dist/__fixtures__/configs/invalid.d.cts.map +1 -0
  22. package/dist/__fixtures__/configs/invalid.d.mts +4 -0
  23. package/dist/__fixtures__/configs/invalid.d.mts.map +1 -0
  24. package/dist/__fixtures__/configs/invalid.mjs +6 -0
  25. package/dist/__fixtures__/configs/invalid.mjs.map +1 -0
  26. package/dist/__fixtures__/configs/javascript/snap.config.cjs +6 -0
  27. package/dist/__fixtures__/configs/javascript/snap.config.cjs.map +1 -0
  28. package/dist/__fixtures__/configs/javascript/snap.config.d.cts +2 -0
  29. package/dist/__fixtures__/configs/javascript/snap.config.d.cts.map +1 -0
  30. package/dist/__fixtures__/configs/javascript/snap.config.d.mts +2 -0
  31. package/dist/__fixtures__/configs/javascript/snap.config.d.mts.map +1 -0
  32. package/dist/__fixtures__/configs/javascript/snap.config.mjs +5 -0
  33. package/dist/__fixtures__/configs/javascript/snap.config.mjs.map +1 -0
  34. package/dist/__fixtures__/configs/typescript/snap.config.cjs +7 -0
  35. package/dist/__fixtures__/configs/typescript/snap.config.cjs.map +1 -0
  36. package/dist/__fixtures__/configs/typescript/snap.config.d.cts +4 -0
  37. package/dist/__fixtures__/configs/typescript/snap.config.d.cts.map +1 -0
  38. package/dist/__fixtures__/configs/typescript/snap.config.d.mts +4 -0
  39. package/dist/__fixtures__/configs/typescript/snap.config.d.mts.map +1 -0
  40. package/dist/__fixtures__/configs/typescript/snap.config.mjs +5 -0
  41. package/dist/__fixtures__/configs/typescript/snap.config.mjs.map +1 -0
  42. package/dist/builders.cjs +132 -0
  43. package/dist/builders.cjs.map +1 -0
  44. package/dist/{types/builders.d.ts → builders.d.cts} +2 -1
  45. package/dist/builders.d.cts.map +1 -0
  46. package/dist/builders.d.mts +9 -0
  47. package/dist/builders.d.mts.map +1 -0
  48. package/dist/builders.mjs +127 -8
  49. package/dist/builders.mjs.map +1 -1
  50. package/dist/cli.cjs +71 -0
  51. package/dist/cli.cjs.map +1 -0
  52. package/dist/{types/cli.d.ts → cli.d.cts} +1 -0
  53. package/dist/cli.d.cts.map +1 -0
  54. package/dist/cli.d.mts +16 -0
  55. package/dist/cli.d.mts.map +1 -0
  56. package/dist/cli.mjs +69 -20
  57. package/dist/cli.mjs.map +1 -1
  58. package/dist/commands/build/build.cjs +53 -0
  59. package/dist/commands/build/build.cjs.map +1 -0
  60. package/dist/{types/commands/build/build.d.ts → commands/build/build.d.cts} +3 -1
  61. package/dist/commands/build/build.d.cts.map +1 -0
  62. package/dist/commands/build/build.d.mts +12 -0
  63. package/dist/commands/build/build.d.mts.map +1 -0
  64. package/dist/commands/build/build.mjs +48 -28
  65. package/dist/commands/build/build.mjs.map +1 -1
  66. package/dist/commands/build/implementation.cjs +31 -0
  67. package/dist/commands/build/implementation.cjs.map +1 -0
  68. package/dist/{types/commands/build/implementation.d.ts → commands/build/implementation.d.cts} +3 -2
  69. package/dist/commands/build/implementation.d.cts.map +1 -0
  70. package/dist/commands/build/implementation.d.mts +11 -0
  71. package/dist/commands/build/implementation.d.mts.map +1 -0
  72. package/dist/commands/build/implementation.mjs +26 -27
  73. package/dist/commands/build/implementation.mjs.map +1 -1
  74. package/dist/commands/build/index.cjs +44 -0
  75. package/dist/commands/build/index.cjs.map +1 -0
  76. package/dist/{types/commands/eval/index.d.ts → commands/build/index.d.cts} +4 -3
  77. package/dist/commands/build/index.d.cts.map +1 -0
  78. package/dist/{types/commands/manifest/index.d.ts → commands/build/index.d.mts} +4 -3
  79. package/dist/commands/build/index.d.mts.map +1 -0
  80. package/dist/commands/build/index.mjs +23 -31
  81. package/dist/commands/build/index.mjs.map +1 -1
  82. package/dist/commands/eval/__test__/browserify/bad/snap.config.cjs +10 -0
  83. package/dist/commands/eval/__test__/browserify/bad/snap.config.cjs.map +1 -0
  84. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.cts +4 -0
  85. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.cts.map +1 -0
  86. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.mts +4 -0
  87. package/dist/commands/eval/__test__/browserify/bad/snap.config.d.mts.map +1 -0
  88. package/dist/commands/eval/__test__/browserify/bad/snap.config.mjs +8 -0
  89. package/dist/commands/eval/__test__/browserify/bad/snap.config.mjs.map +1 -0
  90. package/dist/commands/eval/__test__/browserify/good/snap.config.cjs +10 -0
  91. package/dist/commands/eval/__test__/browserify/good/snap.config.cjs.map +1 -0
  92. package/dist/commands/eval/__test__/browserify/good/snap.config.d.cts +4 -0
  93. package/dist/commands/eval/__test__/browserify/good/snap.config.d.cts.map +1 -0
  94. package/dist/commands/eval/__test__/browserify/good/snap.config.d.mts +4 -0
  95. package/dist/commands/eval/__test__/browserify/good/snap.config.d.mts.map +1 -0
  96. package/dist/commands/eval/__test__/browserify/good/snap.config.mjs +8 -0
  97. package/dist/commands/eval/__test__/browserify/good/snap.config.mjs.map +1 -0
  98. package/dist/commands/eval/__test__/webpack/bad/snap.config.cjs +12 -0
  99. package/dist/commands/eval/__test__/webpack/bad/snap.config.cjs.map +1 -0
  100. package/dist/commands/eval/__test__/webpack/bad/snap.config.d.cts +4 -0
  101. package/dist/commands/eval/__test__/webpack/bad/snap.config.d.cts.map +1 -0
  102. package/dist/commands/eval/__test__/webpack/bad/snap.config.d.mts +4 -0
  103. package/dist/commands/eval/__test__/webpack/bad/snap.config.d.mts.map +1 -0
  104. package/dist/commands/eval/__test__/webpack/bad/snap.config.mjs +10 -0
  105. package/dist/commands/eval/__test__/webpack/bad/snap.config.mjs.map +1 -0
  106. package/dist/commands/eval/__test__/webpack/good/snap.config.cjs +12 -0
  107. package/dist/commands/eval/__test__/webpack/good/snap.config.cjs.map +1 -0
  108. package/dist/commands/eval/__test__/webpack/good/snap.config.d.cts +4 -0
  109. package/dist/commands/eval/__test__/webpack/good/snap.config.d.cts.map +1 -0
  110. package/dist/commands/eval/__test__/webpack/good/snap.config.d.mts +4 -0
  111. package/dist/commands/eval/__test__/webpack/good/snap.config.d.mts.map +1 -0
  112. package/dist/commands/eval/__test__/webpack/good/snap.config.mjs +10 -0
  113. package/dist/commands/eval/__test__/webpack/good/snap.config.mjs.map +1 -0
  114. package/dist/commands/eval/__test__/webpack/snap.config.cjs +8 -0
  115. package/dist/commands/eval/__test__/webpack/snap.config.cjs.map +1 -0
  116. package/dist/commands/eval/__test__/webpack/snap.config.d.cts +4 -0
  117. package/dist/commands/eval/__test__/webpack/snap.config.d.cts.map +1 -0
  118. package/dist/commands/eval/__test__/webpack/snap.config.d.mts +4 -0
  119. package/dist/commands/eval/__test__/webpack/snap.config.d.mts.map +1 -0
  120. package/dist/commands/eval/__test__/webpack/snap.config.mjs +6 -0
  121. package/dist/commands/eval/__test__/webpack/snap.config.mjs.map +1 -0
  122. package/dist/commands/eval/eval.cjs +57 -0
  123. package/dist/commands/eval/eval.cjs.map +1 -0
  124. package/dist/{types/commands/eval/eval.d.ts → commands/eval/eval.d.cts} +2 -1
  125. package/dist/commands/eval/eval.d.cts.map +1 -0
  126. package/dist/commands/eval/eval.d.mts +15 -0
  127. package/dist/commands/eval/eval.d.mts.map +1 -0
  128. package/dist/commands/eval/eval.mjs +52 -17
  129. package/dist/commands/eval/eval.mjs.map +1 -1
  130. package/dist/commands/eval/implementation.cjs +30 -0
  131. package/dist/commands/eval/implementation.cjs.map +1 -0
  132. package/dist/{types/commands/eval/implementation.d.ts → commands/eval/implementation.d.cts} +2 -0
  133. package/dist/commands/eval/implementation.d.cts.map +1 -0
  134. package/dist/commands/eval/implementation.d.mts +11 -0
  135. package/dist/commands/eval/implementation.d.mts.map +1 -0
  136. package/dist/commands/eval/implementation.mjs +26 -8
  137. package/dist/commands/eval/implementation.mjs.map +1 -1
  138. package/dist/commands/eval/index.cjs +35 -0
  139. package/dist/commands/eval/index.cjs.map +1 -0
  140. package/dist/commands/eval/index.d.cts +11 -0
  141. package/dist/commands/eval/index.d.cts.map +1 -0
  142. package/dist/commands/eval/index.d.mts +11 -0
  143. package/dist/commands/eval/index.d.mts.map +1 -0
  144. package/dist/commands/eval/index.mjs +14 -20
  145. package/dist/commands/eval/index.mjs.map +1 -1
  146. package/dist/commands/index.cjs +19 -0
  147. package/dist/commands/index.cjs.map +1 -0
  148. package/dist/{types/commands/index.d.ts → commands/index.d.cts} +1 -0
  149. package/dist/commands/index.d.cts.map +1 -0
  150. package/dist/commands/index.d.mts +9 -0
  151. package/dist/commands/index.d.mts.map +1 -0
  152. package/dist/commands/index.mjs +13 -38
  153. package/dist/commands/index.mjs.map +1 -1
  154. package/dist/commands/manifest/implementation.cjs +64 -0
  155. package/dist/commands/manifest/implementation.cjs.map +1 -0
  156. package/dist/{types/commands/manifest/implementation.d.ts → commands/manifest/implementation.d.cts} +3 -1
  157. package/dist/commands/manifest/implementation.d.cts.map +1 -0
  158. package/dist/commands/manifest/implementation.d.mts +14 -0
  159. package/dist/commands/manifest/implementation.d.mts.map +1 -0
  160. package/dist/commands/manifest/implementation.mjs +60 -16
  161. package/dist/commands/manifest/implementation.mjs.map +1 -1
  162. package/dist/commands/manifest/index.cjs +35 -0
  163. package/dist/commands/manifest/index.cjs.map +1 -0
  164. package/dist/commands/manifest/index.d.cts +11 -0
  165. package/dist/commands/manifest/index.d.cts.map +1 -0
  166. package/dist/commands/manifest/index.d.mts +11 -0
  167. package/dist/commands/manifest/index.d.mts.map +1 -0
  168. package/dist/commands/manifest/index.mjs +14 -20
  169. package/dist/commands/manifest/index.mjs.map +1 -1
  170. package/dist/commands/manifest/manifest.cjs +57 -0
  171. package/dist/commands/manifest/manifest.cjs.map +1 -0
  172. package/dist/{types/commands/manifest/manifest.d.ts → commands/manifest/manifest.d.cts} +2 -1
  173. package/dist/commands/manifest/manifest.d.cts.map +1 -0
  174. package/dist/commands/manifest/manifest.d.mts +15 -0
  175. package/dist/commands/manifest/manifest.d.mts.map +1 -0
  176. package/dist/commands/manifest/manifest.mjs +52 -17
  177. package/dist/commands/manifest/manifest.mjs.map +1 -1
  178. package/dist/commands/serve/index.cjs +19 -0
  179. package/dist/commands/serve/index.cjs.map +1 -0
  180. package/dist/{types/commands/serve/index.d.ts → commands/serve/index.d.cts} +3 -2
  181. package/dist/commands/serve/index.d.cts.map +1 -0
  182. package/dist/{types/commands/build/index.d.ts → commands/serve/index.d.mts} +3 -3
  183. package/dist/commands/serve/index.d.mts.map +1 -0
  184. package/dist/commands/serve/index.mjs +12 -27
  185. package/dist/commands/serve/index.mjs.map +1 -1
  186. package/dist/commands/serve/serve.cjs +21 -0
  187. package/dist/commands/serve/serve.cjs.map +1 -0
  188. package/dist/{types/commands/serve/serve.d.ts → commands/serve/serve.d.cts} +2 -1
  189. package/dist/commands/serve/serve.d.cts.map +1 -0
  190. package/dist/commands/serve/serve.d.mts +17 -0
  191. package/dist/commands/serve/serve.d.mts.map +1 -0
  192. package/dist/commands/serve/serve.mjs +16 -27
  193. package/dist/commands/serve/serve.mjs.map +1 -1
  194. package/dist/commands/watch/implementation.cjs +38 -0
  195. package/dist/{chunk-BAEGXYL7.mjs.map → commands/watch/implementation.cjs.map} +1 -1
  196. package/dist/{types/commands/watch/implementation.d.ts → commands/watch/implementation.d.cts} +4 -3
  197. package/dist/commands/watch/implementation.d.cts.map +1 -0
  198. package/dist/commands/watch/implementation.d.mts +15 -0
  199. package/dist/commands/watch/implementation.d.mts.map +1 -0
  200. package/dist/commands/watch/implementation.mjs +33 -27
  201. package/dist/commands/watch/implementation.mjs.map +1 -1
  202. package/dist/commands/watch/index.cjs +49 -0
  203. package/dist/commands/watch/index.cjs.map +1 -0
  204. package/dist/commands/watch/index.d.cts +11 -0
  205. package/dist/commands/watch/index.d.cts.map +1 -0
  206. package/dist/commands/watch/index.d.mts +11 -0
  207. package/dist/commands/watch/index.d.mts.map +1 -0
  208. package/dist/commands/watch/index.mjs +28 -31
  209. package/dist/commands/watch/index.mjs.map +1 -1
  210. package/dist/commands/watch/watch.cjs +49 -0
  211. package/dist/commands/watch/watch.cjs.map +1 -0
  212. package/dist/{types/commands/watch/watch.d.ts → commands/watch/watch.d.cts} +2 -1
  213. package/dist/commands/watch/watch.d.cts.map +1 -0
  214. package/dist/commands/watch/watch.d.mts +20 -0
  215. package/dist/commands/watch/watch.d.mts.map +1 -0
  216. package/dist/commands/watch/watch.mjs +44 -28
  217. package/dist/commands/watch/watch.mjs.map +1 -1
  218. package/dist/config.cjs +334 -0
  219. package/dist/config.cjs.map +1 -0
  220. package/dist/{types/config.d.ts → config.d.cts} +44 -43
  221. package/dist/config.d.cts.map +1 -0
  222. package/dist/config.d.mts +821 -0
  223. package/dist/config.d.mts.map +1 -0
  224. package/dist/config.mjs +322 -35
  225. package/dist/config.mjs.map +1 -1
  226. package/dist/errors.cjs +38 -0
  227. package/dist/errors.cjs.map +1 -0
  228. package/dist/{types/errors.d.ts → errors.d.cts} +1 -0
  229. package/dist/errors.d.cts.map +1 -0
  230. package/dist/errors.d.mts +26 -0
  231. package/dist/errors.d.mts.map +1 -0
  232. package/dist/errors.mjs +32 -11
  233. package/dist/errors.mjs.map +1 -1
  234. package/dist/index.cjs +39 -0
  235. package/dist/index.cjs.map +1 -0
  236. package/dist/index.d.cts +6 -0
  237. package/dist/index.d.cts.map +1 -0
  238. package/dist/index.d.mts +6 -0
  239. package/dist/index.d.mts.map +1 -0
  240. package/dist/index.mjs +4 -44
  241. package/dist/index.mjs.map +1 -1
  242. package/dist/main.cjs +24 -0
  243. package/dist/main.cjs.map +1 -0
  244. package/dist/main.d.cts +3 -0
  245. package/dist/main.d.cts.map +1 -0
  246. package/dist/main.d.mts +3 -0
  247. package/dist/main.d.mts.map +1 -0
  248. package/dist/main.mjs +15 -45
  249. package/dist/main.mjs.map +1 -1
  250. package/dist/structs.cjs +31 -0
  251. package/dist/structs.cjs.map +1 -0
  252. package/dist/{types/structs.d.ts → structs.d.cts} +1 -0
  253. package/dist/structs.d.cts.map +1 -0
  254. package/dist/structs.d.mts +21 -0
  255. package/dist/structs.d.mts.map +1 -0
  256. package/dist/structs.mjs +26 -7
  257. package/dist/structs.mjs.map +1 -1
  258. package/dist/utils/cli.cjs +52 -0
  259. package/dist/utils/cli.cjs.map +1 -0
  260. package/dist/{types/utils/cli.d.ts → utils/cli.d.cts} +1 -0
  261. package/dist/utils/cli.d.cts.map +1 -0
  262. package/dist/utils/cli.d.mts +18 -0
  263. package/dist/utils/cli.d.mts.map +1 -0
  264. package/dist/utils/cli.mjs +43 -13
  265. package/dist/utils/cli.mjs.map +1 -1
  266. package/dist/utils/errors.cjs +49 -0
  267. package/dist/utils/errors.cjs.map +1 -0
  268. package/dist/{types/utils/errors.d.ts → utils/errors.d.cts} +1 -0
  269. package/dist/utils/errors.d.cts.map +1 -0
  270. package/dist/utils/errors.d.mts +24 -0
  271. package/dist/utils/errors.d.mts.map +1 -0
  272. package/dist/utils/errors.mjs +43 -10
  273. package/dist/utils/errors.mjs.map +1 -1
  274. package/dist/utils/index.cjs +23 -0
  275. package/dist/utils/index.cjs.map +1 -0
  276. package/dist/utils/index.d.cts +7 -0
  277. package/dist/utils/index.d.cts.map +1 -0
  278. package/dist/utils/index.d.mts +7 -0
  279. package/dist/utils/index.d.mts.map +1 -0
  280. package/dist/utils/index.mjs +6 -46
  281. package/dist/utils/index.mjs.map +1 -1
  282. package/dist/utils/legacy.cjs +53 -0
  283. package/dist/utils/legacy.cjs.map +1 -0
  284. package/dist/{types/utils/legacy.d.ts → utils/legacy.d.cts} +2 -1
  285. package/dist/utils/legacy.d.cts.map +1 -0
  286. package/dist/utils/legacy.d.mts +28 -0
  287. package/dist/utils/legacy.d.mts.map +1 -0
  288. package/dist/utils/legacy.mjs +46 -12
  289. package/dist/utils/legacy.mjs.map +1 -1
  290. package/dist/utils/logging.cjs +48 -0
  291. package/dist/utils/logging.cjs.map +1 -0
  292. package/dist/{types/utils/logging.d.ts → utils/logging.d.cts} +2 -1
  293. package/dist/utils/logging.d.cts.map +1 -0
  294. package/dist/utils/logging.d.mts +23 -0
  295. package/dist/utils/logging.d.mts.map +1 -0
  296. package/dist/utils/logging.mjs +42 -11
  297. package/dist/utils/logging.mjs.map +1 -1
  298. package/dist/utils/path.cjs +17 -0
  299. package/dist/utils/path.cjs.map +1 -0
  300. package/dist/{types/utils/path.d.ts → utils/path.d.cts} +1 -0
  301. package/dist/utils/path.d.cts.map +1 -0
  302. package/dist/utils/path.d.mts +10 -0
  303. package/dist/utils/path.d.mts.map +1 -0
  304. package/dist/utils/path.mjs +12 -7
  305. package/dist/utils/path.mjs.map +1 -1
  306. package/dist/utils/steps.cjs +51 -0
  307. package/dist/utils/steps.cjs.map +1 -0
  308. package/dist/{types/utils/steps.d.ts → utils/steps.d.cts} +2 -1
  309. package/dist/utils/steps.d.cts.map +1 -0
  310. package/dist/utils/steps.d.mts +18 -0
  311. package/dist/utils/steps.d.mts.map +1 -0
  312. package/dist/utils/steps.mjs +51 -10
  313. package/dist/utils/steps.mjs.map +1 -1
  314. package/dist/webpack/compiler.cjs +19 -0
  315. package/dist/webpack/compiler.cjs.map +1 -0
  316. package/dist/{types/webpack/compiler.d.ts → webpack/compiler.d.cts} +3 -2
  317. package/dist/webpack/compiler.d.cts.map +1 -0
  318. package/dist/webpack/compiler.d.mts +11 -0
  319. package/dist/webpack/compiler.d.mts.map +1 -0
  320. package/dist/webpack/compiler.mjs +15 -24
  321. package/dist/webpack/compiler.mjs.map +1 -1
  322. package/dist/webpack/config.cjs +349 -0
  323. package/dist/webpack/config.cjs.map +1 -0
  324. package/dist/{types/webpack/config.d.ts → webpack/config.d.cts} +4 -3
  325. package/dist/webpack/config.d.cts.map +1 -0
  326. package/dist/webpack/config.d.mts +38 -0
  327. package/dist/webpack/config.d.mts.map +1 -0
  328. package/dist/webpack/config.mjs +349 -23
  329. package/dist/webpack/config.mjs.map +1 -1
  330. package/dist/webpack/index.cjs +21 -0
  331. package/dist/webpack/index.cjs.map +1 -0
  332. package/dist/webpack/index.d.cts +5 -0
  333. package/dist/webpack/index.d.cts.map +1 -0
  334. package/dist/webpack/index.d.mts +5 -0
  335. package/dist/webpack/index.d.mts.map +1 -0
  336. package/dist/webpack/index.mjs +4 -43
  337. package/dist/webpack/index.mjs.map +1 -1
  338. package/dist/webpack/loaders/browserify.cjs +84 -0
  339. package/dist/webpack/loaders/browserify.cjs.map +1 -0
  340. package/dist/{types/webpack/loaders/browserify.d.ts → webpack/loaders/browserify.d.cts} +4 -2
  341. package/dist/webpack/loaders/browserify.d.cts.map +1 -0
  342. package/dist/webpack/loaders/browserify.d.mts +18 -0
  343. package/dist/webpack/loaders/browserify.d.mts.map +1 -0
  344. package/dist/webpack/loaders/browserify.mjs +84 -17
  345. package/dist/webpack/loaders/browserify.mjs.map +1 -1
  346. package/dist/webpack/loaders/function.cjs +45 -0
  347. package/dist/webpack/loaders/function.cjs.map +1 -0
  348. package/dist/{types/webpack/loaders/function.d.ts → webpack/loaders/function.d.cts} +2 -1
  349. package/dist/webpack/loaders/function.d.cts.map +1 -0
  350. package/dist/webpack/loaders/function.d.mts +35 -0
  351. package/dist/webpack/loaders/function.d.mts.map +1 -0
  352. package/dist/webpack/loaders/function.mjs +39 -8
  353. package/dist/webpack/loaders/function.mjs.map +1 -1
  354. package/dist/webpack/loaders/index.cjs +26 -0
  355. package/dist/webpack/loaders/index.cjs.map +1 -0
  356. package/dist/webpack/loaders/index.d.cts +4 -0
  357. package/dist/webpack/loaders/index.d.cts.map +1 -0
  358. package/dist/webpack/loaders/index.d.mts +4 -0
  359. package/dist/webpack/loaders/index.d.mts.map +1 -0
  360. package/dist/webpack/loaders/index.mjs +3 -24
  361. package/dist/webpack/loaders/index.mjs.map +1 -1
  362. package/dist/webpack/loaders/wasm.cjs +103 -0
  363. package/dist/webpack/loaders/wasm.cjs.map +1 -0
  364. package/dist/{types/webpack/loaders/wasm.d.ts → webpack/loaders/wasm.d.cts} +2 -1
  365. package/dist/webpack/loaders/wasm.d.cts.map +1 -0
  366. package/dist/webpack/loaders/wasm.d.mts +43 -0
  367. package/dist/webpack/loaders/wasm.d.mts.map +1 -0
  368. package/dist/webpack/loaders/wasm.mjs +95 -14
  369. package/dist/webpack/loaders/wasm.mjs.map +1 -1
  370. package/dist/webpack/plugins.cjs +277 -0
  371. package/dist/webpack/plugins.cjs.map +1 -0
  372. package/dist/{types/webpack/plugins.d.ts → webpack/plugins.d.cts} +3 -2
  373. package/dist/webpack/plugins.d.cts.map +1 -0
  374. package/dist/webpack/plugins.d.mts +148 -0
  375. package/dist/webpack/plugins.d.mts.map +1 -0
  376. package/dist/webpack/plugins.mjs +270 -27
  377. package/dist/webpack/plugins.mjs.map +1 -1
  378. package/dist/webpack/server.cjs +144 -0
  379. package/dist/webpack/server.cjs.map +1 -0
  380. package/dist/{types/webpack/server.d.ts → webpack/server.d.cts} +5 -3
  381. package/dist/webpack/server.d.cts.map +1 -0
  382. package/dist/webpack/server.d.mts +32 -0
  383. package/dist/webpack/server.d.mts.map +1 -0
  384. package/dist/webpack/server.mjs +142 -9
  385. package/dist/webpack/server.mjs.map +1 -1
  386. package/dist/webpack/utils.cjs +359 -0
  387. package/dist/webpack/utils.cjs.map +1 -0
  388. package/dist/{types/webpack/utils.d.ts → webpack/utils.d.cts} +4 -3
  389. package/dist/webpack/utils.d.cts.map +1 -0
  390. package/dist/webpack/utils.d.mts +259 -0
  391. package/dist/webpack/utils.d.mts.map +1 -0
  392. package/dist/webpack/utils.mjs +350 -37
  393. package/dist/webpack/utils.mjs.map +1 -1
  394. package/package.json +22 -22
  395. package/dist/builders.js +0 -10
  396. package/dist/builders.js.map +0 -1
  397. package/dist/chunk-24QJ2ZUZ.mjs +0 -55
  398. package/dist/chunk-24QJ2ZUZ.mjs.map +0 -1
  399. package/dist/chunk-2P3D6FNV.mjs +0 -23
  400. package/dist/chunk-2P3D6FNV.mjs.map +0 -1
  401. package/dist/chunk-2ZBAKBVW.js +0 -28
  402. package/dist/chunk-2ZBAKBVW.js.map +0 -1
  403. package/dist/chunk-3WWFQLH4.mjs +0 -30
  404. package/dist/chunk-3WWFQLH4.mjs.map +0 -1
  405. package/dist/chunk-45LOTCC4.mjs +0 -1
  406. package/dist/chunk-45LOTCC4.mjs.map +0 -1
  407. package/dist/chunk-4A5QZUC7.mjs +0 -68
  408. package/dist/chunk-4A5QZUC7.mjs.map +0 -1
  409. package/dist/chunk-4JEJ7WKR.js +0 -61
  410. package/dist/chunk-4JEJ7WKR.js.map +0 -1
  411. package/dist/chunk-4QUVE3EK.js +0 -53
  412. package/dist/chunk-4QUVE3EK.js.map +0 -1
  413. package/dist/chunk-5IN3GGMV.js +0 -68
  414. package/dist/chunk-5IN3GGMV.js.map +0 -1
  415. package/dist/chunk-6ABGZTV7.mjs +0 -16
  416. package/dist/chunk-6ABGZTV7.mjs.map +0 -1
  417. package/dist/chunk-6EEZHGF5.js +0 -23
  418. package/dist/chunk-6EEZHGF5.js.map +0 -1
  419. package/dist/chunk-7H5FH7RY.js +0 -22
  420. package/dist/chunk-7H5FH7RY.js.map +0 -1
  421. package/dist/chunk-7RHK2YTB.mjs +0 -32
  422. package/dist/chunk-7RHK2YTB.mjs.map +0 -1
  423. package/dist/chunk-AQSQ7YYP.mjs +0 -24
  424. package/dist/chunk-AQSQ7YYP.mjs.map +0 -1
  425. package/dist/chunk-AZMQTZXZ.mjs +0 -28
  426. package/dist/chunk-AZMQTZXZ.mjs.map +0 -1
  427. package/dist/chunk-B3NNVTA6.js +0 -32
  428. package/dist/chunk-B3NNVTA6.js.map +0 -1
  429. package/dist/chunk-BAEGXYL7.mjs +0 -35
  430. package/dist/chunk-BALQOCUO.js +0 -22
  431. package/dist/chunk-BALQOCUO.js.map +0 -1
  432. package/dist/chunk-BYNQODL3.mjs +0 -23
  433. package/dist/chunk-BYNQODL3.mjs.map +0 -1
  434. package/dist/chunk-C44RRX3H.js +0 -18
  435. package/dist/chunk-C44RRX3H.js.map +0 -1
  436. package/dist/chunk-C46KEPAC.js +0 -37
  437. package/dist/chunk-C46KEPAC.js.map +0 -1
  438. package/dist/chunk-CB77QR32.js +0 -52
  439. package/dist/chunk-CB77QR32.js.map +0 -1
  440. package/dist/chunk-CZRGAFVI.mjs +0 -28
  441. package/dist/chunk-CZRGAFVI.mjs.map +0 -1
  442. package/dist/chunk-D2ZIM5W2.js +0 -370
  443. package/dist/chunk-D2ZIM5W2.js.map +0 -1
  444. package/dist/chunk-DBLADLQ4.js +0 -10
  445. package/dist/chunk-DBLADLQ4.js.map +0 -1
  446. package/dist/chunk-ERSRIVYH.mjs +0 -64
  447. package/dist/chunk-ERSRIVYH.mjs.map +0 -1
  448. package/dist/chunk-G62Q4YO5.js +0 -30
  449. package/dist/chunk-G62Q4YO5.js.map +0 -1
  450. package/dist/chunk-HAYK73YO.js +0 -23
  451. package/dist/chunk-HAYK73YO.js.map +0 -1
  452. package/dist/chunk-HLQEI6DV.js +0 -54
  453. package/dist/chunk-HLQEI6DV.js.map +0 -1
  454. package/dist/chunk-HLSCFGA7.mjs +0 -13
  455. package/dist/chunk-HLSCFGA7.mjs.map +0 -1
  456. package/dist/chunk-HOVEQTF3.mjs +0 -346
  457. package/dist/chunk-HOVEQTF3.mjs.map +0 -1
  458. package/dist/chunk-JAHNVVLT.mjs +0 -18
  459. package/dist/chunk-JAHNVVLT.mjs.map +0 -1
  460. package/dist/chunk-JCVSYVPD.mjs +0 -24
  461. package/dist/chunk-JCVSYVPD.mjs.map +0 -1
  462. package/dist/chunk-JL3URCHO.mjs +0 -53
  463. package/dist/chunk-JL3URCHO.mjs.map +0 -1
  464. package/dist/chunk-K26BOY6Z.mjs +0 -51
  465. package/dist/chunk-K26BOY6Z.mjs.map +0 -1
  466. package/dist/chunk-KLOPX6DO.js +0 -51
  467. package/dist/chunk-KLOPX6DO.js.map +0 -1
  468. package/dist/chunk-KWHAT6UJ.mjs +0 -22
  469. package/dist/chunk-KWHAT6UJ.mjs.map +0 -1
  470. package/dist/chunk-L72RLBV5.mjs +0 -37
  471. package/dist/chunk-L72RLBV5.mjs.map +0 -1
  472. package/dist/chunk-MECBOP7G.js +0 -35
  473. package/dist/chunk-MECBOP7G.js.map +0 -1
  474. package/dist/chunk-MR44GPM3.mjs +0 -135
  475. package/dist/chunk-MR44GPM3.mjs.map +0 -1
  476. package/dist/chunk-MR5TAGOG.mjs +0 -54
  477. package/dist/chunk-MR5TAGOG.mjs.map +0 -1
  478. package/dist/chunk-MUYXNION.js +0 -30
  479. package/dist/chunk-MUYXNION.js.map +0 -1
  480. package/dist/chunk-MXOKUCLH.js +0 -347
  481. package/dist/chunk-MXOKUCLH.js.map +0 -1
  482. package/dist/chunk-NGS23BTR.js +0 -13
  483. package/dist/chunk-NGS23BTR.js.map +0 -1
  484. package/dist/chunk-NOBUMOYX.mjs +0 -61
  485. package/dist/chunk-NOBUMOYX.mjs.map +0 -1
  486. package/dist/chunk-NR4OJOGX.mjs +0 -370
  487. package/dist/chunk-NR4OJOGX.mjs.map +0 -1
  488. package/dist/chunk-OIFTFHZ4.mjs +0 -30
  489. package/dist/chunk-OIFTFHZ4.mjs.map +0 -1
  490. package/dist/chunk-PDYQXXLP.js +0 -30
  491. package/dist/chunk-PDYQXXLP.js.map +0 -1
  492. package/dist/chunk-QAM2JJRA.mjs +0 -52
  493. package/dist/chunk-QAM2JJRA.mjs.map +0 -1
  494. package/dist/chunk-QHCKVO3P.js +0 -28
  495. package/dist/chunk-QHCKVO3P.js.map +0 -1
  496. package/dist/chunk-QMB2ZRWW.js +0 -16
  497. package/dist/chunk-QMB2ZRWW.js.map +0 -1
  498. package/dist/chunk-QMD3VO6R.mjs +0 -30
  499. package/dist/chunk-QMD3VO6R.mjs.map +0 -1
  500. package/dist/chunk-QRW2GKA3.mjs +0 -347
  501. package/dist/chunk-QRW2GKA3.mjs.map +0 -1
  502. package/dist/chunk-R77RJHC5.mjs +0 -44
  503. package/dist/chunk-R77RJHC5.mjs.map +0 -1
  504. package/dist/chunk-RANTKN66.js +0 -24
  505. package/dist/chunk-RANTKN66.js.map +0 -1
  506. package/dist/chunk-S7UP2YYF.js +0 -135
  507. package/dist/chunk-S7UP2YYF.js.map +0 -1
  508. package/dist/chunk-SQXMNT7M.js +0 -326
  509. package/dist/chunk-SQXMNT7M.js.map +0 -1
  510. package/dist/chunk-SYRWT2KT.mjs +0 -124
  511. package/dist/chunk-SYRWT2KT.mjs.map +0 -1
  512. package/dist/chunk-TDSL55B3.mjs +0 -10
  513. package/dist/chunk-TDSL55B3.mjs.map +0 -1
  514. package/dist/chunk-TJ2F3J6X.js +0 -31
  515. package/dist/chunk-TJ2F3J6X.js.map +0 -1
  516. package/dist/chunk-U4VFMIGO.js +0 -24
  517. package/dist/chunk-U4VFMIGO.js.map +0 -1
  518. package/dist/chunk-V6SYDSWM.mjs +0 -326
  519. package/dist/chunk-V6SYDSWM.mjs.map +0 -1
  520. package/dist/chunk-VXOV3ZCB.js +0 -1
  521. package/dist/chunk-VXOV3ZCB.js.map +0 -1
  522. package/dist/chunk-X3D3MHWF.js +0 -44
  523. package/dist/chunk-X3D3MHWF.js.map +0 -1
  524. package/dist/chunk-X7TESUC7.mjs +0 -22
  525. package/dist/chunk-X7TESUC7.mjs.map +0 -1
  526. package/dist/chunk-XGWLFH7Y.js +0 -41
  527. package/dist/chunk-XGWLFH7Y.js.map +0 -1
  528. package/dist/chunk-YCOC4VEP.js +0 -346
  529. package/dist/chunk-YCOC4VEP.js.map +0 -1
  530. package/dist/chunk-YCYGKEXF.mjs +0 -41
  531. package/dist/chunk-YCYGKEXF.mjs.map +0 -1
  532. package/dist/chunk-YGEAZQSC.js +0 -124
  533. package/dist/chunk-YGEAZQSC.js.map +0 -1
  534. package/dist/chunk-YQ2E7NEA.js +0 -64
  535. package/dist/chunk-YQ2E7NEA.js.map +0 -1
  536. package/dist/chunk-ZAW4ZWQX.mjs +0 -31
  537. package/dist/chunk-ZAW4ZWQX.mjs.map +0 -1
  538. package/dist/chunk-ZVUF6JDJ.js +0 -55
  539. package/dist/chunk-ZVUF6JDJ.js.map +0 -1
  540. package/dist/cli.js +0 -21
  541. package/dist/cli.js.map +0 -1
  542. package/dist/commands/build/build.js +0 -29
  543. package/dist/commands/build/build.js.map +0 -1
  544. package/dist/commands/build/implementation.js +0 -28
  545. package/dist/commands/build/implementation.js.map +0 -1
  546. package/dist/commands/build/index.js +0 -33
  547. package/dist/commands/build/index.js.map +0 -1
  548. package/dist/commands/eval/eval.js +0 -18
  549. package/dist/commands/eval/eval.js.map +0 -1
  550. package/dist/commands/eval/implementation.js +0 -9
  551. package/dist/commands/eval/implementation.js.map +0 -1
  552. package/dist/commands/eval/index.js +0 -22
  553. package/dist/commands/eval/index.js.map +0 -1
  554. package/dist/commands/index.js +0 -39
  555. package/dist/commands/index.js.map +0 -1
  556. package/dist/commands/manifest/implementation.js +0 -17
  557. package/dist/commands/manifest/implementation.js.map +0 -1
  558. package/dist/commands/manifest/index.js +0 -22
  559. package/dist/commands/manifest/index.js.map +0 -1
  560. package/dist/commands/manifest/manifest.js +0 -18
  561. package/dist/commands/manifest/manifest.js.map +0 -1
  562. package/dist/commands/serve/index.js +0 -29
  563. package/dist/commands/serve/index.js.map +0 -1
  564. package/dist/commands/serve/serve.js +0 -28
  565. package/dist/commands/serve/serve.js.map +0 -1
  566. package/dist/commands/watch/implementation.js +0 -28
  567. package/dist/commands/watch/implementation.js.map +0 -1
  568. package/dist/commands/watch/index.js +0 -33
  569. package/dist/commands/watch/index.js.map +0 -1
  570. package/dist/commands/watch/watch.js +0 -29
  571. package/dist/commands/watch/watch.js.map +0 -1
  572. package/dist/config.js +0 -36
  573. package/dist/config.js.map +0 -1
  574. package/dist/errors.js +0 -12
  575. package/dist/errors.js.map +0 -1
  576. package/dist/index.js +0 -45
  577. package/dist/index.js.map +0 -1
  578. package/dist/main.js +0 -49
  579. package/dist/main.js.map +0 -1
  580. package/dist/structs.js +0 -8
  581. package/dist/structs.js.map +0 -1
  582. package/dist/tsconfig.build.tsbuildinfo +0 -1
  583. package/dist/types/__fixtures__/configs/cjs.d.ts +0 -1
  584. package/dist/types/__fixtures__/configs/esm.d.ts +0 -3
  585. package/dist/types/__fixtures__/configs/invalid.d.ts +0 -3
  586. package/dist/types/__fixtures__/configs/javascript/snap.config.d.ts +0 -0
  587. package/dist/types/__fixtures__/configs/typescript/snap.config.d.ts +0 -3
  588. package/dist/types/commands/eval/__test__/browserify/bad/snap.config.d.ts +0 -3
  589. package/dist/types/commands/eval/__test__/browserify/good/snap.config.d.ts +0 -3
  590. package/dist/types/commands/eval/__test__/webpack/bad/snap.config.d.ts +0 -3
  591. package/dist/types/commands/eval/__test__/webpack/good/snap.config.d.ts +0 -3
  592. package/dist/types/commands/eval/__test__/webpack/snap.config.d.ts +0 -3
  593. package/dist/types/commands/watch/index.d.ts +0 -10
  594. package/dist/types/index.d.ts +0 -5
  595. package/dist/types/main.d.ts +0 -2
  596. package/dist/types/utils/index.d.ts +0 -6
  597. package/dist/types/webpack/index.d.ts +0 -4
  598. package/dist/types/webpack/loaders/index.d.ts +0 -3
  599. package/dist/types/yargs.d.js +0 -1
  600. package/dist/types/yargs.d.js.map +0 -1
  601. package/dist/types/yargs.d.mjs +0 -1
  602. package/dist/types/yargs.d.mjs.map +0 -1
  603. package/dist/utils/cli.js +0 -14
  604. package/dist/utils/cli.js.map +0 -1
  605. package/dist/utils/errors.js +0 -11
  606. package/dist/utils/errors.js.map +0 -1
  607. package/dist/utils/index.js +0 -47
  608. package/dist/utils/index.js.map +0 -1
  609. package/dist/utils/legacy.js +0 -13
  610. package/dist/utils/legacy.js.map +0 -1
  611. package/dist/utils/logging.js +0 -12
  612. package/dist/utils/logging.js.map +0 -1
  613. package/dist/utils/path.js +0 -8
  614. package/dist/utils/path.js.map +0 -1
  615. package/dist/utils/steps.js +0 -11
  616. package/dist/utils/steps.js.map +0 -1
  617. package/dist/webpack/compiler.js +0 -25
  618. package/dist/webpack/compiler.js.map +0 -1
  619. package/dist/webpack/config.js +0 -24
  620. package/dist/webpack/config.js.map +0 -1
  621. package/dist/webpack/index.js +0 -44
  622. package/dist/webpack/index.js.map +0 -1
  623. package/dist/webpack/loaders/browserify.js +0 -19
  624. package/dist/webpack/loaders/browserify.js.map +0 -1
  625. package/dist/webpack/loaders/function.js +0 -10
  626. package/dist/webpack/loaders/function.js.map +0 -1
  627. package/dist/webpack/loaders/index.js +0 -25
  628. package/dist/webpack/loaders/index.js.map +0 -1
  629. package/dist/webpack/loaders/wasm.js +0 -16
  630. package/dist/webpack/loaders/wasm.js.map +0 -1
  631. package/dist/webpack/plugins.js +0 -29
  632. package/dist/webpack/plugins.js.map +0 -1
  633. package/dist/webpack/server.js +0 -10
  634. package/dist/webpack/server.js.map +0 -1
  635. package/dist/webpack/utils.js +0 -39
  636. package/dist/webpack/utils.js.map +0 -1
@@ -0,0 +1,259 @@
1
+ /// <reference types="browserify" />
2
+ import type { Ora } from "ora/index.js";
3
+ import type { Configuration } from "webpack";
4
+ import type { ProcessedWebpackConfig } from "../config.mjs";
5
+ export declare const BROWSERSLIST_FILE: string;
6
+ export declare const WEBPACK_FALLBACKS: {
7
+ assert: string;
8
+ buffer: string;
9
+ console: string;
10
+ constants: string;
11
+ crypto: string;
12
+ domain: string;
13
+ events: string;
14
+ http: string;
15
+ https: string;
16
+ os: string;
17
+ path: string;
18
+ punycode: string;
19
+ process: string;
20
+ querystring: string;
21
+ stream: string;
22
+ _stream_duplex: string;
23
+ _stream_passthrough: string;
24
+ _stream_readable: string;
25
+ _stream_transform: string;
26
+ _stream_writable: string;
27
+ string_decoder: string;
28
+ sys: string;
29
+ timers: string;
30
+ tty: string;
31
+ url: string;
32
+ util: string;
33
+ vm: string;
34
+ zlib: string;
35
+ };
36
+ /**
37
+ * Get the default loader for JavaScript and TypeScript files, based on the
38
+ * config object.
39
+ *
40
+ * - If the `legacy` option is set, we use the custom `browserify` loader. This
41
+ * uses the legacy Browserify config to transpile the code.
42
+ * - Otherwise, we use the `swc-loader`. This is a Webpack loader that uses the
43
+ * `SWC` compiler, which is a much faster alternative to Babel and TypeScript's
44
+ * own compiler.
45
+ *
46
+ * @param config - The processed snap Webpack config.
47
+ * @param config.legacy - The legacy config object, if any.
48
+ * @param config.sourceMap - Whether to generate source maps.
49
+ * @see https://swc.rs/docs/usage/swc-loader
50
+ * @returns The default loader.
51
+ */
52
+ export declare function getDefaultLoader({ legacy, sourceMap, }: ProcessedWebpackConfig): Promise<{
53
+ loader: string;
54
+ options: {
55
+ fn: import("webpack").LoaderDefinitionFunction<{
56
+ transpilationMode: import("../builders").TranspilationModes.LocalAndDeps;
57
+ depsToTranspile: string[];
58
+ writeManifest: boolean;
59
+ bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
60
+ } | {
61
+ transpilationMode: import("../builders").TranspilationModes.LocalOnly | import("../builders").TranspilationModes.None;
62
+ depsToTranspile: unknown[];
63
+ writeManifest: boolean;
64
+ bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
65
+ }, {}>;
66
+ } & ({
67
+ transpilationMode: import("../builders").TranspilationModes.LocalAndDeps;
68
+ depsToTranspile: string[];
69
+ writeManifest: boolean;
70
+ bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
71
+ } | {
72
+ transpilationMode: import("../builders").TranspilationModes.LocalOnly | import("../builders").TranspilationModes.None;
73
+ depsToTranspile: unknown[];
74
+ writeManifest: boolean;
75
+ bundlerCustomizer?: ((bundler: import("browserify").BrowserifyObject) => void) | undefined;
76
+ });
77
+ } | {
78
+ /**
79
+ * We use the `swc-loader` to transpile TypeScript and JavaScript files.
80
+ * This is a Webpack loader that uses the `SWC` compiler, which is a much
81
+ * faster alternative to Babel and TypeScript's own compiler.
82
+ */
83
+ loader: string;
84
+ /**
85
+ * The options for the `swc-loader`. These can be overridden in the
86
+ * `.swcrc` file.
87
+ *
88
+ * @see https://swc.rs/docs/configuration/swcrc
89
+ */
90
+ options: {
91
+ sync: boolean;
92
+ /**
93
+ * This tells SWC to generate source maps. We set it to the
94
+ * `sourceMap` value from the config object.
95
+ *
96
+ * This must be enabled if source maps are enabled in the config.
97
+ */
98
+ sourceMaps: boolean;
99
+ jsc: {
100
+ parser: {
101
+ /**
102
+ * This tells the parser to parse TypeScript files. If you
103
+ * don't need to support TypeScript, you can set this to
104
+ * `ecmascript` instead, but there's no harm in leaving it
105
+ * as `typescript`.
106
+ *
107
+ * @see https://swc.rs/docs/configuration/compilation#jscparser
108
+ */
109
+ syntax: string;
110
+ /**
111
+ * This tells the parser to transpile JSX.
112
+ *
113
+ * @see https://swc.rs/docs/configuration/compilation#jscparser
114
+ * @see https://swc.rs/docs/configuration/compilation#jscparserjsx
115
+ */
116
+ tsx: boolean;
117
+ };
118
+ transform: {
119
+ react: {
120
+ /**
121
+ * This tells SWC to use the JSX runtime, instead of the
122
+ * `createElement` function.
123
+ *
124
+ * @see https://swc.rs/docs/configuration/compilation#jsctransformreact
125
+ */
126
+ runtime: string;
127
+ /**
128
+ * This tells SWC to import the JSX runtime from the
129
+ * `@metamask/snaps-sdk` package, instead of the default React
130
+ * package.
131
+ *
132
+ * @see https://swc.rs/docs/configuration/compilation#jsctransformreact
133
+ */
134
+ importSource: string;
135
+ /**
136
+ * This tells SWC to use `Object.assign` and `Object.create` for
137
+ * JSX spread attributes, instead of the default behavior.
138
+ *
139
+ * @see https://swc.rs/docs/configuration/compilation#jsctransformreact
140
+ */
141
+ useBuiltins: boolean;
142
+ };
143
+ };
144
+ };
145
+ /**
146
+ * The module configuration. This tells SWC how to output the
147
+ * transpiled code.
148
+ *
149
+ * @see https://swc.rs/docs/configuration/modules
150
+ */
151
+ module: {
152
+ /**
153
+ * This tells SWC to output ES6 modules. This will allow Webpack to
154
+ * optimize the output code better. Snaps don't support ES6 however, so
155
+ * the output code will be transpiled to CommonJS by Webpack later in
156
+ * the build process.
157
+ *
158
+ * @see https://swc.rs/docs/configuration/modules#es6
159
+ */
160
+ type: string;
161
+ };
162
+ env: {
163
+ targets: string;
164
+ };
165
+ };
166
+ }>;
167
+ /**
168
+ * Get the Webpack devtool configuration based on the given snap config.
169
+ *
170
+ * - If `sourceMap` is `inline`, return `inline-source-map`.
171
+ * - If `sourceMap` is `true`, return `source-map`.
172
+ * - Otherwise, return `false`.
173
+ *
174
+ * @param sourceMap - The `sourceMap` value from the snap config.
175
+ * @returns The Webpack devtool configuration.
176
+ */
177
+ export declare function getDevTool(sourceMap: ProcessedWebpackConfig['sourceMap']): Configuration['devtool'];
178
+ /**
179
+ * Get a function that can be used as handler function for Webpack's
180
+ * `ProgressPlugin`.
181
+ *
182
+ * @param spinner - The spinner to update.
183
+ * @param spinnerText - The initial spinner text. This will be prepended to the
184
+ * percentage.
185
+ * @returns A function that can be used as handler function for Webpack's
186
+ * `ProgressPlugin`.
187
+ */
188
+ export declare function getProgressHandler(spinner?: Ora, spinnerText?: string): (percentage: number) => void;
189
+ /**
190
+ * Get the targets from the `.browserslistrc` file.
191
+ *
192
+ * @returns The browser targets as an array of strings.
193
+ */
194
+ export declare function getBrowserslistTargets(): Promise<string[]>;
195
+ /**
196
+ * Get a singular or plural string based on the given count. This is useful for
197
+ * generating messages like "1 error" or "2 errors". By default, the plural
198
+ * string is the singular string with an "s" appended to it.
199
+ *
200
+ * This assumes that the text is in English, and likely won't work for some
201
+ * other languages.
202
+ *
203
+ * @param count - The count.
204
+ * @param singular - The singular string.
205
+ * @param plural - The plural string.
206
+ * @returns The singular or plural string.
207
+ * @example
208
+ * ```typescript
209
+ * pluralize(1, 'error'); // => 'error'
210
+ * pluralize(2, 'error'); // => 'errors'
211
+ * pluralize(1, 'error', 'problem'); // => 'error'
212
+ * pluralize(2, 'error', 'problems'); // => 'problems'
213
+ * ```
214
+ */
215
+ export declare function pluralize(count: number, singular: string, plural?: string): string;
216
+ /**
217
+ * Get an object that can be used as fallback config for Webpack's
218
+ * `fallback` config.
219
+ *
220
+ * @param polyfills - The polyfill object from the snap config.
221
+ * @returns The webpack fallback config.
222
+ */
223
+ export declare function getFallbacks(polyfills: ProcessedWebpackConfig['polyfills']): {
224
+ [index: string]: string | false;
225
+ };
226
+ /**
227
+ * Get an object that can be used as environment variables for Webpack's
228
+ * `DefinePlugin`.
229
+ *
230
+ * @param environment - The environment object from the Snap config.
231
+ * @param defaults - The default environment variables.
232
+ * @returns The Webpack environment variables.
233
+ */
234
+ export declare function getEnvironmentVariables(environment: Record<string, unknown>, defaults?: {
235
+ NODE_DEBUG: string;
236
+ NODE_ENV: string;
237
+ DEBUG: string;
238
+ }): {
239
+ [k: string]: string;
240
+ };
241
+ /**
242
+ * Format the given text to fit within the terminal width.
243
+ *
244
+ * @param text - The text to format.
245
+ * @param indent - The indentation to use.
246
+ * @param initialIndent - The initial indentation to use, i.e., the indentation
247
+ * for the first line.
248
+ * @returns The formatted text.
249
+ */
250
+ export declare function formatText(text: string, indent: number, initialIndent?: number): string;
251
+ /**
252
+ * Get an SVG from the given bytes and mime type.
253
+ *
254
+ * @param mimeType - The mime type of the image.
255
+ * @param bytes - The image bytes.
256
+ * @returns The SVG.
257
+ */
258
+ export declare function getImageSVG(mimeType: string, bytes: Uint8Array): string;
259
+ //# sourceMappingURL=utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../src/webpack/utils.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAY;AAG/B,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB;AAE7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAkB;AAGxD,eAAO,MAAM,iBAAiB,QAM7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC7B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,SAAS,GACV,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;IAarB;;;;OAIG;;IAGH;;;;;OAKG;;;QAID;;;;;WAKG;;;;gBAKC;;;;;;;mBAOG;;gBAGH;;;;;mBAKG;;;;;oBAMD;;;;;uBAKG;;oBAGH;;;;;;uBAMG;;oBAGH;;;;;uBAKG;;;;;QAMT;;;;;WAKG;;YAED;;;;;;;eAOG;;;;;;;GASV;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,sBAAsB,CAAC,WAAW,CAAC,GAC7C,aAAa,CAAC,SAAS,CAAC,CAU1B;AAED;;;;;;;;;GASG;AAEH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,MAAM,gBAChD,MAAM,UAO3B;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,sBAM3C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,SAAiB,UAGxB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,sBAAsB,CAAC,WAAW,CAAC,GAAG;IAC5E,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;CACjC,CAsBA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,QAAQ;;;;CAIP;;EAQF;AAiDD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,aAAa,SAAS,UAWvB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,UAG9D"}
@@ -1,39 +1,352 @@
1
- import {
2
- BROWSERSLIST_FILE,
3
- WEBPACK_FALLBACKS,
4
- formatText,
5
- getBrowserslistTargets,
6
- getDefaultLoader,
7
- getDevTool,
8
- getEnvironmentVariables,
9
- getFallbacks,
10
- getImageSVG,
11
- getProgressHandler,
12
- pluralize
13
- } from "../chunk-V6SYDSWM.mjs";
14
- import "../chunk-AZMQTZXZ.mjs";
15
- import "../chunk-ERSRIVYH.mjs";
16
- import "../chunk-JL3URCHO.mjs";
17
- import "../chunk-L72RLBV5.mjs";
18
- import "../chunk-QMD3VO6R.mjs";
19
- import "../chunk-TDSL55B3.mjs";
20
- import "../chunk-YCYGKEXF.mjs";
21
- import "../chunk-7RHK2YTB.mjs";
22
- import "../chunk-ZAW4ZWQX.mjs";
23
- import "../chunk-MR44GPM3.mjs";
24
- import "../chunk-X7TESUC7.mjs";
25
- import "../chunk-R77RJHC5.mjs";
26
- export {
27
- BROWSERSLIST_FILE,
28
- WEBPACK_FALLBACKS,
29
- formatText,
30
- getBrowserslistTargets,
31
- getDefaultLoader,
32
- getDevTool,
33
- getEnvironmentVariables,
34
- getFallbacks,
35
- getImageSVG,
36
- getProgressHandler,
37
- pluralize
1
+ function $importDefault(module) {
2
+ if (module?.__esModule) {
3
+ return module.default;
4
+ }
5
+ return module;
6
+ }
7
+ import { bytesToBase64 } from "@metamask/utils";
8
+ import $chalk from "chalk";
9
+ const { dim } = $chalk;
10
+ import { promises as fs } from "fs";
11
+ import { builtinModules } from "module";
12
+ import { dirname, resolve } from "path";
13
+ import $stripAnsi from "strip-ansi/index.js";
14
+ const stripAnsi = $importDefault($stripAnsi);
15
+ 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');
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'),
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/'),
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'),
38
50
  };
51
+ /**
52
+ * Get the default loader for JavaScript and TypeScript files, based on the
53
+ * config object.
54
+ *
55
+ * - If the `legacy` option is set, we use the custom `browserify` loader. This
56
+ * uses the legacy Browserify config to transpile the code.
57
+ * - Otherwise, we use the `swc-loader`. This is a Webpack loader that uses the
58
+ * `SWC` compiler, which is a much faster alternative to Babel and TypeScript's
59
+ * own compiler.
60
+ *
61
+ * @param config - The processed snap Webpack config.
62
+ * @param config.legacy - The legacy config object, if any.
63
+ * @param config.sourceMap - Whether to generate source maps.
64
+ * @see https://swc.rs/docs/usage/swc-loader
65
+ * @returns The default loader.
66
+ */
67
+ export async function getDefaultLoader({ legacy, sourceMap, }) {
68
+ if (legacy) {
69
+ /**
70
+ * If the snap uses the legacy config, we use the custom `browserify`
71
+ * loader. This uses the legacy Browserify config to transpile the code.
72
+ * This is necessary for backwards compatibility with the
73
+ * `bundlerCustomizer` function.
74
+ */
75
+ return getFunctionLoader(browserify, legacy);
76
+ }
77
+ const targets = await getBrowserslistTargets();
78
+ return {
79
+ /**
80
+ * We use the `swc-loader` to transpile TypeScript and JavaScript files.
81
+ * This is a Webpack loader that uses the `SWC` compiler, which is a much
82
+ * faster alternative to Babel and TypeScript's own compiler.
83
+ */
84
+ loader: require.resolve('swc-loader'),
85
+ /**
86
+ * The options for the `swc-loader`. These can be overridden in the
87
+ * `.swcrc` file.
88
+ *
89
+ * @see https://swc.rs/docs/configuration/swcrc
90
+ */
91
+ options: {
92
+ sync: false,
93
+ /**
94
+ * This tells SWC to generate source maps. We set it to the
95
+ * `sourceMap` value from the config object.
96
+ *
97
+ * This must be enabled if source maps are enabled in the config.
98
+ */
99
+ sourceMaps: Boolean(getDevTool(sourceMap)),
100
+ jsc: {
101
+ parser: {
102
+ /**
103
+ * This tells the parser to parse TypeScript files. If you
104
+ * don't need to support TypeScript, you can set this to
105
+ * `ecmascript` instead, but there's no harm in leaving it
106
+ * as `typescript`.
107
+ *
108
+ * @see https://swc.rs/docs/configuration/compilation#jscparser
109
+ */
110
+ syntax: 'typescript',
111
+ /**
112
+ * This tells the parser to transpile JSX.
113
+ *
114
+ * @see https://swc.rs/docs/configuration/compilation#jscparser
115
+ * @see https://swc.rs/docs/configuration/compilation#jscparserjsx
116
+ */
117
+ tsx: true,
118
+ },
119
+ transform: {
120
+ react: {
121
+ /**
122
+ * This tells SWC to use the JSX runtime, instead of the
123
+ * `createElement` function.
124
+ *
125
+ * @see https://swc.rs/docs/configuration/compilation#jsctransformreact
126
+ */
127
+ runtime: 'automatic',
128
+ /**
129
+ * This tells SWC to import the JSX runtime from the
130
+ * `@metamask/snaps-sdk` package, instead of the default React
131
+ * package.
132
+ *
133
+ * @see https://swc.rs/docs/configuration/compilation#jsctransformreact
134
+ */
135
+ importSource: '@metamask/snaps-sdk',
136
+ /**
137
+ * This tells SWC to use `Object.assign` and `Object.create` for
138
+ * JSX spread attributes, instead of the default behavior.
139
+ *
140
+ * @see https://swc.rs/docs/configuration/compilation#jsctransformreact
141
+ */
142
+ useBuiltins: true,
143
+ },
144
+ },
145
+ },
146
+ /**
147
+ * The module configuration. This tells SWC how to output the
148
+ * transpiled code.
149
+ *
150
+ * @see https://swc.rs/docs/configuration/modules
151
+ */
152
+ module: {
153
+ /**
154
+ * This tells SWC to output ES6 modules. This will allow Webpack to
155
+ * optimize the output code better. Snaps don't support ES6 however, so
156
+ * the output code will be transpiled to CommonJS by Webpack later in
157
+ * the build process.
158
+ *
159
+ * @see https://swc.rs/docs/configuration/modules#es6
160
+ */
161
+ type: 'es6',
162
+ },
163
+ env: {
164
+ targets: targets.join(', '),
165
+ },
166
+ },
167
+ };
168
+ }
169
+ /**
170
+ * Get the Webpack devtool configuration based on the given snap config.
171
+ *
172
+ * - If `sourceMap` is `inline`, return `inline-source-map`.
173
+ * - If `sourceMap` is `true`, return `source-map`.
174
+ * - Otherwise, return `false`.
175
+ *
176
+ * @param sourceMap - The `sourceMap` value from the snap config.
177
+ * @returns The Webpack devtool configuration.
178
+ */
179
+ export function getDevTool(sourceMap) {
180
+ if (sourceMap === 'inline') {
181
+ return 'inline-source-map';
182
+ }
183
+ if (sourceMap === true) {
184
+ return 'source-map';
185
+ }
186
+ return false;
187
+ }
188
+ /**
189
+ * Get a function that can be used as handler function for Webpack's
190
+ * `ProgressPlugin`.
191
+ *
192
+ * @param spinner - The spinner to update.
193
+ * @param spinnerText - The initial spinner text. This will be prepended to the
194
+ * percentage.
195
+ * @returns A function that can be used as handler function for Webpack's
196
+ * `ProgressPlugin`.
197
+ */
198
+ // Note: This is extracted for testing purposes.
199
+ export function getProgressHandler(spinner, spinnerText) {
200
+ return (percentage) => {
201
+ if (spinner && spinnerText) {
202
+ spinner.text = `${spinnerText} ${dim(`(${Math.round(percentage * 100)}%)`)}`;
203
+ }
204
+ };
205
+ }
206
+ /**
207
+ * Get the targets from the `.browserslistrc` file.
208
+ *
209
+ * @returns The browser targets as an array of strings.
210
+ */
211
+ export async function getBrowserslistTargets() {
212
+ const contents = await fs.readFile(BROWSERSLIST_FILE, 'utf8');
213
+ return contents
214
+ .split('\n')
215
+ .map((line) => line.trim())
216
+ .filter((line) => line && !line.startsWith('#'));
217
+ }
218
+ /**
219
+ * Get a singular or plural string based on the given count. This is useful for
220
+ * generating messages like "1 error" or "2 errors". By default, the plural
221
+ * string is the singular string with an "s" appended to it.
222
+ *
223
+ * This assumes that the text is in English, and likely won't work for some
224
+ * other languages.
225
+ *
226
+ * @param count - The count.
227
+ * @param singular - The singular string.
228
+ * @param plural - The plural string.
229
+ * @returns The singular or plural string.
230
+ * @example
231
+ * ```typescript
232
+ * pluralize(1, 'error'); // => 'error'
233
+ * pluralize(2, 'error'); // => 'errors'
234
+ * pluralize(1, 'error', 'problem'); // => 'error'
235
+ * pluralize(2, 'error', 'problems'); // => 'problems'
236
+ * ```
237
+ */
238
+ export function pluralize(count, singular, plural = `${singular}s`) {
239
+ return count === 1 ? singular : plural;
240
+ }
241
+ /**
242
+ * Get an object that can be used as fallback config for Webpack's
243
+ * `fallback` config.
244
+ *
245
+ * @param polyfills - The polyfill object from the snap config.
246
+ * @returns The webpack fallback config.
247
+ */
248
+ export function getFallbacks(polyfills) {
249
+ if (polyfills === true) {
250
+ return Object.fromEntries(builtinModules.map((name) => [
251
+ name,
252
+ WEBPACK_FALLBACKS[name] ?? false,
253
+ ]));
254
+ }
255
+ if (polyfills === false) {
256
+ return Object.fromEntries(builtinModules.map((name) => [name, false]));
257
+ }
258
+ return Object.fromEntries(builtinModules.map((name) => [
259
+ name,
260
+ polyfills[name]
261
+ ? WEBPACK_FALLBACKS[name]
262
+ : false,
263
+ ]));
264
+ }
265
+ /**
266
+ * Get an object that can be used as environment variables for Webpack's
267
+ * `DefinePlugin`.
268
+ *
269
+ * @param environment - The environment object from the Snap config.
270
+ * @param defaults - The default environment variables.
271
+ * @returns The Webpack environment variables.
272
+ */
273
+ export function getEnvironmentVariables(environment, defaults = {
274
+ NODE_DEBUG: 'false',
275
+ NODE_ENV: 'production',
276
+ DEBUG: 'false',
277
+ }) {
278
+ return Object.fromEntries(Object.entries({
279
+ ...defaults,
280
+ ...environment,
281
+ }).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]));
282
+ }
283
+ /**
284
+ * Format the given line to fit within the terminal width.
285
+ *
286
+ * @param line - The line to format.
287
+ * @param indent - The indentation to use.
288
+ * @param initialIndent - The initial indentation to use, i.e., the indentation
289
+ * for the first line.
290
+ * @returns The formatted line.
291
+ */
292
+ function formatLine(line, indent, initialIndent) {
293
+ const terminalWidth = process.stdout.columns;
294
+ if (!terminalWidth) {
295
+ return `${' '.repeat(initialIndent)}${line}`;
296
+ }
297
+ return line.split(' ').reduce(({ formattedText, currentLineLength }, word, index) => {
298
+ // `chalk` adds ANSI escape codes to the text, which are not visible
299
+ // characters. We need to strip them to get the visible length of the
300
+ // text.
301
+ const visibleWord = stripAnsi(word);
302
+ // Determine if a space should be added before the word.
303
+ const spaceBeforeWord = index > 0 ? ' ' : '';
304
+ const wordLengthWithSpace = visibleWord.length + spaceBeforeWord.length;
305
+ // If the word would exceed the terminal width, start a new line.
306
+ if (currentLineLength + wordLengthWithSpace > terminalWidth) {
307
+ return {
308
+ formattedText: `${formattedText}\n${' '.repeat(indent)}${word}`,
309
+ currentLineLength: indent + visibleWord.length,
310
+ };
311
+ }
312
+ // Otherwise, add the word to the current line.
313
+ return {
314
+ formattedText: formattedText + spaceBeforeWord + word,
315
+ currentLineLength: currentLineLength + wordLengthWithSpace,
316
+ };
317
+ }, {
318
+ formattedText: ' '.repeat(initialIndent),
319
+ currentLineLength: initialIndent,
320
+ }).formattedText;
321
+ }
322
+ /**
323
+ * Format the given text to fit within the terminal width.
324
+ *
325
+ * @param text - The text to format.
326
+ * @param indent - The indentation to use.
327
+ * @param initialIndent - The initial indentation to use, i.e., the indentation
328
+ * for the first line.
329
+ * @returns The formatted text.
330
+ */
331
+ export function formatText(text, indent, initialIndent = indent) {
332
+ const lines = text.split('\n');
333
+ // Apply formatting to each line separately and then join them.
334
+ return lines
335
+ .map((line, index) => {
336
+ const lineIndent = index === 0 ? initialIndent : indent;
337
+ return formatLine(line, indent, lineIndent);
338
+ })
339
+ .join('\n');
340
+ }
341
+ /**
342
+ * Get an SVG from the given bytes and mime type.
343
+ *
344
+ * @param mimeType - The mime type of the image.
345
+ * @param bytes - The image bytes.
346
+ * @returns The SVG.
347
+ */
348
+ export function getImageSVG(mimeType, bytes) {
349
+ const dataUrl = `data:${mimeType};base64,${bytesToBase64(bytes)}`;
350
+ return `<svg xmlns="http://www.w3.org/2000/svg"><image href="${dataUrl}" /></svg>`;
351
+ }
39
352
  //# sourceMappingURL=utils.mjs.map