Skip to content

Commit 05cf1a5

Browse files
authored
Adjustments for Netlify Edge Functions (#3150)
* Adjustments for Netlify Edge Functions * Adds a changeset
1 parent 44e294c commit 05cf1a5

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.changeset/small-radios-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/netlify': patch
3+
---
4+
5+
Outputs manifest.json in correct folder for Netlify Edge Functions

packages/integrations/netlify/src/integration-edge-functions.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function createEdgeManifest(routes: RouteData[], entryFile: string, dir: U
4343
} else {
4444
functions.push({
4545
function: entryFile,
46-
pattern: route.pattern.source,
46+
pattern: route.pattern.toString(),
4747
});
4848
}
4949
}
@@ -53,7 +53,10 @@ async function createEdgeManifest(routes: RouteData[], entryFile: string, dir: U
5353
version: 1,
5454
};
5555

56-
const manifestURL = new URL('./manifest.json', dir);
56+
const baseDir = new URL('./.netlify/edge-functions/', dir)
57+
await fs.promises.mkdir(baseDir, { recursive: true });
58+
59+
const manifestURL = new URL('./manifest.json', baseDir);
5760
const _manifest = JSON.stringify(manifest, null, ' ');
5861
await fs.promises.writeFile(manifestURL, _manifest, 'utf-8');
5962
}
@@ -79,6 +82,7 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
7982
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
8083
buildConfig.client = _config.outDir;
8184
buildConfig.server = new URL('./edge-functions/', _config.outDir);
85+
buildConfig.serverEntry = 'entry.js';
8286
},
8387
'astro:build:setup': ({ vite, target }) => {
8488
if (target === 'server') {
@@ -88,7 +92,7 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
8892
}
8993
},
9094
'astro:build:done': async ({ routes, dir }) => {
91-
await createEdgeManifest(routes, entryFile, new URL('./edge-functions/', dir));
95+
await createEdgeManifest(routes, entryFile, _config.root);
9296
},
9397
},
9498
};

0 commit comments

Comments
 (0)