-
Notifications
You must be signed in to change notification settings - Fork 31
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
Use ECMAScript modules nearly everywhere (bis) #8535
Closed
Closed
Conversation
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
1bf2a2a
to
9750681
Compare
Size Change: 0 B 🆕 Total Size: 0 B |
a709690
to
8221e46
Compare
"This PR is stale because it has been open 30 days with no activity. Unless a comment is added or the “stale” label removed, this will be closed in 3 days" |
f0fa1e3
to
2ac0f21
Compare
mxdvl
commented
Sep 22, 2023
a267a6b
to
5ce3b13
Compare
e4405b9
to
4c2a634
Compare
a861787
to
2ae076f
Compare
Unify our files to be mostly ECMAScript modules, rather than mixed, since it is supported in the current LTS version of Node https://nodejs.org/docs/latest-v18.x/api/esm.html CommonJS modules get the explicit `.cjs` / `.cts` extension Jest tests uses the unstable ESM mocking API, which requires mocked modules to be imported after the mock using dynamic imports. https://jestjs.io/docs/ecmascript-modules#module-mocking-in-esm CDK now uses the ESM version of `ts-node` which loads CommonJS for `.cts` files, reducing the difference between tsconfig.json files, which requires `allowImportingTsExtensions` to be true. https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions
- tests use jest’s unstable module mock - CDK uses commonJS explicitly
2ae076f
to
a51c1dc
Compare
This was referenced Sep 28, 2023
I think this is best done piecemeal… |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
What does this change?
Unify nearly all our modules to be ECMAScript modules, since it is supported in the current LTS version of Node https://nodejs.org/docs/latest-v18.x/api/esm.html
CommonJS modules get the explicit
.cjs
/.cts
extensionJest tests uses the unstable ESM mocking API, which requires mocked modules to be imported after the mock using dynamic imports.
CDK now uses the ESM version of
ts-node
which loads CommonJS for.cts
files, reducing the difference between tsconfig.json files, which requiresallowImportingTsExtensions
to be true.Why?
Reduce the amount of different way a module is interpreted based on the extension.
Before:
.js
CommonJS JavaScript.ts
ESM TypeScript.mjs
ESM JavaScript (only a few files).ts
CommonJS TypeScript (only a few files)After:
.js
ESM JavaScript.ts
ESM TypeScript.cjs
CommonJS JavaScript (only a few files).cts
CommonJS Typescript (only a few files)Another go at #8482