Skip to content

Commit

Permalink
remove envVarsInUse (#9942)
Browse files Browse the repository at this point in the history
Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
Rich-Harris and Rich Harris authored May 17, 2023
1 parent 245edc9 commit 8cf8ddb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
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

0 comments on commit 8cf8ddb

Please sign in to comment.