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

Build edge/worker runtime with webworker ssr target #7101

Merged
merged 2 commits into from
May 17, 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/quiet-gifts-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': patch
---

Add missing esbuild dependency
7 changes: 7 additions & 0 deletions .changeset/silver-ties-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astrojs/cloudflare': patch
'@astrojs/vercel': patch
'@astrojs/solid-js': patch
---

Always build edge/worker runtime with Vite `webworker` SSR target
8 changes: 4 additions & 4 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export default function createIntegration(args?: Options): AstroIntegration {
},
'astro:build:setup': ({ vite, target }) => {
if (target === 'server') {
vite.resolve = vite.resolve || {};
vite.resolve.alias = vite.resolve.alias || {};
vite.resolve ||= {};
vite.resolve.alias ||= {};

const aliases = [{ find: 'react-dom/server', replacement: 'react-dom/server.browser' }];

Expand All @@ -84,8 +84,8 @@ export default function createIntegration(args?: Options): AstroIntegration {
(vite.resolve.alias as Record<string, string>)[alias.find] = alias.replacement;
}
}
vite.ssr = vite.ssr || {};
vite.ssr.target = vite.ssr.target || 'webworker';
vite.ssr ||= {};
vite.ssr.target = 'webworker';
}
},
'astro:build:done': async ({ pages }) => {
Expand Down
1 change: 0 additions & 1 deletion packages/integrations/solid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ async function getViteConfiguration(isDev: boolean, astroConfig: AstroConfig) {
exclude: ['@astrojs/solid-js/server.js', ...solidPkgsConfig.optimizeDeps.exclude],
},
ssr: {
target: 'node',
external: ['babel-preset-solid', ...solidPkgsConfig.ssr.external],
noExternal: [...solidPkgsConfig.ssr.noExternal],
},
Expand Down
1 change: 1 addition & 0 deletions packages/integrations/vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@astrojs/webapi": "^2.1.1",
"@vercel/analytics": "^0.1.8",
"@vercel/nft": "^0.22.1",
"esbuild": "^0.17.12",
"fast-glob": "^3.2.11",
"set-cookie-parser": "^2.5.1",
"web-vitals": "^3.1.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/vercel/src/edge/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default function vercelEdge({
}

vite.ssr ||= {};
vite.ssr.target ||= 'webworker';
vite.ssr.target = 'webworker';

// Vercel edge runtime is a special webworker-ish environment that supports process.env,
// but Vite would replace away `process.env` in webworkers, so we set a define here to prevent it
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.