Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ The monorepo uses a hierarchical configuration approach for different tools. For

- `tsconfig.base.json` defines shared compiler defaults for all other config files.
- `tsconfig.json` defines TypeScript settings for repository scripts and editor features.
- `tsconfig.packages.json` defines shared source, editor, and type-checking settings for all packages.
- `tsconfig.packages.json` defines shared TypeScript settings for all packages.
- Packages are either Snaps or non-Snaps:
- `tsconfig.packages.snaps.json` defines shared TypeScript settings for all Snap packages.
- `tsconfig.packages.non-snaps.build.json` defines shared declaration build settings for non-Snap packages, used by `ts-bridge`.
- `tsconfig.scripts.json` defines shared TypeScript settings for directories in `scripts/`.
- The root `lint:tsc` script checks repository scripts with `tsconfig.json`, then checks each
workspace package configuration directly. It does not build Snap bundles with `tsc`.
- `packages/**/tsconfig.json` (and `scripts/create-package/package-template/tsconfig.json`) defines TypeScript settings for each package that are meant to be used by code editors and type checking.
- Library packages and the package template also have `tsconfig.build.json` files for `ts-bridge` declaration builds. Snap packages do not have build configs because `mm-snap` builds their bundles.
- Non-Snap packages and the package template also have `tsconfig.build.json` files for `ts-bridge` declaration builds. Snap packages do not have build configs because `mm-snap` builds their bundles.
- `scripts/create-package/tsconfig.json` customizes TypeScript settings for the `create-package` tool.

#### Jest
Expand Down
25 changes: 3 additions & 22 deletions packages/bitcoin-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.packages.snaps.json",
"compilerOptions": {
"baseUrl": "./",
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"resolveJsonModule": true,
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"lib": ["ES2023", "DOM"],
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["jest"]
"baseUrl": "./"
},
"include": [
"**/*.ts",
"**/*.tsx",
"locales/*.json",
"snap.manifest.json",
"src/**/*.json"
]
"include": ["**/*.ts", "**/*.tsx", "**/*.json"]
}
10 changes: 3 additions & 7 deletions packages/sample-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.packages.snaps.json",
"compilerOptions": {
"baseUrl": "./",
"jsx": "react-jsx",
"skipLibCheck": true,
"jsxImportSource": "@metamask/snaps-sdk",
"types": ["jest"]
"baseUrl": "./"
},
"include": ["**/*.ts", "**/*.tsx", "locales/*.json"]
"include": ["**/*.ts", "**/*.tsx", "**/*.json"]
}
17 changes: 6 additions & 11 deletions packages/snap-networks-utils/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
{
"extends": "./tsconfig.json",
"extends": "../../tsconfig.packages.non-snaps.build.json",
"compilerOptions": {
"baseUrl": "./",
"composite": true,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"inlineSources": true,
"noEmit": false,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src"
},
"references": [],
"include": ["../../types", "./src"],
"exclude": ["**/*.test.ts", "**/tests", "**/jest.config.ts"]
/**
* Unlike Snap's which include all TypeScript, TSX and JSON files, here we want
* to mirror what gets built.
*/
"include": ["./src"]
}
10 changes: 6 additions & 4 deletions packages/snap-networks-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"extends": "../../tsconfig.packages.json",
"compilerOptions": {
"baseUrl": "./",
"skipLibCheck": true,
"types": ["jest"]
"baseUrl": "./"
},
"include": ["../../types", "./src"]
/**
* Unlike Snap's which include all TypeScript, TSX and JSON files, here we want
* to mirror what gets built.
*/
"include": ["./src"]
}
25 changes: 3 additions & 22 deletions packages/solana-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.packages.snaps.json",
"compilerOptions": {
"baseUrl": "./",
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"resolveJsonModule": true,
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"lib": ["ES2023", "DOM"],
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["jest"]
"baseUrl": "./"
},
"include": [
"**/*.ts",
"**/*.tsx",
"locales/*.json",
"snap.manifest.json",
"src/**/*.json"
]
"include": ["**/*.ts", "**/*.tsx", "**/*.json"]
}
25 changes: 3 additions & 22 deletions packages/stellar-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.packages.snaps.json",
"compilerOptions": {
"baseUrl": "./",
"resolveJsonModule": true /* lets us import JSON modules from within TypeScript modules. */,
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"lib": ["ES2023", "DOM"],
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["jest"]
"baseUrl": "./"
},
"include": [
"**/*.ts",
"**/*.tsx",
"locales/*.json",
"snap.manifest.json",
"tokenlists/*.json"
]
"include": ["**/*.ts", "**/*.tsx", "**/*.json"]
}
26 changes: 3 additions & 23 deletions packages/tron-wallet-snap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../tsconfig.packages.snaps.json",
"compilerOptions": {
"baseUrl": "./",
"resolveJsonModule": true /* lets us import JSON modules from within TypeScript modules. */,
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"lib": ["ES2023", "DOM"],
"target": "es2023",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["jest"]
"baseUrl": "./"
},
"include": [
"**/*.ts",
"**/*.tsx",
"locales/*.json",
"messages.json",
"snap.manifest.json",
"src/**/*.json"
]
"include": ["**/*.ts", "**/*.tsx", "**/*.json"]
}
5 changes: 2 additions & 3 deletions scripts/create-package/package-template/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "../../tsconfig.packages.build.json",
"extends": "../../../tsconfig.packages.non-snaps.build.json",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 levels isn't it make it outside the repo from this tree level?

"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist",
"rootDir": "./src"
},
"references": [],
"include": ["../../types", "./src"]
"include": ["./src"]
}
5 changes: 2 additions & 3 deletions scripts/create-package/package-template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.packages.json",
"extends": "../../../tsconfig.packages.json",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also might be too deep here

"compilerOptions": {
"baseUrl": "./"
},
"references": [],
"include": ["../../types", "./src"]
"include": ["./src"]
}
12 changes: 11 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
/**
* This configuration is extended by all other TypeScript configurations.
* Configuration extended by all other TypeScript configurations, whose purpose is described here:
*
* `tsconfig.json` - Repository root configuration.
* `tsconfig.scripts.json` - Used for the `scripts/` directory.
* `tsconfig.packages.json` - Shared by all `packages/`, whether Snaps or not.
*
* `tsconfig.packages.non-snaps.json` - Inexistant because it's would be the same as `tsconfig.packages.json`.
* `tsconfig.packages.non-snaps.build.json` - Configurations for `ts-bridge`'s emission of declarations.
*
* `tsconfig.packages.snaps.json` - Snap specific configurations.
* `tsconfig.packages.snaps.build.json` - Not needed because `mm-snap` already handles everything.
*/
"compilerOptions": {
"esModuleInterop": true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
/**
* Repository-level configuration used by the `lint` script and editors such as VSCode.
* Repository-level configuration used by the `lint` script and editors.
*/
"extends": "./tsconfig.base.json",
"compilerOptions": {
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.packages.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
/**
* Shared settings for package source, editor, and type-checking configurations.
* Shared settings for all packages, whether a Snap or not.
*/
"extends": "./tsconfig.base.json",
"compilerOptions": {
Expand All @@ -18,6 +18,7 @@
"paths": {
"@metamask/*": ["../*/src"]
},
"skipLibCheck": true
"skipLibCheck": true,
"types": ["jest"]
}
}
20 changes: 20 additions & 0 deletions tsconfig.packages.non-snaps.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
/**
* Shared settings for non-Snap package build configurations, used by `ts-bridge` to emit
* declarations.
*
* Non-Snap packages extending this configuration must still define their own `outDir`,
* `rootDir`, and `include`, since these are resolved relative to each package.
*/
"extends": "./tsconfig.packages.json",
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"inlineSources": true,
"noEmit": false,
"sourceMap": true
},
"exclude": ["**/*.test.ts", "**/tests", "**/jest.config.ts"]
}
20 changes: 20 additions & 0 deletions tsconfig.packages.snaps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
/**
* Shared settings for Snap packages, i.e. packages whose bundles are built by `mm-snap`
* rather than by `tsc` or `ts-bridge`.
*
* Snap packages must still set `baseUrl` to their own directory, so that the `paths` option
* resolves correctly.
*/
"extends": "./tsconfig.packages.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false,
"jsx": "react-jsx",
"jsxImportSource": "@metamask/snaps-sdk",
"lib": ["ES2023", "DOM"],
"module": "preserve",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"target": "ES2023"
}
}