Skip to content

fix(vite): enable virtualBundle behind an experimental flag - #3603

Merged
pi0 merged 3 commits into
nitrojs:v3from
hi-ogawa:10-02-fix_vite_enable_virtualbundleplugin_as_opt-in
Oct 2, 2025
Merged

pi0 merged 3 commits into
nitrojs:v3from
hi-ogawa:10-02-fix_vite_enable_virtualbundleplugin_as_opt-in

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Oct 2, 2025 •

Copy link
Copy Markdown
Contributor

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ 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 PR adds experimental.virtualBundle flag to make virtualBundlePlugin opt-in. See #3577 (comment) for more context.

In terms of optimization, I don't think file read/write would be a bottleneck in practice. It's nothing but a speculation, but I would imagine actual bundler logic where processing modules would cost more.

The flag is tested in playground and below is the output. I added 👈 to annotate the difference.

  • default
$ pnpm build

> [email protected] build /home/hiroshi/code/others/nitro/playground
> vite build

ℹ Using server.ts as the server entry.                                                   nitro 2:15:01 PM
ℹ Using app/server.tsx as SSR entry.                                                     nitro 2:15:01 PM
◐ Building Client...                                                                      nitro 2:15:01 PM
vite v7.1.7 building for production...
✓ 28 modules transformed.
.output/public/assets/nitro-DF0LpONz.png   54.51 kB
.output/public/assets/App-rqxwfrMX.js       1.82 kB │ gzip:  0.94 kB
.output/public/assets/index-LGjrhyKI.js     8.59 kB │ gzip:  3.22 kB
.output/public/assets/client-1KOwG8Aa.js  179.11 kB │ gzip: 56.64 kB
✓ built in 464ms
◐ Building SSR...                                                                         nitro 2:15:02 PM
vite v7.1.7 building SSR bundle for production...
✓ 39 modules transformed.
.nitro/vite/services/ssr/server.js  1,198.70 kB  👈
✓ built in 566ms  👈
◐ Building Nitro Server (preset: node-server, compatibility date: 2025-10-02)             nitro 2:15:02 PM
✔ Generated public .output/public                                                        nitro 2:15:02 PM
vite v7.1.7 building SSR bundle for production...
✓ 74 modules transformed.
.output/server/chunks/routes/route.get.mjs    0.13 kB
.output/server/index.mjs                    118.32 kB
.output/server/chunks/build/server.mjs      463.44 kB
✓ built in 1.07s 👈
✔ You can preview this build using node .output/server/index.mjs                         nitro 2:15:03 PM
  • with experimental.virtualBundle
$ pnpm build

> [email protected] build /home/hiroshi/code/others/nitro/playground
> vite build

ℹ Using server.ts as the server entry.                                                   nitro 2:15:35 PM
ℹ Using app/server.tsx as SSR entry.                                                     nitro 2:15:35 PM
◐ Building Client...                                                                      nitro 2:15:35 PM
vite v7.1.7 building for production...
✓ 28 modules transformed.
.output/public/assets/nitro-DF0LpONz.png   54.51 kB
.output/public/assets/App-rqxwfrMX.js       1.82 kB │ gzip:  0.94 kB
.output/public/assets/index-LGjrhyKI.js     8.59 kB │ gzip:  3.22 kB
.output/public/assets/client-1KOwG8Aa.js  179.11 kB │ gzip: 56.64 kB
✓ built in 469ms
◐ Building SSR...                                                                         nitro 2:15:35 PM
vite v7.1.7 building SSR bundle for production...
✓ 39 modules transformed.
✓ built in 550ms  👈
◐ Building Nitro Server (preset: node-server, compatibility date: 2025-10-02)             nitro 2:15:36 PM
✔ Generated public .output/public                                                        nitro 2:15:36 PM
vite v7.1.7 building SSR bundle for production...
✓ 74 modules transformed.
.output/server/chunks/routes/route.get.mjs    0.13 kB
.output/server/index.mjs                    118.31 kB
.output/server/chunks/_/server.mjs          463.44 kB
✓ built in 1.00s 👈
✔ You can preview this build using node .output/server/index.mjs                         nitro 2:15:37 PM

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel

vercel Bot commented Oct 2, 2025

Copy link
Copy Markdown

@hi-ogawa is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@hi-ogawa
hi-ogawa marked this pull request as ready for review October 2, 2025 05:19
@hi-ogawa
hi-ogawa requested a review from pi0 as a code owner October 2, 2025 05:19
@pi0 pi0 changed the title fix(vite): enable virtualBundlePlugin as opt-in fix(vite): enablevirtualBundle behind experimental flag Oct 2, 2025
@pi0 pi0 changed the title fix(vite): enablevirtualBundle behind experimental flag fix(vite): enable virtualBundle behind an experimental flag Oct 2, 2025
@pi0
pi0 merged commit 9ca9834 into nitrojs:v3 Oct 2, 2025
pi0 added a commit that referenced this pull request Oct 2, 2025
@hi-ogawa
hi-ogawa deleted the 10-02-fix_vite_enable_virtualbundleplugin_as_opt-in branch October 2, 2025 06:56
@hi-ogawa

hi-ogawa commented Oct 2, 2025

Copy link
Copy Markdown
Contributor Author

Thanks 🙏

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.

[vite] build fails with relative import to emitFile({ type: 'asset' })

2 participants