feat: Expand property access in externals#2425
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:
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.79, 1.66, 3.52, 6.15, 7.31, 11.06, 19.80, 22.90]
line [0.87, 1.72, 3.89, 5.78, 6.82, 10.43, 19.66, 22.38]
line [0.88, 1.72, 3.90, 5.84, 6.67, 8.46, 18.16, 22.27]
---
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.47, 0.68, 0.81, 1.02, 1.06, 1.29, 1.42]
line [0.34, 0.54, 0.68, 0.79, 1.03, 1.08, 1.33, 1.47]
line [0.27, 0.50, 0.70, 0.84, 1.07, 1.16, 1.36, 1.48]
---
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.87, 2.02, 3.37, 5.78, 10.91, 22.75, 52.68, 106.75]
line [0.77, 1.92, 3.59, 5.76, 11.05, 22.58, 49.18, 99.42]
line [0.83, 1.80, 3.59, 5.75, 10.83, 22.54, 48.57, 100.44]
|
e29acd4 to
d6e4f7e
Compare
…access-in-externals
There was a problem hiding this comment.
Pull request overview
This PR updates the “externals” pipeline end-to-end so tinyest-for-wgsl can collect an expanded external tree (including nested property access), and unplugin-typegpu can embed that richer externals structure into function metadata (bumping metadata format to v2). It also adds/updates unit tests and snapshot fixtures across tinyest-for-wgsl, unplugin-typegpu, typegpu, and the docs example tests to reflect the new metadata/external extraction behavior.
Changes:
- Extend
tinyest-for-wgslexternals collection from a flat list into a nested external tree derived from property access chains. - Update
unplugin-typegpumetadata embedding to store backwards-compatible AST + new externals structure, and bumpMETADATA_FORMAT_VERSIONto 2. - Add new coverage tests (e.g. nested externals) and update many snapshots across packages/docs.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/unplugin-typegpu/test/use-gpu-directive.test.ts | Update snapshots for metadata v2 and new externals object shape. |
| packages/unplugin-typegpu/test/typescript-syntax.test.ts | Update snapshots for metadata v2 / externals object. |
| packages/unplugin-typegpu/test/tgsl-transpiling.test.ts | Update snapshots to reflect nested externals emission and metadata v2. |
| packages/unplugin-typegpu/test/parser-options.test.ts | Update snapshots for metadata v2 / externals object. |
| packages/unplugin-typegpu/test/nested-externals.test.ts | New tests validating nested externals extraction in Babel/Rollup transforms. |
| packages/unplugin-typegpu/test/auto-naming.test.ts | Update snapshots for metadata v2 and externals object shape. |
| packages/unplugin-typegpu/test/aliasing.test.ts | Update snapshots for metadata v2 / externals object. |
| packages/unplugin-typegpu/src/core/factory.ts | Emit externals as a nested object tree (string-based emitter) and embed backwards-compatible AST. |
| packages/unplugin-typegpu/src/core/common.ts | Bump metadata format to v2 and add makeAstBackwardsCompatible. |
| packages/unplugin-typegpu/src/babel.ts | Emit externals as nested AST nodes for Babel plugin output; embed backwards-compatible AST. |
| packages/typegpu/tests/unplugin/autoname.test.ts | Update expected metadata v2 output and externals shape. |
| packages/typegpu/tests/ref.test.ts | Update error message snapshot related to invalid ref usage. |
| packages/typegpu/tests/externalPropAccess.test.ts | New tests validating external property access resolution paths. |
| packages/typegpu/src/core/function/fnTypes.ts | Remove obsolete TranspilationResult type (now owned by tinyest-for-wgsl). |
| packages/tinyest-for-wgsl/tests/parsers.test.ts | Update externals expectations from arrays to nested object trees; add complex-tree test. |
| packages/tinyest-for-wgsl/src/types.ts | Introduce shared types for externals tree + transpilation context/result. |
| packages/tinyest-for-wgsl/src/parsers.ts | Track ancestor chain and build nested externals via new helper. |
| packages/tinyest-for-wgsl/src/index.ts | Export new Externals type. |
| packages/tinyest-for-wgsl/src/externals.ts | New externals-tree builder from ancestor/member-expression chains. |
| apps/typegpu-docs/tests/individual-example-tests/spinning-triangle.test.ts | Update shader snapshot output affected by metadata/externals changes. |
| apps/typegpu-docs/tests/individual-example-tests/shifting-gradient.test.ts | Update shader snapshot output affected by metadata/externals changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
FLAT |
tinyest-for-wgslnow collects "expanded" externals (before, it would return["ext"]):Unplugin then assigns new externals variant:
Finally,
fnCore.tsreplaces the thunks with getters (this change was introduced in #2502), so that we don't needlessly complicate prop access.Unfortunately, we lost the ability to autoname some of the externals:
before,
bufwould be in externals and would be autonamed. Now, thebufin externals is a fake:{ 'buf': { '$': () => buf.$ } }, therefore it won't be named.