-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: include route prefix in vercel func names * chore: add changeset * chore: update pnpm lockfile * refactor: simplify logic that generates vercel func names * fix: properly remove entryFile prefix from func name * refactor: change how vercel function names are generated --------- Co-authored-by: Nate Moore <[email protected]>
- Loading branch information
1 parent
61ad70f
commit 9ffa1a8
Showing
10 changed files
with
104 additions
and
6 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,5 @@ | ||
--- | ||
'@astrojs/vercel': patch | ||
--- | ||
|
||
Fix serverless function naming conflicts for routes with identical filenames but different directory structures |
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
10 changes: 10 additions & 0 deletions
10
packages/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/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,10 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import vercel from '@astrojs/vercel/serverless'; | ||
|
||
export default defineConfig({ | ||
adapter: vercel({ | ||
// Pass some value to make sure it doesn't error out | ||
includeFiles: ['included.js'], | ||
}), | ||
output: 'server' | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/included.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 @@ | ||
'works' |
9 changes: 9 additions & 0 deletions
9
packages/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/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-with-dynamic-routes", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/vercel": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...tegrations/vercel/test/fixtures/serverless-with-dynamic-routes/src/pages/[id]/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 = false; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>testing {Astro.params.id}</title> | ||
</head> | ||
<body> | ||
<h1>testing {Astro.params.id}</h1> | ||
</body> | ||
</html> |
7 changes: 7 additions & 0 deletions
7
...es/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/src/pages/api/[id].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,7 @@ | ||
export const prerender = false; | ||
|
||
export async function GET({ params }) { | ||
return Response.json({ | ||
id: params.id | ||
}); | ||
} |
12 changes: 12 additions & 0 deletions
12
...es/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/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 = import.meta.env.PRERENDER; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>testing</title> | ||
</head> | ||
<body> | ||
<h1>testing</h1> | ||
</body> | ||
</html> |
22 changes: 22 additions & 0 deletions
22
packages/integrations/vercel/test/serverless-with-dynamic-routes.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,22 @@ | ||
import { expect } from 'chai'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Serverless with dynamic routes', () => { | ||
/** @type {import('./test-utils.js').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
process.env.PRERENDER = true; | ||
fixture = await loadFixture({ | ||
root: './fixtures/serverless-with-dynamic-routes/', | ||
output: 'hybrid', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('build successful', async () => { | ||
expect(await fixture.readFile('../.vercel/output/static/index.html')).to.be.ok; | ||
expect(await fixture.readFile('../.vercel/output/functions/[id]/index.astro.func/.vc-config.json')).to.be.ok; | ||
expect(await fixture.readFile('../.vercel/output/functions/api/[id].js.func/.vc-config.json')).to.be.ok; | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.