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

WIP [Content Collections] Fix script bleed in prod builds #6047

Closed
wants to merge 49 commits into from

Conversation

bholmesdev
Copy link
Contributor

Changes

  • Prevent bundling of hoisted scripts for content collection entries
  • Add propagatedScripts map to page build data. This will track scripts that can be injected via head propagation
  • Update SSR build to inject propagated scripts
  • TODO: add a file naming convention for scripts, so the SSR build can match the output of the client build.

Testing

  • Un-skip script bleed test

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2023

🦋 Changeset detected

Latest commit: 0d57caf

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 30, 2023
Comment on lines +92 to +95
// TODO: map raw URL (?type=script) to client build ready URL
// This will inject the raw URL as a script tag as-is,
// which will fail to map with the client build output.
pageData.propagatedScripts = propagatedMapByImporter;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part left to figure out. Today, this naively passes the unformatted URL as a client build entrypoint. This gets mangled by Vite in the output (script.astro?type=script -> script.astro.fancytype.2j234k2.js).

natemoo-re and others added 22 commits February 3, 2023 12:18
* fix: add error handling for invalid arguments

* chore: add changeset

* Update packages/astro/src/core/errors/errors-data.ts

Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>

---------

Co-authored-by: Nate Moore <nate@astro.build>
Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Currently, @astrojs/image allows *importing* images from srcDir
only. Importing images from outside srcDir fails miserably *in dev
mode* and produces incorrect src.

This happens because `path.relative(fileURLToPath(config.srcDir), id)`
resolves to "../something" and when joined with '/@astroimage' cancels
it out (`join('/@astroimage', '../../something')` => `'/something'`).

Rework /@astroimage URL scheme to be similar to "/@fs/" scheme—always
export absolute path to the target file.
* show `cause` in error overlay

* add extra check for string

* add changeset
* fix: load MDX syntax highlighting after user plugins

* chore: changeset
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: BryceRussell <19967622+BryceRussell@users.noreply.github.com>
)

* Fix lit hydration not having the same reactive values

* add changeset

* add clientEntrypoint to package exports

* update tests

* add changeset

* only add defer-hydration when strictly necessary

* remove second changest

* fix test typos
…of type 'String' in Edge Runtime SSR (#6070)

* minor fixes for errors related to vercel SSR in core

* yielding empty string instead of nothing, to not exit the iterator

---------

Co-authored-by: AirBorne04 <>
* fix: apply MDX components during render()

* test: MDX components export in SSG and SSR

* chore: changeset
Co-authored-by: FredKSchott <FredKSchott@users.noreply.github.com>
* Forwards compatiblity for streaming DSD

* add shadowrootmode

* update tests

* add changeset
astrobot-houston and others added 19 commits February 3, 2023 12:18
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…cs as cloudflare) (#6085)

* fix solidjs integration for vercel deployment

* downgrade change to patch

---------

Co-authored-by: AirBorne04 <>
Co-authored-by: FredKSchott <FredKSchott@users.noreply.github.com>
Co-authored-by: Yasser Hennawi <yasser.hennawi@nordsec.com>
)

* Prevent eager rendering of head content in multi-level MDX layout

* Adding a changeset

* Remove old comment

* Keep track of slot position as well
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Node adapter: handle prerendering and serving with query params

* Adding a changeset
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Refactor build into plugins

* maybe fix internals

* Await post-build hooks

* Use extendManualChunks

* Remove commented out code
Co-authored-by: FredKSchott <FredKSchott@users.noreply.github.com>
@github-actions github-actions bot added pkg: example Related to an example package (scope) pkg: lit Related to Lit (scope) pkg: preact Related to Preact (scope) pkg: solid Related to Solid (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) pkg: integration Related to any renderer integration (scope) labels Feb 3, 2023
@matthewp
Copy link
Contributor

matthewp commented Feb 3, 2023

Closing in favor of #6119

@matthewp matthewp closed this Feb 3, 2023
@bluwy bluwy deleted the fix/content-collections-prod-hoisted-scripts branch October 8, 2024 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope) pkg: integration Related to any renderer integration (scope) pkg: lit Related to Lit (scope) pkg: preact Related to Preact (scope) pkg: solid Related to Solid (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.