Skip to content

fix(unplugin-typegpu): Bun plugin should respect earlyPruning config - #3010

Open
iwoplaza wants to merge 1 commit into
mainfrom
fix/bun-early-pruning
Open

iwoplaza wants to merge 1 commit into
mainfrom
fix/bun-early-pruning

Conversation

@iwoplaza

@iwoplaza iwoplaza commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings September 9, 2026 14:07
@github-actions

github-actions Bot commented Sep 9, 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/typegpu@254e074d4f1447f932542be306a5721ee05c3951
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@254e074d4f1447f932542be306a5721ee05c3951
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@254e074d4f1447f932542be306a5721ee05c3951
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@254e074d4f1447f932542be306a5721ee05c3951

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Sep 9, 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.78, 1.52, 3.19, 4.64, 5.97, 9.10, 18.70, 18.19]
  line [0.73, 1.44, 3.17, 4.86, 5.54, 9.74, 18.43, 19.84]
  line [0.75, 1.56, 3.26, 5.39, 5.45, 7.98, 19.13, 19.43]
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.22, 0.40, 0.54, 0.63, 0.87, 0.88, 1.08, 1.27]
  line [0.23, 0.39, 0.50, 0.65, 0.91, 0.95, 1.08, 1.18]
  line [0.22, 0.40, 0.57, 0.63, 0.90, 0.95, 1.12, 1.24]
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.94, 2.13, 4.15, 6.07, 10.18, 19.81, 41.66, 84.53]
  line [0.77, 1.82, 3.14, 5.25, 8.98, 19.14, 43.06, 86.19]
  line [0.73, 1.89, 3.42, 5.40, 9.13, 20.63, 42.20, 85.46]
Loading

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

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

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
0 325 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.

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.

🟢 Approval recommended

The change is minimal, aligns Bun behavior with the intended option semantics, and includes targeted automated test coverage.

Pull request overview

This PR fixes the Bun integration of unplugin-typegpu so that its “early pruning” optimization is controlled by the earlyPruning option (matching the behavior of the shared unplugin factory), and adds a Bun-specific regression test to cover the option behavior.

Changes:

  • Gate Bun’s early-pruning short-circuit behind options.earlyPruning.
  • Add a Vitest suite verifying earlyPruning: false forces transformation, while true/undefined preserves original code when the prune regex doesn’t match.
File summaries
File Description
packages/unplugin-typegpu/src/bun.ts Makes Bun’s early-pruning return path conditional on options.earlyPruning.
packages/unplugin-typegpu/test/bun.test.ts Adds regression coverage for earlyPruning behavior across undefined, true, and false.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@iwoplaza
iwoplaza added this pull request to stack #3013 September 9, 2026 14:12

@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 — This run reviewed the full PR: a one-line change and its accompanying test.

  • Bun plugin honors earlyPruning (src/bun.ts:27) — the early-prune skip is now gated on options.earlyPruning, bringing the Bun plugin in line with the core unpluginFactory, which already applies the earlyPruneRegex code filter only when earlyPruning is enabled. The Bun plugin is the single framework that reimplements pruning manually in its onLoad handler, so this closes a real behavioral gap: with earlyPruning: false, files without tgpu/use gpu markers were previously left untransformed.
  • New regression test (test/bun.test.ts) — it.each([undefined, true, false]) stubs the Bun global, invokes the registered onLoad handler on a marker-free d.struct({...}) snippet, and asserts unchanged output for undefined/true while requiring auto-named output (__TYPEGPU_AUTONAME__, "myStruct") for false. Verified locally that this test fails (1/3) with the fix reverted and passes (3/3) with it, so the coverage is genuine. The undefined case also exercises the defu default (true) merge.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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