fix(unplugin-typegpu): Babel transform preserves exports#2606
fix(unplugin-typegpu): Babel transform preserves exports#2606cieplypolar wants to merge 3 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.92, 1.78, 3.98, 6.44, 7.15, 10.63, 20.38, 22.50]
line [0.91, 1.78, 3.82, 5.83, 7.13, 10.70, 22.03, 23.54]
line [0.90, 1.91, 3.90, 5.93, 7.15, 9.91, 20.99, 20.98]
---
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.26, 0.56, 0.70, 0.86, 1.12, 1.14, 1.44, 1.55]
line [0.33, 0.57, 0.73, 0.88, 1.15, 1.26, 1.50, 1.60]
line [0.34, 0.57, 0.71, 0.85, 1.16, 1.24, 1.48, 1.57]
---
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.83, 1.90, 3.12, 6.35, 11.70, 24.52, 54.35, 108.90]
line [0.89, 1.95, 3.98, 5.75, 11.67, 23.77, 52.84, 109.17]
line [0.92, 2.22, 4.23, 6.46, 12.34, 24.39, 52.87, 110.08]
|
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.