Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

perf(nuxt): skip island-renderer chunk when no islands used - #35456

#35456
Merged
danielroe merged 4 commits into
mainnuxt/nuxt:mainfrom
perf/skip-inactive-island-renderernuxt/nuxt:perf/skip-inactive-island-rendererCopy head branch name to clipboard
Jun 27, 2026
Merged

perf(nuxt): skip island-renderer chunk when no islands used#35456
danielroe merged 4 commits into
mainnuxt/nuxt:mainfrom
perf/skip-inactive-island-renderernuxt/nuxt:perf/skip-inactive-island-rendererCopy head branch name to clipboard

Conversation

@TheAlexLichter

@TheAlexLichter TheAlexLichter commented Jun 27, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

None (perf gainzzz)

📚 Description

This PR uses a generated #build/island-renderer.mjs template for the island renderer.

In default auto mode with no server components or server pages, the template exports a null component, so Vite never pulls app/components/island-renderer and its async chunk into the SSR build.

Bench

Local stats (15 interleaved runs):

  • vite:ssr: −56% (~ −125 ms)
  • total build: −8% (~ −140 ms)

This can vary by app of course and will only applied w/o islands.

Route the root component's island renderer through a generated
`#build/island-renderer.mjs` template. In default `auto` mode with no
server components or server pages, the template exports a null component,
so Vite never pulls `app/components/island-renderer` and its async chunk
into the SSR build. Active islands (server components/pages, explicit
`componentIslands`, or dev) resolve to the real renderer unchanged.
@github-actions github-actions Bot added 5.x ⚡ performance Performance degradation or optimization opportunity labels Jun 27, 2026
Comment thread packages/nuxt/src/core/templates.ts Fixed
@pkg-pr-new

pkg-pr-new Bot commented Jun 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35456

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35456

nuxt

npm i https://pkg.pr.new/nuxt@35456

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35456

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35456

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35456

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35456

commit: 946bd20

@coderabbitai

This comment has been minimized.

Comment thread test/bundle.test.ts Outdated

const serverStats = await analyzeSizes(['**/*.mjs', '!_libs'], serverDir, rootDir)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"70.2k"`)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"70.3k"`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder why this is happening - shouldn't it go the other way, if anything?

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.

Already investigating why!

@TheAlexLichter TheAlexLichter Jun 27, 2026

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.

This might be correct.

We get +23B through that change which pushes us over the limit for rounding 🙈

Before we could skip the whole declaration, but through the no-op we get const IslandRenderer = () => null. So, no "real increase" here

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.

reworked this so we don't rely on a named fn that gets mangled.

@danielroe danielroe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should add an assertion to bundle.test.ts about the number of client-side chunks - wdyt?

@codspeed-hq

codspeed-hq Bot commented Jun 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing perf/skip-inactive-island-renderer (946bd20) with main (5c999b0)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (78ece59) during the generation of this report, so 5c999b0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Use knitwork's genDynamicImport helper instead of manual
JSON.stringify interpolation, matching the convention used by the
other templates (e.g. testComponentWrapperTemplate) and resolving the
CodeQL 'improper code sanitization' alert.
@TheAlexLichter

Copy link
Copy Markdown
Member Author

I think we should add an assertion to bundle.test.ts about the number of client-side chunks - wdyt?

Why client-side? In this case the chunks of the server built are reduced.

Emit a named `IslandRenderer` binding from the template instead of an
anonymous default export. This lets rolldown reuse the short name in the
server entry rather than a verbose module-path-derived one; the server
bundle ends up ~37 bytes smaller than before (the no-op is retained as it
is referenced, but the island chunk's re-exports are dropped). Reverts
the autofix snapshot bump as the size returns to its prior bucket.
@danielroe

Copy link
Copy Markdown
Member

ah!

@danielroe
danielroe added this pull request to the merge queue Jun 27, 2026
Merged via the queue into main with commit 6159274 Jun 27, 2026
31 checks passed
@danielroe
danielroe deleted the perf/skip-inactive-island-renderer branch June 27, 2026 15:00
@github-actions github-actions Bot mentioned this pull request Jun 27, 2026
5 tasks
danielroe pushed a commit that referenced this pull request Jul 17, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
danielroe pushed a commit that referenced this pull request Jul 17, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
danielroe pushed a commit that referenced this pull request Jul 17, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
danielroe pushed a commit that referenced this pull request Jul 17, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
danielroe pushed a commit that referenced this pull request Jul 17, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x ⚡ performance Performance degradation or optimization opportunity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.