Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Log a warning when Astro component scripts and scoped styles are stripped from page partials #11885

Open
1 task
W1M0R opened this issue Aug 30, 2024 · 0 comments
Labels
- P2: nice to have Not breaking anything but nice to have (priority)

Comments

@W1M0R
Copy link
Contributor

W1M0R commented Aug 30, 2024

Astro Info

Astro                    v4.15.1
Node                     v20.12.2
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             astro-i18n-integration
                         @astrojs/sitemap
                         paraglide
                         @astrojs/starlight
                         @astrojs/svelte
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

The documentation clearly states:

Additionally, partials should not be used if the component contains scoped styles or scripts, as these elements will be stripped from the HTML output. If you need scoped styles, it is better to use regular, non-partial pages along with a frontend library that knows how to merge the contents into the head.

It can be difficult to know if a component in your component hierarchy is using scoped styles or Astro component scripts. Currently, if you are using a component in a partial that has scripts, it will be stripped silently.

What's the expected result?

It would be nice if astro could print a warning during dev and during build, if a partial is trying to use a component that has an astro component script or a scoped style.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-rma1f4

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 30, 2024
@ascorbic ascorbic added - P2: nice to have Not breaking anything but nice to have (priority) and removed needs triage Issue needs to be triaged labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority)
Projects
None yet
Development

No branches or pull requests

2 participants