Skip to content

Commit

Permalink
Remove extra properties on ImportExpression node
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Dec 10, 2019
1 parent 93a3451 commit 2e77d76
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 64 deletions.
10 changes: 10 additions & 0 deletions packages/babel-parser/src/plugins/estree.js
Expand Up @@ -421,8 +421,18 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (node.callee.type === "Import") {
((node: N.Node): N.EstreeImportExpression).type = "ImportExpression";
((node: N.Node): N.EstreeImportExpression).source = node.arguments[0];
delete node.arguments;
delete node.callee;
}

return node;
}

// ImportExpressions do not have an arguments array.
toReferencedListDeep(
exprList: $ReadOnlyArray<?N.Expression> = [],
isParenthesizedExpr?: boolean,
): $ReadOnlyArray<?N.Expression> {
return super.toReferencedListDeep(exprList, isParenthesizedExpr);
}
};
2 changes: 0 additions & 2 deletions packages/babel-parser/src/types.js
Expand Up @@ -1041,8 +1041,6 @@ export type EstreeMethodDefinition = NodeBase & {

export type EstreeImportExpression = NodeBase & {
type: "ImportExpression",
callee: Import,
arguments: Array<Expression>,
source: Expression,
};

Expand Down
@@ -1,5 +1,3 @@
{
"plugins": [
"estree"
]
}
"plugins": ["estree"]
}
@@ -1,5 +1,3 @@
{
"plugins": [
"estree"
]
}
"plugins": ["estree"]
}
@@ -1,5 +1,3 @@
{
"plugins": [
"estree"
]
}
"plugins": ["estree"]
}
@@ -1,5 +1,3 @@
{
"plugins": [
"estree"
]
}
"plugins": ["estree"]
}
@@ -1,5 +1,3 @@
{
"plugins": [
"estree"
]
}
"plugins": ["estree"]
}
@@ -1,6 +1,3 @@
{
"plugins": [
"estree",
"bigInt"
]
"plugins": ["estree", "bigInt"]
}
Expand Up @@ -89,40 +89,6 @@
"column": 21
}
},
"callee": {
"type": "Import",
"start": 10,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 16
}
}
},
"arguments": [
{
"type": "Literal",
"start": 17,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 20
}
},
"value": "a",
"raw": "\"a\""
}
],
"source": {
"type": "Literal",
"start": 17,
Expand Down
@@ -1,6 +1,3 @@
{
"plugins": [
"estree",
"dynamicImport"
]
"plugins": ["estree", "dynamicImport"]
}

0 comments on commit 2e77d76

Please sign in to comment.