Fix pipeline beforeHydrationScript handling (#8388)

This commit is contained in:
Nate Moore 2023-09-04 03:11:47 -05:00 committed by GitHub
parent 8d12659ce8
commit 362491b8da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Properly handle `BEFORE_HYDRATION_SCRIPT` generation, fixing MIME type error on hydration.

View file

@ -36,7 +36,7 @@ export class BuildPipeline extends Pipeline {
compressHTML: manifest.compressHTML,
async resolve(specifier: string) {
const hashedFilePath = manifest.entryModules[specifier];
if (typeof hashedFilePath !== 'string') {
if (typeof hashedFilePath !== 'string' || hashedFilePath === '') {
// If no "astro:scripts/before-hydration.js" script exists in the build,
// then we can assume that no before-hydration scripts are needed.
if (specifier === BEFORE_HYDRATION_SCRIPT_ID) {