-
Notifications
You must be signed in to change notification settings - Fork 2
WIP: Custom JSX transpilation into Qwik-specific _jsxSorted and _jsxSplit calls #56
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
base: main
Are you sure you want to change the base?
Conversation
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.
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
qwik-optimizer/optimizer/src/transform.rs
Lines 859 to 865 in b0aa585
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() |
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
qwik-optimizer/optimizer/src/transform.rs
Lines 646 to 655 in b0aa585
// 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, | |
) |
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
qwik-optimizer/optimizer/src/transform.rs
Lines 266 to 271 in b0aa585
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); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
input.code, | ||
language, | ||
Some(path.with_extension("").to_string_lossy().to_string()), | ||
)?, |
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.
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.
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:
bind:
event handler attributes