Skip to content

Commit 8bd49c9

Browse files
authored
fix(integrations): astro:build:done dir now matches SSR client output (#3008)
* `dir` now matches client output * Updated integrations * Changeset
1 parent 13b782f commit 8bd49c9

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

.changeset/empty-pens-talk.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'astro': patch
3+
'@astrojs/partytown': patch
4+
'@astrojs/vercel': patch
5+
---
6+
7+
Updated integrations' `astro:build:done` hook: now it matches the client dist when using SSR

packages/astro/src/core/build/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class AstroBuilder {
174174
await viteServer.close();
175175
await runHookBuildDone({
176176
config: this.config,
177+
buildConfig,
177178
pages: pageNames,
178179
routes: Object.values(allPages).map((pd) => pd.route),
179180
});

packages/astro/src/integrations/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AstroConfig, AstroRenderer, BuildConfig, RouteData } from '../@types/as
44
import { mergeConfig } from '../core/config.js';
55
import ssgAdapter from '../adapter-ssg/index.js';
66
import type { ViteConfigWithSSR } from '../core/create-vite.js';
7+
import { isBuildingToSSR } from '../core/util.js';
78

89
export async function runHookConfigSetup({
910
config: _config,
@@ -136,18 +137,22 @@ export async function runHookBuildSetup({
136137

137138
export async function runHookBuildDone({
138139
config,
140+
buildConfig,
139141
pages,
140142
routes,
141143
}: {
142144
config: AstroConfig;
145+
buildConfig: BuildConfig;
143146
pages: string[];
144147
routes: RouteData[];
145148
}) {
149+
const dir = isBuildingToSSR(config) ? buildConfig.client : config.outDir;
150+
146151
for (const integration of config.integrations) {
147152
if (integration.hooks['astro:build:done']) {
148153
await integration.hooks['astro:build:done']({
149154
pages: pages.map((p) => ({ pathname: p })),
150-
dir: config.outDir,
155+
dir,
151156
routes,
152157
});
153158
}

packages/integrations/partytown/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export default function createPlugin(): AstroIntegration {
3232
})
3333
);
3434
},
35-
'astro:build:done': async () => {
36-
await copyLibFiles(fileURLToPath(new URL('~partytown', config.outDir)), {
35+
'astro:build:done': async ({ dir }) => {
36+
await copyLibFiles(fileURLToPath(new URL('~partytown', dir)), {
3737
debugDir: false,
3838
});
3939
},

packages/integrations/vercel/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function vercel(): AstroIntegration {
3535
buildConfig.client = new URL('./static/', _config.outDir);
3636
buildConfig.server = new URL('./server/tmp/', _config.outDir);
3737
},
38-
'astro:build:done': async ({ dir, routes }) => {
38+
'astro:build:done': async ({ routes }) => {
3939
/*
4040
Why do we need two folders? Why don't we just generate all inside `server/pages/`?
4141
When the app builds, it throws some metadata inside a `chunks/` folder.
@@ -50,8 +50,8 @@ export default function vercel(): AstroIntegration {
5050
need to bundle as much as possible in one file. Hence, the following code
5151
*/
5252

53-
const tmpDir = new URL('./server/tmp/', dir);
54-
const bundleDir = new URL('./server/pages/', dir);
53+
const tmpDir = new URL('./server/tmp/', _config.outDir);
54+
const bundleDir = new URL('./server/pages/', _config.outDir);
5555

5656
await fs.mkdir(bundleDir, { recursive: true });
5757

@@ -69,7 +69,7 @@ export default function vercel(): AstroIntegration {
6969

7070
// Routes Manifest
7171
// https://vercel.com/docs/file-system-api#configuration/routes
72-
await writeJson(new URL(`./routes-manifest.json`, dir), {
72+
await writeJson(new URL(`./routes-manifest.json`, _config.outDir), {
7373
version: 3,
7474
basePath: '/',
7575
pages404: false,

0 commit comments

Comments
 (0)