Skip to content

Commit

Permalink
Update packages to be browser-first and use separate export for Node.…
Browse files Browse the repository at this point in the history
…js (#2211)

This refactors all packages to be browser-first: All APIs and packages
used should be compatible with browsers. This means no use of Node.js
builtins, or native packages. Node-specific APIs have been moved to a
separate export `/node` (e.g., `@metamask/snaps-controllers/node`). For
the `snaps-controllers` package I've also added a `/react-native`
export, which exports the React Native webview service.

This also means we can remove the "browser" field from the packages that
were using it.

## Breaking changes

- Anything that uses Node.js was removed from the default export, and
needs to be imported from `/node`.
- The React Native webview service was moved, and needs to be imported
from `/react-native`.
  • Loading branch information
Mrtenz authored Feb 23, 2024
1 parent 9617754 commit 72cfc76
Show file tree
Hide file tree
Showing 100 changed files with 280 additions and 158 deletions.
13 changes: 13 additions & 0 deletions .yarn/patches/tsconfig-paths-npm-3.14.2-90ce75420d.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/try-path.js b/lib/try-path.js
index de11ccbf9090658eb0ee61bdba1984ee21bcb3b7..2e75f72483aa7b05bf0a2cde06b3c009eb2103e8 100644
--- a/lib/try-path.js
+++ b/lib/try-path.js
@@ -85,6 +85,6 @@ function matchStar(pattern, search) {
if (search.substr(search.length - part2.length) !== part2) {
return undefined;
}
- return search.substr(star, search.length - part2.length);
+ return search.substr(star, search.length - part2.length - part1.length);
}
//# sourceMappingURL=try-path.js.map
\ No newline at end of file
5 changes: 3 additions & 2 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ gen_enforced_field(WorkspaceCwd, 'scripts.build', 'tsup --clean && yarn build:ty
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.',
WorkspaceCwd \= 'packages/snaps-simulator',
WorkspaceCwd \= 'packages/snaps-cli'.
gen_enforced_field(WorkspaceCwd, 'build:types', 'tsc --project tsconfig.build.json') :-
WorkspaceCwd \= 'packages/snaps-cli',
WorkspaceCwd \= 'packages/snaps-execution-environments'.
gen_enforced_field(WorkspaceCwd, 'scripts.build:types', 'tsc --project tsconfig.build.json') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
Expand Down
1 change: 1 addition & 0 deletions jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module.exports = {
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'^@metamask/(.+)/test-utils$': ['<rootDir>/../$1/src/test-utils'],
'^@metamask/(.+)/node$': ['<rootDir>/../$1/src/node'],
'^@metamask/(.+)$': [
'<rootDir>/../$1/src',
'<rootDir>/../../node_modules/@metamask/$1',
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
"jest-util@^29.5.0": "patch:jest-util@npm%3A29.6.3#./.yarn/patches/jest-util-npm-29.6.3-6ffdea2c1c.patch",
"jest-util@^29.6.3": "patch:jest-util@npm%3A29.6.3#./.yarn/patches/jest-util-npm-29.6.3-6ffdea2c1c.patch",
"lavamoat-browserify@^17.0.4": "patch:lavamoat-browserify@npm%3A17.0.4#./.yarn/patches/lavamoat-browserify-npm-17.0.4-5df88049cf.patch",
"luxon@^3.2.1": "patch:luxon@npm%3A3.3.0#./.yarn/patches/luxon-npm-3.3.0-bdbae9bfd5.patch"
"luxon@^3.2.1": "patch:luxon@npm%3A3.3.0#./.yarn/patches/luxon-npm-3.3.0-bdbae9bfd5.patch",
"tsconfig-paths@^3.11.0": "patch:tsconfig-paths@npm%3A3.14.2#./.yarn/patches/tsconfig-paths-npm-3.14.2-90ce75420d.patch",
"tsconfig-paths@^3.14.1": "patch:tsconfig-paths@npm%3A3.14.2#./.yarn/patches/tsconfig-paths-npm-3.14.2-90ce75420d.patch",
"tsconfig-paths@^4.1.2": "patch:tsconfig-paths@npm%3A3.14.2#./.yarn/patches/tsconfig-paths-npm-3.14.2-90ce75420d.patch"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-snap/src/cmds/init/initHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
readJsonFile,
createSnapManifest,
logInfo,
} from '@metamask/snaps-utils';
} from '@metamask/snaps-utils/node';
import type { SemVerRange, SemVerVersion } from '@metamask/utils';
import { satisfiesVersionRange } from '@metamask/utils';
import { promises as fs } from 'fs';
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/bip32/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip32/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "AaLbshZePKcSV2NORnmd5AjzkX5vNQToD3PaE4YpUUQ=",
"shasum": "Gd22Ra/FTR8V9vvsBZIWjDZG5z1NfmbzvX5j6/hYAyA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/bip44/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip44/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "q5WeZJXrE5mgP2Z6Fo/aJrVuspPsQgsUn3/SmHuwsGY=",
"shasum": "/kHhPnMUYOkC3E1CuB5ngM8Mnou4PkjimKqCmpK2Gck=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/browserify-plugin/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/browserify/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/examples/packages/browserify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"resolveJsonModule": true,
"baseUrl": "./",
"paths": {
"@metamask/*/node": ["../../../*/src/node"],
"@metamask/*": ["../../../*/src"]
}
},
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/client-status/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/cronjobs/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/cronjobs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "wXAAi/QR4BT1Gp6OiSqCpq+3U7pyRtMQ/LP9LeWwEPk=",
"shasum": "zHa2vgQgfBfSIXT3QqDKVL4YfpxwDonbdZkILpwGPO8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/dialogs/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/dialogs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "EepV6igtZ0ZCX579Ws6f9u0/kYnp65+6OK1SgzCm9Dg=",
"shasum": "Wftu6BGjaYT+DXL/Cn8Gck1QXoBwB38MCj2yB63WWuk=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/errors/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/ethereum-provider/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/ethers-js/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/ethers-js/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "AjzlrjmJQTKwGM77EXcpEzjF9bsKK7up36BSA4qhasU=",
"shasum": "XmL7EjQCPlW0awlEn4xSV9KRP/bilZUtkKVug0XkfHs=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/get-entropy/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-entropy/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "9jRaEw4/0RCp3b3oAI+PK2zcgwupdOnBhaL4zX4pKRg=",
"shasum": "sJ3r94HPmIlla/608eE3rfQIynwqld8hNuFlB1ql6+8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/get-file/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/home-page/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/home-page/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "4LSF+30bmPlizM/wYBrq4dp72wkcca9rwYyqkz7ZPvY=",
"shasum": "mHYTfsz7m1KBUGY1ea3oyzKMlkALE+1LuapH8lHQgkg=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/images/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/images/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "v2cJ3d1fomwpUzSR+XZCLF88e5k0NOm5aVo8dftKKSU=",
"shasum": "BP1QxFZ4M09F0DquuEgBisM2RX4kejUUzzRyh2+Rxzw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/interactive-ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "sKqHlIDCKGyzDhV7wlJTv7RR6m6lrJF4KgyoTacwYao=",
"shasum": "+2kLtnz+tutH+k4Q3Zl4mBwsDCQ3i91pbSpJ07l/S8w=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../../../$1/src/node',
'<rootDir>/../../../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../../../$1/src',
'<rootDir>/../../../../../../node_modules/@metamask/$1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../../../$1/src/node',
'<rootDir>/../../../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../../../$1/src',
'<rootDir>/../../../../../../node_modules/@metamask/$1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "ojUZu1+nqCNBVoWHAaDkNRqWx+JVQfaKTOcyGDFD2Wg=",
"shasum": "/NEqj3PPnJcIbd89StkOwZiS6IftZWX/vnb0ffIeOfw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/json-rpc/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
1 change: 1 addition & 0 deletions packages/examples/packages/json-rpc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@metamask/*/node": ["../../../*/src/node"],
"@metamask/*": ["../../../*/src"]
}
},
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/packages/lifecycle-hooks/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = deepmerge(baseConfig, {
// This is required for the tests to run inside the `MetaMask/snaps`
// repository. You don't need this in your own project.
moduleNameMapper: {
'^@metamask/(.+)/node$': [
'<rootDir>/../../../$1/src/node',
'<rootDir>/../../../../node_modules/@metamask/$1/node',
'<rootDir>/node_modules/@metamask/$1/node',
],
'^@metamask/(.+)$': [
'<rootDir>/../../../$1/src',
'<rootDir>/../../../../node_modules/@metamask/$1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "cyr+aslb2DLAQOj2fs5pBwp3l1WKZU6muxrmhsbAtks=",
"shasum": "9bi/uW6gAhAeO+I8KTcTWhAHyX9kKKvC3Cmr6IiTerY=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Loading

0 comments on commit 72cfc76

Please sign in to comment.