parsed AST does not contain JSXElement nodes #17145
-
|
@babel/parser 7.26.9 I am trying to write a vite plugin that walks the source files of the project and find all JSX elements and collect the path attribute of that element and at the end of the walk writes out a txt files with one path on each line. I am trying to use babel to do so but it doesn't work because the parsed AST doesn't contain nodes with type JSXElement. I am hoping someone here can tell me what I need to do to get JSX* nodes in the parsed AST? The file that contains the stuff I'm interested is, is this one: https://github.com/steinarb/sampleapp/blob/master/sampleapp.web.frontend/src/main/frontend/src/App.js The JSON-ified version of the AST for App.js (as logged in the code below), looks like this: https://gist.github.com/steinarb/e3d8b0a5c2bd64378250a985f3de2852 For the time being I have just put the vite plugin into the (not sure if transform() is the function that should be used since it sounds like it tries to transform something, but for now I'm just trying to find the Route elements and their attributes...) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
This comment was marked as spam.
This comment was marked as spam.
-
|
package-lock.json I've added package.json and package-lock.json for the project. |
Beta Was this translation helpful? Give feedback.
-
|
You are writing a rollup plugin which runs after esbuild . |
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.
You are writing a rollup plugin which runs after esbuild .
So JSX has been converted to JS.
As a workaround, you can try to read the original file from id or write an esbuild plugin.