Skip to content

Commit

Permalink
Vercel externals (#3614)
Browse files Browse the repository at this point in the history
* expose external option on adapter-vercel

* update docs

* add an Options type
  • Loading branch information
Rich-Harris authored Jan 29, 2022
1 parent d0310c1 commit 48f4816
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-birds-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-vercel': patch
---

Expose external option
8 changes: 7 additions & 1 deletion packages/adapter-vercel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ import vercel from '@sveltejs/adapter-vercel';
export default {
kit: {
...
adapter: vercel()
adapter: vercel(options)
}
};
```

## Options

You can pass an `options` argument, if necessary, with the following:

- `external` — an array of dependencies that [esbuild](https://esbuild.github.io/api/#external) should treat as external

## Changelog

[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/adapter-vercel/CHANGELOG.md).
6 changes: 5 additions & 1 deletion packages/adapter-vercel/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Adapter } from '@sveltejs/kit';

declare function plugin(): Adapter;
type Options = {
external?: string[];
};

declare function plugin(options?: Options): Adapter;
export = plugin;
5 changes: 3 additions & 2 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import esbuild from 'esbuild';
const dir = '.vercel_build_output';

/** @type {import('.')} **/
export default function () {
export default function ({ external = [] } = {}) {
return {
name: '@sveltejs/adapter-vercel',

Expand Down Expand Up @@ -52,7 +52,8 @@ export default function () {
outfile: `${dirs.lambda}/index.js`,
target: 'node14',
bundle: true,
platform: 'node'
platform: 'node',
external
});

writeFileSync(`${dirs.lambda}/package.json`, JSON.stringify({ type: 'commonjs' }));
Expand Down

0 comments on commit 48f4816

Please sign in to comment.