@sveltejs/adapter-vercel 1.0.0-next.33 → 1.0.0-next.37
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/index.js +36 -25
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { writeFileSync } from 'fs';
|
|
2
|
-
import {
|
|
2
|
+
import { posix } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import esbuild from 'esbuild';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
// https://vercel.com/docs/file-system-api
|
|
8
|
-
const VERCEL_OUTPUT = '.output';
|
|
6
|
+
const dir = '.vercel_build_output';
|
|
9
7
|
|
|
10
8
|
/** @type {import('.')} **/
|
|
11
9
|
export default function () {
|
|
@@ -15,18 +13,25 @@ export default function () {
|
|
|
15
13
|
async adapt(builder) {
|
|
16
14
|
const tmp = builder.getBuildDirectory('vercel-tmp');
|
|
17
15
|
|
|
18
|
-
builder.rimraf(
|
|
16
|
+
builder.rimraf(dir);
|
|
19
17
|
builder.rimraf(tmp);
|
|
20
18
|
|
|
19
|
+
const files = fileURLToPath(new URL('./files', import.meta.url));
|
|
20
|
+
|
|
21
|
+
const dirs = {
|
|
22
|
+
static: `${dir}/static`,
|
|
23
|
+
lambda: `${dir}/functions/node/render`
|
|
24
|
+
};
|
|
25
|
+
|
|
21
26
|
builder.log.minor('Prerendering static pages...');
|
|
27
|
+
|
|
22
28
|
await builder.prerender({
|
|
23
|
-
dest: `${
|
|
29
|
+
dest: `${dir}/static`
|
|
24
30
|
});
|
|
25
31
|
|
|
26
32
|
builder.log.minor('Generating serverless function...');
|
|
27
33
|
|
|
28
|
-
const
|
|
29
|
-
const relativePath = relative(tmp, builder.getServerDirectory());
|
|
34
|
+
const relativePath = posix.relative(tmp, builder.getServerDirectory());
|
|
30
35
|
|
|
31
36
|
builder.copy(files, tmp, {
|
|
32
37
|
replace: {
|
|
@@ -44,33 +49,39 @@ export default function () {
|
|
|
44
49
|
|
|
45
50
|
await esbuild.build({
|
|
46
51
|
entryPoints: [`${tmp}/entry.js`],
|
|
47
|
-
outfile: `${
|
|
52
|
+
outfile: `${dirs.lambda}/index.js`,
|
|
48
53
|
target: 'node14',
|
|
49
54
|
bundle: true,
|
|
50
55
|
platform: 'node'
|
|
51
56
|
});
|
|
52
57
|
|
|
53
|
-
writeFileSync(
|
|
54
|
-
`${VERCEL_OUTPUT}/server/pages/package.json`,
|
|
55
|
-
JSON.stringify({ type: 'commonjs' })
|
|
56
|
-
);
|
|
58
|
+
writeFileSync(`${dirs.lambda}/package.json`, JSON.stringify({ type: 'commonjs' }));
|
|
57
59
|
|
|
58
60
|
builder.log.minor('Copying assets...');
|
|
59
|
-
builder.writeClient(`${VERCEL_OUTPUT}/static`);
|
|
60
|
-
builder.writeStatic(`${VERCEL_OUTPUT}/static`);
|
|
61
61
|
|
|
62
|
-
builder.
|
|
62
|
+
builder.writeStatic(dirs.static);
|
|
63
|
+
builder.writeClient(dirs.static);
|
|
64
|
+
|
|
65
|
+
builder.log.minor('Writing routes...');
|
|
66
|
+
|
|
67
|
+
builder.mkdirp(`${dir}/config`);
|
|
63
68
|
writeFileSync(
|
|
64
|
-
`${
|
|
65
|
-
JSON.stringify(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
regex: '^/.*'
|
|
69
|
+
`${dir}/config/routes.json`,
|
|
70
|
+
JSON.stringify([
|
|
71
|
+
{
|
|
72
|
+
src: `/${builder.appDir}/.+`,
|
|
73
|
+
headers: {
|
|
74
|
+
'cache-control': 'public, immutable, max-age=31536000'
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
handle: 'filesystem'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
src: '/.*',
|
|
82
|
+
dest: '.vercel/functions/render'
|
|
83
|
+
}
|
|
84
|
+
])
|
|
74
85
|
);
|
|
75
86
|
}
|
|
76
87
|
};
|
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.37",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"esbuild": "^0.13.15"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@sveltejs/kit": "1.0.0-next.
|
|
28
|
+
"@sveltejs/kit": "1.0.0-next.232"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"lint": "eslint --ignore-path .gitignore \"**/*.{ts,js,svelte}\" && npm run check-format",
|