@metamask/snaps-cli 5.1.1 → 6.0.1
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 +13 -1
- package/dist/builders.js +10 -0
- package/dist/builders.js.map +1 -0
- package/dist/builders.mjs +10 -0
- package/dist/builders.mjs.map +1 -0
- package/dist/chunk-26C34AS7.mjs +287 -0
- package/dist/chunk-26C34AS7.mjs.map +1 -0
- package/dist/chunk-2SUDRRT6.mjs +50 -0
- package/dist/chunk-2SUDRRT6.mjs.map +1 -0
- package/dist/chunk-3WWFQLH4.mjs +30 -0
- package/dist/chunk-3WWFQLH4.mjs.map +1 -0
- package/dist/chunk-45LOTCC4.mjs +1 -0
- package/dist/chunk-45LOTCC4.mjs.map +1 -0
- package/dist/chunk-4QUVE3EK.js +53 -0
- package/dist/chunk-4QUVE3EK.js.map +1 -0
- package/dist/chunk-5CLEKHXE.js +54 -0
- package/dist/chunk-5CLEKHXE.js.map +1 -0
- package/dist/chunk-5KQNAW4C.mjs +346 -0
- package/dist/chunk-5KQNAW4C.mjs.map +1 -0
- package/dist/chunk-6EEZHGF5.js +23 -0
- package/dist/chunk-6EEZHGF5.js.map +1 -0
- package/dist/chunk-7NQQGJZJ.mjs +35 -0
- package/dist/chunk-7NQQGJZJ.mjs.map +1 -0
- package/dist/chunk-7RHK2YTB.mjs +32 -0
- package/dist/chunk-7RHK2YTB.mjs.map +1 -0
- package/dist/chunk-AZMQTZXZ.mjs +28 -0
- package/dist/chunk-AZMQTZXZ.mjs.map +1 -0
- package/dist/chunk-B3NNVTA6.js +32 -0
- package/dist/chunk-B3NNVTA6.js.map +1 -0
- package/dist/chunk-BALQOCUO.js +22 -0
- package/dist/chunk-BALQOCUO.js.map +1 -0
- package/dist/chunk-BVPYLBE5.js +365 -0
- package/dist/chunk-BVPYLBE5.js.map +1 -0
- package/dist/chunk-BYNQODL3.mjs +23 -0
- package/dist/chunk-BYNQODL3.mjs.map +1 -0
- package/dist/chunk-C44RRX3H.js +18 -0
- package/dist/chunk-C44RRX3H.js.map +1 -0
- package/dist/chunk-C46KEPAC.js +37 -0
- package/dist/chunk-C46KEPAC.js.map +1 -0
- package/dist/chunk-CGJKCIHP.js +28 -0
- package/dist/chunk-CGJKCIHP.js.map +1 -0
- package/dist/chunk-CIYE263O.js +30 -0
- package/dist/chunk-CIYE263O.js.map +1 -0
- package/dist/chunk-DBLADLQ4.js +10 -0
- package/dist/chunk-DBLADLQ4.js.map +1 -0
- package/dist/chunk-EDEA4QTA.js +35 -0
- package/dist/chunk-EDEA4QTA.js.map +1 -0
- package/dist/chunk-ERSRIVYH.mjs +64 -0
- package/dist/chunk-ERSRIVYH.mjs.map +1 -0
- package/dist/chunk-G3COWLG5.mjs +23 -0
- package/dist/chunk-G3COWLG5.mjs.map +1 -0
- package/dist/chunk-GKRRE4WN.mjs +30 -0
- package/dist/chunk-GKRRE4WN.mjs.map +1 -0
- package/dist/chunk-HQBA5RU6.mjs +54 -0
- package/dist/chunk-HQBA5RU6.mjs.map +1 -0
- package/dist/chunk-HYPSSFE5.mjs +13 -0
- package/dist/chunk-HYPSSFE5.mjs.map +1 -0
- package/dist/chunk-JAHNVVLT.mjs +18 -0
- package/dist/chunk-JAHNVVLT.mjs.map +1 -0
- package/dist/chunk-JCVSYVPD.mjs +24 -0
- package/dist/chunk-JCVSYVPD.mjs.map +1 -0
- package/dist/chunk-JI3B665Z.js +24 -0
- package/dist/chunk-JI3B665Z.js.map +1 -0
- package/dist/chunk-JL3URCHO.mjs +53 -0
- package/dist/chunk-JL3URCHO.mjs.map +1 -0
- package/dist/chunk-K26BOY6Z.mjs +51 -0
- package/dist/chunk-K26BOY6Z.mjs.map +1 -0
- package/dist/chunk-K5QMGTQL.mjs +22 -0
- package/dist/chunk-K5QMGTQL.mjs.map +1 -0
- package/dist/chunk-KLOPX6DO.js +51 -0
- package/dist/chunk-KLOPX6DO.js.map +1 -0
- package/dist/chunk-KUSHMQXD.js +64 -0
- package/dist/chunk-KUSHMQXD.js.map +1 -0
- package/dist/chunk-L72RLBV5.mjs +37 -0
- package/dist/chunk-L72RLBV5.mjs.map +1 -0
- package/dist/chunk-MDHJ5HLM.js +287 -0
- package/dist/chunk-MDHJ5HLM.js.map +1 -0
- package/dist/chunk-MR44GPM3.mjs +135 -0
- package/dist/chunk-MR44GPM3.mjs.map +1 -0
- package/dist/chunk-MUYXNION.js +30 -0
- package/dist/chunk-MUYXNION.js.map +1 -0
- package/dist/chunk-OKDY7C7S.js +346 -0
- package/dist/chunk-OKDY7C7S.js.map +1 -0
- package/dist/chunk-OPE2PGM6.mjs +24 -0
- package/dist/chunk-OPE2PGM6.mjs.map +1 -0
- package/dist/chunk-PDYQXXLP.js +30 -0
- package/dist/chunk-PDYQXXLP.js.map +1 -0
- package/dist/chunk-PFB25A2Q.mjs +52 -0
- package/dist/chunk-PFB25A2Q.mjs.map +1 -0
- package/dist/chunk-QFK7JVP3.js +52 -0
- package/dist/chunk-QFK7JVP3.js.map +1 -0
- package/dist/chunk-QHCKVO3P.js +28 -0
- package/dist/chunk-QHCKVO3P.js.map +1 -0
- package/dist/chunk-QMD3VO6R.mjs +30 -0
- package/dist/chunk-QMD3VO6R.mjs.map +1 -0
- package/dist/chunk-R6NBQKVH.js +16 -0
- package/dist/chunk-R6NBQKVH.js.map +1 -0
- package/dist/chunk-R77RJHC5.mjs +44 -0
- package/dist/chunk-R77RJHC5.mjs.map +1 -0
- package/dist/chunk-S45DIQPN.js +13 -0
- package/dist/chunk-S45DIQPN.js.map +1 -0
- package/dist/chunk-S76EZ6HY.js +23 -0
- package/dist/chunk-S76EZ6HY.js.map +1 -0
- package/dist/chunk-S7UP2YYF.js +135 -0
- package/dist/chunk-S7UP2YYF.js.map +1 -0
- package/dist/chunk-SVYNCWMH.js +61 -0
- package/dist/chunk-SVYNCWMH.js.map +1 -0
- package/dist/chunk-SYRWT2KT.mjs +124 -0
- package/dist/chunk-SYRWT2KT.mjs.map +1 -0
- package/dist/chunk-T7NEPTM5.mjs +61 -0
- package/dist/chunk-T7NEPTM5.mjs.map +1 -0
- package/dist/chunk-TDSL55B3.mjs +10 -0
- package/dist/chunk-TDSL55B3.mjs.map +1 -0
- package/dist/chunk-TJ2F3J6X.js +31 -0
- package/dist/chunk-TJ2F3J6X.js.map +1 -0
- package/dist/chunk-U4VFMIGO.js +24 -0
- package/dist/chunk-U4VFMIGO.js.map +1 -0
- package/dist/chunk-VXOV3ZCB.js +1 -0
- package/dist/chunk-VXOV3ZCB.js.map +1 -0
- package/dist/chunk-WO7DMSQU.mjs +16 -0
- package/dist/chunk-WO7DMSQU.mjs.map +1 -0
- package/dist/chunk-WP2N4NCO.js +50 -0
- package/dist/chunk-WP2N4NCO.js.map +1 -0
- package/dist/chunk-WYDHPUWV.mjs +28 -0
- package/dist/chunk-WYDHPUWV.mjs.map +1 -0
- package/dist/chunk-X3D3MHWF.js +44 -0
- package/dist/chunk-X3D3MHWF.js.map +1 -0
- package/dist/chunk-X7TESUC7.mjs +22 -0
- package/dist/chunk-X7TESUC7.mjs.map +1 -0
- package/dist/chunk-X7VYAL2L.mjs +365 -0
- package/dist/chunk-X7VYAL2L.mjs.map +1 -0
- package/dist/chunk-XGWLFH7Y.js +41 -0
- package/dist/chunk-XGWLFH7Y.js.map +1 -0
- package/dist/{cjs/webpack/config.js → chunk-XUYXKO4F.js} +181 -153
- package/dist/chunk-XUYXKO4F.js.map +1 -0
- package/dist/chunk-XZJLYKES.mjs +64 -0
- package/dist/chunk-XZJLYKES.mjs.map +1 -0
- package/dist/chunk-YCYGKEXF.mjs +41 -0
- package/dist/chunk-YCYGKEXF.mjs.map +1 -0
- package/dist/chunk-YGEAZQSC.js +124 -0
- package/dist/chunk-YGEAZQSC.js.map +1 -0
- package/dist/chunk-YQ2E7NEA.js +64 -0
- package/dist/chunk-YQ2E7NEA.js.map +1 -0
- package/dist/chunk-YQVCFM6L.js +22 -0
- package/dist/chunk-YQVCFM6L.js.map +1 -0
- package/dist/{esm/webpack/config.js → chunk-YWCNJELN.mjs} +182 -156
- package/dist/chunk-YWCNJELN.mjs.map +1 -0
- package/dist/chunk-ZAW4ZWQX.mjs +31 -0
- package/dist/chunk-ZAW4ZWQX.mjs.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +21 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/commands/build/build.js +29 -0
- package/dist/commands/build/build.js.map +1 -0
- package/dist/commands/build/build.mjs +29 -0
- package/dist/commands/build/build.mjs.map +1 -0
- package/dist/commands/build/implementation.js +28 -0
- package/dist/commands/build/implementation.js.map +1 -0
- package/dist/commands/build/implementation.mjs +28 -0
- package/dist/commands/build/implementation.mjs.map +1 -0
- package/dist/commands/build/index.js +33 -0
- package/dist/commands/build/index.js.map +1 -0
- package/dist/commands/build/index.mjs +33 -0
- package/dist/commands/build/index.mjs.map +1 -0
- package/dist/commands/eval/eval.js +18 -0
- package/dist/commands/eval/eval.js.map +1 -0
- package/dist/commands/eval/eval.mjs +18 -0
- package/dist/commands/eval/eval.mjs.map +1 -0
- package/dist/commands/eval/implementation.js +9 -0
- package/dist/commands/eval/implementation.js.map +1 -0
- package/dist/commands/eval/implementation.mjs +9 -0
- package/dist/commands/eval/implementation.mjs.map +1 -0
- package/dist/commands/eval/index.js +22 -0
- package/dist/commands/eval/index.js.map +1 -0
- package/dist/commands/eval/index.mjs +22 -0
- package/dist/commands/eval/index.mjs.map +1 -0
- package/dist/commands/index.js +39 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/index.mjs +39 -0
- package/dist/commands/index.mjs.map +1 -0
- package/dist/commands/manifest/implementation.js +17 -0
- package/dist/commands/manifest/implementation.js.map +1 -0
- package/dist/commands/manifest/implementation.mjs +17 -0
- package/dist/commands/manifest/implementation.mjs.map +1 -0
- package/dist/commands/manifest/index.js +22 -0
- package/dist/commands/manifest/index.js.map +1 -0
- package/dist/commands/manifest/index.mjs +22 -0
- package/dist/commands/manifest/index.mjs.map +1 -0
- package/dist/commands/manifest/manifest.js +18 -0
- package/dist/commands/manifest/manifest.js.map +1 -0
- package/dist/commands/manifest/manifest.mjs +18 -0
- package/dist/commands/manifest/manifest.mjs.map +1 -0
- package/dist/commands/serve/index.js +29 -0
- package/dist/commands/serve/index.js.map +1 -0
- package/dist/commands/serve/index.mjs +29 -0
- package/dist/commands/serve/index.mjs.map +1 -0
- package/dist/commands/serve/serve.js +28 -0
- package/dist/commands/serve/serve.js.map +1 -0
- package/dist/commands/serve/serve.mjs +28 -0
- package/dist/commands/serve/serve.mjs.map +1 -0
- package/dist/commands/watch/implementation.js +28 -0
- package/dist/commands/watch/implementation.js.map +1 -0
- package/dist/commands/watch/implementation.mjs +28 -0
- package/dist/commands/watch/implementation.mjs.map +1 -0
- package/dist/commands/watch/index.js +33 -0
- package/dist/commands/watch/index.js.map +1 -0
- package/dist/commands/watch/index.mjs +33 -0
- package/dist/commands/watch/index.mjs.map +1 -0
- package/dist/commands/watch/watch.js +29 -0
- package/dist/commands/watch/watch.js.map +1 -0
- package/dist/commands/watch/watch.mjs +29 -0
- package/dist/commands/watch/watch.mjs.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +36 -0
- package/dist/config.mjs.map +1 -0
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +12 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +43 -0
- package/dist/index.mjs.map +1 -0
- package/dist/main.js +49 -0
- package/dist/main.js.map +1 -0
- package/dist/main.mjs +49 -0
- package/dist/main.mjs.map +1 -0
- package/dist/structs.js +8 -0
- package/dist/structs.js.map +1 -0
- package/dist/structs.mjs +8 -0
- package/dist/structs.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/commands/eval/implementation.d.ts +1 -1
- package/dist/types/config.d.ts +2 -2
- package/dist/types/structs.d.ts +20 -0
- package/dist/types/webpack/loaders/function.d.ts +34 -0
- package/dist/types/webpack/loaders/index.d.ts +3 -0
- package/dist/types/webpack/utils.d.ts +13 -11
- package/dist/types/yargs.d.js +1 -0
- package/dist/types/yargs.d.js.map +1 -0
- package/dist/types/yargs.d.mjs +1 -0
- package/dist/types/yargs.d.mjs.map +1 -0
- package/dist/utils/cli.js +14 -0
- package/dist/utils/cli.js.map +1 -0
- package/dist/utils/cli.mjs +14 -0
- package/dist/utils/cli.mjs.map +1 -0
- package/dist/utils/errors.js +11 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/errors.mjs +11 -0
- package/dist/utils/errors.mjs.map +1 -0
- package/dist/utils/index.js +47 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +47 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/legacy.js +13 -0
- package/dist/utils/legacy.js.map +1 -0
- package/dist/utils/legacy.mjs +13 -0
- package/dist/utils/legacy.mjs.map +1 -0
- package/dist/utils/logging.js +12 -0
- package/dist/utils/logging.js.map +1 -0
- package/dist/utils/logging.mjs +12 -0
- package/dist/utils/logging.mjs.map +1 -0
- package/dist/utils/path.js +8 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/path.mjs +8 -0
- package/dist/utils/path.mjs.map +1 -0
- package/dist/utils/steps.js +11 -0
- package/dist/utils/steps.js.map +1 -0
- package/dist/utils/steps.mjs +11 -0
- package/dist/utils/steps.mjs.map +1 -0
- package/dist/webpack/compiler.js +25 -0
- package/dist/webpack/compiler.js.map +1 -0
- package/dist/webpack/compiler.mjs +25 -0
- package/dist/webpack/compiler.mjs.map +1 -0
- package/dist/webpack/config.js +24 -0
- package/dist/webpack/config.js.map +1 -0
- package/dist/webpack/config.mjs +24 -0
- package/dist/webpack/config.mjs.map +1 -0
- package/dist/webpack/index.js +44 -0
- package/dist/webpack/index.js.map +1 -0
- package/dist/webpack/index.mjs +44 -0
- package/dist/webpack/index.mjs.map +1 -0
- package/dist/webpack/loaders/browserify.js +19 -0
- package/dist/webpack/loaders/browserify.js.map +1 -0
- package/dist/webpack/loaders/browserify.mjs +19 -0
- package/dist/webpack/loaders/browserify.mjs.map +1 -0
- package/dist/webpack/loaders/function.js +10 -0
- package/dist/webpack/loaders/function.js.map +1 -0
- package/dist/webpack/loaders/function.mjs +10 -0
- package/dist/webpack/loaders/function.mjs.map +1 -0
- package/dist/webpack/loaders/index.js +25 -0
- package/dist/webpack/loaders/index.js.map +1 -0
- package/dist/webpack/loaders/index.mjs +25 -0
- package/dist/webpack/loaders/index.mjs.map +1 -0
- package/dist/webpack/loaders/wasm.js +16 -0
- package/dist/webpack/loaders/wasm.js.map +1 -0
- package/dist/webpack/loaders/wasm.mjs +16 -0
- package/dist/webpack/loaders/wasm.mjs.map +1 -0
- package/dist/webpack/plugins.js +29 -0
- package/dist/webpack/plugins.js.map +1 -0
- package/dist/webpack/plugins.mjs +29 -0
- package/dist/webpack/plugins.mjs.map +1 -0
- package/dist/webpack/server.js +10 -0
- package/dist/webpack/server.js.map +1 -0
- package/dist/webpack/server.mjs +10 -0
- package/dist/webpack/server.mjs.map +1 -0
- package/dist/webpack/utils.js +37 -0
- package/dist/webpack/utils.js.map +1 -0
- package/dist/webpack/utils.mjs +37 -0
- package/dist/webpack/utils.mjs.map +1 -0
- package/package.json +21 -21
- package/.browserslistrc +0 -3
- package/dist/cjs/builders.js +0 -148
- package/dist/cjs/builders.js.map +0 -1
- package/dist/cjs/cli.js +0 -68
- package/dist/cjs/cli.js.map +0 -1
- package/dist/cjs/commands/build/build.js +0 -54
- package/dist/cjs/commands/build/build.js.map +0 -1
- package/dist/cjs/commands/build/implementation.js +0 -31
- package/dist/cjs/commands/build/implementation.js.map +0 -1
- package/dist/cjs/commands/build/index.js +0 -45
- package/dist/cjs/commands/build/index.js.map +0 -1
- package/dist/cjs/commands/eval/eval.js +0 -57
- package/dist/cjs/commands/eval/eval.js.map +0 -1
- package/dist/cjs/commands/eval/implementation.js +0 -27
- package/dist/cjs/commands/eval/implementation.js.map +0 -1
- package/dist/cjs/commands/eval/index.js +0 -50
- package/dist/cjs/commands/eval/index.js.map +0 -1
- package/dist/cjs/commands/index.js +0 -30
- package/dist/cjs/commands/index.js.map +0 -1
- package/dist/cjs/commands/manifest/implementation.js +0 -34
- package/dist/cjs/commands/manifest/implementation.js.map +0 -1
- package/dist/cjs/commands/manifest/index.js +0 -50
- package/dist/cjs/commands/manifest/index.js.map +0 -1
- package/dist/cjs/commands/manifest/manifest.js +0 -55
- package/dist/cjs/commands/manifest/manifest.js.map +0 -1
- package/dist/cjs/commands/serve/index.js +0 -33
- package/dist/cjs/commands/serve/index.js.map +0 -1
- package/dist/cjs/commands/serve/serve.js +0 -21
- package/dist/cjs/commands/serve/serve.js.map +0 -1
- package/dist/cjs/commands/watch/implementation.js +0 -35
- package/dist/cjs/commands/watch/implementation.js.map +0 -1
- package/dist/cjs/commands/watch/index.js +0 -47
- package/dist/cjs/commands/watch/index.js.map +0 -1
- package/dist/cjs/commands/watch/watch.js +0 -51
- package/dist/cjs/commands/watch/watch.js.map +0 -1
- package/dist/cjs/config.js +0 -320
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/errors.js +0 -37
- package/dist/cjs/errors.js.map +0 -1
- package/dist/cjs/index.js +0 -77
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/main.js +0 -19
- package/dist/cjs/main.js.map +0 -1
- package/dist/cjs/utils/cli.js +0 -61
- package/dist/cjs/utils/cli.js.map +0 -1
- package/dist/cjs/utils/errors.js +0 -42
- package/dist/cjs/utils/errors.js.map +0 -1
- package/dist/cjs/utils/index.js +0 -25
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/legacy.js +0 -48
- package/dist/cjs/utils/legacy.js.map +0 -1
- package/dist/cjs/utils/logging.js +0 -46
- package/dist/cjs/utils/logging.js.map +0 -1
- package/dist/cjs/utils/path.js +0 -16
- package/dist/cjs/utils/path.js.map +0 -1
- package/dist/cjs/utils/steps.js +0 -52
- package/dist/cjs/utils/steps.js.map +0 -1
- package/dist/cjs/webpack/compiler.js +0 -19
- package/dist/cjs/webpack/compiler.js.map +0 -1
- package/dist/cjs/webpack/config.js.map +0 -1
- package/dist/cjs/webpack/index.js +0 -23
- package/dist/cjs/webpack/index.js.map +0 -1
- package/dist/cjs/webpack/loaders/browserify.js +0 -97
- package/dist/cjs/webpack/loaders/browserify.js.map +0 -1
- package/dist/cjs/webpack/loaders/wasm.js +0 -92
- package/dist/cjs/webpack/loaders/wasm.js.map +0 -1
- package/dist/cjs/webpack/plugins.js +0 -341
- package/dist/cjs/webpack/plugins.js.map +0 -1
- package/dist/cjs/webpack/server.js +0 -139
- package/dist/cjs/webpack/server.js.map +0 -1
- package/dist/cjs/webpack/utils.js +0 -254
- package/dist/cjs/webpack/utils.js.map +0 -1
- package/dist/esm/builders.js +0 -130
- package/dist/esm/builders.js.map +0 -1
- package/dist/esm/cli.js +0 -56
- package/dist/esm/cli.js.map +0 -1
- package/dist/esm/commands/build/build.js +0 -51
- package/dist/esm/commands/build/build.js.map +0 -1
- package/dist/esm/commands/build/implementation.js +0 -27
- package/dist/esm/commands/build/implementation.js.map +0 -1
- package/dist/esm/commands/build/index.js +0 -17
- package/dist/esm/commands/build/index.js.map +0 -1
- package/dist/esm/commands/eval/eval.js +0 -54
- package/dist/esm/commands/eval/eval.js.map +0 -1
- package/dist/esm/commands/eval/implementation.js +0 -24
- package/dist/esm/commands/eval/implementation.js.map +0 -1
- package/dist/esm/commands/eval/index.js +0 -22
- package/dist/esm/commands/eval/index.js.map +0 -1
- package/dist/esm/commands/index.js +0 -15
- package/dist/esm/commands/index.js.map +0 -1
- package/dist/esm/commands/manifest/implementation.js +0 -33
- package/dist/esm/commands/manifest/implementation.js.map +0 -1
- package/dist/esm/commands/manifest/index.js +0 -22
- package/dist/esm/commands/manifest/index.js.map +0 -1
- package/dist/esm/commands/manifest/manifest.js +0 -52
- package/dist/esm/commands/manifest/manifest.js.map +0 -1
- package/dist/esm/commands/serve/index.js +0 -18
- package/dist/esm/commands/serve/index.js.map +0 -1
- package/dist/esm/commands/serve/serve.js +0 -17
- package/dist/esm/commands/serve/serve.js.map +0 -1
- package/dist/esm/commands/watch/implementation.js +0 -34
- package/dist/esm/commands/watch/implementation.js.map +0 -1
- package/dist/esm/commands/watch/index.js +0 -19
- package/dist/esm/commands/watch/index.js.map +0 -1
- package/dist/esm/commands/watch/watch.js +0 -50
- package/dist/esm/commands/watch/watch.js.map +0 -1
- package/dist/esm/config.js +0 -324
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/errors.js +0 -30
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/main.js +0 -10
- package/dist/esm/main.js.map +0 -1
- package/dist/esm/utils/cli.js +0 -43
- package/dist/esm/utils/cli.js.map +0 -1
- package/dist/esm/utils/errors.js +0 -43
- package/dist/esm/utils/errors.js.map +0 -1
- package/dist/esm/utils/index.js +0 -8
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/legacy.js +0 -47
- package/dist/esm/utils/legacy.js.map +0 -1
- package/dist/esm/utils/logging.js +0 -40
- package/dist/esm/utils/logging.js.map +0 -1
- package/dist/esm/utils/path.js +0 -13
- package/dist/esm/utils/path.js.map +0 -1
- package/dist/esm/utils/steps.js +0 -43
- package/dist/esm/utils/steps.js.map +0 -1
- package/dist/esm/webpack/compiler.js +0 -15
- package/dist/esm/webpack/compiler.js.map +0 -1
- package/dist/esm/webpack/config.js.map +0 -1
- package/dist/esm/webpack/index.js +0 -6
- package/dist/esm/webpack/index.js.map +0 -1
- package/dist/esm/webpack/loaders/browserify.js +0 -82
- package/dist/esm/webpack/loaders/browserify.js.map +0 -1
- package/dist/esm/webpack/loaders/wasm.js +0 -87
- package/dist/esm/webpack/loaders/wasm.js.map +0 -1
- package/dist/esm/webpack/plugins.js +0 -344
- package/dist/esm/webpack/plugins.js.map +0 -1
- package/dist/esm/webpack/server.js +0 -133
- package/dist/esm/webpack/server.js.map +0 -1
- package/dist/esm/webpack/utils.js +0 -285
- package/dist/esm/webpack/utils.js.map +0 -1
package/dist/esm/config.js
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import { literal, union } from '@metamask/snaps-sdk';
|
|
2
|
-
import { createFromStruct, file, indent, isFile, SnapsStructError, named } from '@metamask/snaps-utils';
|
|
3
|
-
import { hasProperty } from '@metamask/utils';
|
|
4
|
-
import { transform } from '@swc/core';
|
|
5
|
-
import { dim } from 'chalk';
|
|
6
|
-
import { readFile } from 'fs/promises';
|
|
7
|
-
import Module from 'module';
|
|
8
|
-
import { basename, dirname, resolve } from 'path';
|
|
9
|
-
import { array, boolean, create, defaulted, define, func, number, object, optional, record, string, type, unknown, empty } from 'superstruct';
|
|
10
|
-
import { TranspilationModes } from './builders';
|
|
11
|
-
import { ConfigError } from './errors';
|
|
12
|
-
import { CONFIG_FILE, TS_CONFIG_FILE } from './utils';
|
|
13
|
-
const CONFIG_FILES = [
|
|
14
|
-
CONFIG_FILE,
|
|
15
|
-
TS_CONFIG_FILE
|
|
16
|
-
];
|
|
17
|
-
// This struct is essentially the same as the `func` struct, but it's defined
|
|
18
|
-
// separately so that we include the function type in the inferred TypeScript
|
|
19
|
-
// type definitions.
|
|
20
|
-
const SnapsBrowserifyBundlerCustomizerFunctionStruct = define('function', func().validator);
|
|
21
|
-
export const SnapsBrowserifyConfigStruct = object({
|
|
22
|
-
bundler: defaulted(literal('browserify'), 'browserify'),
|
|
23
|
-
cliOptions: defaulted(object({
|
|
24
|
-
bundle: optional(file()),
|
|
25
|
-
dist: defaulted(file(), 'dist'),
|
|
26
|
-
eval: defaulted(boolean(), true),
|
|
27
|
-
manifest: defaulted(boolean(), true),
|
|
28
|
-
port: defaulted(number(), 8081),
|
|
29
|
-
outfileName: defaulted(string(), 'bundle.js'),
|
|
30
|
-
root: defaulted(file(), process.cwd()),
|
|
31
|
-
sourceMaps: defaulted(boolean(), false),
|
|
32
|
-
src: defaulted(file(), 'src/index.js'),
|
|
33
|
-
stripComments: defaulted(boolean(), true),
|
|
34
|
-
suppressWarnings: defaulted(boolean(), false),
|
|
35
|
-
transpilationMode: defaulted(union([
|
|
36
|
-
literal('localAndDeps'),
|
|
37
|
-
literal('localOnly'),
|
|
38
|
-
literal('none')
|
|
39
|
-
]), 'localOnly'),
|
|
40
|
-
depsToTranspile: defaulted(array(string()), []),
|
|
41
|
-
verboseErrors: defaulted(boolean(), true),
|
|
42
|
-
writeManifest: defaulted(boolean(), true),
|
|
43
|
-
serve: defaulted(boolean(), true)
|
|
44
|
-
}), {}),
|
|
45
|
-
bundlerCustomizer: optional(SnapsBrowserifyBundlerCustomizerFunctionStruct)
|
|
46
|
-
});
|
|
47
|
-
// This struct is essentially the same as the `func` struct, but it's defined
|
|
48
|
-
// separately so that we include the function type in the inferred TypeScript
|
|
49
|
-
// type definitions.
|
|
50
|
-
const SnapsWebpackCustomizeWebpackConfigFunctionStruct = define('function', func().validator);
|
|
51
|
-
export const SnapsWebpackConfigStruct = object({
|
|
52
|
-
bundler: literal('webpack'),
|
|
53
|
-
input: defaulted(file(), resolve(process.cwd(), 'src/index.js')),
|
|
54
|
-
sourceMap: defaulted(union([
|
|
55
|
-
boolean(),
|
|
56
|
-
literal('inline')
|
|
57
|
-
]), false),
|
|
58
|
-
evaluate: defaulted(boolean(), true),
|
|
59
|
-
output: defaulted(object({
|
|
60
|
-
path: defaulted(file(), resolve(process.cwd(), 'dist')),
|
|
61
|
-
filename: defaulted(string(), 'bundle.js'),
|
|
62
|
-
clean: defaulted(boolean(), false),
|
|
63
|
-
minimize: defaulted(boolean(), true)
|
|
64
|
-
}), {}),
|
|
65
|
-
manifest: defaulted(object({
|
|
66
|
-
path: defaulted(file(), resolve(process.cwd(), 'snap.manifest.json')),
|
|
67
|
-
update: defaulted(boolean(), true)
|
|
68
|
-
}), {}),
|
|
69
|
-
server: defaulted(object({
|
|
70
|
-
enabled: defaulted(boolean(), true),
|
|
71
|
-
root: defaulted(file(), process.cwd()),
|
|
72
|
-
port: defaulted(number(), 8081)
|
|
73
|
-
}), {}),
|
|
74
|
-
environment: defaulted(record(string(), unknown()), {}),
|
|
75
|
-
stats: defaulted(object({
|
|
76
|
-
verbose: defaulted(boolean(), false),
|
|
77
|
-
builtIns: defaulted(union([
|
|
78
|
-
object({
|
|
79
|
-
ignore: defaulted(array(string()), [])
|
|
80
|
-
}),
|
|
81
|
-
literal(false)
|
|
82
|
-
]), {}),
|
|
83
|
-
buffer: defaulted(boolean(), true)
|
|
84
|
-
}), {}),
|
|
85
|
-
polyfills: defaulted(union([
|
|
86
|
-
boolean(),
|
|
87
|
-
object({
|
|
88
|
-
assert: defaulted(boolean(), false),
|
|
89
|
-
buffer: defaulted(boolean(), false),
|
|
90
|
-
console: defaulted(boolean(), false),
|
|
91
|
-
constants: defaulted(boolean(), false),
|
|
92
|
-
crypto: defaulted(boolean(), false),
|
|
93
|
-
domain: defaulted(boolean(), false),
|
|
94
|
-
events: defaulted(boolean(), false),
|
|
95
|
-
http: defaulted(boolean(), false),
|
|
96
|
-
https: defaulted(boolean(), false),
|
|
97
|
-
os: defaulted(boolean(), false),
|
|
98
|
-
path: defaulted(boolean(), false),
|
|
99
|
-
punycode: defaulted(boolean(), false),
|
|
100
|
-
process: defaulted(boolean(), false),
|
|
101
|
-
querystring: defaulted(boolean(), false),
|
|
102
|
-
stream: defaulted(boolean(), false),
|
|
103
|
-
/* eslint-disable @typescript-eslint/naming-convention */ _stream_duplex: defaulted(boolean(), false),
|
|
104
|
-
_stream_passthrough: defaulted(boolean(), false),
|
|
105
|
-
_stream_readable: defaulted(boolean(), false),
|
|
106
|
-
_stream_transform: defaulted(boolean(), false),
|
|
107
|
-
_stream_writable: defaulted(boolean(), false),
|
|
108
|
-
string_decoder: defaulted(boolean(), false),
|
|
109
|
-
/* eslint-enable @typescript-eslint/naming-convention */ sys: defaulted(boolean(), false),
|
|
110
|
-
timers: defaulted(boolean(), false),
|
|
111
|
-
tty: defaulted(boolean(), false),
|
|
112
|
-
url: defaulted(boolean(), false),
|
|
113
|
-
util: defaulted(boolean(), false),
|
|
114
|
-
vm: defaulted(boolean(), false),
|
|
115
|
-
zlib: defaulted(boolean(), false)
|
|
116
|
-
})
|
|
117
|
-
]), false),
|
|
118
|
-
customizeWebpackConfig: optional(SnapsWebpackCustomizeWebpackConfigFunctionStruct),
|
|
119
|
-
experimental: defaulted(object({
|
|
120
|
-
wasm: defaulted(boolean(), false)
|
|
121
|
-
}), {})
|
|
122
|
-
});
|
|
123
|
-
export const SnapsConfigStruct = type({
|
|
124
|
-
bundler: defaulted(union([
|
|
125
|
-
literal('browserify'),
|
|
126
|
-
literal('webpack')
|
|
127
|
-
]), 'browserify')
|
|
128
|
-
});
|
|
129
|
-
export const LegacyOptionsStruct = union([
|
|
130
|
-
named('object with `transpilationMode` set to `localAndDeps` and `depsToTranspile` set to an array of strings', type({
|
|
131
|
-
depsToTranspile: array(string()),
|
|
132
|
-
transpilationMode: literal(TranspilationModes.LocalAndDeps),
|
|
133
|
-
writeManifest: boolean(),
|
|
134
|
-
bundlerCustomizer: optional(SnapsBrowserifyBundlerCustomizerFunctionStruct)
|
|
135
|
-
})),
|
|
136
|
-
named('object without `depsToTranspile`', type({
|
|
137
|
-
depsToTranspile: named('empty array', empty(array())),
|
|
138
|
-
transpilationMode: union([
|
|
139
|
-
literal(TranspilationModes.LocalOnly),
|
|
140
|
-
literal(TranspilationModes.None)
|
|
141
|
-
]),
|
|
142
|
-
writeManifest: boolean(),
|
|
143
|
-
bundlerCustomizer: optional(SnapsBrowserifyBundlerCustomizerFunctionStruct)
|
|
144
|
-
}))
|
|
145
|
-
]);
|
|
146
|
-
/**
|
|
147
|
-
* Get a validated snap config. This validates the config and adds default
|
|
148
|
-
* values for any missing properties.
|
|
149
|
-
*
|
|
150
|
-
* @param config - The config to validate.
|
|
151
|
-
* @param argv - The CLI arguments.
|
|
152
|
-
* @returns The validated config.
|
|
153
|
-
*/ export function getConfig(config, argv) {
|
|
154
|
-
const prefix = 'The snap config file is invalid';
|
|
155
|
-
const suffix = dim(// TODO: Link to `docs.metamask.io` once the docs are published.
|
|
156
|
-
'Refer to the documentation for more information: https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli/');
|
|
157
|
-
const { bundler } = createFromStruct(config, SnapsConfigStruct, prefix, suffix);
|
|
158
|
-
if (bundler === 'browserify') {
|
|
159
|
-
const legacyConfig = createFromStruct(config, SnapsBrowserifyConfigStruct, prefix, suffix);
|
|
160
|
-
return getWebpackConfig(mergeLegacyOptions(argv, legacyConfig));
|
|
161
|
-
}
|
|
162
|
-
return createFromStruct(config, SnapsWebpackConfigStruct, prefix, suffix);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Load a snap config from a file. This supports both JavaScript and TypeScript
|
|
166
|
-
* config files, in the CommonJS module format and the ES module format.
|
|
167
|
-
*
|
|
168
|
-
* This assumes that the config file exports a default object, either through
|
|
169
|
-
* `module.exports` or `export default`.
|
|
170
|
-
*
|
|
171
|
-
* @param path - The full path to the config file.
|
|
172
|
-
* @param argv - The CLI arguments.
|
|
173
|
-
* @returns The validated config.
|
|
174
|
-
* @throws If the config file is invalid, or if the config file does not have a
|
|
175
|
-
* default export.
|
|
176
|
-
*/ export async function loadConfig(path, argv) {
|
|
177
|
-
try {
|
|
178
|
-
const contents = await readFile(path, 'utf8');
|
|
179
|
-
const source = await transform(contents, {
|
|
180
|
-
swcrc: false,
|
|
181
|
-
jsc: {
|
|
182
|
-
parser: {
|
|
183
|
-
syntax: 'typescript'
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
module: {
|
|
187
|
-
type: 'commonjs'
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
const config = new Module(path);
|
|
191
|
-
// @ts-expect-error - This function is not typed.
|
|
192
|
-
config.paths = Module._nodeModulePaths(dirname(path));
|
|
193
|
-
// @ts-expect-error - This function is not typed.
|
|
194
|
-
config._compile(source.code, path);
|
|
195
|
-
if (!hasProperty(config.exports, 'default')) {
|
|
196
|
-
return getConfig(config.exports, argv);
|
|
197
|
-
}
|
|
198
|
-
return getConfig(config.exports.default, argv);
|
|
199
|
-
} catch (error) {
|
|
200
|
-
if (error instanceof SnapsStructError) {
|
|
201
|
-
throw new ConfigError(error.message);
|
|
202
|
-
}
|
|
203
|
-
throw new ConfigError(`Unable to load snap config file at "${path}".\n\n${indent(error.message)}`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Resolve a snap config. This function will look for a `snap.config.js` or
|
|
208
|
-
* `snap.config.ts` file in the current or specified directory.
|
|
209
|
-
*
|
|
210
|
-
* @param path - The path to resolve the snap config from. Defaults to the
|
|
211
|
-
* current working directory.
|
|
212
|
-
* @param argv - The CLI arguments.
|
|
213
|
-
* @returns The resolved and validated snap config.
|
|
214
|
-
* @throws If a snap config could not be found.
|
|
215
|
-
*/ export async function resolveConfig(path, argv) {
|
|
216
|
-
for (const configFile of CONFIG_FILES){
|
|
217
|
-
const filePath = resolve(path, configFile);
|
|
218
|
-
if (await isFile(filePath)) {
|
|
219
|
-
return await loadConfig(filePath, argv);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
throw new ConfigError(`Could not find a "snap.config.js" or "snap.config.ts" file in the current or specified directory ("${path}").`);
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Get a snap config from the CLI arguments. This will either load the config
|
|
226
|
-
* from the specified config file, or resolve the config from the current
|
|
227
|
-
* working directory.
|
|
228
|
-
*
|
|
229
|
-
* @param argv - The CLI arguments.
|
|
230
|
-
* @param cwd - The current working directory. Defaults to `process.cwd()`.
|
|
231
|
-
* @returns The resolved and validated snap config.
|
|
232
|
-
*/ export async function getConfigByArgv(argv, cwd = process.cwd()) {
|
|
233
|
-
if (argv.config) {
|
|
234
|
-
if (!await isFile(argv.config)) {
|
|
235
|
-
throw new ConfigError(`Could not find a config file at "${argv.config}". Make sure that the path is correct.`);
|
|
236
|
-
}
|
|
237
|
-
return await loadConfig(argv.config, argv);
|
|
238
|
-
}
|
|
239
|
-
return await resolveConfig(cwd, argv);
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Merge legacy CLI options into the config. This is used to support the legacy
|
|
243
|
-
* config format, where options can be specified both in the config file and
|
|
244
|
-
* through CLI flags.
|
|
245
|
-
*
|
|
246
|
-
* @param argv - The CLI arguments.
|
|
247
|
-
* @param config - The config to merge the CLI options into.
|
|
248
|
-
* @returns The config with the CLI options merged in.
|
|
249
|
-
* @deprecated This function is only used to support the legacy config format.
|
|
250
|
-
*/ export function mergeLegacyOptions(argv, config) {
|
|
251
|
-
const cliOptions = Object.keys(config.cliOptions).reduce((accumulator, key)=>{
|
|
252
|
-
if (argv[key] !== undefined) {
|
|
253
|
-
return {
|
|
254
|
-
...accumulator,
|
|
255
|
-
[key]: argv[key]
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
return accumulator;
|
|
259
|
-
}, config.cliOptions);
|
|
260
|
-
return {
|
|
261
|
-
...config,
|
|
262
|
-
cliOptions
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Get a Webpack config from a legacy browserify config. This is used to
|
|
267
|
-
* support the legacy config format, and convert it to the new format.
|
|
268
|
-
*
|
|
269
|
-
* @param legacyConfig - The legacy browserify config.
|
|
270
|
-
* @returns The Webpack config.
|
|
271
|
-
*/ export function getWebpackConfig(legacyConfig) {
|
|
272
|
-
const defaultConfig = create({
|
|
273
|
-
bundler: 'webpack'
|
|
274
|
-
}, SnapsWebpackConfigStruct);
|
|
275
|
-
// The legacy config has two options for specifying the output path and
|
|
276
|
-
// filename: `bundle`, and `dist` + `outfileName`. If `bundle` is specified,
|
|
277
|
-
// we use that as the output path and filename. Otherwise, we use `dist` and
|
|
278
|
-
// `outfileName`.
|
|
279
|
-
const path = legacyConfig.cliOptions.bundle ? dirname(legacyConfig.cliOptions.bundle) : legacyConfig.cliOptions.dist;
|
|
280
|
-
const filename = legacyConfig.cliOptions.bundle ? basename(legacyConfig.cliOptions.bundle) : legacyConfig.cliOptions.outfileName;
|
|
281
|
-
return {
|
|
282
|
-
...defaultConfig,
|
|
283
|
-
input: legacyConfig.cliOptions.src,
|
|
284
|
-
evaluate: legacyConfig.cliOptions.eval,
|
|
285
|
-
sourceMap: legacyConfig.cliOptions.sourceMaps,
|
|
286
|
-
output: {
|
|
287
|
-
path,
|
|
288
|
-
filename,
|
|
289
|
-
// The legacy config has an option to remove comments from the bundle, but
|
|
290
|
-
// the terser plugin does this by default, so we only enable the terser if
|
|
291
|
-
// the legacy config has `stripComments` set to `true`. This is not a
|
|
292
|
-
// perfect solution, but it's the best we can do without breaking the
|
|
293
|
-
// legacy config.
|
|
294
|
-
minimize: legacyConfig.cliOptions.stripComments,
|
|
295
|
-
// The legacy config does not have a `clean` option, so we default to
|
|
296
|
-
// `false` here.
|
|
297
|
-
clean: false
|
|
298
|
-
},
|
|
299
|
-
manifest: {
|
|
300
|
-
// The legacy config does not have a `manifest` option, so we default to
|
|
301
|
-
// `process.cwd()/snap.manifest.json`.
|
|
302
|
-
path: resolve(process.cwd(), 'snap.manifest.json'),
|
|
303
|
-
update: legacyConfig.cliOptions.writeManifest
|
|
304
|
-
},
|
|
305
|
-
server: {
|
|
306
|
-
enabled: legacyConfig.cliOptions.serve,
|
|
307
|
-
port: legacyConfig.cliOptions.port,
|
|
308
|
-
root: legacyConfig.cliOptions.root
|
|
309
|
-
},
|
|
310
|
-
stats: {
|
|
311
|
-
verbose: false,
|
|
312
|
-
// These plugins are designed to be used with the modern config format, so
|
|
313
|
-
// we disable them for the legacy config format.
|
|
314
|
-
builtIns: false,
|
|
315
|
-
buffer: false
|
|
316
|
-
},
|
|
317
|
-
legacy: createFromStruct({
|
|
318
|
-
...legacyConfig.cliOptions,
|
|
319
|
-
bundlerCustomizer: legacyConfig.bundlerCustomizer
|
|
320
|
-
}, LegacyOptionsStruct, 'Invalid Browserify CLI options')
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
//# sourceMappingURL=config.js.map
|
package/dist/esm/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config.ts"],"sourcesContent":["import { literal, union } from '@metamask/snaps-sdk';\nimport {\n createFromStruct,\n file,\n indent,\n isFile,\n SnapsStructError,\n named,\n} from '@metamask/snaps-utils';\nimport { hasProperty } from '@metamask/utils';\nimport { transform } from '@swc/core';\nimport type { BrowserifyObject } from 'browserify';\nimport { dim } from 'chalk';\nimport { readFile } from 'fs/promises';\nimport Module from 'module';\nimport { basename, dirname, resolve } from 'path';\nimport type { Infer } from 'superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n define,\n func,\n number,\n object,\n optional,\n record,\n string,\n type,\n unknown,\n empty,\n} from 'superstruct';\nimport type { Configuration as WebpackConfiguration } from 'webpack';\n\nimport { TranspilationModes } from './builders';\nimport { ConfigError } from './errors';\nimport type { YargsArgs } from './types/yargs';\nimport { CONFIG_FILE, TS_CONFIG_FILE } from './utils';\n\nconst CONFIG_FILES = [CONFIG_FILE, TS_CONFIG_FILE];\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\nexport type SnapBrowserifyConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler?: 'browserify';\n\n /**\n * The options for the Snaps CLI. These are merged with the options passed to\n * the CLI, with the CLI options taking precedence.\n *\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n cliOptions?: {\n /**\n * The path to the snap bundle file.\n *\n * @default 'dist/bundle.js'\n */\n bundle?: string;\n\n /**\n * The directory to output the snap to. This is only used if `bundle` is\n * not specified.\n *\n * @default 'dist'\n */\n dist?: string;\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n eval?: boolean;\n\n /**\n * Whether to validate the snap manifest.\n *\n * @default true\n */\n manifest?: boolean;\n\n /**\n * The name of the bundle file. This is only used if `bundle` is not\n * specified.\n *\n * @default 'bundle.js'\n */\n outfileName?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n\n /**\n * The root directory to serve the snap from.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * Whether to generate source maps for the snap bundle.\n *\n * @default false\n */\n sourceMaps?: boolean;\n\n /**\n * The path to the snap entry point.\n *\n * @default 'src/index.js'\n */\n src?: string;\n\n /**\n * Whether to remove comments from the bundle.\n *\n * @default true\n */\n stripComments?: boolean;\n\n /**\n * Whether to suppress warnings.\n *\n * @default false\n */\n suppressWarnings?: boolean;\n\n /**\n * The transpilation mode to use, which determines which files are\n * transpiled.\n *\n * - `'localAndDeps'`: Transpile the snap entry point and all dependencies.\n * - `'localOnly'`: Transpile only the snap entry point.\n * - `'none'`: Don't transpile any files.\n *\n * @default 'localOnly'\n */\n transpilationMode?: 'localAndDeps' | 'localOnly' | 'none';\n\n /**\n * The dependencies to transpile when `transpilationMode` is set to\n * `'localAndDeps'`. If not specified, all dependencies will be transpiled.\n */\n depsToTranspile?: string[];\n\n /**\n * Whether to show original errors.\n *\n * @default true\n */\n verboseErrors?: boolean;\n\n /**\n * Whether to write the updated manifest to disk.\n *\n * @default true\n */\n writeManifest?: boolean;\n\n /**\n * Whether to serve the snap locally.\n *\n * @default true\n */\n serve?: boolean;\n };\n\n /**\n * A function that can be used to customize the Browserify instance used to\n * build the snap.\n *\n * @param bundler - The Browserify instance.\n * @deprecated The Browserify bundler is deprecated and will be removed in a\n * future release. Use the Webpack bundler instead.\n */\n bundlerCustomizer?: (bundler: BrowserifyObject) => void;\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapWebpackConfig = {\n /**\n * The bundler to use to build the snap. For backwards compatibility, if not\n * specified, Browserify will be used. However, the Browserify bundler is\n * deprecated and will be removed in a future release, so it's recommended to\n * use the Webpack bundler instead.\n */\n bundler: 'webpack';\n\n /**\n * The path to the snap entry point. This should be a JavaScript or TypeScript\n * file.\n */\n input: string;\n\n /**\n * Whether to generate source maps for the snap. If `true`, source maps will\n * be generated as separate files. If `'inline'`, source maps will be\n * inlined in the generated JavaScript bundle.\n *\n * @default true\n */\n sourceMap?: boolean | 'inline';\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n evaluate?: boolean;\n\n output?: {\n /**\n * The path to the directory where the snap will be built. This directory\n * will be created if it doesn't exist.\n *\n * If the path is relative, it will be resolved relative to the current\n * working directory.\n *\n * @default 'dist'\n */\n path?: string;\n\n /**\n * The name of the JavaScript bundle file.\n *\n * @default 'bundle.js'\n */\n filename?: string;\n\n /**\n * Whether to clean the output directory before building the snap. If\n * `true`, the output directory will be deleted and recreated. Otherwise,\n * the output directory will be left as-is.\n *\n * @default false\n */\n clean?: boolean;\n\n /**\n * Whether to minimize the snap bundle. If `true`, the bundle will be\n * minified. Otherwise, the bundle will be left as-is.\n *\n * @default true\n */\n minimize?: boolean;\n };\n\n manifest?: {\n /**\n * The path to the snap manifest file. If the path is relative, it will be\n * resolved relative to the current working directory.\n *\n * @default 'snap.manifest.json'\n */\n path?: string;\n\n /**\n * Whether to automatically update the manifest. If `true`, the manifest\n * will be updated with the latest shasum of the snap bundle, and some\n * common fields will be updated if they are missing or incorrect. If\n * `false`, the manifest will be left as-is.\n *\n * @default true\n */\n update?: boolean;\n };\n\n server?: {\n /**\n * Whether to enable the local server. If `true`, the snap will be served\n * from a local server, when running the `watch` command. If `false`, the\n * snap will not be served.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * The root directory to serve the snap from. If the path is relative, it\n * will be resolved relative to the current working directory.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n };\n\n /**\n * The environment variables to set when building the snap. These will be\n * available in the snap as `process.env`. In addition to these environment\n * variables, the following environment variables will always be set:\n *\n * - `NODE_DEBUG`: `false`\n * - `NODE_ENV`: `'production'`\n * - `DEBUG`: `false`\n *\n * Any environment variables specified here will override these defaults. You\n * can also override any variables here by setting them in your shell when\n * running the CLI.\n */\n environment?: Record<string, unknown>;\n\n /**\n * Options that control the logging output of the CLI.\n */\n stats?: {\n /**\n * Whether to enable verbose logging.\n *\n * @default false\n */\n verbose?: boolean;\n\n /**\n * Whether to log warnings about unresolved built-in modules. If `false`,\n * warnings will not be logged.\n */\n builtIns?:\n | {\n /**\n * The built-in modules to ignore when resolving modules. If a module\n * is ignored, no warning will be logged if it is not resolved.\n */\n ignore?: string[];\n }\n | false;\n\n /**\n * Whether to log warnings about the use of the `Buffer` global. If `false`,\n * warnings will not be logged. If `true`, the CLI will warn if the `Buffer`\n * global is used, but not provided by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n };\n\n /**\n * Whether to provide polyfills for node builtins. If `true`, all the available\n * polyfills will be provided. If `false` no polyfills will be provided. If a\n * configuration object is passed only the polyfills set to `true` will be provided.\n *\n * @default false\n * @example\n * ```ts\n * polyfills: true\n *\n * // or\n *\n * polyfills: {\n * assert: true,\n * buffer: true\n * }\n * ```\n */\n polyfills?:\n | boolean\n | {\n assert?: boolean;\n buffer?: boolean;\n console?: boolean;\n constants?: boolean;\n crypto?: boolean;\n domain?: boolean;\n events?: boolean;\n http?: boolean;\n https?: boolean;\n os?: boolean;\n path?: boolean;\n punycode?: boolean;\n process?: boolean;\n querystring?: boolean;\n stream?: boolean;\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex?: boolean;\n _stream_passthrough?: boolean;\n _stream_readable?: boolean;\n _stream_transform?: boolean;\n _stream_writable?: boolean;\n string_decoder?: boolean;\n /* eslint-enable @typescript-eslint/naming-convention */\n sys?: boolean;\n timers?: boolean;\n tty?: boolean;\n url?: boolean;\n util?: boolean;\n vm?: boolean;\n zlib?: boolean;\n };\n\n /**\n * A function to customize the Webpack configuration used to build the snap.\n * This function will be called with the default Webpack configuration, and\n * should return the modified configuration. If not specified, the default\n * configuration will be used.\n *\n * It's recommended to use the `webpack-merge` package to merge the default\n * configuration with your customizations. The merge function is exported as\n * `merge` from the `@metamask/snaps-cli` package.\n *\n * @example\n * ```ts\n * import type { SnapsConfig } from '@metamask/snaps-cli';\n * import { merge } from '@metamask/snaps-cli';\n *\n * const config: SnapsConfig = {\n * bundler: 'webpack',\n * entry: 'src/index.ts',\n * customizeWebpackConfig: (config) => merge(config, {\n * module: {\n * rules: [\n * {\n * test: /\\.wasm$/,\n * type: 'assets/resource',\n * },\n * ],\n * },\n * }),\n * };\n *\n * export default config;\n * ```\n */\n customizeWebpackConfig?: (\n config: WebpackConfiguration,\n ) => WebpackConfiguration;\n\n /**\n * Experimental features that can be enabled. These features are not\n * guaranteed to be stable, and may be removed or changed in a future release.\n */\n experimental?: {\n /**\n * Whether to enable WebAssembly support. If `true`, the Webpack\n * configuration will be modified to support WebAssembly. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default false\n */\n wasm?: boolean;\n };\n};\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapConfig = SnapBrowserifyConfig | SnapWebpackConfig;\n\ntype SnapsBrowserifyBundlerCustomizerFunction = (\n bundler: BrowserifyObject,\n) => void;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsBrowserifyBundlerCustomizerFunctionStruct =\n define<SnapsBrowserifyBundlerCustomizerFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsBrowserifyConfigStruct = object({\n bundler: defaulted(literal('browserify'), 'browserify'),\n cliOptions: defaulted(\n object({\n bundle: optional(file()),\n dist: defaulted(file(), 'dist'),\n eval: defaulted(boolean(), true),\n manifest: defaulted(boolean(), true),\n port: defaulted(number(), 8081),\n outfileName: defaulted(string(), 'bundle.js'),\n root: defaulted(file(), process.cwd()),\n sourceMaps: defaulted(boolean(), false),\n src: defaulted(file(), 'src/index.js'),\n stripComments: defaulted(boolean(), true),\n suppressWarnings: defaulted(boolean(), false),\n transpilationMode: defaulted(\n union([literal('localAndDeps'), literal('localOnly'), literal('none')]),\n 'localOnly',\n ),\n depsToTranspile: defaulted(array(string()), []),\n verboseErrors: defaulted(boolean(), true),\n writeManifest: defaulted(boolean(), true),\n serve: defaulted(boolean(), true),\n }),\n {},\n ),\n bundlerCustomizer: optional(SnapsBrowserifyBundlerCustomizerFunctionStruct),\n});\n\ntype SnapsWebpackCustomizeWebpackConfigFunction = (\n config: WebpackConfiguration,\n) => WebpackConfiguration;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsWebpackCustomizeWebpackConfigFunctionStruct =\n define<SnapsWebpackCustomizeWebpackConfigFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsWebpackConfigStruct = object({\n bundler: literal('webpack'),\n input: defaulted(file(), resolve(process.cwd(), 'src/index.js')),\n sourceMap: defaulted(union([boolean(), literal('inline')]), false),\n evaluate: defaulted(boolean(), true),\n\n output: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'dist')),\n filename: defaulted(string(), 'bundle.js'),\n clean: defaulted(boolean(), false),\n minimize: defaulted(boolean(), true),\n }),\n {},\n ),\n\n manifest: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'snap.manifest.json')),\n update: defaulted(boolean(), true),\n }),\n {},\n ),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n root: defaulted(file(), process.cwd()),\n port: defaulted(number(), 8081),\n }),\n {},\n ),\n\n environment: defaulted(record(string(), unknown()), {}),\n\n stats: defaulted(\n object({\n verbose: defaulted(boolean(), false),\n builtIns: defaulted(\n union([\n object({ ignore: defaulted(array(string()), []) }),\n literal(false),\n ]),\n {},\n ),\n buffer: defaulted(boolean(), true),\n }),\n {},\n ),\n\n polyfills: defaulted(\n union([\n boolean(),\n object({\n assert: defaulted(boolean(), false),\n buffer: defaulted(boolean(), false),\n console: defaulted(boolean(), false),\n constants: defaulted(boolean(), false),\n crypto: defaulted(boolean(), false),\n domain: defaulted(boolean(), false),\n events: defaulted(boolean(), false),\n http: defaulted(boolean(), false),\n https: defaulted(boolean(), false),\n os: defaulted(boolean(), false),\n path: defaulted(boolean(), false),\n punycode: defaulted(boolean(), false),\n process: defaulted(boolean(), false),\n querystring: defaulted(boolean(), false),\n stream: defaulted(boolean(), false),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: defaulted(boolean(), false),\n _stream_passthrough: defaulted(boolean(), false),\n _stream_readable: defaulted(boolean(), false),\n _stream_transform: defaulted(boolean(), false),\n _stream_writable: defaulted(boolean(), false),\n string_decoder: defaulted(boolean(), false),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: defaulted(boolean(), false),\n timers: defaulted(boolean(), false),\n tty: defaulted(boolean(), false),\n url: defaulted(boolean(), false),\n util: defaulted(boolean(), false),\n vm: defaulted(boolean(), false),\n zlib: defaulted(boolean(), false),\n }),\n ]),\n false,\n ),\n\n customizeWebpackConfig: optional(\n SnapsWebpackCustomizeWebpackConfigFunctionStruct,\n ),\n\n experimental: defaulted(\n object({\n wasm: defaulted(boolean(), false),\n }),\n {},\n ),\n});\n\nexport const SnapsConfigStruct = type({\n bundler: defaulted(\n union([literal('browserify'), literal('webpack')]),\n 'browserify',\n ),\n});\n\nexport const LegacyOptionsStruct = union([\n named(\n 'object with `transpilationMode` set to `localAndDeps` and `depsToTranspile` set to an array of strings',\n type({\n depsToTranspile: array(string()),\n transpilationMode: literal(TranspilationModes.LocalAndDeps),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n named(\n 'object without `depsToTranspile`',\n type({\n depsToTranspile: named('empty array', empty(array())),\n transpilationMode: union([\n literal(TranspilationModes.LocalOnly),\n literal(TranspilationModes.None),\n ]),\n writeManifest: boolean(),\n bundlerCustomizer: optional(\n SnapsBrowserifyBundlerCustomizerFunctionStruct,\n ),\n }),\n ),\n]);\n\nexport type LegacyOptions = Infer<typeof LegacyOptionsStruct>;\n\nexport type ProcessedBrowserifyConfig = Infer<\n typeof SnapsBrowserifyConfigStruct\n>;\n\nexport type ProcessedWebpackConfig = Infer<typeof SnapsWebpackConfigStruct> & {\n /**\n * The legacy Browserify config, if the bundler is Browserify. This is used\n * to support the legacy config format.\n */\n legacy?: LegacyOptions;\n};\n\nexport type ProcessedConfig = ProcessedWebpackConfig;\n\n/**\n * Get a validated snap config. This validates the config and adds default\n * values for any missing properties.\n *\n * @param config - The config to validate.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n */\nexport function getConfig(config: unknown, argv: YargsArgs): ProcessedConfig {\n const prefix = 'The snap config file is invalid';\n const suffix = dim(\n // TODO: Link to `docs.metamask.io` once the docs are published.\n 'Refer to the documentation for more information: https://github.com/MetaMask/snaps/tree/main/packages/snaps-cli/',\n );\n\n const { bundler } = createFromStruct(\n config,\n SnapsConfigStruct,\n prefix,\n suffix,\n );\n\n if (bundler === 'browserify') {\n const legacyConfig = createFromStruct(\n config,\n SnapsBrowserifyConfigStruct,\n prefix,\n suffix,\n );\n\n return getWebpackConfig(mergeLegacyOptions(argv, legacyConfig));\n }\n\n return createFromStruct(config, SnapsWebpackConfigStruct, prefix, suffix);\n}\n\n/**\n * Load a snap config from a file. This supports both JavaScript and TypeScript\n * config files, in the CommonJS module format and the ES module format.\n *\n * This assumes that the config file exports a default object, either through\n * `module.exports` or `export default`.\n *\n * @param path - The full path to the config file.\n * @param argv - The CLI arguments.\n * @returns The validated config.\n * @throws If the config file is invalid, or if the config file does not have a\n * default export.\n */\nexport async function loadConfig(path: string, argv: YargsArgs) {\n try {\n const contents = await readFile(path, 'utf8');\n const source = await transform(contents, {\n swcrc: false,\n jsc: {\n parser: {\n syntax: 'typescript',\n },\n },\n module: {\n type: 'commonjs',\n },\n });\n\n const config = new Module(path);\n\n // @ts-expect-error - This function is not typed.\n config.paths = Module._nodeModulePaths(dirname(path));\n\n // @ts-expect-error - This function is not typed.\n config._compile(source.code, path);\n\n if (!hasProperty(config.exports, 'default')) {\n return getConfig(config.exports, argv);\n }\n\n return getConfig(config.exports.default, argv);\n } catch (error) {\n if (error instanceof SnapsStructError) {\n throw new ConfigError(error.message);\n }\n\n throw new ConfigError(\n `Unable to load snap config file at \"${path}\".\\n\\n${indent(\n error.message,\n )}`,\n );\n }\n}\n\n/**\n * Resolve a snap config. This function will look for a `snap.config.js` or\n * `snap.config.ts` file in the current or specified directory.\n *\n * @param path - The path to resolve the snap config from. Defaults to the\n * current working directory.\n * @param argv - The CLI arguments.\n * @returns The resolved and validated snap config.\n * @throws If a snap config could not be found.\n */\nexport async function resolveConfig(path: string, argv: YargsArgs) {\n for (const configFile of CONFIG_FILES) {\n const filePath = resolve(path, configFile);\n if (await isFile(filePath)) {\n return await loadConfig(filePath, argv);\n }\n }\n\n throw new ConfigError(\n `Could not find a \"snap.config.js\" or \"snap.config.ts\" file in the current or specified directory (\"${path}\").`,\n );\n}\n\n/**\n * Get a snap config from the CLI arguments. This will either load the config\n * from the specified config file, or resolve the config from the current\n * working directory.\n *\n * @param argv - The CLI arguments.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The resolved and validated snap config.\n */\nexport async function getConfigByArgv(\n argv: YargsArgs,\n cwd: string = process.cwd(),\n) {\n if (argv.config) {\n if (!(await isFile(argv.config))) {\n throw new ConfigError(\n `Could not find a config file at \"${argv.config}\". Make sure that the path is correct.`,\n );\n }\n\n return await loadConfig(argv.config, argv);\n }\n\n return await resolveConfig(cwd, argv);\n}\n\n/**\n * Merge legacy CLI options into the config. This is used to support the legacy\n * config format, where options can be specified both in the config file and\n * through CLI flags.\n *\n * @param argv - The CLI arguments.\n * @param config - The config to merge the CLI options into.\n * @returns The config with the CLI options merged in.\n * @deprecated This function is only used to support the legacy config format.\n */\nexport function mergeLegacyOptions(\n argv: YargsArgs,\n config: ProcessedBrowserifyConfig,\n) {\n const cliOptions = Object.keys(config.cliOptions).reduce<\n ProcessedBrowserifyConfig['cliOptions']\n >((accumulator, key) => {\n if (argv[key] !== undefined) {\n return {\n ...accumulator,\n [key]: argv[key],\n };\n }\n\n return accumulator;\n }, config.cliOptions);\n\n return {\n ...config,\n cliOptions,\n };\n}\n\n/**\n * Get a Webpack config from a legacy browserify config. This is used to\n * support the legacy config format, and convert it to the new format.\n *\n * @param legacyConfig - The legacy browserify config.\n * @returns The Webpack config.\n */\nexport function getWebpackConfig(\n legacyConfig: ProcessedBrowserifyConfig,\n): ProcessedWebpackConfig {\n const defaultConfig = create(\n { bundler: 'webpack' },\n SnapsWebpackConfigStruct,\n );\n\n // The legacy config has two options for specifying the output path and\n // filename: `bundle`, and `dist` + `outfileName`. If `bundle` is specified,\n // we use that as the output path and filename. Otherwise, we use `dist` and\n // `outfileName`.\n const path = legacyConfig.cliOptions.bundle\n ? dirname(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.dist;\n\n const filename = legacyConfig.cliOptions.bundle\n ? basename(legacyConfig.cliOptions.bundle)\n : legacyConfig.cliOptions.outfileName;\n\n return {\n ...defaultConfig,\n input: legacyConfig.cliOptions.src,\n evaluate: legacyConfig.cliOptions.eval,\n sourceMap: legacyConfig.cliOptions.sourceMaps,\n output: {\n path,\n filename,\n\n // The legacy config has an option to remove comments from the bundle, but\n // the terser plugin does this by default, so we only enable the terser if\n // the legacy config has `stripComments` set to `true`. This is not a\n // perfect solution, but it's the best we can do without breaking the\n // legacy config.\n minimize: legacyConfig.cliOptions.stripComments,\n\n // The legacy config does not have a `clean` option, so we default to\n // `false` here.\n clean: false,\n },\n manifest: {\n // The legacy config does not have a `manifest` option, so we default to\n // `process.cwd()/snap.manifest.json`.\n path: resolve(process.cwd(), 'snap.manifest.json'),\n update: legacyConfig.cliOptions.writeManifest,\n },\n server: {\n enabled: legacyConfig.cliOptions.serve,\n port: legacyConfig.cliOptions.port,\n root: legacyConfig.cliOptions.root,\n },\n stats: {\n verbose: false,\n\n // These plugins are designed to be used with the modern config format, so\n // we disable them for the legacy config format.\n builtIns: false,\n buffer: false,\n },\n legacy: createFromStruct(\n {\n ...legacyConfig.cliOptions,\n bundlerCustomizer: legacyConfig.bundlerCustomizer,\n },\n LegacyOptionsStruct,\n 'Invalid Browserify CLI options',\n ),\n };\n}\n"],"names":["literal","union","createFromStruct","file","indent","isFile","SnapsStructError","named","hasProperty","transform","dim","readFile","Module","basename","dirname","resolve","array","boolean","create","defaulted","define","func","number","object","optional","record","string","type","unknown","empty","TranspilationModes","ConfigError","CONFIG_FILE","TS_CONFIG_FILE","CONFIG_FILES","SnapsBrowserifyBundlerCustomizerFunctionStruct","validator","SnapsBrowserifyConfigStruct","bundler","cliOptions","bundle","dist","eval","manifest","port","outfileName","root","process","cwd","sourceMaps","src","stripComments","suppressWarnings","transpilationMode","depsToTranspile","verboseErrors","writeManifest","serve","bundlerCustomizer","SnapsWebpackCustomizeWebpackConfigFunctionStruct","SnapsWebpackConfigStruct","input","sourceMap","evaluate","output","path","filename","clean","minimize","update","server","enabled","environment","stats","verbose","builtIns","ignore","buffer","polyfills","assert","console","constants","crypto","domain","events","http","https","os","punycode","querystring","stream","_stream_duplex","_stream_passthrough","_stream_readable","_stream_transform","_stream_writable","string_decoder","sys","timers","tty","url","util","vm","zlib","customizeWebpackConfig","experimental","wasm","SnapsConfigStruct","LegacyOptionsStruct","LocalAndDeps","LocalOnly","None","getConfig","config","argv","prefix","suffix","legacyConfig","getWebpackConfig","mergeLegacyOptions","loadConfig","contents","source","swcrc","jsc","parser","syntax","module","paths","_nodeModulePaths","_compile","code","exports","default","error","message","resolveConfig","configFile","filePath","getConfigByArgv","Object","keys","reduce","accumulator","key","undefined","defaultConfig","legacy"],"mappings":"AAAA,SAASA,OAAO,EAAEC,KAAK,QAAQ,sBAAsB;AACrD,SACEC,gBAAgB,EAChBC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,QACA,wBAAwB;AAC/B,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,GAAG,QAAQ,QAAQ;AAC5B,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,YAAY,SAAS;AAC5B,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,QAAQ,OAAO;AAElD,SACEC,KAAK,EACLC,OAAO,EACPC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,KAAK,QACA,cAAc;AAGrB,SAASC,kBAAkB,QAAQ,aAAa;AAChD,SAASC,WAAW,QAAQ,WAAW;AAEvC,SAASC,WAAW,EAAEC,cAAc,QAAQ,UAAU;AAEtD,MAAMC,eAAe;IAACF;IAAaC;CAAe;AAwblD,6EAA6E;AAC7E,6EAA6E;AAC7E,oBAAoB;AACpB,MAAME,iDACJf,OACE,YACAC,OAAOe,SAAS;AAGpB,OAAO,MAAMC,8BAA8Bd,OAAO;IAChDe,SAASnB,UAAUnB,QAAQ,eAAe;IAC1CuC,YAAYpB,UACVI,OAAO;QACLiB,QAAQhB,SAASrB;QACjBsC,MAAMtB,UAAUhB,QAAQ;QACxBuC,MAAMvB,UAAUF,WAAW;QAC3B0B,UAAUxB,UAAUF,WAAW;QAC/B2B,MAAMzB,UAAUG,UAAU;QAC1BuB,aAAa1B,UAAUO,UAAU;QACjCoB,MAAM3B,UAAUhB,QAAQ4C,QAAQ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ACAxB,UAAU;YACR,wEAAwE;YACxE,sCAAsC;YACtCsB,MAAMlD,QAAQgC,QAAQC,GAAG,IAAI;YAC7BqB,QAAQgD,aAAa9E,UAAU,CAACiB,aAAa;QAC/C;QACAc,QAAQ;YACNC,SAAS8C,aAAa9E,UAAU,CAACkB,KAAK;YACtCb,MAAMyE,aAAa9E,UAAU,CAACK,IAAI;YAClCE,MAAMuE,aAAa9E,UAAU,CAACO,IAAI;QACpC;QACA2B,OAAO;YACLC,SAAS;YAET,0EAA0E;YAC1E,gDAAgD;YAChDC,UAAU;YACVE,QAAQ;QACV;QACAsE,QAAQjJ,iBACN;YACE,GAAGmH,aAAa9E,UAAU;YAC1BmB,mBAAmB2D,aAAa3D,iBAAiB;QACnD,GACAkD,qBACA;IAEJ;AACF"}
|
package/dist/esm/errors.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { bold, red } from 'chalk';
|
|
2
|
-
/**
|
|
3
|
-
* An error that is thrown when the CLI fails. This is the base error for all
|
|
4
|
-
* CLI errors. It is not thrown directly, but is instead extended by other
|
|
5
|
-
* errors.
|
|
6
|
-
*
|
|
7
|
-
* This error is assumed to have all the information needed to display a
|
|
8
|
-
* readable error message, so it does not include the stack trace when it is
|
|
9
|
-
* thrown.
|
|
10
|
-
*/ export class CLIError extends Error {
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* An error that is thrown when a command fails.
|
|
14
|
-
*
|
|
15
|
-
* It wraps the error prefix in a bold red "Error" string.
|
|
16
|
-
*/ export class CommandError extends CLIError {
|
|
17
|
-
constructor(message, name = 'Error'){
|
|
18
|
-
super(message);
|
|
19
|
-
this.name = bold(red(name));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* An error that is thrown when the config file cannot be loaded.
|
|
24
|
-
*/ export class ConfigError extends CommandError {
|
|
25
|
-
constructor(message){
|
|
26
|
-
super(message, 'Config Error');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/esm/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors.ts"],"sourcesContent":["import { bold, red } from 'chalk';\n\n/**\n * An error that is thrown when the CLI fails. This is the base error for all\n * CLI errors. It is not thrown directly, but is instead extended by other\n * errors.\n *\n * This error is assumed to have all the information needed to display a\n * readable error message, so it does not include the stack trace when it is\n * thrown.\n */\nexport class CLIError extends Error {}\n\n/**\n * An error that is thrown when a command fails.\n *\n * It wraps the error prefix in a bold red \"Error\" string.\n */\nexport class CommandError extends CLIError {\n constructor(message: string, name = 'Error') {\n super(message);\n this.name = bold(red(name));\n }\n}\n\n/**\n * An error that is thrown when the config file cannot be loaded.\n */\nexport class ConfigError extends CommandError {\n constructor(message: string) {\n super(message, 'Config Error');\n }\n}\n"],"names":["bold","red","CLIError","Error","CommandError","constructor","message","name","ConfigError"],"mappings":"AAAA,SAASA,IAAI,EAAEC,GAAG,QAAQ,QAAQ;AAElC;;;;;;;;CAQC,GACD,OAAO,MAAMC,iBAAiBC;AAAO;AAErC;;;;CAIC,GACD,OAAO,MAAMC,qBAAqBF;IAChCG,YAAYC,OAAe,EAAEC,OAAO,OAAO,CAAE;QAC3C,KAAK,CAACD;QACN,IAAI,CAACC,IAAI,GAAGP,KAAKC,IAAIM;IACvB;AACF;AAEA;;CAEC,GACD,OAAO,MAAMC,oBAAoBJ;IAC/BC,YAAYC,OAAe,CAAE;QAC3B,KAAK,CAACA,SAAS;IACjB;AACF"}
|
package/dist/esm/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * as utils from './utils';
|
|
2
|
-
export { getDefaultConfiguration, SnapsStatsPlugin, SnapsWatchPlugin, SnapsBuiltInResolver, SnapsBundleWarningsPlugin } from './webpack';
|
|
3
|
-
// Re-exported from `snaps-cli` for convenience.
|
|
4
|
-
export { merge } from 'webpack-merge';
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * as utils from './utils';\nexport type { SnapConfig } from './config';\nexport {\n getDefaultConfiguration,\n SnapsStatsPlugin,\n SnapsWatchPlugin,\n SnapsBuiltInResolver,\n SnapsBundleWarningsPlugin,\n} from './webpack';\nexport type {\n SnapsStatsPluginOptions,\n SnapsWatchPluginOptions,\n SnapsBuiltInResolverOptions,\n SnapsBundleWarningsPluginOptions,\n} from './webpack';\n\n// Re-exported from `snaps-cli` for convenience.\nexport { merge } from 'webpack-merge';\n"],"names":["utils","getDefaultConfiguration","SnapsStatsPlugin","SnapsWatchPlugin","SnapsBuiltInResolver","SnapsBundleWarningsPlugin","merge"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,UAAU;AAEjC,SACEC,uBAAuB,EACvBC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,yBAAyB,QACpB,YAAY;AAQnB,gDAAgD;AAChD,SAASC,KAAK,QAAQ,gBAAgB"}
|
package/dist/esm/main.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { logError } from '@metamask/snaps-utils';
|
|
3
|
-
import { cli } from './cli';
|
|
4
|
-
import commands from './commands';
|
|
5
|
-
cli(process.argv, commands).catch((error)=>{
|
|
6
|
-
logError(error);
|
|
7
|
-
process.exitCode = 1;
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=main.js.map
|
package/dist/esm/main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/main.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { logError } from '@metamask/snaps-utils';\n\nimport { cli } from './cli';\nimport commands from './commands';\n\ncli(process.argv, commands).catch((error) => {\n logError(error);\n process.exitCode = 1;\n});\n"],"names":["logError","cli","commands","process","argv","catch","error","exitCode"],"mappings":";AAEA,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD,SAASC,GAAG,QAAQ,QAAQ;AAC5B,OAAOC,cAAc,aAAa;AAElCD,IAAIE,QAAQC,IAAI,EAAEF,UAAUG,KAAK,CAAC,CAACC;IACjCN,SAASM;IACTH,QAAQI,QAAQ,GAAG;AACrB"}
|
package/dist/esm/utils/cli.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export const CONFIG_FILE = 'snap.config.js';
|
|
3
|
-
export const TS_CONFIG_FILE = 'snap.config.ts';
|
|
4
|
-
// CLI arguments whose values are file paths.
|
|
5
|
-
const pathArguments = new Set([
|
|
6
|
-
'src',
|
|
7
|
-
's',
|
|
8
|
-
'dist',
|
|
9
|
-
'd',
|
|
10
|
-
'bundle',
|
|
11
|
-
'b',
|
|
12
|
-
'root',
|
|
13
|
-
'r'
|
|
14
|
-
]);
|
|
15
|
-
/**
|
|
16
|
-
* Sanitizes inputs. Currently normalizes "./" paths to ".".
|
|
17
|
-
* Yargs handles other path normalization as specified in builders.
|
|
18
|
-
*
|
|
19
|
-
* @param argv - Arguments as an object generated by yargs.
|
|
20
|
-
*/ export function sanitizeInputs(argv) {
|
|
21
|
-
Object.keys(argv).forEach((key)=>{
|
|
22
|
-
if (typeof argv[key] === 'string') {
|
|
23
|
-
// Node's path.normalize() does not do this
|
|
24
|
-
if (argv[key] === './') {
|
|
25
|
-
argv[key] = '.';
|
|
26
|
-
}
|
|
27
|
-
if (pathArguments.has(key)) {
|
|
28
|
-
argv[key] = path.normalize(argv[key]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Trims leading and trailing periods "." and forward slashes "/" from the
|
|
35
|
-
* given path string.
|
|
36
|
-
*
|
|
37
|
-
* @param pathString - The path string to trim.
|
|
38
|
-
* @returns The trimmed path string.
|
|
39
|
-
*/ export function trimPathString(pathString) {
|
|
40
|
-
return pathString.replace(/^[./]+|[./]+$/gu, '');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/cli.ts"],"sourcesContent":["import path from 'path';\n\nexport const CONFIG_FILE = 'snap.config.js';\nexport const TS_CONFIG_FILE = 'snap.config.ts';\n\n// CLI arguments whose values are file paths.\nconst pathArguments = new Set([\n 'src',\n 's',\n 'dist',\n 'd',\n 'bundle',\n 'b',\n 'root',\n 'r',\n]);\n\n/**\n * Sanitizes inputs. Currently normalizes \"./\" paths to \".\".\n * Yargs handles other path normalization as specified in builders.\n *\n * @param argv - Arguments as an object generated by yargs.\n */\nexport function sanitizeInputs(argv: Record<string, unknown>) {\n Object.keys(argv).forEach((key) => {\n if (typeof argv[key] === 'string') {\n // Node's path.normalize() does not do this\n if (argv[key] === './') {\n argv[key] = '.';\n }\n\n if (pathArguments.has(key)) {\n argv[key] = path.normalize(argv[key] as string);\n }\n }\n });\n}\n\n/**\n * Trims leading and trailing periods \".\" and forward slashes \"/\" from the\n * given path string.\n *\n * @param pathString - The path string to trim.\n * @returns The trimmed path string.\n */\nexport function trimPathString(pathString: string): string {\n return pathString.replace(/^[./]+|[./]+$/gu, '');\n}\n"],"names":["path","CONFIG_FILE","TS_CONFIG_FILE","pathArguments","Set","sanitizeInputs","argv","Object","keys","forEach","key","has","normalize","trimPathString","pathString","replace"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAExB,OAAO,MAAMC,cAAc,iBAAiB;AAC5C,OAAO,MAAMC,iBAAiB,iBAAiB;AAE/C,6CAA6C;AAC7C,MAAMC,gBAAgB,IAAIC,IAAI;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;;CAKC,GACD,OAAO,SAASC,eAAeC,IAA6B;IAC1DC,OAAOC,IAAI,CAACF,MAAMG,OAAO,CAAC,CAACC;QACzB,IAAI,OAAOJ,IAAI,CAACI,IAAI,KAAK,UAAU;YACjC,2CAA2C;YAC3C,IAAIJ,IAAI,CAACI,IAAI,KAAK,MAAM;gBACtBJ,IAAI,CAACI,IAAI,GAAG;YACd;YAEA,IAAIP,cAAcQ,GAAG,CAACD,MAAM;gBAC1BJ,IAAI,CAACI,IAAI,GAAGV,KAAKY,SAAS,CAACN,IAAI,CAACI,IAAI;YACtC;QACF;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,eAAeC,UAAkB;IAC/C,OAAOA,WAAWC,OAAO,CAAC,mBAAmB;AAC/C"}
|
package/dist/esm/utils/errors.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { hasProperty, isObject } from '@metamask/utils';
|
|
2
|
-
import { CLIError } from '../errors';
|
|
3
|
-
/**
|
|
4
|
-
* Get the error message from an error in a Yargs `fail` handler. If the error
|
|
5
|
-
* is not `undefined`, {@link getErrorMessage} is used to get the error message.
|
|
6
|
-
* Otherwise, the given message is returned.
|
|
7
|
-
*
|
|
8
|
-
* @param message - The error message.
|
|
9
|
-
* @param error - The error object. This may be `undefined`.
|
|
10
|
-
* @returns The error message.
|
|
11
|
-
*/ export function getYargsErrorMessage(message, error) {
|
|
12
|
-
if (error) {
|
|
13
|
-
if (error instanceof CLIError) {
|
|
14
|
-
return error.message;
|
|
15
|
-
}
|
|
16
|
-
return getErrorMessage(error);
|
|
17
|
-
}
|
|
18
|
-
return message;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get the error message from an error.
|
|
22
|
-
*
|
|
23
|
-
* - If the error is an object with a `stack` property, the `stack` property is
|
|
24
|
-
* returned.
|
|
25
|
-
* - If the error is an object with a `message` property, the `message`
|
|
26
|
-
* property is returned.
|
|
27
|
-
* - Otherwise, the error is converted to a string and returned.
|
|
28
|
-
*
|
|
29
|
-
* @param error - The error to get the message from.
|
|
30
|
-
* @returns The error message.
|
|
31
|
-
*/ export function getErrorMessage(error) {
|
|
32
|
-
if (isObject(error)) {
|
|
33
|
-
if (hasProperty(error, 'stack') && typeof error.stack === 'string') {
|
|
34
|
-
return error.stack;
|
|
35
|
-
}
|
|
36
|
-
if (hasProperty(error, 'message') && typeof error.message === 'string') {
|
|
37
|
-
return error.message;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return String(error);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/errors.ts"],"sourcesContent":["import { hasProperty, isObject } from '@metamask/utils';\n\nimport { CLIError } from '../errors';\n\n/**\n * Get the error message from an error in a Yargs `fail` handler. If the error\n * is not `undefined`, {@link getErrorMessage} is used to get the error message.\n * Otherwise, the given message is returned.\n *\n * @param message - The error message.\n * @param error - The error object. This may be `undefined`.\n * @returns The error message.\n */\nexport function getYargsErrorMessage(message: string, error?: unknown): string {\n if (error) {\n if (error instanceof CLIError) {\n return error.message;\n }\n\n return getErrorMessage(error);\n }\n\n return message;\n}\n\n/**\n * Get the error message from an error.\n *\n * - If the error is an object with a `stack` property, the `stack` property is\n * returned.\n * - If the error is an object with a `message` property, the `message`\n * property is returned.\n * - Otherwise, the error is converted to a string and returned.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n */\nexport function getErrorMessage(error: unknown): string {\n if (isObject(error)) {\n if (hasProperty(error, 'stack') && typeof error.stack === 'string') {\n return error.stack;\n }\n\n if (hasProperty(error, 'message') && typeof error.message === 'string') {\n return error.message;\n }\n }\n\n return String(error);\n}\n"],"names":["hasProperty","isObject","CLIError","getYargsErrorMessage","message","error","getErrorMessage","stack","String"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,kBAAkB;AAExD,SAASC,QAAQ,QAAQ,YAAY;AAErC;;;;;;;;CAQC,GACD,OAAO,SAASC,qBAAqBC,OAAe,EAAEC,KAAe;IACnE,IAAIA,OAAO;QACT,IAAIA,iBAAiBH,UAAU;YAC7B,OAAOG,MAAMD,OAAO;QACtB;QAEA,OAAOE,gBAAgBD;IACzB;IAEA,OAAOD;AACT;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASE,gBAAgBD,KAAc;IAC5C,IAAIJ,SAASI,QAAQ;QACnB,IAAIL,YAAYK,OAAO,YAAY,OAAOA,MAAME,KAAK,KAAK,UAAU;YAClE,OAAOF,MAAME,KAAK;QACpB;QAEA,IAAIP,YAAYK,OAAO,cAAc,OAAOA,MAAMD,OAAO,KAAK,UAAU;YACtE,OAAOC,MAAMD,OAAO;QACtB;IACF;IAEA,OAAOI,OAAOH;AAChB"}
|
package/dist/esm/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export * from './cli';\nexport * from './errors';\nexport * from './legacy';\nexport * from './logging';\nexport * from './path';\nexport * from './steps';\n"],"names":[],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,UAAU"}
|
package/dist/esm/utils/legacy.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { TranspilationModes } from '../builders';
|
|
2
|
-
/**
|
|
3
|
-
* Get the dependencies to transpile, as well as the regular input file.
|
|
4
|
-
*
|
|
5
|
-
* If `transpilationMode` is not set to `localAndDeps`, this will return an
|
|
6
|
-
* empty array.
|
|
7
|
-
*
|
|
8
|
-
* @param config - The config object.
|
|
9
|
-
* @returns An array with regular expressions of dependencies that should be
|
|
10
|
-
* transpiled.
|
|
11
|
-
*/ export function processDependencies(config) {
|
|
12
|
-
const { depsToTranspile, transpilationMode } = config;
|
|
13
|
-
if (transpilationMode === TranspilationModes.LocalAndDeps) {
|
|
14
|
-
const regex = getDependencyRegExp(depsToTranspile);
|
|
15
|
-
if (regex !== null) {
|
|
16
|
-
return [
|
|
17
|
-
regex
|
|
18
|
-
];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Processes a string of space delimited dependencies into one RegExp string.
|
|
25
|
-
*
|
|
26
|
-
* @param dependencies - An array of dependencies to add to the RegExp.
|
|
27
|
-
* @returns A RegExp object.
|
|
28
|
-
*/ export function getDependencyRegExp(dependencies) {
|
|
29
|
-
if (!dependencies || dependencies.includes('.') || !dependencies.length) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const paths = sanitizeDependencyPaths(dependencies);
|
|
33
|
-
return RegExp(`/node_modules/(?!${paths.join('|')})`, 'u');
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Helper function to remove any leading and trailing slashes from dependency
|
|
37
|
-
* list.
|
|
38
|
-
*
|
|
39
|
-
* @param dependencies - An array of dependencies to sanitize.
|
|
40
|
-
* @returns An array of sanitized paths.
|
|
41
|
-
*/ export function sanitizeDependencyPaths(dependencies) {
|
|
42
|
-
return dependencies.map((dependency)=>{
|
|
43
|
-
return dependency.replace(/^[/\\]+/u, '').replace(/[/\\]+$/u, '');
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=legacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/legacy.ts"],"sourcesContent":["import { TranspilationModes } from '../builders';\nimport type { LegacyOptions } from '../config';\n\n/**\n * Get the dependencies to transpile, as well as the regular input file.\n *\n * If `transpilationMode` is not set to `localAndDeps`, this will return an\n * empty array.\n *\n * @param config - The config object.\n * @returns An array with regular expressions of dependencies that should be\n * transpiled.\n */\nexport function processDependencies(config: LegacyOptions) {\n const { depsToTranspile, transpilationMode } = config;\n if (transpilationMode === TranspilationModes.LocalAndDeps) {\n const regex = getDependencyRegExp(depsToTranspile);\n if (regex !== null) {\n return [regex];\n }\n }\n\n return [];\n}\n\n/**\n * Processes a string of space delimited dependencies into one RegExp string.\n *\n * @param dependencies - An array of dependencies to add to the RegExp.\n * @returns A RegExp object.\n */\nexport function getDependencyRegExp(dependencies: string[]): RegExp | null {\n if (!dependencies || dependencies.includes('.') || !dependencies.length) {\n return null;\n }\n\n const paths: string[] = sanitizeDependencyPaths(dependencies);\n return RegExp(`/node_modules/(?!${paths.join('|')})`, 'u');\n}\n\n/**\n * Helper function to remove any leading and trailing slashes from dependency\n * list.\n *\n * @param dependencies - An array of dependencies to sanitize.\n * @returns An array of sanitized paths.\n */\nexport function sanitizeDependencyPaths(dependencies: string[]): string[] {\n return dependencies.map((dependency) => {\n return dependency.replace(/^[/\\\\]+/u, '').replace(/[/\\\\]+$/u, '');\n });\n}\n"],"names":["TranspilationModes","processDependencies","config","depsToTranspile","transpilationMode","LocalAndDeps","regex","getDependencyRegExp","dependencies","includes","length","paths","sanitizeDependencyPaths","RegExp","join","map","dependency","replace"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,cAAc;AAGjD;;;;;;;;;CASC,GACD,OAAO,SAASC,oBAAoBC,MAAqB;IACvD,MAAM,EAAEC,eAAe,EAAEC,iBAAiB,EAAE,GAAGF;IAC/C,IAAIE,sBAAsBJ,mBAAmBK,YAAY,EAAE;QACzD,MAAMC,QAAQC,oBAAoBJ;QAClC,IAAIG,UAAU,MAAM;YAClB,OAAO;gBAACA;aAAM;QAChB;IACF;IAEA,OAAO,EAAE;AACX;AAEA;;;;;CAKC,GACD,OAAO,SAASC,oBAAoBC,YAAsB;IACxD,IAAI,CAACA,gBAAgBA,aAAaC,QAAQ,CAAC,QAAQ,CAACD,aAAaE,MAAM,EAAE;QACvE,OAAO;IACT;IAEA,MAAMC,QAAkBC,wBAAwBJ;IAChD,OAAOK,OAAO,CAAC,iBAAiB,EAAEF,MAAMG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;AACxD;AAEA;;;;;;CAMC,GACD,OAAO,SAASF,wBAAwBJ,YAAsB;IAC5D,OAAOA,aAAaO,GAAG,CAAC,CAACC;QACvB,OAAOA,WAAWC,OAAO,CAAC,YAAY,IAAIA,OAAO,CAAC,YAAY;IAChE;AACF"}
|