Skip to content

feat: Minify variables in plugin - #2755

Draft
aleksanderkatan wants to merge 14 commits into
mainfrom
feat/minify-variables-in-plugin
Draft

feat: Minify variables in plugin#2755
aleksanderkatan wants to merge 14 commits into
mainfrom
feat/minify-variables-in-plugin

Conversation

@aleksanderkatan

@aleksanderkatan aleksanderkatan commented Jul 23, 2026

Copy link
Copy Markdown
Member
image

We minify variables, externals and parameters. Struct props are left as-is.

I tested it by:

  • going through all examples with minification enabled (apps/typegpu-docs/astro.config.mjs:56),
  • skimming the diffs in updated example snapshots with minification enabled (apps/typegpu-docs/vitest.config.mts:12),
  • seeing all failing tests in typegpu/tests with minification enabled (packages/typegpu/vitest.config.mts:11).

Things that still can be minified (in different PRs):

  • all resources named via $name,
  • whitespaces,
  • (?) struct props,
  • entrypoint function parameters.

Also, helpers like fullScreenTriangle will remain as is, they are implemented in raw wgsl.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/eslint-plugin-typegpu@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/tgpu-gen@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/radiance-cascades@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/sdf@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/three@e2e428b79b06844e18f7a95fe5d3af587f761611
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@e2e428b79b06844e18f7a95fe5d3af587f761611

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased (max 0.01%) ❔ Unknown
0 301 21 0

import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):

Test tsdown
tgpu_init.ts 258.91 kB ($${\color{green}-3.2\%}$$)
tgpu_initFromDevice.ts 258.40 kB ($${\color{green}-3.4\%}$$)
tgpu_resolve.ts 164.61 kB ($${\color{green}-38.4\%}$$)
tgpu_resolveWithContext.ts 164.54 kB ($${\color{green}-38.5\%}$$)
tgpu_bindGroupLayout.ts 68.97 kB ($${\color{green}-74.2\%}$$)
tgpu_mutableAccessor.ts 65.97 kB ($${\color{green}-75.3\%}$$)
tgpu_accessor.ts 65.96 kB ($${\color{green}-75.3\%}$$)
tgpu_privateVar.ts 65.31 kB ($${\color{green}-75.6\%}$$)
tgpu_workgroupVar.ts 65.30 kB ($${\color{green}-75.6\%}$$)
tgpu_const.ts 64.55 kB ($${\color{green}-75.9\%}$$)
tgpu_fn.ts 38.14 kB ($${\color{green}-85.7\%}$$)
tgpu_fragmentFn.ts 38.14 kB ($${\color{green}-85.7\%}$$)
tgpu_vertexFn.ts 37.96 kB ($${\color{green}-85.8\%}$$)
tgpu_computeFn.ts 37.66 kB ($${\color{green}-85.9\%}$$)
tgpu_vertexLayout.ts 26.79 kB ($${\color{green}-90.0\%}$$)
tgpu_comptime.ts 14.48 kB ($${\color{green}-94.6\%}$$)
tgpu_unroll.ts 1.66 kB ($${\color{green}-99.4\%}$$)
tgpu_slot.ts 1.54 kB ($${\color{green}-99.4\%}$$)
tgpu_lazy.ts 1.19 kB ($${\color{green}-99.6\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

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, 2.01, 4.27, 6.68, 8.22, 11.70, 23.29, 26.62]
  line [0.99, 2.04, 4.65, 7.18, 7.67, 13.53, 23.16, 29.12]
  line [1.02, 2.07, 4.23, 6.98, 8.36, 12.44, 23.14, 24.78]
Loading
---
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.33, 0.57, 0.73, 0.86, 1.18, 1.23, 1.43, 1.71]
  line [0.36, 0.53, 0.77, 0.86, 1.17, 1.18, 1.44, 1.60]
  line [0.32, 0.53, 0.72, 0.87, 1.17, 1.25, 1.51, 1.69]
Loading
---
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 [1.10, 2.54, 4.78, 8.43, 13.46, 27.07, 57.56, 117.06]
  line [1.02, 2.30, 3.76, 6.84, 13.63, 27.12, 58.36, 118.00]
  line [0.99, 2.13, 4.54, 6.99, 13.55, 29.36, 59.75, 121.94]
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant