Skip to content

Conversation

adam-nelson-kunai
Copy link
Collaborator

@adam-nelson-kunai adam-nelson-kunai commented Jun 30, 2025

Qwik v2 includes custom JSX transpilation logic that uses its own builtin functions (_jsxSorted and _jsxSplit) as the compilation result of JSX expressions. These functions expect the JSX attributes to be divided into constant and variable attributes, and expect the variable attributes to be lexicographically sorted.

Still remaining to do, not in this PR yet:

  • Special-case parsing for bind: event handler attributes

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Unstable Unwraps in JSX Processing

The exit_jsx_child function contains unsafe unwrap() calls on self.replace_expr when processing JSXChild::Element and JSXChild::Fragment. This can lead to panics if self.replace_expr is None, as it incorrectly assumes the expression has always been set by prior traversal steps. Additionally, debug println! statements related to JSX element/fragment replacement were accidentally committed and should be removed.

optimizer/src/transform.rs#L859-L865

JSXChild::Element(_) => {
println!("Replacing JSX child element on exit");
self.replace_expr.take().unwrap().into()
}
JSXChild::Fragment(_) => {
println!("Replacing JSX child fragment on exit");
self.replace_expr.take().unwrap().into()

Fix in CursorFix in Web


Bug: JSX Flag Bit Collision

The binary flags for JSX elements, static_subtree and static_listeners, are incorrectly calculated. Both 0b1 and 0b01 set the same bit (bit 0), making the flags indistinguishable. The static_listeners flag should use 0b10 (bit 1) to set a distinct bit.

optimizer/src/transform.rs#L646-L655

// flags
self.builder
.expression_numeric_literal(
node.span(),
((if jsx.static_subtree { 0b1 } else { 0 })
| (if jsx.static_listeners { 0b01 } else { 0 }))
.into(),
None,
NumberBase::Binary,
)

Fix in CursorFix in Web


Bug: Production Code Leaks Debug Statements

Unwanted println! debug statements are present throughout the code, producing console output in production builds. These statements are not guarded by the DEBUG constant.

optimizer/src/transform.rs#L266-L271

fn enter_program(&mut self, node: &mut Program<'a>, ctx: &mut TraverseCtx<'a>) {
println!("ENTERING PROGRAM {}", self.source_info.file_name);
}
fn exit_program(&mut self, node: &mut Program<'a>, ctx: &mut TraverseCtx<'a>) {
println!("EXITING PROGRAM {}", self.source_info.file_name);

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

input.code,
language,
Some(path.with_extension("").to_string_lossy().to_string()),
)?,
Copy link

Choose a reason for hiding this comment

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

Bug: Path Resolution Fails with Incorrect Source Handling

The Source::from_source call now incorrectly passes an absolute path with its file extension removed, instead of the intended path relative to the source directory. This breaks path resolution and module identification, as downstream code expects relative paths with extensions.

Locations (1)

Fix in CursorFix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants