feat(@tinacms/astro): forward containerOptions to island route container#7166
Open
dfan1028 wants to merge 1 commit into
Open
feat(@tinacms/astro): forward containerOptions to island route container#7166dfan1028 wants to merge 1 commit into
dfan1028 wants to merge 1 commit into
Conversation
experimental_createIslandRoute creates its AstroContainer with no
renderers. Unlike the page pipeline, the container does not inherit
renderers from the Astro config, so islands that use a UI framework
(React, Vue, ...) fail to render in visual editing.
Add an optional containerOptions argument forwarded to
AstroContainer.create so callers can register renderers, e.g.
{ containerOptions: { renderers: [{ name: '@astrojs/react', ssr }] } }.
The argument is optional; existing callers are unaffected.
Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 9631b68 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
| }); | ||
|
|
||
| it('forwards containerOptions to AstroContainer.create', async () => { | ||
| const spy = vi.spyOn(AstroContainer, 'create'); |
Member
There was a problem hiding this comment.
Nit: consider restoring this spy via try/finally or an afterEach cleanup so a failure before mockRestore() does not leave AstroContainer.create mocked for later tests. Not a blocker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
experimental_createIslandRouterenders each island through a freshAstroContainercreated withAstroContainer.create()— no renderers. Unlike Astro's page pipeline, the container does not inherit renderers from the project's Astro config, so any island that renders a UI-framework component (React, Vue, Svelte, …) fails to render during visual editing. The island-refresh request 500s and the editor silently falls back to form-only editing (no live preview).This doesn't affect islands that render plain Astro/markdown, which is why it hasn't surfaced in the
examples/astro/visual-editingapp — but it reliably bites projects that put framework components inside visually-edited regions (in our case, a React component library rendered in TinaMarkdown blocks and an interactive search island).Fix
Add an optional
containerOptionsargument toexperimental_createIslandRoute, forwarded toAstroContainer.create. Callers register renderers explicitly:Passing renderers explicitly (rather than auto-loading via
astro:container'sloadRenderers) keeps this working in a plain Node/SSR context — theastro:containervirtual module only resolves inside Vite.The argument is optional, so existing callers are unchanged.
Changes
island-route.ts:IslandRouteOptionstype; forwardoptions?.containerOptionstoAstroContainer.create.experimental.ts: exportIslandRouteOptions.containerOptionsis forwarded toAstroContainer.create.Validation
Verified in a downstream Astro + React project: with this change the island route renders React islands in visual editing; without it the same islands 500. I did not run the full monorepo suite locally — deferring to CI — but the added unit test follows the existing
island-route.test.tspatterns.Notes
Happy to adjust the API shape (e.g. accept
renderersdirectly instead of the nestedcontainerOptions) or add auto-loading behind a flag if preferred.Made with Cursor