fix(#5723): build prerendered pages with Netlify edge functions (#5885)

* fix(#5723): build prerendered pages with Netlify edge functions

* chore: add changeset

Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
Nate Moore 2023-01-18 12:54:49 -06:00 committed by GitHub
parent dc2496f702
commit 8f1ae06e58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 15 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/netlify': patch
---
Fix issue with prerendered pages when using `edge-functions` adapter

View file

@ -117,18 +117,6 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
name: '@astrojs/netlify/edge-functions',
hooks: {
'astro:config:setup': ({ config, updateConfig }) => {
// Add a plugin that shims the global environment.
const injectPlugin: VitePlugin = {
name: '@astrojs/netlify/plugin-inject',
generateBundle(_options, bundle) {
if (_buildConfig.serverEntry in bundle) {
const chunk = bundle[_buildConfig.serverEntry];
if (chunk && chunk.type === 'chunk') {
chunk.code = `globalThis.process = { argv: [], env: {}, };${chunk.code}`;
}
}
},
};
const outDir = dist ?? new URL('./dist/', config.root);
updateConfig({
outDir,
@ -137,9 +125,6 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
server: new URL('./.netlify/edge-functions/', config.root),
serverEntry: 'entry.js',
},
vite: {
plugins: [injectPlugin],
},
});
},
'astro:config:done': ({ config, setAdapter }) => {