@sveltejs/kit 1.0.0-next.432 → 1.0.0-next.433
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/package.json +1 -1
- package/src/core/prerender/prerender.js +2 -1
- package/src/runtime/server/page/index.js +1 -15
- package/src/vite/build/build_server.js +12 -7
- package/src/vite/index.js +7 -1
- package/src/vite/preview/index.js +1 -1
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +1 -1
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ import { load_config } from '../config/index.js';
|
|
|
15
15
|
* @typedef {import('types').Logger} Logger
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
const [, , client_out_dir, results_path, manifest_path, verbose] = process.argv;
|
|
18
|
+
const [, , client_out_dir, results_path, manifest_path, verbose, env] = process.argv;
|
|
19
19
|
|
|
20
20
|
prerender();
|
|
21
21
|
|
|
@@ -159,6 +159,7 @@ export async function prerender() {
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
const server = new Server(manifest);
|
|
162
|
+
await server.init({ env: JSON.parse(env) });
|
|
162
163
|
|
|
163
164
|
const error = normalise_error_handler(log, config);
|
|
164
165
|
|
|
@@ -5,6 +5,7 @@ import { method_not_allowed, error_to_pojo, allowed_methods } from '../utils.js'
|
|
|
5
5
|
import { create_fetch } from './fetch.js';
|
|
6
6
|
import { HttpError, Redirect } from '../../../index/private.js';
|
|
7
7
|
import { error, json } from '../../../index/index.js';
|
|
8
|
+
import { compact } from '../../../utils/array.js';
|
|
8
9
|
import { normalize_error } from '../../../utils/error.js';
|
|
9
10
|
import { load_data, load_server_data } from './load_data.js';
|
|
10
11
|
|
|
@@ -401,18 +402,3 @@ function redirect_response(status, location) {
|
|
|
401
402
|
headers: { location }
|
|
402
403
|
});
|
|
403
404
|
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* @template T
|
|
407
|
-
* @param {Array<T | null>} array
|
|
408
|
-
* @returns {T[]}
|
|
409
|
-
*/
|
|
410
|
-
function compact(array) {
|
|
411
|
-
const compacted = [];
|
|
412
|
-
for (const item of array) {
|
|
413
|
-
if (item) {
|
|
414
|
-
compacted.push(item);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return compacted;
|
|
418
|
-
}
|
|
@@ -84,7 +84,12 @@ export class Server {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Take care: Some adapters may have to call \`Server.init\` per-request to set env vars,
|
|
89
|
+
* so anything that shouldn't be rerun should be wrapped in an \`if\` block to make sure it hasn't
|
|
90
|
+
* been done already.
|
|
91
|
+
*/
|
|
92
|
+
async init({ env }) {
|
|
88
93
|
const entries = Object.entries(env);
|
|
89
94
|
|
|
90
95
|
const prv = Object.fromEntries(entries.filter(([k]) => !k.startsWith('${
|
|
@@ -99,12 +104,6 @@ export class Server {
|
|
|
99
104
|
set_public_env(pub);
|
|
100
105
|
|
|
101
106
|
this.options.public_env = pub;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async respond(request, options = {}) {
|
|
105
|
-
if (!(request instanceof Request)) {
|
|
106
|
-
throw new Error('The first argument to server.respond must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details');
|
|
107
|
-
}
|
|
108
107
|
|
|
109
108
|
if (!this.options.hooks) {
|
|
110
109
|
const module = await import(${s(hooks)});
|
|
@@ -114,6 +113,12 @@ export class Server {
|
|
|
114
113
|
externalFetch: module.externalFetch || fetch
|
|
115
114
|
};
|
|
116
115
|
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async respond(request, options = {}) {
|
|
119
|
+
if (!(request instanceof Request)) {
|
|
120
|
+
throw new Error('The first argument to server.respond must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details');
|
|
121
|
+
}
|
|
117
122
|
|
|
118
123
|
return respond(request, this.options, options);
|
|
119
124
|
}
|
package/src/vite/index.js
CHANGED
|
@@ -411,7 +411,13 @@ function kit() {
|
|
|
411
411
|
|
|
412
412
|
const child = fork(
|
|
413
413
|
script,
|
|
414
|
-
[
|
|
414
|
+
[
|
|
415
|
+
vite_config.build.outDir,
|
|
416
|
+
results_path,
|
|
417
|
+
manifest_path,
|
|
418
|
+
'' + verbose,
|
|
419
|
+
JSON.stringify({ ...env.private, ...env.public })
|
|
420
|
+
],
|
|
415
421
|
{
|
|
416
422
|
stdio: 'inherit'
|
|
417
423
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -264,7 +264,7 @@ export interface ResolveOptions {
|
|
|
264
264
|
|
|
265
265
|
export class Server {
|
|
266
266
|
constructor(manifest: SSRManifest);
|
|
267
|
-
init(options: ServerInitOptions): void
|
|
267
|
+
init(options: ServerInitOptions): Promise<void>;
|
|
268
268
|
respond(request: Request, options: RequestOptions): Promise<Response>;
|
|
269
269
|
}
|
|
270
270
|
|
package/types/internal.d.ts
CHANGED