Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solidjs integration for vercel edge build (adopting same mechanics as cloudflare) #6085

Merged
merged 3 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-seas-happen.md
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 16 additions & 8 deletions packages/integrations/vercel/src/edge/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
import esbuild from 'esbuild';
import { relative as relativePath } from 'node:path';
import { fileURLToPath } from 'node:url';

Expand Down Expand Up @@ -74,18 +75,25 @@ export default function vercelEdge({ includeFiles = [] }: VercelEdgeConfig = {})
}
}

vite.ssr = {
target: 'webworker',
noExternal: true,
};

vite.build ||= {};
vite.build.minify = true;
vite.ssr ||= {};
vite.ssr.target ||= 'webworker';
}
},
'astro:build:done': async ({ routes }) => {
const entry = new URL(serverEntry, 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
const commonAncestor = await copyFilesToFunction(
Expand All @@ -100,7 +108,7 @@ export default function vercelEdge({ includeFiles = [] }: VercelEdgeConfig = {})
// https://vercel.com/docs/build-output-api/v3#vercel-primitives/edge-functions/configuration
await writeJson(new URL(`./.vc-config.json`, functionFolder), {
runtime: 'edge',
entrypoint: relativePath(commonAncestor, fileURLToPath(entry)),
entrypoint: relativePath(commonAncestor, entryPath),
});

// Output configuration
Expand Down