Huáng Jùnliàng 94af0e5c62
Improve template tokenizing (#13919)
* add benchmarks

* refactor: tokenize template as middle + tail

* perf: avoid push tc.brace

* refactor: overwrite skipSpace in jsx plugin

* transform tl.templateMiddle/Tail

* refactor: simplify JSX context tracking

* fix flow error

* refactor: move JSX context to context.js

* fix: ensure comment stack is correctly handled

* rename createPositionFromPosition

* rename token type and methods

* add tokenIsTemplate

* refactor: merge babel 7 logic in babel7CompatTokens

* fix flow error
2021-12-06 16:43:46 -05:00

62 lines
1.9 KiB
JSON

{
"type": "File",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"program": {
"type": "Program",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}},
"expression": {
"type": "TemplateLiteral",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}},
"expressions": [
{
"type": "Identifier",
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"a"},
"name": "a"
}
],
"quasis": [
{
"type": "TemplateElement",
"start":1,"end":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},
"value": {
"raw": "",
"cooked": ""
},
"tail": false
},
{
"type": "TemplateElement",
"start":5,"end":5,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":5}},
"value": {
"raw": "",
"cooked": ""
},
"tail": true
}
]
},
"trailingComments": [
{
"type": "CommentLine",
"value": " comment",
"start":7,"end":17,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":17}}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " comment",
"start":7,"end":17,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":17}}
}
]
}