From 7bb96bbde0a19192d541d80e963610bc303f9fb2 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 23 Jan 2023 23:00:05 +0800 Subject: [PATCH] Handle custom injected entry files during build (#5499) --- .changeset/kind-seahorses-reply.md | 5 +++++ packages/astro/src/core/build/static-build.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/kind-seahorses-reply.md diff --git a/.changeset/kind-seahorses-reply.md b/.changeset/kind-seahorses-reply.md new file mode 100644 index 000000000..03ca7b07b --- /dev/null +++ b/.changeset/kind-seahorses-reply.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Handle custom injected entry files during build diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 03084625b..fba8449f9 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -15,6 +15,7 @@ import { appendForwardSlash, prependForwardSlash } from '../../core/path.js'; import { isModeServerWithNoAdapter } from '../../core/util.js'; import { runHookBuildSetup } from '../../integrations/index.js'; import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; +import { resolvedPagesVirtualModuleId } from '../app/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { info } from '../logger/core.js'; import { getOutDirWithinCwd } from './common.js'; @@ -138,7 +139,13 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp chunkFileNames: `chunks/[name].[hash].mjs`, assetFileNames: `${settings.config.build.assets}/[name].[hash][extname]`, ...viteConfig.build?.rollupOptions?.output, - entryFileNames: opts.buildConfig.serverEntry, + entryFileNames(chunkInfo) { + if (chunkInfo.facadeModuleId === resolvedPagesVirtualModuleId) { + return opts.buildConfig.serverEntry; + } else { + return '[name].mjs'; + } + }, }, }, ssr: true,