Skip to content

Conversation

@apatel369
Copy link
Contributor

@apatel369 apatel369 commented Nov 30, 2024

Changes

Testing

Manual and new fixture test

Docs

Changeset

@changeset-bot
Copy link

changeset-bot bot commented Nov 30, 2024

🦋 Changeset detected

Latest commit: 41e55b2

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Nov 30, 2024
@apatel369 apatel369 changed the title Arpan #12252 mdx islands feat: add support for server islands for MDX Nov 30, 2024
@apatel369 apatel369 marked this pull request as draft November 30, 2024 20:39
@apatel369 apatel369 changed the title feat: add support for server islands for MDX feat: add server islands support for MDX Nov 30, 2024
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 30, 2024

CodSpeed Performance Report

Merging #12574 will not alter performance

Comparing apatel369:arpan-#12252-mdx-islands (b072817) with main (fbcfa68)

Summary

✅ 6 untouched benchmarks

@ematipico
Copy link
Member

@apatel369 any updates?

@apatel369
Copy link
Contributor Author

@ematipico I applied the changes suggested by @matthewp. Tests are still failing.

@ematipico
Copy link
Member

@apatel369 the PR was in draft for a long time without any updates. What suggestions are you referring to? What kind of help do you need?

@florian-lefebvre florian-lefebvre self-assigned this May 21, 2025
@github-actions github-actions bot added the pkg: example Related to an example package (scope) label May 21, 2025
@github-actions github-actions bot removed the pkg: example Related to an example package (scope) label May 21, 2025
}
},
transform(_code, id) {
if (id.endsWith('.astro')) {
Copy link
Member

Choose a reason for hiding this comment

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

This was preventing retrieving server islands data from mdx files metadata

props[key] = value;
}
}
const str = await renderToString(result, vnode.type as any, props, slots);
Copy link
Member

Choose a reason for hiding this comment

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

This was calling the component factory as is. Instead, we want it to go through renderAstroComponent so the server island special handling can take effect

...meta,
astro: {
...(meta.astro ?? { hydratedComponents: [], clientOnlyComponents: [], scripts: [] }),
...(meta.astro ?? createDefaultAstroMetadata()),
Copy link
Member

Choose a reason for hiding this comment

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

Now that the server island plugin is running for all files, this was failing because the metadata was not initialized with serverComponents: []

@florian-lefebvre florian-lefebvre marked this pull request as ready for review May 21, 2025 12:46
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Just confirming that no docs update is needed:

  • there's nothing in docs that explicitly says this wasn't possible before, or that server islands could only be rendered in .astro components
  • all current wording re: MDX refers to the ability to "use Astro components", which server islands are.

@florian-lefebvre florian-lefebvre marked this pull request as draft May 21, 2025 13:08
@florian-lefebvre florian-lefebvre marked this pull request as ready for review May 26, 2025 14:12
Comment on lines +43 to +46
logger.error(
'islands',
'You tried to render a server island without an adapter added to your project. An adapter is required to use the `server:defer` attribute on any component. Your project will fail to build unless you add an adapter or remove the attribute.',
);
Copy link
Member

@ematipico ematipico May 26, 2025

Choose a reason for hiding this comment

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

Suggested change
logger.error(
'islands',
'You tried to render a server island without an adapter added to your project. An adapter is required to use the `server:defer` attribute on any component. Your project will fail to build unless you add an adapter or remove the attribute.',
);
logger.error(
'islands',
'You tried to render a server island without an adapter added to your project. An adapter is required to use the `server:defer` attribute on any component. Your project will fail to build unless you add an adapter or remove the attribute.',
);
continue;

We should not process the island, I think. Make sure to print the name of the component, so the users know which component island is failing.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should stop the processing. We have this in a few places IIRC where we only warn if stuff is going to break if no adapter is added, and only break during build. I think that applies here too

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Looks good!

@florian-lefebvre florian-lefebvre merged commit da266d0 into withastro:main May 26, 2025
17 checks passed
@astrobot-houston astrobot-houston mentioned this pull request May 26, 2025
openscript pushed a commit to openscript/astro that referenced this pull request Sep 12, 2025
Co-authored-by: Matthew Phillips <[email protected]>
Co-authored-by: Emanuele Stoppa <[email protected]>
Co-authored-by: Florian Lefebvre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server Islands not rendering as islands in .mdx files

5 participants