Skip to content

Hoisted scripts break when components are re-exported from a typescript file #7673

@ottomated

Description

@ottomated

What version of astro are you using?

2.8.3

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Firefox

Describe the Bug

When components are re-exported, like so:

import Component from './Component.astro';
import Layout from './Layout.astro';

export { Component, Layout };

Astro loses track of which components are included on which pages, leading to hoisted scripts being included on a page where the component does not exist.

This is impactful on a monorepo that includes a library of Astro components, as there is no easy way to avoid re-exporting them.

What's the expected result?

Re-exporting components should function identically to importing them directly.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-15jfdd?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P2: nice to haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions