Skip to content

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Oct 18, 2025

🔗 Linked issue

I think this can be removed from each service build since final nitro environment has noExternal: true, which can take care bundling up dependencies. Currently it's causing a large intermediate build for each service, for example in Vue Router SSR demo nitrojs/vite-examples#5, the build log shows a following:

◐ Building [Client]                                                                                                                                                                                                      ...
...
✓ built in 416ms

◐ Building [SSR]                                                                                                                                                                                                         
...
...
.nitro/vite/services/ssr/assets/parser-DCdUCwrd.js                        15.00 kB
.nitro/vite/services/ssr/entry-server.js                               1,438.92 kB  👈👈 all dependencies are bundled at this stage
✓ built in 992ms 👈👈

◐ Building [Nitro] (preset: node-server, compatibility: 2025-10-18)                                                                                                                                                      ...
...
.output/server/index.mjs                                               75.11 kB
.output/server/chunks/build/entry-server.mjs                        1,407.94 kB 👈👈 then mostly copied to here
✓ built in 1.89s 👈👈

After removing noExternal: true from each service (by locally patching), the build becomes:

◐ Building [Client]                                                                                                                                                                                                      ...
...
✓ built in 414ms

◐ Building [SSR]                                                                                                                                                                                                         ...
...
.nitro/vite/services/ssr/assets/app-Bm8psYAt.js                        1.86 kB
.nitro/vite/services/ssr/entry-server.js                               3.23 kB 👈👈
✓ built in 44ms 👈👈

◐ Building [Nitro] (preset: node-server, compatibility: 2025-10-18)                                                                                                                                                      ...
...
.output/server/chunks/build/entry-server.mjs                         5.46 kB
.output/server/index.mjs                                            75.11 kB 👈👈
✓ built in 1.05s 👈👈

With this, the build got faster and external tracing of nitro environment properly isolated runtime dependencies .output/server/node_modules, so .output becomes standalone output.

❓ 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

📝 Checklist

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

@vercel
Copy link

vercel bot commented Oct 18, 2025

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

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/nitrojs/nitro@3665

commit: 66d35c2

@hi-ogawa hi-ogawa changed the title fix(vite): remove noExternal: true from each service build fix(vite): remove noExternal: true from service environment build Oct 18, 2025
@pi0
Copy link
Member

pi0 commented Oct 18, 2025

Looks good @hi-ogawa. Any reason still kept in draft? / also wondering should we enable externals by default for other services?

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Oct 18, 2025

Oh, I just forgot to undraft.

also wondering should we enable externals by default for other services?

What do you mean? After this change, the build behavior seems good to me. Ssr environment build leaves external as is (users or framework can still specify noExternal for their framework level package) and nitro environment build can take care external tracing to make final .output self-contained.

@hi-ogawa hi-ogawa marked this pull request as ready for review October 18, 2025 08:42
@hi-ogawa hi-ogawa requested a review from pi0 as a code owner October 18, 2025 08:42
@pi0 pi0 merged commit c8dc542 into nitrojs:main Oct 18, 2025
5 of 6 checks passed
@hi-ogawa hi-ogawa deleted the 10-18-fix_vite_remove_noexternal_true_from_each_service_build branch October 18, 2025 09:05
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.

2 participants