diff --git a/.changeset/unlucky-otters-agree.md b/.changeset/unlucky-otters-agree.md new file mode 100644 index 000000000..2da789e51 --- /dev/null +++ b/.changeset/unlucky-otters-agree.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix regression with SSRManifest and client assets diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts index e543e925e..ce386872b 100644 --- a/packages/astro/src/core/build/vite-plugin-ssr.ts +++ b/packages/astro/src/core/build/vite-plugin-ssr.ts @@ -70,12 +70,6 @@ if(_start in adapter) { return void 0; }, async generateBundle(_opts, bundle) { - internals.staticFiles = new Set( - await glob('**/*', { - cwd: fileURLToPath(buildOpts.buildConfig.client), - }) - ); - // Add assets from this SSR chunk as well. for (const [_chunkName, chunk] of Object.entries(bundle)) { if (chunk.type === 'asset') { @@ -101,6 +95,16 @@ export async function injectManifest(buildOpts: StaticBuildOptions, internals: B throw new Error(`Did not generate an entry chunk for SSR`); } + // Add assets from the client build. + const clientStatics = new Set( + await glob('**/*', { + cwd: fileURLToPath(buildOpts.buildConfig.client), + }) + ); + for(const file of clientStatics) { + internals.staticFiles.add(file); + } + const staticFiles = internals.staticFiles; const manifest = buildManifest(buildOpts, internals, Array.from(staticFiles)); await runHookBuildSsr({ config: buildOpts.astroConfig, manifest }); diff --git a/packages/astro/test/fixtures/ssr-scripts/astro.config.mjs b/packages/astro/test/fixtures/ssr-scripts/astro.config.mjs new file mode 100644 index 000000000..08916b1fe --- /dev/null +++ b/packages/astro/test/fixtures/ssr-scripts/astro.config.mjs @@ -0,0 +1,7 @@ +import { defineConfig } from 'astro/config'; +import preact from '@astrojs/preact'; + +// https://astro.build/config +export default defineConfig({ + integrations: [preact()], +}); diff --git a/packages/astro/test/fixtures/ssr-scripts/package.json b/packages/astro/test/fixtures/ssr-scripts/package.json new file mode 100644 index 000000000..2050dfbec --- /dev/null +++ b/packages/astro/test/fixtures/ssr-scripts/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/ssr-scripts", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/preact": "workspace:", + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/ssr-scripts/src/components/Hello.jsx b/packages/astro/test/fixtures/ssr-scripts/src/components/Hello.jsx new file mode 100644 index 000000000..70279a587 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-scripts/src/components/Hello.jsx @@ -0,0 +1,6 @@ + +export default function() { + return ( +