-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
o 'SimpleObjAssignable Arguments', -> new Call (new Value $1), $2 | ||
o 'ObjSpreadExpr Arguments', -> new Call $1, $2 | ||
] | ||
|
@@ -485,6 +486,7 @@ grammar = | |
o 'Value OptFuncExist String', -> new TaggedTemplateCall $1, $3, $2 | ||
o 'Value OptFuncExist Arguments', -> new Call $1, $3, $2 | ||
o 'SUPER OptFuncExist Arguments', -> new SuperCall LOC(1)(new Super), $3, $2, $1 | ||
o 'DYNAMIC_IMPORT Arguments', -> new DynamicImportCall LOC(1)(new DynamicImport), $2 | ||
] | ||
|
||
# An optional existence check on a function. | ||
|
@@ -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 commentThe 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 |
||
['left', 'POST_IF'] | ||
] | ||
|
||
|
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.
It evaluates in browsers too:
Though it makes no sense, as the
import()
returns a Promise. Not sure how that’s supposed to interact with object spread, and apparently it doesn’t 😄but still the code compiles even if it’s useless.