diff --git a/.changeset/good-birds-clap.md b/.changeset/good-birds-clap.md new file mode 100644 index 000000000000..1a05c065c69a --- /dev/null +++ b/.changeset/good-birds-clap.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a case where omitting a semicolon and line ending with carriage return - CRLF - in the `prerender` option could throw an error. diff --git a/packages/astro/src/vite-plugin-scanner/scan.ts b/packages/astro/src/vite-plugin-scanner/scan.ts index f447a1f28f3e..b9f61e3b836d 100644 --- a/packages/astro/src/vite-plugin-scanner/scan.ts +++ b/packages/astro/src/vite-plugin-scanner/scan.ts @@ -65,7 +65,7 @@ export async function scan( .trim(); // For a given export, check the value of the first non-whitespace token. // Basically extract the `true` from the statement `export const prerender = true` - const suffix = code.slice(endOfLocalName).trim().replace(/=/, '').trim().split(/[;\n]/)[0]; + const suffix = code.slice(endOfLocalName).trim().replace(/=/, '').trim().split(/[;\n\r]/)[0].trim(); if (prefix !== 'const' || !(isTruthy(suffix) || isFalsy(suffix))) { throw new AstroError({ ...AstroErrorData.InvalidPrerenderExport,