Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Supportrequire(esm) in--module nodenext#60761

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
andrewbranch merged 11 commits intomicrosoft:mainfromandrewbranch:module-node20
Jan 23, 2025

Conversation

andrewbranch
Copy link
Member

@andrewbranchandrewbranch commentedDec 13, 2024
edited
Loading

Fixes#60534

require(esm) is currently unflagged in Node.js v22,butmay be in v20 by the time this PR lands for 5.8. We’ll have a discussion about the flag name if it doesn’t happen by 5.8-beta.EDIT: the backport will not come in time for 5.8; we are only changing--module nodenext here, and will aim to make a--module node20 in 5.9.

This PR does not currently attempt to error onrequire calls of async modules (those with top-levelawait). We do not emit any special marker in declaration files indicating the presence of TLA, which is a prerequisite. My suspicion is that the sentiment will be that a static check for async modules in therequire graph isnot worth the pain of making a backward-incompatible declaration file change.

The other change in this PR is that import assertions are now prohibited in--module nodenext, since Node.js v22+ does not parse them. Since there have been a lot of module target changes in fast succession, here’s the summary:

5.6

targetmoduleResolutionimport assertionsimport attributesJSON importsrequire(esm)
node16es2022node16no restrictions
nodenextesnextnodenextno restrictions

5.7.3

targetmoduleResolutionimport assertionsimport attributesJSON importsrequire(esm)
node16es2022node16no restrictions
nodenextesnextnodenextneedstype "json"

5.8

targetmoduleResolutionimport assertionsimport attributesJSON importsrequire(esm)
node16es2022node16no restrictions
node18es2022node16needstype "json"
nodenextesnextnodenextneedstype "json"

5.9 (planned)

targetmoduleResolutionimport assertionsimport attributesJSON importsrequire(esm)
node16es2022node16no restrictions
node18es2022node16needstype "json"
node20es2023node16needstype "json"
nodenextesnextnodenextneedstype "json"

marco-ippolito, robpalme, zanminkian, tonivj5, kirillgroshkov, niieani, kirkwaiblinger, Stanzilla, shrujalshah28, nguyenlc1993, and 7 more reacted with thumbs up emojimarco-ippolito, zanminkian, tonivj5, kirillgroshkov, and dnalborczyk reacted with hooray emojimarco-ippolito, tonivj5, acommodari, kirillgroshkov, niieani, paescuj, dnalborczyk, and kohlmannj-nyt reacted with heart emojihellbilly13source reacted with eyes emoji
@typescript-bottypescript-bot added Author: Team For Milestone BugPRs that fix a bug with a specific milestone labelsDec 13, 2024
@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping@sheetalkamat,@mjbvz,@zkat, and@joj for you. Feel free to loop in other consumers/maintainers if necessary.

hellbilly13source reacted with eyes emoji

@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document themon our wiki's API Breaking Changes page.

Also, please make sure@DanielRosenwasser and@RyanCavanaugh are aware of the changes, just as a heads up.

hellbilly13source reacted with eyes emoji

@marco-ippolito
Copy link

marco-ippolito commentedDec 13, 2024
edited
Loading

I will probably release Node v20 (maybe the backport for require(esm)) around half of January 🙂

andrewbranch, cardoso, kirillgroshkov, and erickzhao reacted with heart emojihellbilly13source reacted with eyes emoji

@andrewbranch
Copy link
MemberAuthor

@marco-ippolito things still look good for backporting?

@marco-ippolito
Copy link

marco-ippolito commentedJan 21, 2025
edited
Loading

@marco-ippolito things still look good for backporting?

It might take a bit longer than expected due to the complexity of the backport,@joyeecheung is actively working on it. Ill keep here updated.

andrewbranch reacted with thumbs up emoji

@marco-ippolito
Copy link

We won't actually be able to fully backportrequire(esm) in the next v20 release happening next week, it will go to next one probably (March I think)

andrewbranch reacted with thumbs up emoji

@andrewbranch
Copy link
MemberAuthor

Since the backport won’t happen until after 5.8 stable is out, I think the best thing to do might be to put this functionality only in--module nodenext for this release, and hopefully for 5.9 we can snap a--module node20

kirillgroshkov reacted with thumbs up emoji

Copy link
Member

@jakebaileyjakebailey left a comment

Choose a reason for hiding this comment

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

Code LGTM but I know the naming very much depends on Node's scheduling and our own scheduling.

@andrewbranchandrewbranch changed the titleAdd--module node20 withrequire(esm) supportSupportrequire(esm) in--module nodenextJan 23, 2025
Copy link
Member

@jakebaileyjakebailey left a comment

Choose a reason for hiding this comment

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

Approving a second time, but I do enjoy how "make require(ESM) work" is just a one line change 😄

andrewbranch reacted with heart emoji
@andrewbranchandrewbranch merged commit5e52b28 intomicrosoft:mainJan 23, 2025
32 checks passed
@andrewbranchandrewbranch deleted the module-node20 branchJanuary 23, 2025 00:56
@joyeecheung
Copy link

Hi, as commented by Marco before the backport was more challenging than we thought, though there's still hope to get it out in the March release. Seenodejs/node#52697 (comment) andnodejs/node#56730 for more information about the progress.

andrewbranch reacted with thumbs up emoji

@andrewbranch
Copy link
MemberAuthor

If the March release contains the backport, that will be on track for TypeScript 5.9. 5.8 stable is scheduled to come out in February.

@rauschma
Copy link

Wish: Show the tables (maybe only the one for the most recent version of TypeScript) in the documentation somewhere. I find them very useful.

andrewbranch reacted with thumbs up emoji

@zanminkian
Copy link

zanminkian commentedMar 22, 2025
edited
Loading

importpackageJsonfrom'../package.json'with{type:'json'};

Code above will causetsc fail undernodenext withoutresolveJsonModule field. However, Node v18.20 supported it now.

TS 5.9 should defaultly allow it withoutresolveJsonModule field.

@andrewbranch
Copy link
MemberAuthor

@rauschma they’re here now:https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-node18-nodenext

@zanminkian I agree.

rauschma, zanminkian, and khriaduddintomnoy018 reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jakebaileyjakebaileyjakebailey approved these changes

@weswighamweswighamAwaiting requested review from weswigham

Assignees

@andrewbranchandrewbranch

Labels
Author: TeamFor Milestone BugPRs that fix a bug with a specific milestone
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add--module node22 (or--module node20) with support forrequire(esm)
7 participants
@andrewbranch@typescript-bot@marco-ippolito@joyeecheung@rauschma@zanminkian@jakebailey

[8]ページ先頭

©2009-2025 Movatter.jp