fix(unplugin-typegpu): Babel transform preserves exports#2606
fix(unplugin-typegpu): Babel transform preserves exports#2606cieplypolar wants to merge 4 commits into
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (355 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.76, 1.56, 3.26, 5.48, 5.70, 8.74, 17.32, 19.54]
line [0.76, 1.45, 3.14, 4.57, 5.64, 8.13, 15.92, 18.87]
line [0.77, 1.63, 3.18, 4.92, 5.42, 8.52, 15.45, 18.02]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.28, 0.50, 0.54, 0.67, 0.90, 1.04, 1.15, 1.35]
line [0.27, 0.42, 0.56, 0.64, 0.93, 0.99, 1.16, 1.26]
line [0.27, 0.49, 0.56, 0.72, 0.97, 1.05, 1.23, 1.37]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.85, 1.74, 3.40, 4.87, 9.27, 20.07, 43.32, 88.54]
line [0.82, 1.60, 3.87, 5.54, 9.86, 19.52, 42.44, 85.38]
line [0.85, 1.71, 3.47, 4.97, 9.69, 20.00, 42.73, 86.60]
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the Babel-based unplugin-typegpu transform so that when a "use gpu" exported function declaration is hoisted/replaced, the corresponding export is preserved (instead of being accidentally removed). It also updates the test suite to assert the corrected Babel output alongside the Rollup output.
Changes:
- Preserve
exportstatements when hoisting transformedexport function .../export default function ...in the Babel plugin. - Extend the existing “hoists exported…” test to cover both Babel and Rollup transforms with separate snapshots.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/unplugin-typegpu/src/babel.ts | When hoisting a transformed exported function declaration, replaces the enclosing export node with an equivalent export (export { id } / export default id) instead of removing it. |
| packages/unplugin-typegpu/test/use-gpu-directive.test.ts | Splits the exported-hoisting test into babel and rollup assertions and adds an inline snapshot verifying Babel now preserves exports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.