This repository was archived by the owner on Sep 11, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Use tsup for bundling
#144
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
73d2322
Use tsup for bundling
Mrtenz 7507a19
Simplify CI workflows
Mrtenz cf776a2
Remove unused dependency
Mrtenz 01285e1
Remove unnecessary config option
Mrtenz 775f71d
Use `tsc` for generating declarations
Mrtenz fe758df
Fix formatting of package.json
Mrtenz befdf2d
Enable code splitting
Mrtenz d6bdabd
Revert some changes
Mrtenz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,30 +11,24 @@ | |
| "url": "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/MetaMask/utils.git" | ||
| }, | ||
| "license": "ISC", | ||
| "sideEffects": false, | ||
| "exports": { | ||
| ".": { | ||
| "import": "./dist/esm/index.js", | ||
| "require": "./dist/cjs/index.js", | ||
| "import": "./dist/index.mjs", | ||
| "require": "./dist/index.js", | ||
| "types": "./dist/types/index.d.ts" | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "main": "./dist/cjs/index.js", | ||
| "module": "./dist/esm/index.js", | ||
| "main": "./dist/index.js", | ||
| "module": "./dist/index.mjs", | ||
| "types": "./dist/types/index.d.ts", | ||
| "files": [ | ||
| "dist/cjs/**", | ||
| "dist/esm/**", | ||
| "dist/types/**" | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "yarn build:source && yarn build:types", | ||
| "build:cjs": "swc src --out-dir dist/cjs --config-file .swcrc.build.json --config module.type=commonjs", | ||
| "build:clean": "rimraf dist && yarn build", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see that the |
||
| "build": "tsup && yarn build:types", | ||
| "build:docs": "typedoc", | ||
| "build:esm": "swc src --out-dir dist/esm --config-file .swcrc.build.json --config module.type=es6 && yarn build:esm:package", | ||
| "build:esm:package": "echo >dist/esm/package.json \"{\\\"type\\\":\\\"module\\\"}\"", | ||
| "build:source": "yarn build:esm && yarn build:cjs", | ||
| "build:types": "tsc --project tsconfig.build.json", | ||
| "lint": "yarn lint:eslint && yarn lint:constraints && yarn lint:misc --check && yarn lint:dependencies --check && yarn lint:changelog", | ||
| "lint:changelog": "auto-changelog validate", | ||
|
|
@@ -69,8 +63,6 @@ | |
| "@metamask/eslint-config-jest": "^12.0.0", | ||
| "@metamask/eslint-config-nodejs": "^12.0.0", | ||
| "@metamask/eslint-config-typescript": "^12.0.0", | ||
| "@swc/cli": "^0.1.62", | ||
| "@swc/core": "^1.3.66", | ||
| "@types/jest": "^28.1.7", | ||
| "@types/node": "^17.0.23", | ||
| "@typescript-eslint/eslint-plugin": "^5.43.0", | ||
|
|
@@ -88,11 +80,11 @@ | |
| "jest-it-up": "^2.0.2", | ||
| "prettier": "^2.7.1", | ||
| "prettier-plugin-packagejson": "^2.3.0", | ||
| "rimraf": "^3.0.2", | ||
| "stdio-mock": "^1.2.0", | ||
| "ts-jest": "^29.0.3", | ||
| "ts-node": "^10.7.0", | ||
| "tsd": "^0.24.1", | ||
| "tsup": "^7.2.0", | ||
| "typedoc": "^0.23.15", | ||
| "typescript": "~4.8.4" | ||
| }, | ||
|
|
@@ -107,7 +99,7 @@ | |
| "lavamoat": { | ||
| "allowScripts": { | ||
| "@lavamoat/preinstall-always-fail": false, | ||
| "@swc/core": true | ||
| "tsup>esbuild": true | ||
| } | ||
| }, | ||
| "tsd": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| "./src/**/__tests__/**/*", | ||
| "./src/**/__snapshots__/**/*", | ||
| "./src/**/*.test.ts", | ||
| "./src/**/*.test-d.ts", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, good catch. |
||
| "./src/**/*.test.*.ts" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { defineConfig } from 'tsup'; | ||
|
|
||
| export default defineConfig({ | ||
| // The entry to bundle. | ||
| entry: [ | ||
| 'src/**/*.ts', | ||
| '!src/**/__fixtures__/**/*', | ||
| '!src/**/__mocks__/**/*', | ||
| '!src/**/__test__/**/*', | ||
| '!src/**/__tests__/**/*', | ||
| '!src/**/__snapshots__/**/*', | ||
| '!src/**/*.test.ts', | ||
| '!src/**/*.test-d.ts', | ||
| '!src/**/*.test.*.ts', | ||
| ], | ||
|
|
||
| // The output formats. We want to generate both CommonJS and ESM bundles. | ||
| // https://tsup.egoist.dev/#bundle-formats | ||
| format: ['cjs', 'esm'], | ||
|
|
||
| // Generate sourcemaps as separate files. | ||
| // https://tsup.egoist.dev/#generate-sourcemap-file | ||
| sourcemap: true, | ||
|
|
||
| // Clean the dist folder before bundling. | ||
| clean: true, | ||
|
|
||
| // Enables shimming of `__dirname` and `import.meta.url`, so that they work | ||
| // in both CommonJS and ESM. | ||
| // https://tsup.egoist.dev/#inject-cjs-and-esm-shims | ||
| shims: true, | ||
|
|
||
| // Hide unnecessary logs from the console. Warnings and errors will still be | ||
| // shown. | ||
| silent: true, | ||
|
|
||
| // Split the output into chunks. This is useful for tree-shaking. | ||
| // https://tsup.egoist.dev/#code-splitting | ||
| splitting: true, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this option in the module template, but it wasn't enabled in
utilsyet.