Repository navigation
impr(unplugin-typegpu): Support parsing all metadata fields - #3020
cieplypolar wants to merge 50 commits into
Conversation
|
pkg.pr.new packages benchmark commit |
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.56, 1.15, 2.38, 3.74, 4.00, 7.38, 14.22, 12.73]
line [0.54, 1.02, 2.06, 3.69, 4.23, 6.92, 14.26, 14.61]
line [0.53, 1.07, 2.21, 3.80, 4.11, 6.74, 13.73, 13.22]
---
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.16, 0.27, 0.41, 0.47, 0.63, 0.70, 0.81, 0.89]
line [0.19, 0.32, 0.43, 0.47, 0.63, 0.68, 0.77, 0.91]
line [0.14, 0.31, 0.39, 0.40, 0.60, 0.60, 0.76, 0.78]
---
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.62, 1.33, 2.57, 3.89, 7.40, 15.30, 31.88, 65.15]
line [0.58, 1.43, 2.54, 4.19, 7.47, 15.39, 32.91, 66.00]
line [0.57, 1.23, 2.14, 3.78, 7.71, 14.77, 30.80, 64.24]
|
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased | ❔ Unknown |
|---|---|---|---|
| 0 | 355 | 0 | 0 |
No notable changes.
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
c6ccc73 to
0e1183c
Compare
c8b1cdc to
4fcb009
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Restructured the bundler-rewrite tests (
packages/unplugin-typegpu/test/embedded-metadata.test.ts): the shareddualTestblock was replaced by explicit[BABEL]/[ROLLUP]tests, and the embeddedfnbody switched tolet a=1,b=2— a multi-declaration statementtinyest-for-wgslrejects — so a recognition regression now re-transforms and throws rather than passing on the low occurrence-count assertion alone. - Added
parses switch statements: asserts the parsedfunction.ast.bodymatchestranspileBabelFn-derived output for aswitchcontaining fallthrough,default, and an externalcase ext. - Added
points astPath to the ast object of the metadata: pins thatastPathis theastproperty'sObjectExpression(asserting itsparentPathis theastObjectPropertyand thatevaluate()yields the expected{ params, body }). - Dropped the unused
outputparameter fromdualTest, simplifying both collector paths.
The only production source files in this PR are unchanged since the prior review; this delta is test-only. Verified at head: 79/79 tests in embedded-metadata.test.ts pass and pnpm --filter unplugin-typegpu test:types is clean.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
getEmbeddedTypegpuMetadata now throws an unhandled TypeError when a .set(...) call referencing __TYPEGPU_META__ has a single argument — the removed metadataPath === undefined guard was load-bearing. Details inline.
Reviewed changes
- Descend through metadata wrappers (
packages/unplugin-typegpu/src/core/embeddedMetadata.ts): addedskipTransparentWrappersDownand switched the metadata argument fromskipTransparentWrappersUp(metadataPath)toskipTransparentWrappersDown(callPath.get('arguments.1')), so metadata written as(meta)or(meta as any)!is now unwrapped and recognized. - Tests (
test/embedded-metadata.test.ts): added aparenthesized metadatavariant to the bundler-rewrite matrix and atype-wrapped metadatacase asserting the AST parses and the function is not re-transformed. 82 tests pass at head;tsc --noEmitclean.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
30c30cd to
5208e45
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — the prior crash is fixed; one small test gap inline.
Reviewed changes
- Restored the
metadataPath === undefinedguard (packages/unplugin-typegpu/src/core/embeddedMetadata.ts): a.set(...)call referencing__TYPEGPU_META__with a single argument now returnsundefinedagain instead of throwingTypeError: Cannot read properties of undefined (reading 'node'). - Kept unwrapping the metadata argument with
skipTransparentWrappersDown, so(meta)and(meta as any)!remain recognized; dropped the redundantas NodePathon thecallPath.get('arguments.1')call. - Tests (
test/embedded-metadata.test.ts): added theparenthesized metadatabundler-rewrite variant and atype-wrapped metadatacase.
Verified at head 5208e45: 82/82 embedded-metadata.test.ts tests pass, test:types is clean, and a scratch probe confirms the one-argument .set(...) case no longer throws.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Recognize downleveled external getters (
packages/unplugin-typegpu/src/core/embeddedMetadata.ts):parseExternalsPathno longer requires an externals property's value to be anArrowFunctionExpression, so getters that tools such as Babel'stransform-arrow-functionslower tofunctionexpressions are accepted instead of makingparseExternalsPathreturnundefinedand abort the whole transform. - Added a regression test (
packages/unplugin-typegpu/test/embedded-metadata.test.ts):recognizes external getters downleveled by transform-arrow-functions pluginlowers an arrow getter withtransform-arrow-functions, runs the output throughdualTest, and asserts the parsed getter bodies.
Verified at head 99777d94: the new test's [BABEL] and [ROLLUP] variants both fail against the pre-change (c17c69a8) parseExternalsPath, confirming the test pins the fix; 275/275 non-Deno unplugin-typegpu tests pass (84 in embedded-metadata.test.ts) and test:types is clean. The sole prior Pullfrog thread (embeddedMetadata.ts:259-261) remains resolved.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Parse ast and externals out of embedded metadata.