fix: correctly add react-dom
alias to Vercel edge (#4421)
* fix: correctly add react-dom alias to vercel edge * chore: changeset
This commit is contained in:
parent
39088e11db
commit
7820096e1b
2 changed files with 16 additions and 2 deletions
5
.changeset/heavy-pants-change.md
Normal file
5
.changeset/heavy-pants-change.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/vercel': patch
|
||||
---
|
||||
|
||||
Fix react-dom on Vercel edge
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue