Skip to content

feat(@typegpu/cli): Resolve template package versions at build time - #3298

Open
iwoplaza wants to merge 1 commit into
mainfrom
feat/cli-template-versions
Open

iwoplaza wants to merge 1 commit into
mainfrom
feat/cli-template-versions

Conversation

@iwoplaza

Copy link
Copy Markdown
Collaborator

Templates now use workspace:^ for our packages instead of hard-coded versions. When scaffolding, the CLI replaces it with ^<version>, using the package versions from the repo at the time the CLI was built. Add-ons use the same versions.

This way templates can rely on any API released alongside the CLI, and the versions can't drift apart.

@github-actions

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@da45c5994de69765f642136a22f58ad48700da93
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@da45c5994de69765f642136a22f58ad48700da93
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@da45c5994de69765f642136a22f58ad48700da93
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@da45c5994de69765f642136a22f58ad48700da93
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@da45c5994de69765f642136a22f58ad48700da93

benchmark
view benchmark

commit
view commit

@github-actions

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.

@github-actions

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.06, 2.13, 4.48, 6.88, 8.40, 13.47, 27.29, 26.12]
  line [1.12, 2.17, 4.71, 7.04, 8.72, 15.12, 28.52, 29.62]
  line [0.93, 2.04, 4.48, 7.04, 8.93, 12.36, 26.54, 25.15]
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.28, 0.51, 0.71, 0.87, 1.13, 1.21, 1.48, 1.65]
  line [0.36, 0.54, 0.72, 0.89, 1.28, 1.30, 1.57, 1.76]
  line [0.32, 0.49, 0.74, 0.90, 1.16, 1.29, 1.43, 1.58]
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.97, 2.02, 4.45, 7.76, 13.73, 27.65, 59.07, 120.31]
  line [1.00, 2.26, 4.74, 7.78, 13.99, 28.87, 62.26, 127.38]
  line [0.94, 2.41, 4.22, 7.36, 13.55, 27.94, 60.25, 119.99]
Loading

@iwoplaza
iwoplaza marked this pull request as ready for review October 30, 2026 15:51
@iwoplaza
iwoplaza requested review from aleksanderkatan, cieplypolar, reczkok and vende11s and a balanced review from Copilot October 30, 2026 15:51

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

No active review issues block the change aligning scaffolded projects and add-ons with build-time package versions.

No open issues 🎉

What changed in this PR

This PR ties TypeGPU dependency versions in scaffolded projects and add-ons to the package versions captured when the CLI is built, replacing manually maintained version ranges.

Changes:

  • Embed public workspace package versions into the CLI at build time.
  • Replace hard-coded TypeGPU versions in six templates with workspace:^ placeholders.
  • Resolve placeholders during scaffolding, reject unresolved versions, and use the same version lookup for add-ons.
File Description
packages/​typegpu-cli/​tsdown.config.ts Collect and inject public workspace package versions.
packages/​typegpu-cli/​templates/​template-waku-bare/​_package.json Use workspace placeholders for Waku template dependencies.
packages/​typegpu-cli/​templates/​template-vite-react/​_package.json Use workspace placeholders for Vite React template dependencies.
packages/​typegpu-cli/​templates/​template-vite-complex/​_package.json Use workspace placeholders for the complex Vite template.
packages/​typegpu-cli/​templates/​template-vite-bare/​_package.json Use workspace placeholders for the bare Vite template.
packages/​typegpu-cli/​templates/​template-nextjs-bare/​_package.json Use workspace placeholders for Next.js template dependencies.
packages/​typegpu-cli/​templates/​template-expo-bare/​_package.json Use workspace placeholders for Expo template dependencies.
packages/​typegpu-cli/​src/​utils/​pkg.ts Add package-specific version lookup and placeholder resolution.
packages/​typegpu-cli/​src/​utils/​inputs.ts Resolve selected add-on versions individually.
packages/​typegpu-cli/​src/​utils/​files.ts Resolve template versions and validate them during scaffolding.
packages/​typegpu-cli/​src/​steps/​typegpu.ts Use captured package versions when installing TypeGPU packages.

Review effort: Balanced

@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 — verified the template version resolution end to end: built the CLI, scaffolded templates with and without add-ons, and typechecked/linted the changed sources.

  • Build-time version map — tsdown.config.ts scans packages/*/package.json for non-private packages and injects __WORKSPACE_PACKAGE_VERSIONS__ via define; the identifier is inlined into the bundle (confirmed in dist/index.js).
  • Placeholder resolution — resolveWorkspaceVersions rewrites workspace:^ in template deps to ^<version> and returns unresolved names, which scaffoldProject turns into an [INTERNAL] failure.
  • Add-on versions — getVersionRange replaces the removed VERSION constant in the three call sites; every name it receives is pre-validated against typegpuPkgs by parseAddons, so the new throw is effectively unreachable.
  • Templates — all six templates now use workspace:^ for TypeGPU packages; no hard-coded TypeGPU versions remain.

The release paths (scripts/publish.ts, scripts/publish-pkg-pr.ts) build via prepublishOnly at publish time, so the baked versions track the versions already committed to source — the "can't drift apart" goal holds.

Pullfrog  | 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