fix: solidjs integration for vercel edge build (adopting same mechanics as cloudflare) (#6085)
* fix solidjs integration for vercel deployment * downgrade change to patch --------- Co-authored-by: AirBorne04 <>
This commit is contained in:
parent
2934c3a9e9
commit
39aae03429
2 changed files with 21 additions and 8 deletions
5
.changeset/wild-seas-happen.md
Normal file
5
.changeset/wild-seas-happen.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/vercel': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Added second build step through esbuild, to allow framework defined build (vite build) and target defined bundling (esbuilt step)
|
|
@ -1,4 +1,5 @@
|
||||||
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
|
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
|
||||||
|
import esbuild from 'esbuild';
|
||||||
import { relative as relativePath } from 'node:path';
|
import { relative as relativePath } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
@ -74,18 +75,25 @@ export default function vercelEdge({ includeFiles = [] }: VercelEdgeConfig = {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vite.ssr = {
|
vite.ssr ||= {};
|
||||||
target: 'webworker',
|
vite.ssr.target ||= 'webworker';
|
||||||
noExternal: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
vite.build ||= {};
|
|
||||||
vite.build.minify = true;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'astro:build:done': async ({ routes }) => {
|
'astro:build:done': async ({ routes }) => {
|
||||||
const entry = new URL(serverEntry, buildTempFolder);
|
const entry = new URL(serverEntry, buildTempFolder);
|
||||||
const generatedFiles = await getFilesFromFolder(buildTempFolder);
|
const generatedFiles = await getFilesFromFolder(buildTempFolder);
|
||||||
|
const entryPath = fileURLToPath(entry);
|
||||||
|
|
||||||
|
await esbuild.build({
|
||||||
|
target: 'es2020',
|
||||||
|
platform: 'browser',
|
||||||
|
entryPoints: [entryPath],
|
||||||
|
outfile: entryPath,
|
||||||
|
allowOverwrite: true,
|
||||||
|
format: 'esm',
|
||||||
|
bundle: true,
|
||||||
|
minify: true,
|
||||||
|
});
|
||||||
|
|
||||||
// Copy entry and other server files
|
// Copy entry and other server files
|
||||||
const commonAncestor = await copyFilesToFunction(
|
const commonAncestor = await copyFilesToFunction(
|
||||||
|
@ -100,7 +108,7 @@ export default function vercelEdge({ includeFiles = [] }: VercelEdgeConfig = {})
|
||||||
// https://vercel.com/docs/build-output-api/v3#vercel-primitives/edge-functions/configuration
|
// https://vercel.com/docs/build-output-api/v3#vercel-primitives/edge-functions/configuration
|
||||||
await writeJson(new URL(`./.vc-config.json`, functionFolder), {
|
await writeJson(new URL(`./.vc-config.json`, functionFolder), {
|
||||||
runtime: 'edge',
|
runtime: 'edge',
|
||||||
entrypoint: relativePath(commonAncestor, fileURLToPath(entry)),
|
entrypoint: relativePath(commonAncestor, entryPath),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Output configuration
|
// Output configuration
|
||||||
|
|
Loading…
Reference in a new issue