diff --git a/packages/astro/package.json b/packages/astro/package.json index 9b399b98f..4382317fd 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -94,7 +94,7 @@ "prismjs": "^1.25.0", "rehype-slug": "^5.0.0", "resolve": "^1.20.0", - "rollup": "^2.59.0", + "rollup": "~2.59.0", "sass": "^1.43.4", "semver": "^7.3.5", "send": "^0.17.1", diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts index 4c6ceccd7..7fd890040 100644 --- a/packages/astro/src/vite-plugin-astro/compile.ts +++ b/packages/astro/src/vite-plugin-astro/compile.ts @@ -12,21 +12,7 @@ type CompilationCache = Map; const configCache = new WeakMap(); -// https://github.com/vitejs/vite/discussions/5109#discussioncomment-1450726 -function isSSR(options: undefined | boolean | { ssr: boolean }): boolean { - if (options === undefined) { - return false; - } - if (typeof options === 'boolean') { - return options; - } - if (typeof options == 'object') { - return !!options.ssr; - } - return false; -} - -async function compile(config: AstroConfig, filename: string, source: string, viteTransform: TransformHook, opts: boolean | undefined) { +async function compile(config: AstroConfig, filename: string, source: string, viteTransform: TransformHook, opts?: { ssr?: boolean }) { // pages and layouts should be transformed as full documents (implicit etc) // everything else is treated as a fragment const filenameURL = new URL(`file://${filename}`); @@ -57,7 +43,7 @@ async function compile(config: AstroConfig, filename: string, source: string, vi lang, id: filename, transformHook: viteTransform, - ssr: isSSR(opts), + ssr: Boolean(opts?.ssr), }); let map: SourceMapInput | undefined; @@ -91,7 +77,7 @@ export function invalidateCompilation(config: AstroConfig, filename: string) { } } -export async function cachedCompilation(config: AstroConfig, filename: string, source: string | null, viteTransform: TransformHook, opts: boolean | undefined) { +export async function cachedCompilation(config: AstroConfig, filename: string, source: string | null, viteTransform: TransformHook, opts?: { ssr?: boolean; }) { let cache: CompilationCache; if (!configCache.has(config)) { cache = new Map(); diff --git a/yarn.lock b/yarn.lock index db522c5c6..dc7dd2f12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8087,6 +8087,13 @@ rollup@^2.43.1, rollup@^2.59.0, rollup@^2.60.0: optionalDependencies: fsevents "~2.3.2" +rollup@~2.59.0: + version "2.59.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.59.0.tgz#108c61b0fa0a37ebc8d1f164f281622056f0db59" + integrity sha512-l7s90JQhCQ6JyZjKgo7Lq1dKh2RxatOM+Jr6a9F7WbS9WgKbocyUSeLmZl8evAse7y96Ae98L2k1cBOwWD8nHw== + optionalDependencies: + fsevents "~2.3.2" + run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee"