Skip to content

Commit b16b7a4

Browse files
authored
Use .mjs extension when building for netlify edge and vercel serverless (#6317)
1 parent 89f6b22 commit b16b7a4

6 files changed

Lines changed: 50 additions & 2 deletions

File tree

packages/integrations/netlify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"build:ci": "astro-scripts build \"src/**/*.ts\"",
3131
"dev": "astro-scripts dev \"src/**/*.ts\"",
3232
"test-fn": "mocha --exit --timeout 20000 test/functions/",
33-
"test-edge": "deno test --allow-run --allow-read --allow-net ./test/edge-functions/",
33+
"test-edge": "deno test --allow-run --allow-read --allow-net --allow-env ./test/edge-functions/",
3434
"test": "npm run test-fn"
3535
},
3636
"dependencies": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
122122
build: {
123123
client: outDir,
124124
server: new URL('./.netlify/edge-functions/', config.root),
125-
serverEntry: 'entry.js',
125+
serverEntry: 'entry.mjs',
126126
},
127127
});
128128
},
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from 'astro/config';
2+
import { netlifyEdgeFunctions } from '@astrojs/netlify';
3+
4+
export default defineConfig({
5+
adapter: netlifyEdgeFunctions({
6+
dist: new URL('./dist/', import.meta.url),
7+
}),
8+
output: 'server',
9+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@test/astro-netlify-prerender",
3+
"version": "0.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"@astrojs/netlify": "workspace:*",
7+
"astro": "workspace:*"
8+
}
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
export const prerender = true
3+
---
4+
5+
<html>
6+
<head>
7+
<title>testing</title>
8+
</head>
9+
<body>
10+
<h1>testing</h1>
11+
</body>
12+
</html>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @ts-ignore
2+
import { runBuild } from './test-utils.ts';
3+
// @ts-ignore
4+
import { assertEquals } from './deps.ts';
5+
6+
// @ts-ignore
7+
Deno.test({
8+
name: 'Prerender',
9+
async fn() {
10+
let close = await runBuild('./fixtures/prerender/');
11+
const { default: handler } = await import(
12+
'./fixtures/prerender/.netlify/edge-functions/entry.mjs'
13+
);
14+
const response = await handler(new Request('http://example.com/index.html'));
15+
assertEquals(response, undefined, 'No response because this is an asset');
16+
await close();
17+
},
18+
});

0 commit comments

Comments
 (0)