From b895113a0ae347ecd81bd8866ae2d816ea20836b Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Tue, 14 Nov 2023 07:53:14 +0100 Subject: [PATCH] fix(assets): bundling regression for specific config on non-Node runtimes (#9087) --- .changeset/red-houses-explode.md | 5 +++++ packages/astro/src/core/build/plugins/plugin-prerender.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/red-houses-explode.md diff --git a/.changeset/red-houses-explode.md b/.changeset/red-houses-explode.md new file mode 100644 index 000000000000..d355327f34a6 --- /dev/null +++ b/.changeset/red-houses-explode.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes the regression which broke bundling of image service for pre-rendered pages, which was introduced by [#8854](https://github.com/withastro/astro/pull/8854) diff --git a/packages/astro/src/core/build/plugins/plugin-prerender.ts b/packages/astro/src/core/build/plugins/plugin-prerender.ts index d3d5305e4f43..0584f15a6b59 100644 --- a/packages/astro/src/core/build/plugins/plugin-prerender.ts +++ b/packages/astro/src/core/build/plugins/plugin-prerender.ts @@ -12,7 +12,11 @@ function vitePluginPrerender(opts: StaticBuildOptions, internals: BuildInternals outputOptions(outputOptions) { extendManualChunks(outputOptions, { - before(id, meta) { + after(id, meta) { + // Split the Astro runtime into a separate chunk for readability + if (id.includes('astro/dist/runtime')) { + return 'astro'; + } const pageInfo = internals.pagesByViteID.get(id); if (pageInfo) { // prerendered pages should be split into their own chunk