-
-
Notifications
You must be signed in to change notification settings - Fork 715
feat(parser): support import defer #6949
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
Conversation
🦋 Changeset detectedLatest commit: 0c74466 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Parser conformance results onjs/262
🎉 Fixed (54):
jsx/babel
symbols/microsoft
🎉 Fixed (1):
ts/babel
ts/microsoft
🔥 Regression (2):
🎉 Fixed (2):
|
CodSpeed Performance ReportMerging #6949 will not alter performanceComparing Summary
|
Out of curiosity, is the following syntax allowed? import defer type * as foo from "bar" |
No, only allow |
Co-authored-by: Denis Bezrukov <6227442+denbezrukov@users.noreply.github.com>
The next step i will support Syntax like: |
also add test case for this example |
xtask/codegen/js.ungram
Outdated
// import defer * as foo from "mod"; | ||
JsImportNamespaceClause = | ||
'type'? | ||
'type'? | 'defer'? |
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.
I’m wondering if we can reuse the logic from Babel:
https://github.com/babel/babel/blob/ab6de823b3353b2af6d8e163b55fdc763aa840a6/packages/babel-parser/src/types.ts#L751
They have a separate token for it: phase.
What do you think?
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.
you are right here,before i make this pr,i also refer swc and oxc's parser imeplement of the import defer,they do the same things as babel does. I will change here too
// import defer * as foo from "mod"; | ||
JsImportNamespaceClause = | ||
'type'? | ||
phase: 'defer'? |
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.
@denbezrukov i add a phase
field here, i will expand this filed in the next pr when i support phase: 'source'
, that case will be different from import defer
here.
import defer
need to support syntax like:
import defer * as x from 'mod';
import source
syntax is:
import source x from 'mod';
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.
Do you mean that a 'source' phase doesn't make any sense for a namespace syntax?
I think you're right!
To be honest I have the same feeling for a 'type' token.
It might be also a 'phase' modifier.
But I'm not sure how many changes it might require.
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.
It’s not a big problem. I’ll observe it again when I implement the import source. We will keep the phase here now.
Summary
closes: #4215
Typescript 5.9 Beta support
import defer
, which is a stage-3 proposal: https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-beta/#support-for-import-deferThe implement we can refer to: https://github.com/microsoft/TypeScript/pull/60757/files
This PR support
import defer
, the syntax looks like:And the syntax
import defer foo from "<specifier>"
orimport defer { foo } from "<specifier>"
is invalid.In this pr, I use
defer
as akeyword
just like what TypeScript do.Test Plan
I add test case for
biome_js_parser
andbiome_js_formatter
.Docs