@sveltejs/adapter-vercel 1.0.0-next.84 → 1.0.0-next.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/index.js +6 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -34,6 +34,34 @@ export default {
|
|
|
34
34
|
};
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
## Environment Variables
|
|
38
|
+
|
|
39
|
+
Vercel makes a set of [deployment-specific environment variables](https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables) available. Like other environment variables, these are accessible from `$env/static/private` and `$env/dynamic/private` (sometimes — more on that later), and inaccessible from their public counterparts. To access one of these variables from the client:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
// +layout.server.js
|
|
43
|
+
import { VERCEL_COMMIT_REF } from '$env/static/private';
|
|
44
|
+
|
|
45
|
+
/** @type {import('./$types').LayoutServerLoad} */
|
|
46
|
+
export function load() {
|
|
47
|
+
return {
|
|
48
|
+
deploymentGitBranch: VERCEL_COMMIT_REF
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```svelte
|
|
54
|
+
<!-- +layout.svelte -->
|
|
55
|
+
<script>
|
|
56
|
+
/** @type {import('./$types').LayoutServerData} */
|
|
57
|
+
export let data;
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<p>This staging environment was deployed from {data.deploymentGitBranch}.</p>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
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_ use `$env/static/private`, as `$env/dynamic/private` and `$env/dynamic/public` are not currently populated in edge functions on Vercel.
|
|
64
|
+
|
|
37
65
|
## Notes
|
|
38
66
|
|
|
39
67
|
### Vercel functions
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { nodeFileTrace } from '@vercel/nft';
|
|
|
5
5
|
import esbuild from 'esbuild';
|
|
6
6
|
|
|
7
7
|
/** @type {import('.').default} **/
|
|
8
|
-
|
|
8
|
+
const plugin = function ({ external = [], edge, split } = {}) {
|
|
9
9
|
return {
|
|
10
10
|
name: '@sveltejs/adapter-vercel',
|
|
11
11
|
|
|
@@ -122,12 +122,12 @@ export default function ({ external = [], edge, split } = {}) {
|
|
|
122
122
|
);
|
|
123
123
|
|
|
124
124
|
await esbuild.build({
|
|
125
|
+
platform: 'neutral',
|
|
126
|
+
mainFields: ['module', 'main'],
|
|
125
127
|
entryPoints: [`${tmp}/edge.js`],
|
|
126
128
|
outfile: `${dirs.functions}/${name}.func/index.js`,
|
|
127
129
|
target: 'es2020', // TODO verify what the edge runtime supports
|
|
128
130
|
bundle: true,
|
|
129
|
-
platform: 'browser',
|
|
130
|
-
format: 'esm',
|
|
131
131
|
external,
|
|
132
132
|
sourcemap: 'linked',
|
|
133
133
|
banner: { js: 'globalThis.global = globalThis;' }
|
|
@@ -196,7 +196,7 @@ export default function ({ external = [], edge, split } = {}) {
|
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
|
-
}
|
|
199
|
+
};
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* @param {string} file
|
|
@@ -333,3 +333,5 @@ async function create_function_bundle(builder, entry, dir, runtime) {
|
|
|
333
333
|
|
|
334
334
|
write(`${dir}/package.json`, JSON.stringify({ type: 'module' }));
|
|
335
335
|
}
|
|
336
|
+
|
|
337
|
+
export default plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-vercel",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.86",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@vercel/nft": "^0.22.1",
|
|
27
|
-
"esbuild": "^0.
|
|
27
|
+
"esbuild": "^0.16.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"@types/node": "^16.18.6",
|
|
31
|
+
"typescript": "^4.9.3",
|
|
32
|
+
"@sveltejs/kit": "1.0.0-next.584"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|