Skip to content

Commit

Permalink
fix: correctly add react-dom alias to Vercel edge (#4421)
Browse files Browse the repository at this point in the history
* fix: correctly add react-dom alias to vercel edge

* chore: changeset
  • Loading branch information
bholmesdev authored Aug 22, 2022
1 parent 39088e1 commit 7820096
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-pants-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': patch
---

Fix react-dom on Vercel edge
13 changes: 11 additions & 2 deletions packages/integrations/vercel/src/edge/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ export default function vercelEdge(): AstroIntegration {
if (target === 'server') {
vite.resolve ||= {};
vite.resolve.alias ||= {};
const alias = vite.resolve.alias as Record<string, string>;
alias['react-dom/server'] = 'react-dom/server.browser';

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

if (Array.isArray(vite.resolve.alias)) {
vite.resolve.alias = [...vite.resolve.alias, ...aliases];
} else {
for (const alias of aliases) {
(vite.resolve.alias as Record<string, string>)[alias.find] = alias.replacement;
}
}

vite.ssr = {
noExternal: true,
};
Expand Down

0 comments on commit 7820096

Please sign in to comment.