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

Vercel externals #3614

Merged
merged 3 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
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).
2 changes: 1 addition & 1 deletion packages/adapter-vercel/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Adapter } from '@sveltejs/kit';

declare function plugin(): Adapter;
declare function plugin({ external }?: { external?: string[] }): Adapter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's worth having the param as plugin(options?: Options) instead to simplify the type signature for intellisense, and conforms with the docs wording of "You can pass an options argument". But this PR is fine with the current type too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, i made that change

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