Skip to content

Impr(unplugin-typegpu): Support for early pruning in Babel plugin - #3295

Open
cieplypolar wants to merge 2 commits into
feat/re-obffrom
impr/early-prune-babel
Open

cieplypolar wants to merge 2 commits into
feat/re-obffrom
impr/early-prune-babel

Conversation

@cieplypolar

Copy link
Copy Markdown
Collaborator

No description provided.

@cieplypolar
cieplypolar added this pull request to stack #3292 October 30, 2026 14:10
Copilot AI balanced review requested due to automatic review settings October 30, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Oct 30, 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/tgpu-gen@329468e89a4a83f862d9c347403eec6b6c6f749a
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@329468e89a4a83f862d9c347403eec6b6c6f749a
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@329468e89a4a83f862d9c347403eec6b6c6f749a
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@329468e89a4a83f862d9c347403eec6b6c6f749a
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@329468e89a4a83f862d9c347403eec6b6c6f749a
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@329468e89a4a83f862d9c347403eec6b6c6f749a

benchmark
view benchmark

commit
view commit

@cieplypolar
cieplypolar force-pushed the impr/early-prune-babel branch from 4ee0d92 to ffadf58 Compare October 30, 2026 14:12
@github-actions

github-actions Bot commented Oct 30, 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 [1.08, 2.22, 5.28, 7.49, 8.61, 16.59, 30.09, 29.25]
  line [1.12, 2.27, 4.79, 7.20, 8.86, 13.20, 29.03, 27.37]
  line [1.08, 2.29, 4.32, 7.57, 8.54, 12.10, 28.50, 28.47]
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.34, 0.58, 0.81, 0.98, 1.40, 1.41, 1.67, 1.82]
  line [0.37, 0.61, 0.80, 0.97, 1.27, 1.37, 1.64, 1.81]
  line [0.33, 0.54, 0.78, 0.91, 1.25, 1.29, 1.55, 1.75]
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 [0.98, 2.43, 4.35, 8.74, 15.51, 30.26, 63.12, 130.13]
  line [0.83, 2.34, 4.51, 8.23, 14.76, 29.34, 64.70, 125.70]
  line [0.93, 2.32, 4.08, 7.59, 15.59, 28.24, 60.63, 122.66]
Loading

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

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

🟢 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.

@cieplypolar cieplypolar changed the title Impr(unplugin-typegpu): Support for early pruning in babel plugin Impr(unplugin-typegpu): Support for early pruning in Babel plugin Oct 30, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — read the full diff (4 files, +95/-16), ran the affected unplugin-typegpu tests, test:types, oxlint and oxfmt, and checked the surrounding common.ts / bun.ts / node.ts / factory.ts early-prune paths.

  • src/babel.ts early pruning — imports getEarlyPruneRegex and, in the Program visitor after the include filter, reads path.hub.getCode() and returns before path.traverse when state.opts.earlyPruning is truthy and no keyword regex matches; state.opts is merged with defaultOptions in pre, so earlyPruning defaults to true, matching the other entry points.
  • test/early-pruning.test.ts — new coverage: earlyPruning: false names a marker-less file, true returns the source unchanged, and each of typegpu/tgpu/'use gpu'/"use gpu" triggers processing.
  • test/obfuscation.test.ts — the metadata-only prune cases are split into [BABEL]/[ROLLUP] variants, with the prune case asserting common.functionVisitor is never read via vi.spyOn(..., 'get').
  • test/auto-naming.test.ts — adds earlyPruning: false to the marker-less "works with properties" Babel case, mirroring the existing rollup case.

Verification: 83/83 tests pass across the three touched test files, test:types is clean, and oxlint/oxfmt --check report no issues.

One thing worth keeping in mind (not a blocker): the Babel plugin now prunes by default, so marker-less files that rely on forceTgpuAlias (or otherwise omit the literal keywords) are no longer transformed unless earlyPruning: false is set — the same tradeoff the other entry points already document. The Options docblock covers this generically.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the branch was rebased from 4ee0d92 to ffadf588 with no content change (all four per-file diff blob hashes are byte-identical to the prior review), so there is no new delta to cover. The initial review stands: the Babel Program-visitor early prune, the new early-pruning test file, and the split [BABEL]/[ROLLUP] obfuscation cases are all correct, and the affected tests, test:types, oxlint and oxfmt pass.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

This branch has not been deployed

No deployments
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.

2 participants