Skip to content

Conversation

@piaccho
Copy link
Collaborator

@piaccho piaccho commented Oct 2, 2025

Changes

This PR introduces a test application for measuring and comparing the tree-shaking and bundling efficiency of different JS bundlers (tsdown, esbuild, webpack) for the typegpu package.


Closes #1747

@github-actions
Copy link

github-actions bot commented Oct 2, 2025

pkg.pr.new

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

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@a68faf33bd1a6f827684ec70348ba2c12a6fecd7
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@a68faf33bd1a6f827684ec70348ba2c12a6fecd7
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@a68faf33bd1a6f827684ec70348ba2c12a6fecd7

benchmark
view benchmark

commit
view commit

@piaccho
Copy link
Collaborator Author

piaccho commented Oct 2, 2025

Bundler efficiency report

example1.ts

import { f32, sizeOf } from 'typegpu/data';
console.log(sizeOf(f32));
Bundler Bundle Size (bytes)
tsdown 38756
esbuild 94104
webpack 39211

example2.ts

import * as d from 'typegpu/data';
console.log(d.sizeOf(d.f32));
Bundler Bundle Size (bytes)
tsdown 38756
esbuild 94104
webpack 39211

example3.ts

import tgpu from 'typegpu';
console.log(tgpu.resolve({ externals: {} }));
Bundler Bundle Size (bytes)
tsdown 246603
esbuild 247759
webpack 269912

@piaccho piaccho requested review from Copilot and iwoplaza October 2, 2025 12:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a test application for measuring and comparing the tree-shaking and bundling efficiency of different JavaScript bundlers (tsdown, esbuild, webpack) for the typegpu package as part of CI automation.

  • Adds a dedicated treeshake-test application with utilities for bundling and measuring output sizes
  • Creates three example TypeScript files to test different import patterns from the typegpu package
  • Implements a GitHub Actions workflow to run tree-shaking tests on pull requests

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/treeshake-test/utils.ts Core bundling utilities for esbuild, webpack, and tsdown with size measurement and markdown report generation
apps/treeshake-test/index.ts Main test runner that processes examples and generates results
apps/treeshake-test/package.json Package configuration with bundler dependencies
apps/treeshake-test/tsconfig.json TypeScript configuration for the test app
apps/treeshake-test/tsdown.config.ts Configuration for tsdown bundler
apps/treeshake-test/examples/*.ts Three test files demonstrating different import patterns
apps/treeshake-test/.gitignore Ignores build output and results
.github/workflows/treeshake-test.yml CI workflow for automated tree-shaking tests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

📊 Bundle Size Comparison

📈 Summary

  • 📈 Increased: 0 bundles

  • 📉 Decreased: 0 bundles

  • Unchanged: 0 bundles

  • Unknown: 24 bundles

📋 Bundle Size Comparison

Test tsdown webpack
dataImportEverything.ts 79.92 kB ($${\color{red}+321.9\%}$$) 85.21 kB ($${\color{red}+1.5\%}$$)
dataImportOneDirect.ts 40.28 kB ($${\color{green}-8.8\%}$$) 40.75 kB ($${\color{red}+28.5\%}$$)
dataImportOneStar.ts 40.28 kB ($${\color{red}+1740.6\%}$$) 40.75 kB ($${\color{green}-55.1\%}$$)
functionWithUseGpu.ts 268 B ($${\color{green}-99.2\%}$$) 276 B ($${\color{green}-99.2\%}$$)
functionWithoutUseGpu.ts 24 B ($${\color{green}-99.7\%}$$) 59 B ($${\color{green}-99.9\%}$$)
importEntireLibrary.ts 256.53 kB ($${\color{red}+378.5\%}$$) 283.53 kB ($${\color{red}+3335.6\%}$$)
importEntireLibraryUnused.ts 0 B ($${\color{green}-100.0\%}$$) 0 B ($${\color{green}-100.0\%}$$)
stdImportEverything.ts 113.09 kB ($${\color{red}+32.3\%}$$) 117.58 kB ($${\color{red}+30.2\%}$$)
stdImportOneDirect.ts 61.97 kB ($${\color{red}+45.1\%}$$) 62.92 kB ($${\color{red}+272.9\%}$$)
stdImportOneStar.ts 61.97 kB ($${\color{red}+59.4\%}$$) 62.92 kB ($${\color{green}-21.8\%}$$)
tgpuImportEverything.ts 237.54 kB ($${\color{red}+232.5\%}$$) 264.16 kB ($${\color{red}+281.2\%}$$)
tgpuImportOne.ts 237.55 kB ($${\color{red}+14841.2\%}$$) 264.17 kB ($${\color{red}+176.1\%}$$)

^percent values are randomized (to be reversed before merge)

@software-mansion software-mansion deleted a comment from github-actions bot Jan 8, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const targetSize = targetGrouped[test]?.[bundler];

output += ` | ${prettifySize(prSize)} ${
calculateTrendMessage(prSize, Math.random() * 100000)
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Hard-coded Math.random() is used instead of targetSize for the comparison. This will produce incorrect trend messages showing random changes rather than actual differences between PR and target branches.

Suggested change
calculateTrendMessage(prSize, Math.random() * 100000)
calculateTrendMessage(prSize, targetSize)

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

I will change this before merging, but for now I'll keep it for illustration purposes

@aleksanderkatan aleksanderkatan marked this pull request as ready for review January 9, 2026 13:18
Copy link
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

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

🌴🌴🌴🌴🌴🌴🌴🌴

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.

chore: Measure tree-shakeability in CI

4 participants