Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tsup with ts-bridge #2682

Merged
merged 19 commits into from
Sep 10, 2024
Merged
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
2 changes: 0 additions & 2 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ jobs:
- run: yarn --immutable --immutable-cache
- name: Build
run: yarn build:ci
- name: Build types
run: yarn build:types
- name: Cache build files
uses: actions/cache@v4
with:
Expand Down
13 changes: 0 additions & 13 deletions .yarn/patches/tsup-npm-8.0.2-86e40f68a7.patch

This file was deleted.

33 changes: 18 additions & 15 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -152,32 +152,40 @@ gen_enforced_field(WorkspaceCwd, 'sideEffects', 'false') :-
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.

% The type definitions entrypoint for the dependency must be `./dist/types/index.d.ts`.
gen_enforced_field(WorkspaceCwd, 'types', './dist/types/index.d.ts') :-
% The type definitions entrypoint for the dependency must be `./dist/index.d.cts`.
gen_enforced_field(WorkspaceCwd, 'types', './dist/index.d.cts') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
gen_enforced_field(WorkspaceCwd, 'exports["."].types', './dist/types/index.d.ts') :-
gen_enforced_field(WorkspaceCwd, 'exports["."].types', null) :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.

% The entrypoint for the dependency must be `./dist/cjs/index.js`.
gen_enforced_field(WorkspaceCwd, 'main', './dist/index.js') :-
% The entrypoint for the dependency must be `./dist/index.cjs`.
gen_enforced_field(WorkspaceCwd, 'main', './dist/index.cjs') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
gen_enforced_field(WorkspaceCwd, 'exports["."].require', './dist/index.js') :-
gen_enforced_field(WorkspaceCwd, 'exports["."].require.types', './dist/index.d.cts') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
gen_enforced_field(WorkspaceCwd, 'exports["."].require.default', './dist/index.cjs') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.

% The module entrypoint for the dependency must be `./dist/esm/index.js`.
% The module entrypoint for the dependency must be `./dist/index.mjs`.
gen_enforced_field(WorkspaceCwd, 'module', './dist/index.mjs') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
gen_enforced_field(WorkspaceCwd, 'exports["."].import', './dist/index.mjs') :-
gen_enforced_field(WorkspaceCwd, 'exports["."].import.types', './dist/index.d.mts') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
gen_enforced_field(WorkspaceCwd, 'exports["."].import.default', './dist/index.mjs') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
Expand All @@ -202,22 +210,17 @@ gen_enforced_field(WorkspaceCwd, 'files', ['dist', 'jest-preset.js']) :-
WorkspaceCwd = 'packages/snaps-jest'.

% Dependencies must have a build script.
gen_enforced_field(WorkspaceCwd, 'scripts.build', 'tsup --clean && yarn build:types') :-
gen_enforced_field(WorkspaceCwd, 'scripts.build', 'ts-bridge --project tsconfig.build.json --verbose --no-references') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.',
WorkspaceCwd \= 'packages/snaps-simulator',
WorkspaceCwd \= 'packages/snaps-cli',
WorkspaceCwd \= 'packages/snaps-execution-environments'.
gen_enforced_field(WorkspaceCwd, 'scripts.build:types', 'tsc --project tsconfig.build.json') :-
gen_enforced_field(WorkspaceCwd, 'scripts.build:types', null) :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.'.
gen_enforced_field(WorkspaceCwd, 'scripts.build:ci', 'tsup --clean') :-
\+ is_example(WorkspaceCwd),
\+ workspace_field(WorkspaceCwd, 'private', true),
WorkspaceCwd \= '.',
WorkspaceCwd \= 'packages/snaps-simulator'.

% Dependencies must have preview scripts.
gen_enforced_field(WorkspaceCwd, 'scripts.publish:preview', 'yarn npm publish --tag preview') :-
Expand Down
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
"lint": "yarn workspaces foreach --all --parallel run lint:eslint && yarn lint:misc --check && yarn lint:tsconfig && yarn constraints && yarn lint:dependencies",
"lint:fix": "yarn workspaces foreach --all --parallel run lint:eslint --fix && yarn lint:misc --write && yarn lint:tsconfig && yarn constraints --fix && yarn dedupe",
"lint:ci": "yarn lint:eslint && yarn lint:misc --check && yarn lint:tsconfig && yarn constraints && yarn lint:dependencies",
"build": "yarn build:source && yarn build:types",
"build:ci": "yarn workspaces filter --include \"packages/*\" --parallel --topological --no-private run build:ci",
"build:clean": "yarn clean && yarn build",
"build:source": "yarn workspaces filter --parallel --topological --exclude \"{packages/examples,packages/examples/packages/invoke-snap}\" run build",
"build:types": "tsc --build tsconfig.build.json",
"build": "ts-bridge --project tsconfig.build.json --verbose && yarn build:examples",
"build:ci": "ts-bridge --project tsconfig.build.json --verbose --clean",
"build:examples": "yarn workspace @metamask/example-snaps build",
"clean": "yarn workspaces foreach --all --parallel --verbose run clean",
"test": "yarn workspaces foreach --all --parallel --verbose run test",
Expand Down Expand Up @@ -65,8 +62,7 @@
"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",
"tsup@^8.0.1": "patch:tsup@npm%3A8.0.2#./.yarn/patches/tsup-npm-8.0.2-86e40f68a7.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.4",
Expand All @@ -78,6 +74,7 @@
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/utils": "^9.2.1",
"@swc/core": "1.3.78",
"@ts-bridge/cli": "^0.4.4",
"@types/jest": "^27.5.1",
"@types/node": "18.14.2",
"@typescript-eslint/eslint-plugin": "^5.42.1",
Expand All @@ -104,7 +101,6 @@
"semver": "^7.5.4",
"simple-git-hooks": "^2.7.0",
"ts-node": "^10.9.1",
"tsup": "^8.0.1",
"typescript": "~5.3.3",
"vite": "^4.3.9"
},
Expand All @@ -122,7 +118,6 @@
"ts-node>@swc/core": true,
"@swc/core": true,
"favicons>sharp": true,
"tsup>esbuild": true,
"vite>esbuild": true
}
},
Expand Down
28 changes: 14 additions & 14 deletions packages/create-snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/types/index.d.ts"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts",
"bin": "./dist/main.js",
"types": "./dist/index.d.cts",
"bin": "./dist/main.cjs",
"files": [
"dist"
],
"scripts": {
"build": "tsup --clean && yarn build:types",
"build:types": "tsc --project tsconfig.build.json",
"build": "ts-bridge --project tsconfig.build.json --verbose --no-references",
"build:chmod": "chmod +x ./dist/main.mjs && chmod +x ./dist/main.js",
"build:clean": "yarn clean && yarn build",
"build:watch": "tsc-watch --onSuccess 'yarn build:chmod'",
"clean": "rimraf '*.tsbuildinfo' 'dist'",
"test": "jest && yarn posttest",
"posttest": "jest-it-up",
"test:watch": "yarn test --watch",
Expand All @@ -42,8 +45,7 @@
"publish:package": "../../scripts/publish-package.sh",
"lint:ci": "yarn lint",
"publish:preview": "yarn npm publish --tag preview",
"lint:dependencies": "depcheck",
"build:ci": "tsup --clean"
"lint:dependencies": "depcheck"
},
"dependencies": {
"@metamask/snaps-utils": "workspace:^",
Expand All @@ -59,9 +61,9 @@
"@metamask/eslint-config-typescript": "^12.1.0",
"@swc/core": "1.3.78",
"@swc/jest": "^0.2.26",
"@ts-bridge/cli": "^0.4.4",
"@types/jest": "^27.5.1",
"@types/node": "18.14.2",
"@types/rimraf": "^3.0.0",
"@types/yargs": "^17.0.24",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^6.21.0",
Expand All @@ -80,10 +82,8 @@
"memfs": "^3.4.13",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.2.11",
"rimraf": "^4.1.2",
"ts-node": "^10.9.1",
"tsc-watch": "^4.5.0",
"tsup": "^8.0.1",
"typescript": "~5.3.3"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-snap/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../../tsconfig.packages.build.json",
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/types",
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["./src"],
Expand Down
2 changes: 1 addition & 1 deletion packages/create-snap/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"baseUrl": "./"
},
"include": ["./src", "./src/**/*.json", "package.json", "tsup.config.ts"],
"include": ["./src", "./src/**/*.json", "package.json"],
"references": [{ "path": "../snaps-cli" }, { "path": "../snaps-utils" }]
}
16 changes: 0 additions & 16 deletions packages/create-snap/tsup.config.ts

This file was deleted.

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": "R8Of/lcLuLbr2AAcUsDD6e0cdbOdHHvHlwxs+BoAHtE=",
"shasum": "oIth1iwHikuY19tkSxTGtl4YzdX1XAiGn2RJl+DAeCs=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "8Iyfr16llKRg4UoML6rvo+76L+R6KhKxg8p0GdAczts=",
"shasum": "Ta9rEMnKSdYz7ecxZh++RZyMSW9JVsQVqa+zFLLO87k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "27ak99bFxoi5UmR0mvMhQWYJfsyZjeYva4kPd2sklgc=",
"shasum": "86NLlsPJvWJxQuiDRc6479u6RvMaCFIK8GNVpTdcPjI=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/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": "f/RSumnRBLYDElSvfXJ98Q+k3qOxINGvpiwGhxe+TFA=",
"shasum": "BXW4yp9Qs+yCSXZXMJfvEIjY0epnS2yhzcHZ8kAb0B0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "LPHBZ8HaW5f2snnJ+7932mfqASK7jcXejfFjVyJ/VXA=",
"shasum": "igAdAUtow5JI5MOgNqhdcqlpBo67XhupsT3Ns8tTbto=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "UDkFbOMBRfWLD2oh0hlFurcqT3W33ysAIjUOBaEx/+k=",
"shasum": "o5qiOur9Zl+yAjHScLzh0FfK7/jcKx7rGqotitpJ6Uo=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "klyP48icUHenhFEjXT4cvgSPT30ZFMqUTFBb2YqS4lI=",
"shasum": "77wtrsk6BY8OSjG5pWALMSJzOmznWaaR7EiM3LGigjI=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "pqp9lYbT/4A1Z2vgozgLu/kxvjdmlfFjmowIMOEsD0k=",
"shasum": "UjXjIPRsp5mK1VwBQL8eRaGjIX1pW7E+KPMls3BGXRA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "E+ijMmCKNfgzuyCynS6PHT0c2F+22NlJpAE0cbNSlcM=",
"shasum": "fwMTtk4KJjak+yf6666Vv/+syXmFVAnVPAsBkalK2Qc=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "UvAKkgLp43SSDI/mUdvjehfLGrQq1rB5lPfETxDTqT4=",
"shasum": "314nMSBFTIeG+Z7RGc9D/FZPRk/vQjaZfzo8rMFMSmY=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "GXJcuL0Bz7RCGE39iUk1v6QSmlMaA0gXJSekaE2l0cw=",
"shasum": "ur2Jxp1kniP1jYLeexXHTB/+dgfJom1volcPQgSNX6c=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-file/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": "BzCYiUBdWeViyl4Ux80SGv2kVJapohrpC/dTW5yM+iA=",
"shasum": "z8vSlRUXBdgkLnThLXk0CxPylXp3zeK0MG70lTqyrHc=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "dZ9WgkIrRPAi7nKbYBSeaD3xV9rKf0VT9/5FgrrK4QE=",
"shasum": "tOQyZkJPX1hUaoCfBlAV+4vl7Tbt9DcPCquAh84IGP4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
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": "r+Vr5LYfHiuQZuvypm1jQNfQzdp7unl6AgskaGCFJnM=",
"shasum": "ewEvZGj7D/wUtBH8bDutuDuJ1leq8n9Penuu8yDAykA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
4 changes: 3 additions & 1 deletion packages/examples/packages/images/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"baseUrl": "./",
"paths": {
"@metamask/*": ["../../../*/src"]
}
},
"module": "ES2020",
"moduleResolution": "Node10"
Comment on lines +8 to +9
Copy link
Member Author

Choose a reason for hiding this comment

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

snaps-sdk has a .ts file which declares *.svg, *.png, etc., but this doesn't work in Node16 or NodeNext module resolution. I've kept snaps-sdk and the image example at Node10 for now, to not introduce any breaking changes.

},
"include": ["src", "snap.config.ts"],
"references": [
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": "/Xgz50XZhm49exI9MtCOtWRox1N894/sLTYZIGYrFX4=",
"shasum": "QIFPu6VwYTRWVGIS5fHeoOWuV7RxLhn7wYFtrcc5pKM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Loading
Loading