diff options
author | 2024-03-29 12:43:37 +0100 | |
---|---|---|
committer | 2024-03-29 12:43:37 +0100 | |
commit | fc292ec1de767319bbd66a7b1c364510b7271abf (patch) | |
tree | 36d3f98470df9b6fbef233bc3b882ca94eb23b67 /packages/integrations/cloudflare/src | |
parent | 2031f63a552c6e288d9ac6e8792a5a2f9bba04bb (diff) | |
download | astro-fc292ec1de767319bbd66a7b1c364510b7271abf.tar.gz astro-fc292ec1de767319bbd66a7b1c364510b7271abf.tar.zst astro-fc292ec1de767319bbd66a7b1c364510b7271abf.zip |
fix(cloudflare): using solid with client directive breaks build (#212)
Co-authored-by: Emanuele Stoppa <602478+ematipico@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/cloudflare/src')
-rw-r--r-- | packages/integrations/cloudflare/src/index.ts | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 7b57b9621..8d7fccdfa 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -152,14 +152,6 @@ export default function createIntegration(args?: Options): AstroIntegration { find: 'react-dom/server', replacement: 'react-dom/server.browser', }, - { - find: 'solid-js/web', - replacement: 'solid-js/web/dist/server', - }, - { - find: 'solid-js', - replacement: 'solid-js/dist/server', - }, ]; if (Array.isArray(vite.resolve.alias)) { @@ -170,6 +162,11 @@ export default function createIntegration(args?: Options): AstroIntegration { } } + vite.resolve.conditions ||= []; + // We need those conditions, previous these conditions where applied at the esbuild step which we removed + // https://github.com/withastro/astro/pull/7092 + vite.resolve.conditions.push('workerd', 'worker'); + vite.ssr ||= {}; vite.ssr.target = 'webworker'; vite.ssr.noExternal = true; @@ -202,6 +199,17 @@ export default function createIntegration(args?: Options): AstroIntegration { ...vite.define, }; } + // we thought that vite config inside `if (target === 'server')` would not apply for client + // but it seems like the same `vite` reference is used for both + // so we need to reset the previous conflicting setting + // in the future we should look into a more robust solution + if (target === 'client') { + vite.resolve ||= {}; + vite.resolve.conditions ||= []; + vite.resolve.conditions = vite.resolve.conditions.filter( + (c) => c !== 'workerd' && c !== 'worker' + ); + } }, 'astro:build:done': async ({ pages, routes, dir, logger }) => { const PLATFORM_FILES = ['_headers', '_redirects', '_routes.json']; |