Hello.
Currently, AST for dynamic imports is using CallExpression: https://github.com/estree/estree/blob/2c161ae714c1b23198be3be08c930e55a621c187/experimental/import-expression.md
But I think an independent node type is better:
interface ImportExpression <: Expression {
type: "ImportExpression";
source: Expression;
}
For some reasons:
source property is consistent with ImportDeclaration to express importing source.
On the other hand, it's hard to read that arguments[0] express the importing source.
- Searching
CallExpressions which have Import node in that callee is not convenient to analyze dependencies.
- The
arguments property doesn't fit Dynamic Imports syntax.
- The syntax cannot have multiple arguments. (i.e.
import() and import(a, b) are syntax error)
- The syntax cannot have trailing commas. (i.e.
import(source,) is syntax error)
- [EDIT]
Import node is not consistent with import.meta meta property. Existing MetaProperty node represents import.meta without Import node. The Import node will confuse us in the future.
Thoughts?
Thank you.
Hello.
Currently, AST for dynamic imports is using
CallExpression: https://github.com/estree/estree/blob/2c161ae714c1b23198be3be08c930e55a621c187/experimental/import-expression.mdBut I think an independent node type is better:
For some reasons:
sourceproperty is consistent with ImportDeclaration to express importing source.On the other hand, it's hard to read that
arguments[0]express the importing source.CallExpressions which haveImportnode in thatcalleeis not convenient to analyze dependencies.argumentsproperty doesn't fit Dynamic Imports syntax.import()andimport(a, b)are syntax error)import(source,)is syntax error)Importnode is not consistent withimport.metameta property. ExistingMetaPropertynode representsimport.metawithoutImportnode. TheImportnode will confuse us in the future.Thoughts?
Thank you.