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 #100

Merged
merged 5 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions estraverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
Identifier: 'Identifier',
IfStatement: 'IfStatement',
Import: 'ImportExpression',
ImportDeclaration: 'ImportDeclaration',
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
Expand Down Expand Up @@ -182,6 +183,7 @@
GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
Identifier: [],
IfStatement: ['test', 'consequent', 'alternate'],
Import: ['argument'],
ImportDeclaration: ['specifiers', 'source'],
ImportDefaultSpecifier: ['local'],
ImportNamespaceSpecifier: ['local'],
Expand Down
30 changes: 30 additions & 0 deletions test/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,36 @@ describe('import', function() {
});
});

describe.skip('dynamic import', function() {
Copy link

@papandreou papandreou Apr 7, 2019

Choose a reason for hiding this comment

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

Couldn’t you get these tests to work by putting in object literals with the ast instead of blocking on espree?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't tried that. I'll give it a go

it('expression pattern #1', function() {
const tree = espree(`import('rabbit-house')`, {
ecmaFeatures: {
modules: true
}
});

checkDump(Dumper.dump(tree), `
enter - Program
enter - ImportExpression
leave - Program
`);
});

it('expression pattern #1', function() {
const tree = espree(`import(\`module-\${foo}\`)`, {
ecmaFeatures: {
modules: true
}
});

checkDump(Dumper.dump(tree), `
enter - Program
enter - ImportExpression
leave - Program
`);
});
});

describe('pattern', function() {
it('assignment pattern#1', function() {
const tree = {
Expand Down