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

Duplicate css and js bundle tags when mdx is rendered in sub-layout #5715

Closed
1 task
fflaten opened this issue Jan 1, 2023 · 6 comments · Fixed by #6034
Closed
1 task

Duplicate css and js bundle tags when mdx is rendered in sub-layout #5715

fflaten opened this issue Jan 1, 2023 · 6 comments · Fixed by #6034
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@fflaten
Copy link
Contributor

fflaten commented Jan 1, 2023

What version of astro are you using?

1.8.0

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

Describe the Bug

When MDX imports a component and is rendered using a sub-layout/nested layout (ex. BlogPostLayout which again uses BaseLayout), link tags for bundled stylesheets and bundled JS module may be injected twice in astro build. The duplicates are placed in the body before the component.

Run astro build in repro and inspect generated HTML.

Repro includes three layouts:

  • One (base). This always works as expected - no duplicates
    • Two (inherits One).
      • Three (inherits Two)

Pages:

  • index*.astro imports <Content /> from MDX. render() with content collections behaves the same.
  • test*.mdx uses layout-frontmatter. This only fails using layout Three for some unknown reason.

Link to Minimal Reproducible Example

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

Participation

  • I am willing to submit a pull request for this issue.
@fflaten fflaten changed the title Duplicate css and js bundles when mdx is rendered in sub-layout Duplicate css and js bundle tags when mdx is rendered in sub-layout Jan 3, 2023
@thejediknight
Copy link

thejediknight commented Jan 5, 2023

Facing same issue, I am using astro 1.9.

@nicholasray
Copy link

Also seeing this issue on my website which uses Astro 1.9.1

@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Jan 12, 2023
@matthewp matthewp self-assigned this Jan 12, 2023
@sarajw
Copy link

sarajw commented Jan 16, 2023

Another one here - not just in dev but in the built static site too. Makes editing CSS in devtools a little annoying!

Just a thank you in advance, at least I hope this is the root of the issue I'm having :)

@matthewp
Copy link
Contributor

Sorry about this one. There's a couple of CSS ordering / duplication bugs floating around and I'm tackling all of those now.

@matthewp
Copy link
Contributor

I think this is likely fixed by #6034 but keeping open to test.

@fflaten
Copy link
Contributor Author

fflaten commented Jan 31, 2023

No more duplicates (🎉) but it injects link+style in body now. Is that intentional?
Updated repro with 2.0.4: https://stackblitz.com/edit/github-ske6w4-cjs3nj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants