Version of Babel in transform mismatched with version of Babel in tree view
jaredp opened this issue · comments
Describe the bug
When the transform panel uses Babel to parse with createParenthesizedExpressions: true
and prints the AST to the console, there are no ParenthesizedExpression
nodes in the console.
This doesn't match the tree view, which shows a ParenthesizedExpression
node in between the ExpressionStatement
and the StringLiteralExpression
This suggests the version of @babel/parser
available in the transform panel is a different (older?) version than available in the tree view, such that the version in the transform panel doesn't support createParenthesizedExpressions
To Reproduce
https://astexplorer.net/#/gist/e7492c62c92b167cbc46e5a58dd28a47/9ad795d751343a625ca8683e0bf644eebbe4434a
Expected behavior
The AST printed to the console to have a ParenthesizedExpression
node in between the ExpressionStatement
and the StringLiteralExpression
nodes.
Browser (please complete the following information):
- OS: MacOS
- Browser Chrome
- Version 102.0.5005.61
astexplorer settings:
- Selected parser:
@babel/parser
withcreateParenthesizedExpressions: true
and pluginsjsx
andtypescript
- Selected transformer recast
- Contents of the local storage key
explorerSettingsV1
(code can be removed if you don't want it to be public)
{"showTransformPanel":false,"parserSettings":{"babylon7":{"sourceType":"module","allowImportExportEverywhere":false,"allowReturnOutsideFunction":false,"createParenthesizedExpressions":false,"ranges":false,"tokens":true,"plugins":["typescript","jsx"],"pipelineOptions":{"proposal":"hack","hackTopicToken":"%"}},"esprima":null,"recast":null},"parserPerCategory":{"javascript":"babylon7"},"workbench":{"parser":"php-parser","code":"<?php\n\n$tips = [\n \"Click on any AST node with a '+' to expand it\",\n\n \"Hovering over a node highlights the \\\n corresponding location in the source code\",\n\n \"Shift click on an AST node to expand the whole subtree\"\n];\n\nfunction printTips() {\n global $tips;\n foreach($tips as $i => $tip) {\n echo \"Tip $i: \" . $tip;\n }\n}\n","keyMap":"default","transform":{"code":"\n\nexport default function transformer(code, { recast, parsers }) {\n\n const ast = recast.parse(code, {\n parser: {\n parse(source: string) {\n return parsers.babel.parse(source, {\n sourceType: 'module',\n // Note: Parens nodes don't make a difference\n createParenthesizedExpressions: true,\n });\n }\n }\n });\n console.log(ast);\n console.log(parsers);\n return recast.print(ast).code;\n}\n","transformer":"recast"}}}
Additional context
Add any other context about the problem here.