fix(integrations): astro:build:done
dir now matches SSR client output (#3008)
* `dir` now matches client output * Updated integrations * Changeset
This commit is contained in:
parent
13b782f421
commit
8bd49c9536
5 changed files with 20 additions and 7 deletions
7
.changeset/empty-pens-talk.md
Normal file
7
.changeset/empty-pens-talk.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
'@astrojs/partytown': patch
|
||||||
|
'@astrojs/vercel': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Updated integrations' `astro:build:done` hook: now it matches the client dist when using SSR
|
|
@ -174,6 +174,7 @@ class AstroBuilder {
|
||||||
await viteServer.close();
|
await viteServer.close();
|
||||||
await runHookBuildDone({
|
await runHookBuildDone({
|
||||||
config: this.config,
|
config: this.config,
|
||||||
|
buildConfig,
|
||||||
pages: pageNames,
|
pages: pageNames,
|
||||||
routes: Object.values(allPages).map((pd) => pd.route),
|
routes: Object.values(allPages).map((pd) => pd.route),
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { AstroConfig, AstroRenderer, BuildConfig, RouteData } from '../@types/as
|
||||||
import { mergeConfig } from '../core/config.js';
|
import { mergeConfig } from '../core/config.js';
|
||||||
import ssgAdapter from '../adapter-ssg/index.js';
|
import ssgAdapter from '../adapter-ssg/index.js';
|
||||||
import type { ViteConfigWithSSR } from '../core/create-vite.js';
|
import type { ViteConfigWithSSR } from '../core/create-vite.js';
|
||||||
|
import { isBuildingToSSR } from '../core/util.js';
|
||||||
|
|
||||||
export async function runHookConfigSetup({
|
export async function runHookConfigSetup({
|
||||||
config: _config,
|
config: _config,
|
||||||
|
@ -136,18 +137,22 @@ export async function runHookBuildSetup({
|
||||||
|
|
||||||
export async function runHookBuildDone({
|
export async function runHookBuildDone({
|
||||||
config,
|
config,
|
||||||
|
buildConfig,
|
||||||
pages,
|
pages,
|
||||||
routes,
|
routes,
|
||||||
}: {
|
}: {
|
||||||
config: AstroConfig;
|
config: AstroConfig;
|
||||||
|
buildConfig: BuildConfig;
|
||||||
pages: string[];
|
pages: string[];
|
||||||
routes: RouteData[];
|
routes: RouteData[];
|
||||||
}) {
|
}) {
|
||||||
|
const dir = isBuildingToSSR(config) ? buildConfig.client : config.outDir;
|
||||||
|
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration.hooks['astro:build:done']) {
|
if (integration.hooks['astro:build:done']) {
|
||||||
await integration.hooks['astro:build:done']({
|
await integration.hooks['astro:build:done']({
|
||||||
pages: pages.map((p) => ({ pathname: p })),
|
pages: pages.map((p) => ({ pathname: p })),
|
||||||
dir: config.outDir,
|
dir,
|
||||||
routes,
|
routes,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@ export default function createPlugin(): AstroIntegration {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'astro:build:done': async () => {
|
'astro:build:done': async ({ dir }) => {
|
||||||
await copyLibFiles(fileURLToPath(new URL('~partytown', config.outDir)), {
|
await copyLibFiles(fileURLToPath(new URL('~partytown', dir)), {
|
||||||
debugDir: false,
|
debugDir: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,7 +35,7 @@ export default function vercel(): AstroIntegration {
|
||||||
buildConfig.client = new URL('./static/', _config.outDir);
|
buildConfig.client = new URL('./static/', _config.outDir);
|
||||||
buildConfig.server = new URL('./server/tmp/', _config.outDir);
|
buildConfig.server = new URL('./server/tmp/', _config.outDir);
|
||||||
},
|
},
|
||||||
'astro:build:done': async ({ dir, routes }) => {
|
'astro:build:done': async ({ routes }) => {
|
||||||
/*
|
/*
|
||||||
Why do we need two folders? Why don't we just generate all inside `server/pages/`?
|
Why do we need two folders? Why don't we just generate all inside `server/pages/`?
|
||||||
When the app builds, it throws some metadata inside a `chunks/` folder.
|
When the app builds, it throws some metadata inside a `chunks/` folder.
|
||||||
|
@ -50,8 +50,8 @@ export default function vercel(): AstroIntegration {
|
||||||
need to bundle as much as possible in one file. Hence, the following code
|
need to bundle as much as possible in one file. Hence, the following code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const tmpDir = new URL('./server/tmp/', dir);
|
const tmpDir = new URL('./server/tmp/', _config.outDir);
|
||||||
const bundleDir = new URL('./server/pages/', dir);
|
const bundleDir = new URL('./server/pages/', _config.outDir);
|
||||||
|
|
||||||
await fs.mkdir(bundleDir, { recursive: true });
|
await fs.mkdir(bundleDir, { recursive: true });
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ export default function vercel(): AstroIntegration {
|
||||||
|
|
||||||
// Routes Manifest
|
// Routes Manifest
|
||||||
// https://vercel.com/docs/file-system-api#configuration/routes
|
// https://vercel.com/docs/file-system-api#configuration/routes
|
||||||
await writeJson(new URL(`./routes-manifest.json`, dir), {
|
await writeJson(new URL(`./routes-manifest.json`, _config.outDir), {
|
||||||
version: 3,
|
version: 3,
|
||||||
basePath: '/',
|
basePath: '/',
|
||||||
pages404: false,
|
pages404: false,
|
||||||
|
|
Loading…
Reference in a new issue