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

remove envVarsInUse #9942

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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/fast-dancers-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-vercel': major
---

breaking: remove obsolete `envVarsInUse` option
5 changes: 2 additions & 3 deletions documentation/docs/25-build-and-deploy/90-adapter-vercel.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ The following options apply to all functions:
- `regions`: an array of [edge network regions](https://vercel.com/docs/concepts/edge-network/regions) (defaulting to `["iad1"]` for serverless functions) or `'all'` if `runtime` is `edge` (its default). Note that multiple regions for serverless functions are only supported on Enterprise plans
- `split`: if `true`, causes a route to be deployed as an individual function. If `split` is set to `true` at the adapter level, all routes will be deployed as individual functions

Additionally, the following options apply to edge functions:
- `envVarsInUse`: an array of environment variables that should be accessible inside the edge function
Additionally, the following option applies to edge functions:
- `external`: an array of dependencies that esbuild should treat as external when bundling functions. This should only be used to exclude optional dependencies that will not run outside Node

And the following option apply to serverless functions:
Expand Down Expand Up @@ -130,7 +129,7 @@ export function load() {
<p>This staging environment was deployed from {data.deploymentGitBranch}.</p>
```

Since all of these variables are unchanged between build time and run time when building on Vercel, we recommend using `$env/static/private` — which will statically replace the variables, enabling optimisations like dead code elimination — rather than `$env/dynamic/private`. If you're deploying with `edge: true` you must either use `$env/static/private` or populate the `envVarsInUse` configuration.
Since all of these variables are unchanged between build time and run time when building on Vercel, we recommend using `$env/static/private` — which will statically replace the variables, enabling optimisations like dead code elimination — rather than `$env/dynamic/private`.

## Notes

Expand Down
5 changes: 0 additions & 5 deletions packages/adapter-vercel/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ export interface EdgeConfig {
* More info: https://vercel.com/docs/concepts/edge-network/regions
*/
regions?: string[] | 'all';
/**
* List of environment variable names that will be available for the Edge Function to utilize.
* Edge only.
*/
envVarsInUse?: string[];
/**
* List of packages that should not be bundled into the Edge Function.
* Edge only.
Expand Down
8 changes: 0 additions & 8 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ const plugin = function (defaults = {}) {
const tmp = builder.getBuildDirectory(`vercel-tmp/${name}`);
const relativePath = path.posix.relative(tmp, builder.getServerDirectory());

const envVarsInUse = new Set();
routes.forEach((route) => {
route.config?.envVarsInUse?.forEach((x) => {
envVarsInUse.add(x);
});
});

builder.copy(`${files}/edge.js`, `${tmp}/edge.js`, {
replace: {
SERVER: `${relativePath}/index.js`,
Expand Down Expand Up @@ -133,7 +126,6 @@ const plugin = function (defaults = {}) {
{
runtime: config.runtime,
regions: config.regions,
envVarsInUse: [...envVarsInUse],
entrypoint: 'index.js'
},
null,
Expand Down