Repository navigation
impr(unplugin-typegpu): Support parsing all metadata fields - #3020
cieplypolar wants to merge 46 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.99, 1.83, 3.67, 6.32, 7.36, 12.57, 23.93, 26.00]
line [0.93, 1.88, 3.90, 6.48, 7.16, 10.76, 23.80, 24.50]
line [0.92, 1.94, 4.22, 5.92, 7.20, 11.20, 23.32, 25.01]
---
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.31, 0.56, 0.72, 0.80, 1.23, 1.23, 1.53, 1.55]
line [0.30, 0.52, 0.74, 0.87, 1.13, 1.11, 1.44, 1.52]
line [0.25, 0.51, 0.63, 0.80, 1.06, 1.10, 1.40, 1.56]
---
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.78, 2.19, 3.36, 6.80, 11.92, 24.52, 53.66, 108.36]
line [0.82, 2.28, 3.73, 6.49, 11.90, 24.65, 52.09, 107.23]
line [0.80, 2.25, 3.75, 6.46, 11.53, 24.45, 53.08, 107.40]
|
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
- Re-integrated the metadata parser onto
main's #3084 detection helpers: mergedmain(now containing #3084's rewrite) and adaptedgetEmbeddedTypegpuMetadatatoskipTransparentWrappersUp/isTypegpuMetadataAccess/ the broadenedisTypegpuMetadataSetCall, adding assignment-RHS andarguments[0]node-identity checks on top of the PR'sobjectPropertyPath/parseAstPath/parseExternalsPath. - Reworked the rewrite tests onto the shared
dualTestharness: the five bundler-rewrite variants now assert both the parsedfunction.astand an exact__TYPEGPU_META__occurrence count, so a recognition regression fails on the count rather than passing via re-transformed metadata. - Broke the
common.ts⇄embeddedMetadata.tsvalue cycle: extractedMETADATA_FORMAT_VERSIONinto the new leaf modulesrc/core/version.tsand repointedbabel.ts,factory.ts, andembeddedMetadata.tsat it.
Verified at head: 218/218 unplugin-typegpu tests pass (75 in embedded-metadata.test.ts), test:types clean, tsdown build succeeds, and test:circular-deps reports no cycles. The sole prior Pullfrog thread is resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
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) | 𝕏

Parse ast and externals out of embedded metadata.