-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AST Explorer #1933
base: main
Are you sure you want to change the base?
AST Explorer #1933
Conversation
The version number at the top of the repl page confused me, because I thought it referred to the version for the currently running repl, and I couldn't find a way to change it to `master` (because whenever you go to the repl page, it changes back to 6.x). I talked to @hzoo and he said it's the docs version (a docusaurus feature). Since we already had some code that was hiding the docusaurus footer on the repl page, I repurposed it a bit and used the same pattern to also hide the docs version link when on the repl page. 
* [email protected] * Drop prettier since we run it from root
Deploy preview for babel ready! Built with commit 00da94b |
That looks good. Would be cool to be able to click on the code and that it shows the location in the AST, as ASTExplorer. Also, do you have an idea how we could remove our internal properties in the AST? ( |
This comment has been minimized.
This comment has been minimized.
We should remove every property prefixed with _ |
All props that start with '_' prefixes are excluded. |
replaces #1421 |
The output looks good (I haven't read the code yet). BinaryExpression {
"left": NumericLiteral {
"value":1
},
"operator": "+",
"right": NumericLiteral {
"value":1
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, I left some inline comments.
Also it would be nice to have an interface element to disable tokens
on the parser level and have it disabled by default (for performance, and tokens are used rarely anyway).
Babel-parser has an option to disable it.
Also as nicolo said type
is the most important field, so I do not see the point in having an option to disable it. I would rather have an option that disables everything but the type
.
@@ -137,6 +138,8 @@ export default function compile(code: string, config: CompileConfig): Return { | |||
}; | |||
|
|||
const transformed = Babel.transform(code, babelConfig); | |||
|
|||
astContext = JSON.stringify(transformed.ast); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is the same as also with #1421. The ast is for the transformed output which is confusing imho. So for example if the input is () => {}
and preset-env is enabled there is no ArrowFunction in the ast instead there is a FunctionExpression.
I wonder if there is a usecase were people want to see the transformed output, but atm I think it is more confusing. So I would prefer doing Babel.parse
here when the ast panel is active (and also disabling all transform options in the interface maybe?)
But not sure what other people think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const src = unflatten(flattenSrc); | ||
|
||
return { | ||
src: src, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the input is changed (props.src
) the options here are ignored. So I disabled location
but as soon as I change the input the locations are back. I have to enable and then disable the locations
option again to remove locations.
There also seems to be a lot of unrelated changes to |
Happy new year! 🎊
It is a very basic concept of AST panel as following as AST explorer.
Except for an auto focusing option in AST explorer, on/off methods, empty keys and location data features are completed.
I appreciate your review and help in advance.
Related Issue : Babel Roadmap - AST Explorer