-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
needs triageIssue needs to be triagedIssue needs to be triaged
Description
What version of astro
are you using?
2.10.4
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
Mac
What browser are you using?
Safari
Describe the Bug
Reproduction Steps
- Setup an
.mdx
file in Starlight - Use
<Tabs>
and<TabItem>
components within that file - Create a new custom component and import that within the aforementioned
.mdx
file - Run
pnpm build && pnpm preview
(I'll come back to why not to usepnpm dev
in a bit) - Notice that the tabs are clickable and work as expected
- Within that newly created custom component import Starlight's
<Icon>
component (essentially using this custom component as a wrapper). (Note: there doesn't seem to be any special issues with the<Icon>
component from what I can tell, this is able to be reproduced with other imported components as well) - Now run
pnpm build && pnpm preview
again. You will notice those tab items are no longer clickable.
Notes
- This bug only happens on production builds and works as expected while in dev mode (
pnpm dev
) - It works as expected in Astro versions
2.8.5
and before, it is broken in2.9.0
and beyond - @HiDeoo took a guess that it may be related to this PR, but no dissecting or anything has been done to determine exactly which commit breaks this: Determine hoisted scripts via AST analysis #7707
- @simonhyll observed that the
<Tabs>
components don't seem to be getting their needed<script>
's added in the production build - Discord thread for any additional context (but it's a bit all over the place 😅): https://discord.com/channels/830184174198718474/1138942969282564217
Files to pay attention to the repro
.mdx
file: https://github.com/lorenzolewis/starlight-component-bug/blob/main/src/content/docs/guides/example.mdx- Astro component: https://github.com/lorenzolewis/starlight-component-bug/blob/main/src/components/IconWrapper.astro
What's the expected result?
The <Tab>
components and their respective JS should be included in the production build
Link to Minimal Reproducible Example
https://github.com/lorenzolewis/starlight-component-bug
Participation
- I am willing to submit a pull request for this issue.
Metadata
Metadata
Assignees
Labels
needs triageIssue needs to be triagedIssue needs to be triaged