Skip to content

perf(dev): improve cold start of dev server - #902

Merged
danielroe merged 43 commits into
mainfrom
refactor/dev
Jun 7, 2025
Merged

perf(dev): improve cold start of dev server#902
danielroe merged 43 commits into
mainfrom
refactor/dev

Conversation

@danielroe

@danielroedanielroe commented Jun 4, 2025

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

this is a set of changes aimed to improve the cold start of the dev server, including using a standalone entrypoint file instead of nuxi _dev, using exsolve for module resolution, starting fork 'earlier' in the process, and deduplicating some code for more consistency

in addition, we now start for the first time in no-fork mode, while creating a pre-warmed fork ready to go if we need to hard-restart.

Important

this does not scale linearly with your project size - the improvements here are shaving off time to the fixed time that nuxt dev takes to initialise

@github-actions

github-actionsBot commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

Bundle Stats — create-nuxt size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files countTotal bundle size% Changed
495.94 MB → 5.94 MB (+1.82 kB)+0.03%
Changeset
FileΔSize
home/runner/work/cli/cli/packages/nuxi/src/dev/utils.ts🆕 +8.65 kB0 B → 8.65 kB
home/runner/work/cli/cli/packages/nuxi/src/dev/index.ts🆕 +2.66 kB0 B → 2.66 kB
home/runner/work/cli/cli/packages/nuxi/src/dev/error.ts🆕 +306 B0 B → 306 B
home/runner/work/cli/cli/packages/nuxi/src/commands/dev.ts📈 +471 B (+4.75%)9.67 kB → 10.13 kB
home/runner/work/cli/cli/packages/nuxi/src/run.ts📈 +9 B (+1.53%)590 B → 599 B
home/runner/work/cli/cli/packages/nuxi/src/utils/kit.ts📈 +11 B (+1.03%)1.04 kB → 1.05 kB
node_modules/listhen/dist/index.mjs📈 +22 B (+0.07%)32.44 kB → 32.46 kB
node_modules/jiti/dist/babel.cjs📉 -12 B (-0.00%)1.82 MB → 1.82 MB
home/runner/work/cli/cli/packages/nuxi/src/commands/info.ts📉 -6 B (-0.13%)4.39 kB → 4.38 kB
home/runner/work/cli/cli/packages/nuxi/src/commands/build.ts📉 -6 B (-0.30%)1.97 kB → 1.96 kB
home/runner/work/cli/cli/packages/nuxi/src/utils/banner.ts📉 -12 B (-1.49%)804 B → 792 B
home/runner/work/cli/cli/packages/nuxi/src/commands/typecheck.ts📉 -30 B (-1.62%)1.81 kB → 1.78 kB
home/runner/work/cli/cli/packages/nuxi/src/commands/dev-child.ts📉 -1.53 kB (-65.94%)2.33 kB → 811 B
home/runner/work/cli/cli/packages/nuxi/src/utils/dev.ts🔥 -8.4 kB (-100%)8.4 kB → 0 B
home/runner/work/cli/cli/packages/nuxi/src/utils/error.ts🔥 -306 B (-100%)306 B → 0 B
View detailed bundle breakdown

Added

AssetFile Size% Changed
shared/create-nuxt.CmOg7Vl1.mjs0 B → 2.02 MB (+2.02 MB)-
shared/create-nuxt.D0mUB528.mjs0 B → 1.17 MB (+1.17 MB)-
shared/create-nuxt.fN2faugk.mjs0 B → 961.97 kB (+961.97 kB)-
shared/create-nuxt.6kuGHDrB.mjs0 B → 108.13 kB (+108.13 kB)-
shared/create-nuxt.CD5NvjJS.mjs0 B → 18.91 kB (+18.91 kB)-
shared/create-nuxt.CaixlH92.mjs0 B → 15.27 kB (+15.27 kB)-
shared/create-nuxt.CMK7JS1B.mjs0 B → 4.07 kB (+4.07 kB)-
shared/create-nuxt.Bg4tbtP5.mjs0 B → 3.9 kB (+3.9 kB)-
shared/create-nuxt.Dj9Jbhqm.mjs0 B → 1.05 kB (+1.05 kB)-
shared/create-nuxt.DIZsfD_C.mjs0 B → 836 B (+836 B)-
shared/create-nuxt.CpXrnfbs.mjs0 B → 792 B (+792 B)-
shared/create-nuxt.D4ZhlYfX.mjs0 B → 715 B (+715 B)-
chunks/jiti.mjs0 B → 305 B (+305 B)-
shared/create-nuxt.QPeHbnX7.mjs0 B → 294 B (+294 B)-

Removed

AssetFile Size% Changed
shared/create-nuxt.1BTwlbMH.mjs2.02 MB → 0 B (-2.02 MB)-100%
shared/create-nuxt.KRfcAabz.mjs961.96 kB → 0 B (-961.96 kB)-100%
chunks/index9.mjs898.9 kB → 0 B (-898.9 kB)-100%
chunks/dev2.mjs252.14 kB → 0 B (-252.14 kB)-100%
shared/create-nuxt.GYyp52oB.mjs108.13 kB → 0 B (-108.13 kB)-100%
shared/create-nuxt.C9PGmh_y.mjs18.91 kB → 0 B (-18.91 kB)-100%
shared/create-nuxt.Dh7YQg9j.mjs15.27 kB → 0 B (-15.27 kB)-100%
shared/create-nuxt.BloYjiZ4.mjs4.07 kB → 0 B (-4.07 kB)-100%
shared/create-nuxt.DCTmUpvU.mjs3.9 kB → 0 B (-3.9 kB)-100%
chunks/kit.mjs1.34 kB → 0 B (-1.34 kB)-100%
shared/create-nuxt.Dn0TYcSC.mjs836 B → 0 B (-836 B)-100%
shared/create-nuxt.C__7_gXu.mjs804 B → 0 B (-804 B)-100%
shared/create-nuxt.CHDOs5mq.mjs715 B → 0 B (-715 B)-100%
shared/create-nuxt.CHZLvr-7.mjs294 B → 0 B (-294 B)-100%

Bigger

AssetFile Size% Changed
chunks/index8.mjs5.85 kB → 898.9 kB (+893.05 kB)+15259.14%
chunks/index3.mjs17.14 kB → 71.99 kB (+54.86 kB)+320.09%
chunks/dev.mjs9.67 kB → 27.27 kB (+17.6 kB)+181.89%
chunks/index5.mjs1.23 kB → 5.85 kB (+4.62 kB)+374.51%

Smaller

AssetFile Size% Changed
chunks/index2.mjs1.17 MB → 255.05 kB (-941.16 kB)-78.68%
chunks/index4.mjs71.99 kB → 1.23 kB (-70.76 kB)-98.29%
chunks/dev-child.mjs2.33 kB → 811 B (-1.53 kB)-65.94%
chunks/typecheck.mjs1.81 kB → 1.78 kB (-30 B)-1.62%
chunks/build.mjs1.97 kB → 1.96 kB (-6 B)-0.30%
chunks/info.mjs4.39 kB → 4.38 kB (-6 B)-0.13%

Unchanged

AssetFile Size% Changed
index.mjs1.07 kB0%
chunks/multipart-parser.mjs5.11 kB0%
chunks/multipart-parser2.mjs4.58 kB0%
chunks/add.mjs6.89 kB0%
chunks/analyze.mjs3.27 kB0%
chunks/cleanup.mjs471 B0%
chunks/devtools.mjs764 B0%
chunks/generate.mjs472 B0%
chunks/index.mjs274 B0%
chunks/prepare.mjs984 B0%
chunks/preview.mjs3.5 kB0%
chunks/test.mjs1.16 kB0%
chunks/upgrade.mjs6.28 kB0%
chunks/prompt.mjs42.91 kB0%
chunks/satisfies.mjs116 B0%
chunks/add2.mjs12.4 kB0%
chunks/search.mjs45.85 kB0%
chunks/xdg-open.mjs25.32 kB0%
chunks/node.mjs145.67 kB0%
chunks/index6.mjs6.25 kB0%
chunks/index7.mjs50.54 kB0%
shared/create-nuxt.BSm0_9Hr.mjs107 B0%
shared/create-nuxt.4t9faemh.mjs43.64 kB0%
shared/create-nuxt.BjhZEm2-.mjs1.75 kB0%
shared/create-nuxt.Vk1IrVtB.mjs26.96 kB0%

@github-actions

github-actionsBot commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

Bundle Stats — nuxt-cli size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files countTotal bundle size% Changed
30 → 3286.79 kB → 88.65 kB (+1.86 kB)+2.15%
Changeset
FileΔSize
home/runner/work/cli/cli/packages/nuxi/src/dev/utils.ts🆕 +8.64 kB0 B → 8.64 kB
home/runner/work/cli/cli/packages/nuxi/src/dev/index.ts🆕 +2.64 kB0 B → 2.64 kB
home/runner/work/cli/cli/packages/nuxi/src/dev/error.ts🆕 +306 B0 B → 306 B
home/runner/work/cli/cli/packages/nuxi/src/commands/dev.ts📈 +511 B (+5.18%)9.63 kB → 10.12 kB
home/runner/work/cli/cli/packages/nuxi/src/run.ts📈 +9 B (+1.54%)586 B → 595 B
src/run.ts📈 +9 B (+1.44%)625 B → 634 B
home/runner/work/cli/cli/packages/nuxi/src/utils/kit.ts📈 +11 B (+1.03%)1.04 kB → 1.05 kB
home/runner/work/cli/cli/packages/nuxi/src/commands/index.ts📈 +2 B (+0.17%)1.12 kB → 1.12 kB
src/dev/index.ts+0 B (0%)0 B → 0 B
home/runner/work/cli/cli/packages/nuxi/src/commands/info.ts📉 -6 B (-0.13%)4.39 kB → 4.39 kB
home/runner/work/cli/cli/packages/nuxi/src/commands/build.ts📉 -6 B (-0.30%)1.97 kB → 1.96 kB
home/runner/work/cli/cli/packages/nuxi/src/commands/module/index.ts📉 -1 B (-0.36%)274 B → 273 B
home/runner/work/cli/cli/packages/nuxi/src/utils/banner.ts📉 -12 B (-1.49%)804 B → 792 B
home/runner/work/cli/cli/packages/nuxi/src/commands/typecheck.ts📉 -30 B (-1.62%)1.81 kB → 1.78 kB
home/runner/work/cli/cli/packages/nuxi/src/commands/dev-child.ts📉 -1.53 kB (-65.84%)2.33 kB → 815 B
home/runner/work/cli/cli/packages/nuxi/src/utils/dev.ts🔥 -8.4 kB (-100%)8.4 kB → 0 B
home/runner/work/cli/cli/packages/nuxi/src/utils/error.ts🔥 -306 B (-100%)306 B → 0 B
View detailed bundle breakdown

Added

AssetFile Size% Changed
shared/cli.yHMpVeHl.mjs0 B → 5.42 kB (+5.42 kB)-
shared/cli.CXdkyDQW.mjs0 B → 1.79 kB (+1.79 kB)-
shared/cli.At9IMXtr.mjs0 B → 1.23 kB (+1.23 kB)-
shared/cli.BrKZotr9.mjs0 B → 1.05 kB (+1.05 kB)-
shared/cli.pLQ0oPGc.mjs0 B → 836 B (+836 B)-
shared/cli.Dvb-m6bf.mjs0 B → 792 B (+792 B)-
shared/cli.BEUGgaW4.mjs0 B → 294 B (+294 B)-
chunks/index2.mjs0 B → 273 B (+273 B)-
shared/cli.B9AmABr3.mjs0 B → 39 B (+39 B)-
dev/index.mjs0 B0%

Removed

AssetFile Size% Changed
chunks/dev2.mjs8.7 kB → 0 B (-8.7 kB)-100%
shared/cli.CyjRwZnH.mjs5.45 kB → 0 B (-5.45 kB)-100%
shared/cli.CkLtVfMJ.mjs1.78 kB → 0 B (-1.78 kB)-100%
shared/cli.CFGy0wx0.mjs1.23 kB → 0 B (-1.23 kB)-100%
shared/cli.DlcAx0De.mjs1.04 kB → 0 B (-1.04 kB)-100%
shared/cli.BI-F07wL.mjs836 B → 0 B (-836 B)-100%
shared/cli.CVvsnRpF.mjs804 B → 0 B (-804 B)-100%
shared/cli.wjLTNSBo.mjs294 B → 0 B (-294 B)-100%

Bigger

AssetFile Size% Changed
chunks/index.mjs274 B → 11.58 kB (+11.31 kB)+4228.47%
chunks/add.mjs6.89 kB → 10.48 kB (+3.59 kB)+52.03%
chunks/dev.mjs9.63 kB → 10.12 kB (+511 B)+5.18%
index.mjs200 B → 236 B (+36 B)+18.00%

Smaller

AssetFile Size% Changed
chunks/add2.mjs10.48 kB → 6.89 kB (-3.59 kB)-34.22%
chunks/dev-child.mjs2.33 kB → 815 B (-1.53 kB)-65.84%
chunks/typecheck.mjs1.81 kB → 1.78 kB (-30 B)-1.62%
chunks/build.mjs1.97 kB → 1.96 kB (-6 B)-0.30%
chunks/info.mjs4.39 kB → 4.39 kB (-6 B)-0.13%

Unchanged

AssetFile Size% Changed
chunks/analyze.mjs3.27 kB0%
chunks/cleanup.mjs471 B0%
chunks/devtools.mjs763 B0%
chunks/generate.mjs472 B0%
chunks/init.mjs8.1 kB0%
chunks/prepare.mjs984 B0%
chunks/preview.mjs3.5 kB0%
chunks/test.mjs1.16 kB0%
chunks/upgrade.mjs6.28 kB0%
chunks/search.mjs2.96 kB0%
shared/cli.BSm0_9Hr.mjs107 B0%
shared/cli.P0cplz3M.mjs78 B0%
shared/cli.C935N1ss.mjs687 B0%

@github-actions

github-actionsBot commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

Bundle Stats — nuxi size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files countTotal bundle size% Changed
55 → 585.51 MB → 5.51 MB (+2.77 kB)+0.05%
Changeset
FileΔSize
src/dev/utils.ts🆕 +8.66 kB0 B → 8.66 kB
src/dev/index.ts🆕 +2.66 kB0 B → 2.66 kB
src/dev/error.ts🆕 +306 B0 B → 306 B
src/commands/dev.ts📈 +471 B (+4.75%)9.67 kB → 10.13 kB
src/run.ts📈 +9 B (+1.44%)627 B → 636 B
src/utils/kit.ts📈 +11 B (+1.03%)1.04 kB → 1.05 kB
node_modules/listhen/dist/index.mjs📈 +32 B (+0.13%)23.98 kB → 24.02 kB
node_modules/jiti/dist/babel.cjs📉 -12 B (-0.00%)1.82 MB → 1.82 MB
node_modules/pkg-types/dist/index.mjs📉 -2 B (-0.08%)2.59 kB → 2.58 kB
src/commands/info.ts📉 -6 B (-0.13%)4.39 kB → 4.38 kB
src/commands/build.ts📉 -6 B (-0.30%)1.97 kB → 1.96 kB
src/utils/banner.ts📉 -12 B (-1.49%)804 B → 792 B
src/commands/typecheck.ts📉 -30 B (-1.62%)1.81 kB → 1.78 kB
src/commands/dev-child.ts📉 -1.56 kB (-67.24%)2.33 kB → 780 B
src/utils/dev.ts🔥 -8.4 kB (-100%)8.4 kB → 0 B
src/utils/error.ts🔥 -306 B (-100%)306 B → 0 B
View detailed bundle breakdown

Added

AssetFile Size% Changed
shared/nuxi.DYaJf8O3.mjs0 B → 2.02 MB (+2.02 MB)-
shared/nuxi.Db0skjkt.mjs0 B → 915.23 kB (+915.23 kB)-
shared/nuxi.Dh2ZdpAd.mjs0 B → 57.22 kB (+57.22 kB)-
shared/nuxi.Cgt_fOtO.mjs0 B → 42.33 kB (+42.33 kB)-
shared/nuxi.DZwsQJ6X.mjs0 B → 25.34 kB (+25.34 kB)-
shared/nuxi.BLoQ2NAr.mjs0 B → 19.17 kB (+19.17 kB)-
shared/nuxi.B6QVXBke.mjs0 B → 15.27 kB (+15.27 kB)-
shared/nuxi.DwmIiB7Y.mjs0 B → 12.8 kB (+12.8 kB)-
shared/nuxi.DtQ0anGB.mjs0 B → 4.07 kB (+4.07 kB)-
shared/nuxi.Cm5apyPX.mjs0 B → 2.57 kB (+2.57 kB)-
shared/nuxi.PB-niEBz.mjs0 B → 1.05 kB (+1.05 kB)-
dev/index.mjs0 B → 961 B (+961 B)-
shared/nuxi.DMyZmNH9.mjs0 B → 836 B (+836 B)-
shared/nuxi.DHJiz6C8.mjs0 B → 792 B (+792 B)-
shared/nuxi.Bys_J6wa.mjs0 B → 715 B (+715 B)-
chunks/jiti.mjs0 B → 305 B (+305 B)-
shared/nuxi.BtDT0y5R.mjs0 B → 294 B (+294 B)-

Removed

AssetFile Size% Changed
shared/nuxi.C4l48OVX.mjs2.02 MB → 0 B (-2.02 MB)-100%
chunks/index7.mjs898.9 kB → 0 B (-898.9 kB)-100%
chunks/dev2.mjs252.14 kB → 0 B (-252.14 kB)-100%
shared/nuxi.CkbmDTVf.mjs76.37 kB → 0 B (-76.37 kB)-100%
shared/nuxi.CDtHTpB4.mjs55.13 kB → 0 B (-55.13 kB)-100%
shared/nuxi.DGlTnfJO.mjs25.34 kB → 0 B (-25.34 kB)-100%
shared/nuxi.CzTDygJD.mjs15.27 kB → 0 B (-15.27 kB)-100%
shared/nuxi.DEraSSNZ.mjs4.07 kB → 0 B (-4.07 kB)-100%
shared/nuxi.DCZEnUMf.mjs2.57 kB → 0 B (-2.57 kB)-100%
shared/nuxi.BxIDvNqq.mjs1.34 kB → 0 B (-1.34 kB)-100%
shared/nuxi.4mU2hXBN.mjs836 B → 0 B (-836 B)-100%
shared/nuxi.Dj-nnhaV.mjs804 B → 0 B (-804 B)-100%
shared/nuxi.BfF9qfft.mjs715 B → 0 B (-715 B)-100%
shared/nuxi.CU8S2ItD.mjs294 B → 0 B (-294 B)-100%

Bigger

AssetFile Size% Changed
chunks/index6.mjs5.85 kB → 898.9 kB (+893.05 kB)+15259.14%
chunks/index3.mjs17.14 kB → 71.99 kB (+54.86 kB)+320.09%
chunks/dev.mjs9.67 kB → 27.27 kB (+17.6 kB)+181.89%
chunks/index5.mjs1.23 kB → 5.85 kB (+4.62 kB)+374.51%
index.mjs210 B → 247 B (+37 B)+17.62%

Smaller

AssetFile Size% Changed
chunks/index2.mjs915.2 kB → 255.05 kB (-660.15 kB)-72.13%
chunks/index4.mjs71.99 kB → 1.23 kB (-70.76 kB)-98.29%
chunks/dev-child.mjs2.33 kB → 780 B (-1.56 kB)-67.24%
chunks/typecheck.mjs1.81 kB → 1.78 kB (-30 B)-1.62%
chunks/build.mjs1.97 kB → 1.96 kB (-6 B)-0.30%
chunks/info.mjs4.39 kB → 4.38 kB (-6 B)-0.13%

Unchanged

AssetFile Size% Changed
chunks/prompt.mjs42.91 kB0%
chunks/add.mjs6.89 kB0%
chunks/analyze.mjs3.27 kB0%
chunks/cleanup.mjs471 B0%
chunks/devtools.mjs764 B0%
chunks/generate.mjs472 B0%
chunks/init.mjs664.23 kB0%
chunks/index.mjs274 B0%
chunks/prepare.mjs984 B0%
chunks/preview.mjs3.5 kB0%
chunks/test.mjs1.16 kB0%
chunks/upgrade.mjs6.28 kB0%
chunks/satisfies.mjs116 B0%
chunks/main.mjs15.3 kB0%
chunks/multipart-parser.mjs5.11 kB0%
chunks/add2.mjs12.4 kB0%
chunks/search.mjs45.85 kB0%
chunks/xdg-open.mjs25.32 kB0%
chunks/node.mjs145.67 kB0%
chunks/multipart-parser2.mjs4.58 kB0%
shared/nuxi.CTyTlDmo.mjs18.91 kB0%
shared/nuxi.D2_bzAv0.mjs1.54 kB0%
shared/nuxi.BSm0_9Hr.mjs107 B0%
shared/nuxi.D5KtpA0t.mjs984 B0%
shared/nuxi.BjhZEm2-.mjs1.75 kB0%
shared/nuxi.DU9QXUOf.mjs26.96 kB0%
shared/nuxi.BzZJv2UC.mjs123.67 kB0%
shared/nuxi.QWnQy_ku.mjs5.75 kB0%
shared/nuxi.Do0aYBCO.mjs5.46 kB0%
shared/nuxi.4t9faemh.mjs43.64 kB0%

@pkg-pr-new

pkg-pr-newBot commented Jun 4, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/create-nuxt@902
npm i https://pkg.pr.new/nuxi@902
npm i https://pkg.pr.new/@nuxt/cli@902

commit: 47e713c

@codspeed-hq

codspeed-hqBot commented Jun 6, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #902 will improve performances by ×2.5

Comparing refactor/dev (47e713c) with main (59f83b1)

Summary

⚡ 1 improvements
✅ 1 untouched benchmarks

Benchmarks breakdown

BenchmarkBASEHEADChange
starts dev server with --no-fork927.7 ms366.3 ms×2.5

Comment threadpackages/nuxt-cli/test/bench/dev.bench.ts Outdated
Comment threadpackages/nuxt-cli/test/bench/dev.bench.ts Outdated
@danielroe
danielroe marked this pull request as ready for review June 7, 2025 21:50
@danielroe
danielroe merged commit 1943f84 into mainJun 7, 2025
@danielroe
danielroe deleted the refactor/dev branch June 7, 2025 21:50
@github-actionsgithub-actionsBot mentioned this pull request Jun 7, 2025
Sign up for freeto 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.

1 participant

@danielroe