Skip to content

fix(nuxt): avoid transforming NuxtTeleportIslandComponent with nuxt-client directive#34817

Open
atinux wants to merge 1 commit intomainfrom
fix/island-component
Open

fix(nuxt): avoid transforming NuxtTeleportIslandComponent with nuxt-client directive#34817
atinux wants to merge 1 commit intomainfrom
fix/island-component

Conversation

@atinux
Copy link
Copy Markdown
Member

@atinux atinux commented Apr 16, 2026

WIP, exploration of Island components with dynamic content on SSR with components.

@atinux atinux requested a review from danielroe as a code owner April 16, 2026 13:05
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@atinux atinux changed the title fix(nuxt): avoid transforming NuxtTeleportIslandComponent with nuxt-c… fix(nuxt): avoid transforming NuxtTeleportIslandComponent with nuxt-client directive Apr 16, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 16, 2026

Open in StackBlitz

@nuxt/kit

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

@nuxt/nitro-server

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 7f8cb6b

@coderabbitai

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/nuxt/src/components/plugins/islands-transform.ts (1)

101-103: Please add a regression test for pre-wrapped island nodes.

Add a case in packages/nuxt/test/island-transform.test.ts where the input already contains NuxtTeleportIslandComponent, and assert the transform does not nest another wrapper. This will lock in the fix behaviour.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/nuxt/src/components/plugins/islands-transform.ts` around lines 101 -
103, Add a regression test in island-transform.test.ts that feeds the
transformer an input already containing the NuxtTeleportIslandComponent wrapper
and asserts the islands-transform result does not add a second wrapper (no
nested NuxtTeleportIslandComponent). Locate the transformer behavior in
islands-transform (the code that checks node.name ===
'NuxtTeleportIslandComponent') and write the test to run the same transform
function on a pre-wrapped AST/markup and assert the output structure (or
snapshot) remains single-wrapped.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/nuxt/src/components/plugins/islands-transform.ts`:
- Around line 101-103: Add a regression test in island-transform.test.ts that
feeds the transformer an input already containing the
NuxtTeleportIslandComponent wrapper and asserts the islands-transform result
does not add a second wrapper (no nested NuxtTeleportIslandComponent). Locate
the transformer behavior in islands-transform (the code that checks node.name
=== 'NuxtTeleportIslandComponent') and write the test to run the same transform
function on a pre-wrapped AST/markup and assert the output structure (or
snapshot) remains single-wrapped.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eac5b2ad-d5fb-47c6-8a82-2fefb473e03e

📥 Commits

Reviewing files that changed from the base of the PR and between 95e6b9f and 7f8cb6b.

📒 Files selected for processing (1)
  • packages/nuxt/src/components/plugins/islands-transform.ts

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 16, 2026

Merging this PR will not alter performance

✅ 20 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing fix/island-component (7f8cb6b) with main (95e6b9f)

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.

@atinux atinux requested a review from huang-julien April 16, 2026 13:55
@danielroe danielroe marked this pull request as draft April 16, 2026 14:29
Copy link
Copy Markdown
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

this doesn't look like it would work.

maybe add a test to validate the desired behaviour?

Copy link
Copy Markdown
Member

@huang-julien huang-julien left a comment

Choose a reason for hiding this comment

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

LGTM, from what I remember there's also one for teleporting slots

@atinux
Copy link
Copy Markdown
Member Author

atinux commented Apr 16, 2026

Interesting comment, will add a test if it helps you understand my change.

So far I did a lot of manual testing (that's why it's still draft), right now if you have in your codebase:

<template>
  <NuxtTeleportIslandComponent nuxt-client>
    <Dynamic>
  <NuxtTeleportIslandComponent>
</template>

The transformer will do:

<template>
  <NuxtTeleportIslandComponent nuxt-client>
    <NuxtTeleportIslandComponent>
      <Dynamic>
    </NuxtTeleportIslandComponent>
  </NuxtTeleportIslandComponent>
</template>

See in the Vite Inspect:

Original code:
CleanShot 2026-04-16 at 16 38 47@2x

Second step:
CleanShot 2026-04-16 at 16 38 52@2x

But if I use the nuxt-client directive:

Original code:
CleanShot 2026-04-16 at 16 40 40@2x

Second step:
CleanShot 2026-04-16 at 16 40 43@2x

With this change, I am almost good to have dynamic markdown rendering support in a server component with hydration for specific components 🚀

@atinux atinux marked this pull request as ready for review April 16, 2026 14:53
@danielroe
Copy link
Copy Markdown
Member

amazing! yes, a test would be great 🙏

@atinux
Copy link
Copy Markdown
Member Author

atinux commented Apr 16, 2026

Right now this is a demo of using Comark in a server/island component with the ability to use the client prop on a component in markdown to hydrate it on client-side:

CleanShot.2026-04-16.at.17.25.22.mp4

I need to do more testing as the behavior changes if the components has slots or not (need to set selectiveClient: 'deep' for instance, but then it's failing for other components without slots on hydration...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants