fkling / fkling/astexplorer

Version of Babel in transform mismatched with version of Babel in tree view

Open
#652 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6.5k
Forks
772
PR merge metrics
No merged PRs in 30d

Description

**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.

**Screenshots**
![Screen Shot 2022-06-08 at 12 01 31 AM](https://user-images.githubusercontent.com/364761/172528369-361ca7f4-3148-4f3d-af53-53c500c8453a.png)
![Screen Shot 2022-06-08 at 12 01 31 AM](https://user-images.githubusercontent.com/364761/172528830-95ef35b3-2c83-4c51-9524-a4f04c679e47.png)

**Browser (please complete the following information):**
- OS: MacOS
- Browser Chrome
- Version 102.0.5005.61

**astexplorer settings:**
- Selected parser: `@babel/parser` with `createParenthesizedExpressions: true` and plugins `jsx` and `typescript`
- 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":" $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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.