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

feat: Vercel adapter #2915

Merged
merged 26 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
dist/
.output/
*.tsbuildinfo
.DS_Store
.vercel
Expand Down
3 changes: 2 additions & 1 deletion examples/blog-multiple-authors/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/blog/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/component/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/env-vars/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-alpine/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-lit/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-multiple/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-preact/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-react/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-solid/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-svelte/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/framework-vue/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/integrations-playground/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/minimal/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/non-html-pages/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/portfolio/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/starter/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/subpath/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/with-markdown-plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/with-markdown-shiki/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/with-markdown/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/with-nanostores/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/with-tailwindcss/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion examples/with-vite-plugin-pwa/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist
dist/
.output/

# dependencies
node_modules/
Expand Down
10 changes: 5 additions & 5 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,11 @@ export interface AstroIntegration {
// injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
}) => void;
'astro:config:done'?: (options: { config: AstroConfig; setAdapter: (adapter: AstroAdapter) => void }) => void | Promise<void>;
'astro:server:setup'?: (options: { server: vite.ViteDevServer }) => void | Promise<void>;
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
'astro:server:done'?: () => void | Promise<void>;
'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise<void>;
'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
'astro:server:setup'?: (options: { config: Readonly<AstroConfig>; server: vite.ViteDevServer }) => void | Promise<void>;
'astro:server:start'?: (options: { config: Readonly<AstroConfig>; address: AddressInfo }) => void | Promise<void>;
'astro:server:done'?: (options: { config: Readonly<AstroConfig> }) => void | Promise<void>;
'astro:build:start'?: (options: { config: Readonly<AstroConfig>; buildConfig: BuildConfig }) => void | Promise<void>;
'astro:build:done'?: (options: { config: Readonly<AstroConfig>; pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/core/build/vite-plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ${
adapter.exports
? `const _exports = adapter.createExports(_manifest, _args);
${adapter.exports.map((name) => `export const ${name} = _exports['${name}'];`).join('\n')}
${adapter.exports.includes('_default') ? `export default _default` : ''}
`
: ''
}
Expand Down
10 changes: 5 additions & 5 deletions packages/astro/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,39 +62,39 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) {
export async function runHookServerSetup({ config, server }: { config: AstroConfig; server: ViteDevServer }) {
for (const integration of config.integrations) {
if (integration.hooks['astro:server:setup']) {
await integration.hooks['astro:server:setup']({ server });
await integration.hooks['astro:server:setup']({ config, server });
JuanM04 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

export async function runHookServerStart({ config, address }: { config: AstroConfig; address: AddressInfo }) {
for (const integration of config.integrations) {
if (integration.hooks['astro:server:start']) {
await integration.hooks['astro:server:start']({ address });
await integration.hooks['astro:server:start']({ config, address });
}
}
}

export async function runHookServerDone({ config }: { config: AstroConfig }) {
for (const integration of config.integrations) {
if (integration.hooks['astro:server:done']) {
await integration.hooks['astro:server:done']();
await integration.hooks['astro:server:done']({ config });
}
}
}

export async function runHookBuildStart({ config, buildConfig }: { config: AstroConfig; buildConfig: BuildConfig }) {
for (const integration of config.integrations) {
if (integration.hooks['astro:build:start']) {
await integration.hooks['astro:build:start']({ buildConfig });
await integration.hooks['astro:build:start']({ config, buildConfig });
}
}
}

export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) {
for (const integration of config.integrations) {
if (integration.hooks['astro:build:done']) {
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes });
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes, config });
}
}
}
22 changes: 22 additions & 0 deletions packages/integrations/vercel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# @astrojs/vercel

Deploy your server-side rendered (SSR) Astro app to [Vercel](https://www.vercel.com/).

Use this integration in your Astro configuration file:

```js
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel';

export default defineConfig({
integrations: [netlify()]
});
```

After you build your site the `.output/` folder will contain your server-side rendered app. Since this feature is still in beta, you'll **need to add this Enviroment Variable to your Vercel project**: `ENABLE_FILE_SYSTEM_API=1`

Now you can deploy!

```shell
vercel
```
32 changes: 32 additions & 0 deletions packages/integrations/vercel/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@astrojs/vercel",
"description": "Deploy your site to Vercel",
"version": "0.0.1",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/withastro/astro.git",
"directory": "packages/integrations/vercel"
},
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://astro.build",
"exports": {
".": "./dist/index.js",
"./server-entrypoint": "./dist/server-entrypoint.js",
"./package.json": "./package.json"
},
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
"@astrojs/webapi": "^0.11.0"
},
"devDependencies": {
"astro": "workspace:*",
"astro-scripts": "workspace:*"
}
}
Loading