-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Dynamic import #5169
Dynamic import #5169
Conversation
@@ -240,6 +240,7 @@ grammar = | |||
o 'Super' | |||
o 'This' | |||
o 'SUPER Arguments', -> new SuperCall LOC(1)(new Super), $2, no, $1 | |||
o 'DYNAMIC_IMPORT Arguments', -> new DynamicImportCall LOC(1)(new DynamicImport), $2 |
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.
Technically it looks like dynamic imports are allowed to be object spread (eg {...import('module')}
compiles in Babel)
Added a corresponding test
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.
@@ -891,7 +893,7 @@ operators = [ | |||
['right', 'YIELD'] | |||
['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'] | |||
['right', 'FORIN', 'FOROF', 'FORFROM', 'BY', 'WHEN'] | |||
['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'IMPORT', 'EXPORT'] | |||
['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'IMPORT', 'EXPORT', 'DYNAMIC_IMPORT'] |
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 don't know if this is technically necessary but it looked like DYNAMIC_IMPORT
belonged at this precedence level (with SUPER
, IMPORT
and EXPORT
)
Co-Authored-By: helixbass <julian@helixbass.net>
Okay, so before we cut a new release we need to update the docs not just to describe If we’re going to add provisional support for Stage 3 things, class fields could be next. |
@GeoffreyBooth This is a pull request years in the making. Thank you! |
when will be this released? |
@GeoffreyBooth do you mind merging latest |
@helixbass Done. |
Fixes #4834
@GeoffreyBooth I came across dynamic
import()
while working on the Prettier plugin and read #4834This PR adds support for dynamic
import()
(requiring explicit call parentheses per the apparent consensus in #4834, which I tend to agree with)It mimics Babel's error message ("import() requires exactly one argument") when supplying less than or more than one argument
It looks like I should do a follow-on PR against
ast
since Babel appears to usetype: 'Import'
for dynamic import