8000 refactor(transformer): don't need to transform `JSXExpression::EmptyExpression` in JSX attributes by Dunqing · Pull Request #8817 · oxc-project/oxc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor(transformer): 8000 don't need to transform JSXExpression::EmptyExpression in JSX attributes #8817

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

Conversation

Dunqing
Copy link
Member
@Dunqing Dunqing commented Jan 31, 2025

No description provided.

Copy link
Member Author
Dunqing commented Jan 31, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Dunqing Dunqing changed the title refactor(transformer): don't need to transform JSXExpression::EmptyExpression in JSX attributes refactor(transformer): don't need to transform JSXExpression::EmptyExpression in JSX attributes Jan 31, 2025
@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jan 31, 2025
@Dunqing Dunqing force-pushed the 01-31-docs_ast_correct_documentation_for_jsxexpression_emptyexpression branch from 90a2999 to 5aea3cf Compare January 31, 2025 15:53
@Dunqing Dunqing requested a review from Boshen as a code owner January 31, 2025 15:53
@Dunqing Dunqing force-pushed the 01-31-refactor_transformer_don_t_need_to_transform_jsxexpression_emptyexpression_in_jsx_attributes branch from c7edd4f to b1d0bb7 Compare January 31, 2025 15:53
Copy link
codspeed-hq bot commented Jan 31, 2025

CodSpeed Performance Report

Merging #8817 will not alter performance

Comparing 01-31-refactor_transformer_don_t_need_to_transform_jsxexpression_emptyexpression_in_jsx_attributes (1c1add7) with main (b00b8c8)

Summary

✅ 33 untouched benchmarks

@Boshen Boshen changed the base branch from 01-31-docs_ast_correct_documentation_for_jsxexpression_emptyexpression to graphite-base/8817 February 1, 2025 02:25
JSXExpression::EmptyExpression(_) => {
// `<div attr={}></div>`
// ^^ Invalid empty expression here
unreachable!()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not make this unreachable in situations where the semantic checker is not run or missed the check, do not emit anything instead.

Copy link
Member Author
@Dunqing Dunqing Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. To achieve "do not emit anything" here we must return a None, which will cause more changes, I will do this later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From reading the JSX spec, it doesn't look like an EmptyExpression is ever valid in this position. If I've understood that right, could we make JSXExpressionContainer just contain an Expression, rather than a JSXExpression?

I assume the reason is recoverability. To achieve that, could we instead raise an error in the parser, and skip adding the JSXAttribute, so that parsing can continue?

It's going to cause a problem serializing to ESTree, because what does it serialize to? The "EmptyExpression" option doesn't exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Boshen Boshen force-pushed the 01-31-refactor_transformer_don_t_need_to_transform_jsxexpression_emptyexpression_in_jsx_attributes branch from b1d0bb7 to cba6a7a Compare February 1, 2025 02:43
@Boshen Boshen force-pushed the graphite-base/8817 branch from 5aea3cf to b00b8c8 Compare February 1, 2025 02:43
@Boshen Boshen changed the base branch from graphite-base/8817 to main February 1, 2025 02:44
@Boshen Boshen force-pushed the 01-31-refactor_transformer_don_t_need_to_transform_jsxexpression_emptyexpression_in_jsx_attributes branch from cba6a7a to 1c1add7 Compare February 1, 2025 02:44
@Dunqing Dunqing marked this pull request as draft February 1, 2025 02:50
@Boshen
Copy link
Member
Boshen commented Mar 7, 2025

Re changing AST:

I double checked, it's a difficult change because we want the span in JSXExpressionContainer, and also support <div>{}</div>.

Close as not planned.

@Boshen Boshen closed this Mar 7, 2025
@Boshen Boshen deleted the 01-31-refactor_transformer_don_t_need_to_transform_jsxexpression_emptyexpression_in_jsx_attributes branch March 7, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0