- Notifications
You must be signed in to change notification settings - Fork335
feat: add jsx support#391
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
papandreou left a comment
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.
I'm no JSX expert, I just wanted to get serialization support in assetgraph. Thanks a lot for picking this up!
I triednpm linking escodegen in with this change, and it seems to do the job! 👍
Would be nice to get support forJSXFragment while you're at it. It's not supported by esprima yet, but you can test that with acorn or espree, for example.
Uh oh!
There was an error while loading.Please reload this page.
| if(expr.value.type==='JSXExpressionContainer'){ | ||
| result.push(this.generateExpression(expr.value.expression,precedence,flags)); | ||
| returnresult; | ||
| } |
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.
You also need to handleexpr.value.type === 'JSXElement' here.
>require('escodegen').generate(require('esprima').parse('(<Foo bar=<Quux/>/>)',{jsx:true}));'<Foo undefined />;'
AndJSXFragment as well, if you go for that:https://github.com/facebook/jsx/blob/master/AST.md#jsx-attributes
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.
Totally forgot about boolean attributes, good catch 👍
Missed it, used to be `[space, '/>]`, forgot to drop the array.Co-Authored-By: erquhart <shawn@erquh.art>
erquhart commentedApr 30, 2019
Haven't forgotten about this, will circle back soon. |
zouxuoz commentedJan 4, 2020
@erquhart how I can help you to finish this update? |
erquhart commentedJan 7, 2020
Just a matter of when, haven't circled back yet. An old fork (https://github.com/ng-vu/escodegen-jsx) that introduced (incompatible) jsx support had some things that felt necessary, so the plan has been to pull in the more thorough bits from there. If you want to take this across the finish line, by all means please do! |
sag1v commentedDec 23, 2021
Is JSX going to be supported or is there any other way to do it? |
smol-honk commentedOct 27, 2022
What if we added thishttps://github.com/wallabyjs/escodegen? |
Adds JSX support.
Notes
valueandrawTodo
generateExpression()Closes#333.