-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converts this package to an ESM module. Kudos to [this guide](https://tsmx.net/convert-existing-nodejs-project-from-commonjs-to-esm/) and this issue: TypeStrong/ts-node#1997 In our organization, this is only possible for this package because it is not used anywhere else, and we rely on CommonJS extensively. Changes in detail: - Update `package.json` for ESM compatibility - Replace all `require()` with `import` statements - Add `.js` file extension to all file imports in TypeScript source files - Update TypeScript, ESLint, and Jest configs for ESM compatibility and recommended best practices - TypeScript (`tsconfig.json`) - Update the `module`/`moduleResolution` fields to `Node16`. - I chose `Node16` over `NodeNext`, as the behavior of `NodeNext` may change in the future. See [here](https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext) for details. - ESLint (`.eslintrc.cjs`) - `parseOptions.sourceType = 'module'` - Jest (`jest.config.cjs`) - Update the `moduleNameMapper` to strip the `.js` from local file imports. See [here](https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/) for details. - Replace `ts-node` with `tsx`, which has better ESM compatibility. - Specifically, the former does not work with Node v20 at the moment: TypeStrong/ts-node#1997 - Update `jest-it-up` - This is so that we can use its `--config` option (thank you @PeterYinusa! rbardini/jest-it-up#12) to target our new `.cjs` config file.
- Loading branch information
Showing
45 changed files
with
577 additions
and
393 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
/* eslint-disable-next-line import/no-unassigned-import,import/no-unresolved */ | ||
require('../dist/cli'); | ||
// eslint-disable-next-line import/no-unassigned-import,import/no-unresolved | ||
import '../dist/cli'; |
This file contains 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 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 |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
"type": "git", | ||
"url": "https://github.com/MetaMask/create-release-branch.git" | ||
}, | ||
"type": "module", | ||
"exports": null, | ||
"bin": "bin/create-release-branch.js", | ||
"files": [ | ||
"bin/", | ||
|
@@ -19,12 +21,12 @@ | |
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", | ||
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", | ||
"prepack": "./scripts/prepack.sh", | ||
"test": "jest && jest-it-up", | ||
"test": "jest && jest-it-up --config jest.config.cjs", | ||
"test:watch": "jest --watch" | ||
}, | ||
"dependencies": { | ||
"@metamask/action-utils": "^1.0.0", | ||
"@metamask/utils": "^8.1.0", | ||
"@metamask/utils": "^8.2.1", | ||
"debug": "^4.3.4", | ||
"execa": "^5.1.1", | ||
"pony-cause": "^2.1.9", | ||
|
@@ -58,15 +60,15 @@ | |
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^29.5.0", | ||
"jest-it-up": "^2.0.2", | ||
"jest-it-up": "^3.0.0", | ||
"jest-when": "^3.5.2", | ||
"nanoid": "^3.3.4", | ||
"prettier": "^2.2.1", | ||
"prettier-plugin-packagejson": "^2.3.0", | ||
"rimraf": "^4.0.5", | ||
"stdio-mock": "^1.2.0", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.7.0", | ||
"tsx": "^4.6.1", | ||
"typescript": "~5.1.6" | ||
}, | ||
"packageManager": "[email protected]", | ||
|
@@ -79,7 +81,8 @@ | |
}, | ||
"lavamoat": { | ||
"allowScripts": { | ||
"@lavamoat/preinstall-always-fail": false | ||
"@lavamoat/preinstall-always-fail": false, | ||
"tsx>esbuild": false | ||
} | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { main } from './main'; | ||
import { main } from './main.js'; | ||
|
||
/** | ||
* The entrypoint to this tool. | ||
|
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.