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 node name changes in next.9 #1503
Comments
At the very least, it'd be ideal if we partition/separate exports and imports, they're semantically and intentionally different. |
The reason for having a single node that contains arbitrary JavaScript is a) in alignment with how it’s parsed, but importantly b), to allow extensions to what’s allowed. Such as That single arbitrary JS node also allows MDX to be extended to support: ```js eval
var number = Math.PI
```
The number is {number}. …through a plugin that walks mdast and replaces Another idea is to allow more vue/svelte like syntax: <script>
var number = Math.PI
</script>
The number is {number}. To answer “they're semantically [...] different” — On the JavaScript level they are. And they are separately available as a subtree. Folks can inspect and transform those subtrees, which is in my opinion preferable over trying to handle a serialized value (such as what |
Ah I see, I suppose we can get close to current support by exposing some APIs for walking the estree for folks that want to do things like plucking/removing imports and specific types of exports. |
These name chagnges are intentional and honestly allow really cool things. See https://v2.mdxjs.com/docs/extending-mdx/#creating-plugins for more info on creating plugins. |
Subject of the issue
The new node types in v2-next.9 renames the types
export
import
jsx
into
mdxjsEsm
mdxJsxFlowElement
I believe a full list of the 5 new node types can be found here
The new node types for
import
andexport
specifically seem to mostly be additive changes (specifically, inserting the new estree AST as data on the node), but the name change will break gatsby-plugin-mdx and anyone else who is depending on the export or import nodes (as well as the jsx node).Also note that the behavior here is slightly different. An
import
and anexport
next to each other are now combined into a singlemdxjsEsm
node.Your environment
Steps to reproduce
Expected behaviour
Expected
import
node andexport
node to be separate and include one import or export per node.Actual behaviour
both import and export are combined into a single new node type, even though the .value string still exists and would provide backwards compatibility.
Additional questions
Is it also possible to provide backwards compatibility for the jsx node?
The text was updated successfully, but these errors were encountered: