Huge untreeshakable size increase due to `undici`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
@actions/http-client and all the packages like @actions/core are now shipping huge amounts of more JavaScript due to the inclusion of undici in a way that is not tree-shakable. Importing any simple function from @actions/core results in the bloat.
This has happened in the recent versions only. It seems the way undici is used results
To Reproduce
Bundle @actions/http-client using a bundler like Parcel
Expected behavior
Make the dependencies tree-shakable and lazy lodable via dynamic imports
Screenshots
Here's the bundling result in setup-cpp:
After updating the version (625 KB minified). Notice all the undici addition:
dist/legacy/setup-cpp.js 625.86 KB 1.23s
├── Code from unknown sourcefiles 84.02 KB 0ms
├── node_modules/undici/lib/llhttp/llhttp-wasm.js 72.23 KB 119ms
├── node_modules/undici/lib/llhttp/llhttp_simd-wasm.js 72.21 KB 119ms
├── node_modules/undici/lib/client.js 25.49 KB 141ms
├── node_modules/@actions/tool-cache/node_modules/semver/semver.js 18.09 KB 149ms
├── node_modules/undici/lib/fetch/index.js 16.29 KB 140ms
├── node_modules/undici/lib/fetch/request.js 9.18 KB 127ms
├── node_modules/@actions/http-client/src/index.ts 9.09 KB 0ms
├── node_modules/undici/lib/fetch/util.js 7.78 KB 114ms
└── node_modules/undici/lib/cache/cache.js 7.2 KB 105ms
└── + 355 more assets
Before updating (237 KB minified)
dist/legacy/setup-cpp.js 237.83 KB 841ms
Related to #1560
https://github.com/actions/toolkit/pull/1561
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by bundling @actions/http-client with Parcel and compare the reported output before and after the recent versions. Inspect how @actions/http-client and packages such as @actions/core include undici, using the setup-cpp bundle as the size reference. Done means dependencies are tree-shakable and lazy-loaded, with the bundle no longer including the reported undici bulk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100