Stub out .astro imports in client modules#14751
Merged
Conversation
🦋 Changeset detectedLatest commit: 4960fc3 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 |
CodSpeed Performance ReportMerging #14751 will not alter performanceComparing Summary
Footnotes |
This comment was marked as spam.
This comment was marked as spam.
delucis
commented
Nov 11, 2025
ematipico
approved these changes
Nov 11, 2025
Closed
1 task
This was referenced Nov 25, 2025
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.
Changes
.astrocomponents in client code, allowing a mixed barrel file that exported both Astro and JSX components (this works in build currently but not dev since Replacekleurwithpicocolors#14598). (I’m not sure if that should be supported, but people are doing it, and on the surface these imports are used in the same place in the same way, so I was curious if we could allow it for now.).astro) that throws an error if used. In prod, it just exports an empty object.Testing
I added a test for dev and build behaviour.
I also tested manually by creating a barrel file in the
framework-reactexample to re-export a React component and a simple Astro component:I also excluded
picocolorsfrom optimized deps in the example config because Vite automatically optimizes this in the monorepo, but not in user projects:I then imported both components from that barrel file and rendered them. Using
client:loadon the React component.Before changing
astro, the example project fails to hydrate due to trying to loadpicocolors(i.e. server code). With the change from this PR in place, everything works as expected in the example, with no hydration issues caused by server code being present during dev.Docs
n/a — bug fix. Although maybe we should consider removing the example in the “Publish to NPM” guide that explicitly shows the mixed Astro/React barrel file code if we’re unsure that’s a best practice.