diff --git a/.changeset/good-birds-clap.md b/.changeset/good-birds-clap.md index a6e0effc4b89..1a05c065c69a 100644 --- a/.changeset/good-birds-clap.md +++ b/.changeset/good-birds-clap.md @@ -2,4 +2,4 @@ 'astro': patch --- -Fixes a case where omitting a semicolon in the `prerender` option could throw an error. +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 e7f6ab53308c..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|\r)]/)[0].trim(); + 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,