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 (337 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
|
After merging this PR, we should be able to change how we get unique index in the for of loop. EDIT: |
There was a problem hiding this comment.
Pull request overview
This PR refines identifier generation by adding block-level scoping to nameRegistry, reducing shadowing and improving determinism in preparation for upcoming bundler changes.
Changes:
- Add block-scope tracking to
NameRegistryand wire it intoResolutionCtxblock scope lifecycle. - Update WGSL generation for
for ... of ...to use a dedicated block scope and add a test for invalid loop variable identifiers. - Update example snapshot tests (variable renames like
i→i_1) and minor docs formatting cleanup.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/src/nameRegistry.ts | Implements a scope stack with function + block scopes and adds push/pop block scope APIs. |
| packages/typegpu/src/resolutionCtx.ts | Ensures block scope pushes/pops also advance the name registry scope stack. |
| packages/typegpu/src/tgsl/wgslGenerator.ts | Wraps for...of loop variable naming/definition in a block scope. |
| packages/typegpu/tests/tgsl/wgslGenerator.test.ts | Updates comptime usage and adds a test asserting invalid loop variable names throw. |
| packages/typegpu/tests/examples/individual/jelly-switch.test.ts | Snapshot update reflecting new scoped renaming (i → i_1). |
| packages/typegpu/tests/examples/individual/jelly-slider.test.ts | Snapshot update reflecting new scoped renaming (i → i_1). |
| packages/typegpu/tests/examples/individual/blur.test.ts | Snapshot update reflecting new scoped renaming (r → r_1) and downstream references. |
| packages/typegpu/tests/examples/individual/3d-fish.test.ts | Snapshot update reflecting new scoped renaming (i → i_1) and downstream references. |
| apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts | Minor expression formatting cleanup (removes unnecessary parentheses). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR introduces finer-grained scoping to our
nameRegistryby implementing block scopes.It aims to:
esbuildtorolldownin upcoming Vite 8Additionally:
Below, I attach diagram of new

nameRegistry