Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustments for Netlify Edge Functions #3150

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-radios-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/netlify': patch
---

Outputs manifest.json in correct folder for Netlify Edge Functions
10 changes: 7 additions & 3 deletions packages/integrations/netlify/src/integration-edge-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function createEdgeManifest(routes: RouteData[], entryFile: string, dir: U
} else {
functions.push({
function: entryFile,
pattern: route.pattern.source,
pattern: route.pattern.toString(),
});
}
}
Expand All @@ -53,7 +53,10 @@ async function createEdgeManifest(routes: RouteData[], entryFile: string, dir: U
version: 1,
};

const manifestURL = new URL('./manifest.json', dir);
const baseDir = new URL('./.netlify/edge-functions/', dir)
await fs.promises.mkdir(baseDir, { recursive: true });

const manifestURL = new URL('./manifest.json', baseDir);
const _manifest = JSON.stringify(manifest, null, ' ');
await fs.promises.writeFile(manifestURL, _manifest, 'utf-8');
}
Expand All @@ -79,6 +82,7 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
buildConfig.client = _config.outDir;
buildConfig.server = new URL('./edge-functions/', _config.outDir);
buildConfig.serverEntry = 'entry.js';
},
'astro:build:setup': ({ vite, target }) => {
if (target === 'server') {
Expand All @@ -88,7 +92,7 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
}
},
'astro:build:done': async ({ routes, dir }) => {
await createEdgeManifest(routes, entryFile, new URL('./edge-functions/', dir));
await createEdgeManifest(routes, entryFile, _config.root);
},
},
};
Expand Down