-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use .mjs extension when building for netlify edge and vercel serverle…
…ss (#6317)
- Loading branch information
Showing
13 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@astrojs/netlify': patch | ||
'@astrojs/vercel': patch | ||
--- | ||
|
||
Use .mjs extension when building to support CJS environments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/integrations/netlify/test/edge-functions/fixtures/prerender/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import { netlifyEdgeFunctions } from '@astrojs/netlify'; | ||
|
||
export default defineConfig({ | ||
adapter: netlifyEdgeFunctions({ | ||
dist: new URL('./dist/', import.meta.url), | ||
}), | ||
output: 'server', | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/integrations/netlify/test/edge-functions/fixtures/prerender/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/astro-netlify-prerender", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/netlify": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/integrations/netlify/test/edge-functions/fixtures/prerender/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
export const prerender = true | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>testing</title> | ||
</head> | ||
<body> | ||
<h1>testing</h1> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
packages/integrations/netlify/test/edge-functions/prerender.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// @ts-ignore | ||
import { runBuild } from './test-utils.ts'; | ||
// @ts-ignore | ||
import { assertEquals } from './deps.ts'; | ||
|
||
// @ts-ignore | ||
Deno.test({ | ||
name: 'Prerender', | ||
async fn() { | ||
let close = await runBuild('./fixtures/prerender/'); | ||
const { default: handler } = await import( | ||
'./fixtures/prerender/.netlify/edge-functions/entry.mjs' | ||
); | ||
const response = await handler(new Request('http://example.com/index.html')); | ||
assertEquals(response, undefined, 'No response because this is an asset'); | ||
await close(); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/integrations/vercel/test/fixtures/serverless-prerender/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import vercel from '@astrojs/vercel/serverless'; | ||
|
||
export default defineConfig({ | ||
adapter: vercel(), | ||
output: 'server' | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/integrations/vercel/test/fixtures/serverless-prerender/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/astro-vercel-serverless-prerender", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/vercel": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/integrations/vercel/test/fixtures/serverless-prerender/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
export const prerender = true | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>testing</title> | ||
</head> | ||
<body> | ||
<h1>testing</h1> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
packages/integrations/vercel/test/serverless-prerender.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { loadFixture } from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('Serverless prerender', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/serverless-prerender/', | ||
}); | ||
}); | ||
|
||
it('build successful', async () => { | ||
await fixture.build(); | ||
expect(fixture.readFile('/static/index.html')).to.be.ok; | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.