Skip to content
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

Support dynamic import call #1740

Closed
wants to merge 1 commit into from
Closed

Conversation

ariya
Copy link
Contributor

@ariya ariya commented Jan 29, 2017

Fix #1728

@codecov-io
Copy link

codecov-io commented Jan 29, 2017

Codecov Report

Merging #1740 into master will not impact coverage.

@@          Coverage Diff           @@
##           master   #1740   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files           1       1           
  Lines        4012    4038   +26     
  Branches      706     712    +6     
======================================
+ Hits         4012    4038   +26
Impacted Files Coverage Δ
dist/esprima.js 100% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c26790...ea5d40d. Read the comment docs.

Copy link
Member

@mikesherov mikesherov left a comment

Choose a reason for hiding this comment

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

Looks good. Maybe a test showing it can't be used in a newExpression? Approving regardless.

@@ -1789,10 +1813,14 @@ export class Parser {
statement = this.parseExportDeclaration();
break;
case 'import':
if (!this.context.isModule) {
this.tolerateUnexpectedToken(this.lookahead, Messages.IllegalImportDeclaration);
if (this.matchImportCall()) {
Copy link
Member

Choose a reason for hiding this comment

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

Oh, interesting, import can be called from scripts? Nice to know!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's my interpretation, not sure if it's correct or not. @domenic do you have an opinion?

Copy link

Choose a reason for hiding this comment

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

Yes, definitely.

@ariya
Copy link
Contributor Author

ariya commented Jan 29, 2017

Maybe a test showing it can't be used in a newExpression?

Good point, I can definitely at that.

@ariya
Copy link
Contributor Author

ariya commented Jan 29, 2017

Ah, I also still forget to tackle the case such as await import(x).

@ghost
Copy link

ghost commented Jul 16, 2018

I get an error with a stack trace that leads to

parseImportDeclaration(): Node.ImportDeclaration {
    if (this.context.inFunctionBody) {
        this.throwError(Messages.IllegalImportDeclaration);
    }

in parser.ts, while parsing valid es2018.

It seems that import statements inside of functions are rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants