@sveltejs/adapter-vercel 1.0.0-next.43 → 1.0.0-next.46
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/files/entry.js +3 -3
- package/files/shims.js +2 -2
- package/index.js +22 -26
- package/package.json +5 -3
- package/files/ambient.d.ts +0 -8
package/files/entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import './shims';
|
|
2
2
|
import { getRequest, setResponse } from '@sveltejs/kit/node';
|
|
3
|
-
import {
|
|
3
|
+
import { Server } from 'SERVER';
|
|
4
4
|
import { manifest } from 'MANIFEST';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const server = new Server(manifest);
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {import('http').IncomingMessage} req
|
|
@@ -19,5 +19,5 @@ export default async (req, res) => {
|
|
|
19
19
|
return res.end(err.reason || 'Invalid request body');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
setResponse(res, await
|
|
22
|
+
setResponse(res, await server.respond(request));
|
|
23
23
|
};
|
package/files/shims.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { installFetch } from '@sveltejs/kit/install-fetch';
|
|
2
|
+
installFetch();
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { writeFileSync } from 'fs';
|
|
2
2
|
import { posix } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import esbuild from 'esbuild';
|
|
@@ -93,26 +93,20 @@ export default function ({ external = [] } = {}) {
|
|
|
93
93
|
builder.rimraf(dir);
|
|
94
94
|
builder.rimraf(tmp);
|
|
95
95
|
|
|
96
|
-
const files = fileURLToPath(new URL('./files', import.meta.url));
|
|
96
|
+
const files = fileURLToPath(new URL('./files', import.meta.url).href);
|
|
97
97
|
|
|
98
98
|
const dirs = {
|
|
99
99
|
static: `${dir}/static`,
|
|
100
100
|
lambda: `${dir}/functions/node/render`
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
builder.log.minor('Prerendering static pages...');
|
|
104
|
-
|
|
105
|
-
const prerendered = await builder.prerender({
|
|
106
|
-
dest: `${dir}/static`
|
|
107
|
-
});
|
|
108
|
-
|
|
109
103
|
builder.log.minor('Generating serverless function...');
|
|
110
104
|
|
|
111
105
|
const relativePath = posix.relative(tmp, builder.getServerDirectory());
|
|
112
106
|
|
|
113
107
|
builder.copy(files, tmp, {
|
|
114
108
|
replace: {
|
|
115
|
-
|
|
109
|
+
SERVER: `${relativePath}/index.js`,
|
|
116
110
|
MANIFEST: './manifest.js'
|
|
117
111
|
}
|
|
118
112
|
});
|
|
@@ -139,34 +133,36 @@ export default function ({ external = [] } = {}) {
|
|
|
139
133
|
|
|
140
134
|
builder.writeStatic(dirs.static);
|
|
141
135
|
builder.writeClient(dirs.static);
|
|
136
|
+
builder.writePrerendered(dirs.static);
|
|
142
137
|
|
|
143
138
|
builder.log.minor('Writing routes...');
|
|
144
139
|
|
|
145
140
|
builder.mkdirp(`${dir}/config`);
|
|
146
141
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
142
|
+
const prerendered_pages = Array.from(builder.prerendered.pages, ([src, page]) => ({
|
|
143
|
+
src,
|
|
144
|
+
dest: page.file
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
const prerendered_redirects = Array.from(
|
|
148
|
+
builder.prerendered.redirects,
|
|
149
|
+
([src, redirect]) => ({
|
|
150
|
+
src,
|
|
151
|
+
headers: {
|
|
152
|
+
Location: redirect.location
|
|
153
|
+
},
|
|
154
|
+
status: redirect.status
|
|
160
155
|
})
|
|
161
|
-
|
|
156
|
+
);
|
|
162
157
|
|
|
163
158
|
writeFileSync(
|
|
164
159
|
`${dir}/config/routes.json`,
|
|
165
160
|
JSON.stringify([
|
|
166
|
-
...redirects[builder.trailingSlash],
|
|
167
|
-
...
|
|
161
|
+
...redirects[builder.config.kit.trailingSlash],
|
|
162
|
+
...prerendered_pages,
|
|
163
|
+
...prerendered_redirects,
|
|
168
164
|
{
|
|
169
|
-
src: `/${builder.appDir}/.+`,
|
|
165
|
+
src: `/${builder.config.kit.appDir}/.+`,
|
|
170
166
|
headers: {
|
|
171
167
|
'cache-control': 'public, immutable, max-age=31536000'
|
|
172
168
|
}
|
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.46",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -25,11 +25,13 @@
|
|
|
25
25
|
"esbuild": "^0.14.21"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@sveltejs/kit": "1.0.0-next.
|
|
28
|
+
"@sveltejs/kit": "1.0.0-next.293",
|
|
29
|
+
"typescript": "^4.6.2"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
|
31
32
|
"lint": "eslint --ignore-path .gitignore \"**/*.{ts,js,svelte}\" && npm run check-format",
|
|
32
33
|
"format": "npm run check-format -- --write",
|
|
33
|
-
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore"
|
|
34
|
+
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|
|
35
|
+
"check": "tsc"
|
|
34
36
|
}
|
|
35
37
|
}
|