From a30766f3f2b60a5d48245dcead587d7837e603d3 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 20 Mar 2026 15:18:37 -0400 Subject: [PATCH] fix(manifest): restrict virtual:astro:manifest to server environments, inline astro:config/client values --- .changeset/lucky-teams-play.md | 5 ++ packages/astro/src/core/create-vite.ts | 2 +- packages/astro/src/manifest/serialized.ts | 10 +++ packages/astro/src/manifest/virtual-module.ts | 88 +++++++++++-------- .../astro.config.mjs | 6 ++ .../astro-manifest-client-script/package.json | 8 ++ .../src/pages/index.astro | 18 ++++ packages/astro/test/serializeManifest.test.js | 20 +++++ pnpm-lock.yaml | 6 ++ 9 files changed, 126 insertions(+), 37 deletions(-) create mode 100644 .changeset/lucky-teams-play.md create mode 100644 packages/astro/test/fixtures/astro-manifest-client-script/astro.config.mjs create mode 100644 packages/astro/test/fixtures/astro-manifest-client-script/package.json create mode 100644 packages/astro/test/fixtures/astro-manifest-client-script/src/pages/index.astro diff --git a/.changeset/lucky-teams-play.md b/.changeset/lucky-teams-play.md new file mode 100644 index 000000000000..e263be2d4b41 --- /dev/null +++ b/.changeset/lucky-teams-play.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a build error where using `astro:config/client` inside a ` + + diff --git a/packages/astro/test/serializeManifest.test.js b/packages/astro/test/serializeManifest.test.js index a7af6f6423a3..2a36352ede93 100644 --- a/packages/astro/test/serializeManifest.test.js +++ b/packages/astro/test/serializeManifest.test.js @@ -89,6 +89,26 @@ describe('astro:config/client', () => { }); }); +describe('astro:config/client in a client script', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + describe('when build', () => { + before(async () => { + fixture = await loadFixture({ + root: './fixtures/astro-manifest-client-script/', + adapter: testAdapter(), + output: 'server', + }); + }); + + it('should build without errors when astro:config/client is used in a client script', async () => { + const error = await fixture.build().catch((err) => err); + assert.equal(error, undefined, `Build failed with: ${error?.message}`); + }); + }); +}); + describe('astro:config/server', () => { /** @type {import('./test-utils').Fixture} */ let fixture; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13a9ef7a06fb..bce060623058 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2287,6 +2287,12 @@ importers: specifier: workspace:* version: link:../../.. + packages/astro/test/fixtures/astro-manifest-client-script: + dependencies: + astro: + specifier: workspace:* + version: link:../../.. + packages/astro/test/fixtures/astro-manifest-invalid: dependencies: astro: