Skip to content

Commit

Permalink
fix(cloudflare): using vue breaks builds (#210)
Browse files Browse the repository at this point in the history
Co-authored-by: Emanuele Stoppa <[email protected]>
  • Loading branch information
alexanderniebuhr and ematipico authored Mar 29, 2024
1 parent 38da2ca commit 317bd95
Show file tree
Hide file tree
Showing 4 changed files with 1,303 additions and 1,942 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-cooks-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---

fixes an issue where projects using `@astrojs/vue` were unusable, due to marking dependencies as external
2 changes: 1 addition & 1 deletion packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"miniflare": "^3.20240320.0",
"esbuild": "^0.19.5",
"tiny-glob": "^0.2.9",
"wrangler": "^3.36.0"
"wrangler": "^3.39.0"
},
"peerDependencies": {
"astro": "^4.2.0"
Expand Down
13 changes: 12 additions & 1 deletion packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,18 @@ export default function createIntegration(args?: Options): AstroIntegration {
vite.ssr ||= {};
vite.ssr.target = 'webworker';
vite.ssr.noExternal = true;
vite.ssr.external = _config.vite.ssr?.external ?? [];

if (typeof _config.vite.ssr?.external === 'undefined') vite.ssr.external = [];
if (typeof _config.vite.ssr?.external === 'boolean')
vite.ssr.external = _config.vite.ssr?.external;
if (Array.isArray(_config.vite.ssr?.external))
// `@astrojs/vue` sets `@vue/server-renderer` to external
// https://github.com/withastro/astro/blob/e648c5575a8774af739231cfa9fc27a32086aa5f/packages/integrations/vue/src/index.ts#L119
// the cloudflare adapter needs to get all dependencies inlined, we use `noExternal` for that, but any `external` config overrides that
// therefore we need to remove `@vue/server-renderer` from the external config again
vite.ssr.external = _config.vite.ssr?.external.filter(
(entry) => entry !== '@vue/server-renderer'
);

vite.build ||= {};
vite.build.rollupOptions ||= {};
Expand Down
Loading

0 comments on commit 317bd95

Please sign in to comment.