diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index 5a4f36c49a..e8845b1941 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "VvMm+Zet1+q467UNweIuLLtYVoHoJdTeNjZn0xnEwO8=", + "shasum": "2OhDjaajEbvT1LdHB1G/Jl9NpfRtJxYl87w1c+1eJck=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index 7ddf383b34..425262a78e 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "ZXgMRkK/FtEZlwVSdOC+dmP99tuBTqHx/2Mj/FNhzAg=", + "shasum": "uh0g/qoSTv4n3PQrESflSZbajX7GaGUZQkr4DxSSWsw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-cli/src/commands/build/implementation.test.ts b/packages/snaps-cli/src/commands/build/implementation.test.ts index 79ff01c15a..26446fe7da 100644 --- a/packages/snaps-cli/src/commands/build/implementation.test.ts +++ b/packages/snaps-cli/src/commands/build/implementation.test.ts @@ -129,7 +129,7 @@ describe('build', () => { const output = await fs.readFile('/snap/output.js', 'utf8'); expect(output).toMatchInlineSnapshot( - `"(()=>{var e={67:e=>{e.exports.onRpcRequest=({request:e})=>{console.log("Hello, world!");const{method:r,id:o}=e;return r+o}}},r={};var o=function o(t){var s=r[t];if(void 0!==s)return s.exports;var n=r[t]={exports:{}};return e[t](n,n.exports,o),n.exports}(67),t=exports;for(var s in o)t[s]=o[s];o.__esModule&&Object.defineProperty(t,"__esModule",{value:!0})})();"`, + `"(()=>{var r={67:r=>{r.exports.onRpcRequest=({request:r})=>{console.log("Hello, world!");const{method:e,id:o}=r;return e+o}}},e={};var o=function o(t){var s=e[t];if(void 0!==s)return s.exports;var n=e[t]={exports:{}};return r[t](n,n.exports,o),n.exports}(67);module.exports=o})();"`, ); }); @@ -191,11 +191,7 @@ describe('build', () => { return module.exports; } var __webpack_exports__ = __webpack_require__(67); - var __webpack_export_target__ = exports; - for (var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i]; - if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { - value: true - }); + module.exports = __webpack_exports__; })();" `); }); @@ -230,7 +226,7 @@ describe('build', () => { .replace(/u.exports\}\(\d+\),t/u, 'u.exports}(1),t'); expect(deterministicOutput).toMatchInlineSnapshot( - `"(()=>{var r={1:r=>{r.exports=function(){function r(e,o,t){function n(s,i){if(!o[s]){if(!e[s]){if(u)return u(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=o[s]={exports:{}};e[s][0].call(c.exports,(function(r){return n(e[s][1][r]||r)}),c,c.exports,r,e,o,t)}return o[s].exports}for(var u=void 0,s=0;s{console.log("Hello, world!");const{method:e,id:o}=r;return e+o}},{}]},{},[1])(1)}},e={};var o=function o(t){var n=e[t];if(void 0!==n)return n.exports;var u=e[t]={exports:{}};return r[t](u,u.exports,o),u.exports}(1),t=exports;for(var n in o)t[n]=o[n];o.__esModule&&Object.defineProperty(t,"__esModule",{value:!0})})();"`, + `"(()=>{var r={1:r=>{r.exports=function(){function r(o,t,e){function n(s,i){if(!t[s]){if(!o[s]){if(u)return u(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=t[s]={exports:{}};o[s][0].call(f.exports,(function(r){return n(o[s][1][r]||r)}),f,f.exports,r,o,t,e)}return t[s].exports}for(var u=void 0,s=0;s{console.log("Hello, world!");const{method:o,id:t}=r;return o+t}},{}]},{},[1])(1)}},o={};var t=function t(e){var n=o[e];if(void 0!==n)return n.exports;var u=o[e]={exports:{}};return r[e](u,u.exports,t),u.exports}(360);module.exports=t})();"`, ); }); @@ -336,11 +332,7 @@ describe('build', () => { return module.exports; } var __webpack_exports__ = __webpack_require__(1); - var __webpack_export_target__ = exports; - for (var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i]; - if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { - value: true - }); + module.exports = __webpack_exports__; })();" `); }); diff --git a/packages/snaps-cli/src/webpack/__snapshots__/config.test.ts.snap b/packages/snaps-cli/src/webpack/__snapshots__/config.test.ts.snap index d7a929c3ff..6a4be43cda 100644 --- a/packages/snaps-cli/src/webpack/__snapshots__/config.test.ts.snap +++ b/packages/snaps-cli/src/webpack/__snapshots__/config.test.ts.snap @@ -4,9 +4,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -93,7 +90,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -177,9 +175,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -266,7 +261,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -350,9 +346,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": "inline-source-map", "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -439,7 +432,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -523,9 +517,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": "source-map", "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -612,7 +603,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -687,9 +679,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -784,7 +773,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -868,9 +858,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -957,7 +944,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -1041,9 +1029,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -1130,7 +1115,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -1214,9 +1200,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -1303,7 +1286,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -1395,9 +1379,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -1484,7 +1465,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -1576,9 +1558,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -1650,7 +1629,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -1734,9 +1714,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -1823,7 +1800,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -1915,9 +1893,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -2004,7 +1979,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -2096,9 +2072,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -2185,7 +2158,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/bar/baz", "publicPath": "/", @@ -2278,9 +2252,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -2367,7 +2338,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/bar/baz", "publicPath": "/", @@ -2451,9 +2423,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -2540,7 +2509,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/bar/baz", "publicPath": "/", @@ -2624,9 +2594,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -2713,7 +2680,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/bar/baz", "publicPath": "/", @@ -2806,9 +2774,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -2895,7 +2860,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/bar/baz", "publicPath": "/", @@ -2988,9 +2954,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.js", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -3073,7 +3036,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -3147,9 +3111,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -3232,7 +3193,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", @@ -3306,9 +3268,6 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t { "devtool": false, "entry": "/foo/bar/src/index.ts", - "experiments": { - "topLevelAwait": false, - }, "infrastructureLogging": { "level": "none", }, @@ -3391,7 +3350,8 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t "clean": false, "filename": "bundle.js", "library": { - "type": "commonjs", + "name": "module.exports", + "type": "assign", }, "path": "/foo/bar/dist", "publicPath": "/", diff --git a/packages/snaps-cli/src/webpack/loaders/wasm.test.ts b/packages/snaps-cli/src/webpack/loaders/wasm.test.ts index feb80e48de..5ab5cbe617 100644 --- a/packages/snaps-cli/src/webpack/loaders/wasm.test.ts +++ b/packages/snaps-cli/src/webpack/loaders/wasm.test.ts @@ -85,8 +85,7 @@ describe('loader', () => { } const bytes = decode(b64); - const module = new WebAssembly.Module(bytes); - const instance = new WebAssembly.Instance(module, { + const { instance } = await WebAssembly.instantiate(bytes, { "../src/bindings.ts": { add }, });