feat(vercel): remove nodeVersion
(#3368)
* Remove `nodeVersion` * Changeset
This commit is contained in:
parent
9dd16bace5
commit
9d01f93b1c
3 changed files with 13 additions and 19 deletions
5
.changeset/silver-toes-retire.md
Normal file
5
.changeset/silver-toes-retire.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/vercel': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Remove `nodeVersion` option for `serverless` target. Now it is inferred from Vercel
|
|
@ -59,19 +59,6 @@ import vercel from '@astrojs/vercel/serverless';
|
||||||
import vercel from '@astrojs/vercel/static';
|
import vercel from '@astrojs/vercel/static';
|
||||||
```
|
```
|
||||||
|
|
||||||
### Node.js version
|
|
||||||
|
|
||||||
When deploying to `serverless` you can choose what version of Node.js you want to target: `12.x`, `14.x` or `16.x` (default).
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { defineConfig } from 'astro/config';
|
|
||||||
import vercel from '@astrojs/vercel/serverless';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
adapter: vercel({ nodeVersion: '14.x' })
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
**A few known complex packages (example: [puppeteer](https://github.com/puppeteer/puppeteer)) do not support bundling and therefore will not work properly with this adapter.** By default, Vercel doesn't include npm installed files & packages from your project's `./node_modules` folder. To address this, the `@astrojs/vercel` adapter automatically bundles your final build output using `esbuild`.
|
**A few known complex packages (example: [puppeteer](https://github.com/puppeteer/puppeteer)) do not support bundling and therefore will not work properly with this adapter.** By default, Vercel doesn't include npm installed files & packages from your project's `./node_modules` folder. To address this, the `@astrojs/vercel` adapter automatically bundles your final build output using `esbuild`.
|
||||||
|
|
|
@ -14,11 +14,7 @@ function getAdapter(): AstroAdapter {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Options {
|
export default function vercelEdge(): AstroIntegration {
|
||||||
nodeVersion?: '12.x' | '14.x' | '16.x';
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function vercelEdge({ nodeVersion = '16.x' }: Options = {}): AstroIntegration {
|
|
||||||
let _config: AstroConfig;
|
let _config: AstroConfig;
|
||||||
let functionFolder: URL;
|
let functionFolder: URL;
|
||||||
let serverEntry: string;
|
let serverEntry: string;
|
||||||
|
@ -57,7 +53,7 @@ export default function vercelEdge({ nodeVersion = '16.x' }: Options = {}): Astr
|
||||||
// Serverless function config
|
// Serverless function config
|
||||||
// https://vercel.com/docs/build-output-api/v3#vercel-primitives/serverless-functions/configuration
|
// https://vercel.com/docs/build-output-api/v3#vercel-primitives/serverless-functions/configuration
|
||||||
await writeJson(new URL(`./.vc-config.json`, functionFolder), {
|
await writeJson(new URL(`./.vc-config.json`, functionFolder), {
|
||||||
runtime: `nodejs${nodeVersion}`,
|
runtime: getRuntime(),
|
||||||
handler: serverEntry,
|
handler: serverEntry,
|
||||||
launcherType: 'Nodejs',
|
launcherType: 'Nodejs',
|
||||||
});
|
});
|
||||||
|
@ -76,3 +72,9 @@ export default function vercelEdge({ nodeVersion = '16.x' }: Options = {}): Astr
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRuntime() {
|
||||||
|
const version = process.version.slice(1); // 'v16.5.0' --> '16.5.0'
|
||||||
|
const major = version.split('.')[0]; // '16.5.0' --> '16'
|
||||||
|
return `nodejs${major}.x`;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue