withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
45.74k stars 2.4k forks source link

JavaScript not being bundled in production build for components #8018

Closed lorenzolewis closed 1 year ago

lorenzolewis commented 1 year ago

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

  1. Setup an .mdx file in Starlight
  2. Use <Tabs> and <TabItem> components within that file
  3. Create a new custom component and import that within the aforementioned .mdx file
  4. Run pnpm build && pnpm preview (I'll come back to why not to use pnpm dev in a bit)
  5. Notice that the tabs are clickable and work as expected
  6. 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)
  7. Now run pnpm build && pnpm preview again. You will notice those tab items are no longer clickable.

Notes

Files to pay attention to the repro

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

lorenzolewis commented 1 year ago

This is potentially also related to https://github.com/withastro/astro/pull/8011, https://github.com/withastro/astro/issues/7744, https://github.com/withastro/astro/issues/7857

lorenzolewis commented 1 year ago

Fixed by 2.10.5 that just came out. Thanks for being amazing! <3