Skip to content

perf: bundle vitest's own dependencies - #10685

Merged
sheremet-va merged 4 commits into
mainfrom
perf/improve-loading-perf
Jul 24, 2026
Merged

sheremet-va merged 4 commits into
mainfrom
perf/improve-loading-perf

Conversation

@sheremet-va

@sheremet-va sheremet-va commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Bundles vitest's own dependencies into its dist to reduce the boot time by cutting the external module resolutions Node performs when loading the worker bundle:

metric main branch Δ
worker boot import (cold, min) 28.8 ms 21.3 ms −26%
wall — forks isolate:true (min) 1029 ms 937 ms −9%
wall — forks isolate:false 382 ms 384 ms ~0 (amortized)
worker boot modules loaded 61 45 −26%
— node: builtins 14 10 −4
— vitest dist chunks 23 28 +5
— external npm resolves 7 2 −71%
boot graph (static closure) 605 KB / 23 chunks 759 KB / 28 chunks +154 KB / +5
dist size 2215 KB 2557 KB +342 KB

Details:

  • tinyrainbow is pinned to a single shared chunk: its default export is a mutable color object whose formatters are toggled at runtime, so inlining it into several chunks would give each chunk its own copy and break runtime color toggling. It is re-exported as disableDefaultColors from vitest/node so programmatic consumers (e.g. our test suite) can disable colors on the instance Vitest actually renders with.
  • NativeModuleRunner is imported lazily so local-pkg stays out of the default worker startup graph; only the viteModuleRunner: false path needs it.

Note

This PR was previously stacked and also carried an isolate-hint diagnostic and the browser optimizeDeps pre-bundling. The stack was split into independent feature PRs: the isolate hint now ships as part of experimental.diagnostics in #10710, and the browser pre-bundling moved to #10713.

TODO

  • Move deps to devDeps

@netlify

netlify Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit ad4b124
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a61fe198000b30007e8abb4
😎 Deploy Preview https://deploy-preview-10685--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sheremet-va
sheremet-va force-pushed the perf/improve-loading-perf branch from ba33fed to 2ca824b Compare July 3, 2026 14:07
@sheremet-va
sheremet-va marked this pull request as ready for review July 3, 2026 16:32
@sheremet-va
sheremet-va marked this pull request as draft July 3, 2026 16:32
@sheremet-va
sheremet-va marked this pull request as ready for review July 4, 2026 14:06
@sheremet-va
sheremet-va force-pushed the perf/improve-loading-perf branch from e2513ed to 053dce5 Compare July 4, 2026 14:23
Comment thread packages/vitest/src/node/core.ts Resolved
Comment thread packages/vitest/src/node/core.ts Resolved
Reduces worker boot time by cutting the external module resolutions Node
performs when loading the worker bundle. tinyrainbow is pinned to a single
shared chunk (its default export is a mutable color object toggled at
runtime) and re-exported as disableDefaultColors from vitest/node so
programmatic consumers can disable colors on the instance Vitest renders
with. NativeModuleRunner is imported lazily to keep local-pkg out of the
default worker startup graph.
@sheremet-va
sheremet-va force-pushed the perf/improve-loading-perf branch from c5f2e54 to 2396184 Compare July 7, 2026 10:23
@sheremet-va sheremet-va changed the title perf: bundle vitest's own dependencies, print a suggestion to disable isolation perf: bundle vitest's own dependencies Jul 7, 2026
Comment thread packages/vitest/rollup.config.js Resolved
AriPerkkio
AriPerkkio previously approved these changes Jul 23, 2026
@sheremet-va
sheremet-va force-pushed the perf/improve-loading-perf branch from ad4b124 to 2545356 Compare July 23, 2026 11:52
@@ -0,0 +1 @@
export * from './dist/display.js'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are required for the dts-bundle plugin, it doesn't seem to support export conditions 👀

@sheremet-va
sheremet-va requested a review from AriPerkkio July 23, 2026 12:33
@sheremet-va
sheremet-va merged commit c050842 into main Jul 24, 2026
65 of 69 checks passed
@sheremet-va
sheremet-va deleted the perf/improve-loading-perf branch July 24, 2026 07:45
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants