Repository navigation
fix(babel-plugin): keep evaluated negative/non-finite numbers static - #4321
Conversation
#4309 switched evaluateAndInline to t.valueToNode for numbers, which builds -1 / 0/0 expressions; the SSR and universal transforms then treated them as dynamic, diverging from the oxc compiler (parity-probes "exotic literal holes"). Build NumericLiteral nodes directly where @babel/types 8 rejects the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMdD4K7882vob4J9vq
🦋 Changeset detectedLatest commit: 5ba6b98 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size (brotli, eager entry chunk)
|
Coverage Report for CI Build 40532949656Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.04%) to 78.627%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions90 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Merging this PR will degrade performance by 13.73%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Export numberLiteral and use it for evaluated prop: numbers, keep -0's sign, and test the static attribute paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1
Summary
#4309 (Babel 8 support) changed
evaluateAndInlineto build evaluated numbers witht.valueToNode, because @babel/types 8'snumericLiteralbuilder rejects negative and non-finite values.valueToNode(-1)builds aUnaryExpressionandvalueToNode(NaN)builds0 / 0, so they are no longerNumericLiterals. The SSR and universal transforms then treatc={-1} d={NaN}as dynamic:ssrAttribute("c", -1)instead of inliningc="-1".d: 0 / 0.Both differ from
@solidjs/compiler. The compiler's parity probes ("exotic literal holes", 6 modes) catch the difference, but that workflow only runs onpackages/compiler/**changes, so it never ran on #4309. It first showed up on #4320.This change keeps the result a
NumericLiteral. Values the v8 builder accepts still go throught.numericLiteral. Negative values,-0and non-finite values are built as plain nodes, which both majors' generators print as-1/NaN/Infinity, as Babel 7's builder did. Theprop:path indom/element.tskeepsvalueToNode, because there the value is a runtime expression anyway.How did you test this change?
packages/babel-plugin:pnpm testgives 411/411 on @babel/core 7, and 411/411 with @babel/core 8.0.9 swapped in as thebabel-8CI job does.<div c={-1} d={NaN} e={-0}>givesc="-1" d="NaN" e="0"in SSR,c: -1, d: NaN, e: 0in universal, andc=-1 d=NaN e=0in the dom template.packages/compiler__tests__/parity-probes.test.jswith the rebuilt plugin: 4080/4080. Onnextwithout this change, the 6 "exotic literal holes" probes fail.Generated by Claude Code