@sveltejs/kit 3.0.0-next.24 → 3.0.0-next.27
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 +16 -10
- package/src/constants.js +6 -0
- package/src/core/adapt/builder.js +128 -33
- package/src/core/adapt/index.js +3 -0
- package/src/core/config/index.js +4 -7
- package/src/core/env.js +39 -14
- package/src/core/generate_manifest/index.js +42 -43
- package/src/core/postbuild/analyse.js +4 -4
- package/src/core/postbuild/fallback.js +1 -1
- package/src/core/postbuild/prerender.js +4 -4
- package/src/core/sync/create_manifest_data/index.js +0 -1
- package/src/core/sync/write_app_manifest.js +3 -2
- package/src/core/sync/write_server.js +3 -17
- package/src/core/utils.js +10 -0
- package/src/exports/adapter.js +22 -0
- package/src/exports/public.d.ts +101 -49
- package/src/exports/vite/build/index.js +1173 -0
- package/src/exports/vite/build/remote.js +4 -4
- package/src/exports/vite/build/service-worker.js +98 -0
- package/src/exports/vite/dev/generate_manifest.js +308 -0
- package/src/exports/vite/dev/index.js +40 -282
- package/src/exports/vite/index.js +156 -1717
- package/src/exports/vite/plugins/env-vars.js +53 -34
- package/src/exports/vite/plugins/guard.js +217 -0
- package/src/exports/vite/plugins/remote.js +237 -0
- package/src/exports/vite/preview/index.js +8 -8
- package/src/exports/vite/static_analysis/index.js +15 -15
- package/src/exports/vite/utils.js +98 -1
- package/src/runner.js +4 -3
- package/src/runtime/app/paths/server.js +2 -2
- package/src/runtime/app/server/index.js +3 -3
- package/src/runtime/app/server/public.d.ts +114 -57
- package/src/runtime/app/server/remote/query.js +2 -2
- package/src/runtime/app/server/remote/requested.js +31 -15
- package/src/runtime/app/state/client.svelte.js +3 -1
- package/src/runtime/client/client.js +43 -198
- package/src/runtime/client/fetcher.js +6 -6
- package/src/runtime/client/focus.js +120 -0
- package/src/runtime/client/remote-functions/command.svelte.js +20 -9
- package/src/runtime/client/remote-functions/form.svelte.js +12 -7
- package/src/runtime/client/remote-functions/query/instance.svelte.js +19 -5
- package/src/runtime/client/remote-functions/shared.svelte.js +22 -1
- package/src/runtime/client/scroll.js +39 -0
- package/src/runtime/client/utils.js +28 -0
- package/src/runtime/form-utils.js +254 -264
- package/src/runtime/server/data/index.js +14 -36
- package/src/runtime/server/errors.js +7 -10
- package/src/runtime/server/fetch.js +21 -25
- package/src/runtime/server/index.js +35 -31
- package/src/runtime/server/internal.js +34 -5
- package/src/runtime/server/page/actions.js +6 -8
- package/src/runtime/server/page/data_serializer.js +6 -10
- package/src/runtime/server/page/index.js +18 -28
- package/src/runtime/server/page/load_data.js +2 -2
- package/src/runtime/server/page/render.js +22 -40
- package/src/runtime/server/page/respond_with_error.js +10 -13
- package/src/runtime/server/page/server_routing.js +21 -27
- package/src/runtime/server/remote-functions.js +136 -136
- package/src/runtime/server/respond.js +66 -64
- package/src/runtime/server/state.js +2 -0
- package/src/runtime/server/utils.js +4 -11
- package/src/runtime/shared.js +9 -0
- package/src/runtime/utils.js +41 -0
- package/src/types/ambient-private.d.ts +1 -2
- package/src/types/global-private.d.ts +8 -0
- package/src/types/internal.d.ts +56 -17
- package/src/utils/filesystem.js +44 -28
- package/src/utils/streaming.js +5 -15
- package/src/version.js +1 -1
- package/types/index.d.ts +235 -93
- package/types/index.d.ts.map +9 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** @import { RequestEvent
|
|
2
|
-
/** @import {
|
|
3
|
-
/** @import { ManifestData, PrerenderOption, RemoteChunk, ServerModule,
|
|
1
|
+
/** @import { RequestEvent } from '@sveltejs/kit' */
|
|
2
|
+
/** @import { ViteDevServer } from 'vite' */
|
|
3
|
+
/** @import { ManifestData, PrerenderOption, RemoteChunk, ServerModule, ValidatedConfig, SSRManifest } from 'types' */
|
|
4
4
|
import process from 'node:process';
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
@@ -8,6 +8,7 @@ import { URL } from 'node:url';
|
|
|
8
8
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
9
9
|
import { styleText } from 'node:util';
|
|
10
10
|
import sirv from 'sirv';
|
|
11
|
+
import { generate_manifest, loud_ssr_load_module } from './generate_manifest.js';
|
|
11
12
|
import { createReadableStream, getRequest, setResponse } from '../../../exports/node/index.js';
|
|
12
13
|
import { coalesce_to_error } from '../../../utils/error.js';
|
|
13
14
|
import { resolve_entry } from '../../../utils/filesystem.js';
|
|
@@ -17,9 +18,8 @@ import { posixify } from '../../../utils/os.js';
|
|
|
17
18
|
import { load_error_page } from '../../../core/config/index.js';
|
|
18
19
|
import { SRC_ROOT, SVELTE_KIT_ASSETS } from '../../../constants.js';
|
|
19
20
|
import * as sync from '../../../core/sync/sync.js';
|
|
20
|
-
import {
|
|
21
|
+
import { get_runtime_base } from '../../../core/utils.js';
|
|
21
22
|
import '../../../utils/mime.js'; // extend mrmime with additional types (affects sirv too)
|
|
22
|
-
import { compact } from '../../../utils/array.js';
|
|
23
23
|
import { is_chrome_devtools_request, is_remote_module, not_found } from '../utils.js';
|
|
24
24
|
import { SCHEME } from '../../../utils/url.js';
|
|
25
25
|
import { check_feature } from '../../../utils/features.js';
|
|
@@ -29,13 +29,9 @@ import { write_server } from '../../../core/sync/write_server.js';
|
|
|
29
29
|
import { write_tsconfig } from '../../../core/sync/write_tsconfig/index.js';
|
|
30
30
|
import create_manifest_data from '../../../core/sync/create_manifest_data/index.js';
|
|
31
31
|
|
|
32
|
-
// vite-specifc queries that we should skip handling for css urls
|
|
33
|
-
const vite_css_query_regex = /(?:\?|&)(?:raw|url|inline)(?:&|$)/;
|
|
34
|
-
|
|
35
32
|
/**
|
|
36
33
|
* @param {typeof import('vite')} vite the peer resolved vite module
|
|
37
34
|
* @param {ViteDevServer} vite_dev_server
|
|
38
|
-
* @param {ResolvedConfig} vite_config
|
|
39
35
|
* @param {ValidatedConfig} svelte_config
|
|
40
36
|
* @param {() => RemoteChunk[]} get_remotes
|
|
41
37
|
* @param {string} root The project root directory
|
|
@@ -45,7 +41,6 @@ const vite_css_query_regex = /(?:\?|&)(?:raw|url|inline)(?:&|$)/;
|
|
|
45
41
|
export async function dev(
|
|
46
42
|
vite,
|
|
47
43
|
vite_dev_server,
|
|
48
|
-
vite_config,
|
|
49
44
|
svelte_config,
|
|
50
45
|
get_remotes,
|
|
51
46
|
root,
|
|
@@ -88,54 +83,22 @@ export async function dev(
|
|
|
88
83
|
let manifest_error = null;
|
|
89
84
|
|
|
90
85
|
const runner = get_runner(vite, vite_dev_server);
|
|
86
|
+
const { hot } = vite_dev_server.environments.client;
|
|
91
87
|
|
|
92
88
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
89
|
+
* Log a response to the console, routed through Vite's logger so that it
|
|
90
|
+
* respects the configured `logLevel` and any `customLogger`
|
|
91
|
+
* @param {number} status
|
|
92
|
+
* @param {string} log
|
|
95
93
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
styleText('red', `Internal server error: ${err.message}`)
|
|
102
|
-
]);
|
|
103
|
-
|
|
104
|
-
if (!vite_dev_server.config.logger.hasErrorLogged(err)) {
|
|
105
|
-
vite_dev_server.config.logger.error(msg, { error: err });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// TODO this is inadequate — it doesn't reliably show the overlay on every page load,
|
|
109
|
-
// and when it does appear it may immediately vanish. `vite.hot.send` broadcasts
|
|
110
|
-
// to all connected clients, even ones that are unaffected by the error.
|
|
111
|
-
// we need a more considered approach
|
|
112
|
-
vite_dev_server.hot.send({
|
|
113
|
-
type: 'error',
|
|
114
|
-
err: /** @type {ErrorPayload['err']} */ ({
|
|
115
|
-
...err,
|
|
116
|
-
// these properties are non-enumerable and will
|
|
117
|
-
// not be serialized unless we explicitly include them
|
|
118
|
-
message: err.message,
|
|
119
|
-
stack: err.stack ?? ''
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
throw err;
|
|
94
|
+
function log_dev_response(status, log) {
|
|
95
|
+
if (status < 400) {
|
|
96
|
+
vite_dev_server.config.logger.info(log);
|
|
97
|
+
} else {
|
|
98
|
+
vite_dev_server.config.logger.error(log);
|
|
124
99
|
}
|
|
125
100
|
}
|
|
126
101
|
|
|
127
|
-
/** @param {string} id */
|
|
128
|
-
async function resolve(id) {
|
|
129
|
-
const url = id.startsWith('..') ? to_fs(path.resolve(id)) : `/${id}`;
|
|
130
|
-
|
|
131
|
-
const module = await loud_ssr_load_module(url);
|
|
132
|
-
|
|
133
|
-
const module_node = await vite_dev_server.environments.ssr.moduleGraph.getModuleByUrl(url);
|
|
134
|
-
if (!module_node) throw new Error(`Could not find node for ${url}`);
|
|
135
|
-
|
|
136
|
-
return { module, module_node, url };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
102
|
async function update_manifest() {
|
|
140
103
|
try {
|
|
141
104
|
manifest_data = create_manifest_data(svelte_config, root);
|
|
@@ -146,18 +109,18 @@ export async function dev(
|
|
|
146
109
|
routes: manifest_data.routes,
|
|
147
110
|
params_path: manifest_data.params,
|
|
148
111
|
root,
|
|
149
|
-
load: (file) => loud_ssr_load_module(file)
|
|
112
|
+
load: (file) => loud_ssr_load_module(vite, vite_dev_server, runner, file)
|
|
150
113
|
});
|
|
151
114
|
|
|
152
115
|
if (manifest_error) {
|
|
153
116
|
manifest_error = null;
|
|
154
|
-
|
|
117
|
+
hot.send({ type: 'full-reload' });
|
|
155
118
|
}
|
|
156
119
|
} catch (error) {
|
|
157
120
|
manifest_error = /** @type {Error} */ (error);
|
|
158
121
|
|
|
159
122
|
console.error(styleText(['bold', 'red'], manifest_error.message));
|
|
160
|
-
|
|
123
|
+
hot.send({
|
|
161
124
|
type: 'error',
|
|
162
125
|
err: {
|
|
163
126
|
message: manifest_error.message ?? 'Invalid routes',
|
|
@@ -168,179 +131,15 @@ export async function dev(
|
|
|
168
131
|
return;
|
|
169
132
|
}
|
|
170
133
|
|
|
171
|
-
manifest =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
imports: [],
|
|
181
|
-
stylesheets: [],
|
|
182
|
-
fonts: [],
|
|
183
|
-
uses_env_dynamic_public: true,
|
|
184
|
-
nodes:
|
|
185
|
-
svelte_config.router.resolution === 'client'
|
|
186
|
-
? undefined
|
|
187
|
-
: manifest_data.nodes.map((node, i) => {
|
|
188
|
-
if (node.component || node.universal) {
|
|
189
|
-
return `${svelte_config.paths.base}${to_fs(svelte_config.outDir)}/generated/dev/client/nodes/${i}.js`;
|
|
190
|
-
}
|
|
191
|
-
}),
|
|
192
|
-
// `css` is not necessary in dev, as the JS file from `nodes` will reference the CSS file
|
|
193
|
-
routes:
|
|
194
|
-
svelte_config.router.resolution === 'client'
|
|
195
|
-
? undefined
|
|
196
|
-
: compact(
|
|
197
|
-
manifest_data.routes.map((route) => {
|
|
198
|
-
if (!route.page) return;
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
id: route.id,
|
|
202
|
-
pattern: route.pattern,
|
|
203
|
-
params: route.params,
|
|
204
|
-
layouts: route.page.layouts.map((l) =>
|
|
205
|
-
l !== undefined ? [!!manifest_data.nodes[l].server, l] : undefined
|
|
206
|
-
),
|
|
207
|
-
errors: route.page.errors,
|
|
208
|
-
leaf: [!!manifest_data.nodes[route.page.leaf].server, route.page.leaf]
|
|
209
|
-
};
|
|
210
|
-
})
|
|
211
|
-
)
|
|
212
|
-
},
|
|
213
|
-
server_assets: new Proxy(
|
|
214
|
-
{},
|
|
215
|
-
{
|
|
216
|
-
has: (_, /** @type {string} */ file) => fs.existsSync(from_fs(file)),
|
|
217
|
-
get: (_, /** @type {string} */ file) => fs.statSync(from_fs(file)).size
|
|
218
|
-
}
|
|
219
|
-
),
|
|
220
|
-
nodes: manifest_data.nodes.map((node, index) => {
|
|
221
|
-
return async () => {
|
|
222
|
-
const result = /** @type {SSRNode} */ ({});
|
|
223
|
-
result.index = index;
|
|
224
|
-
result.universal_id = node.universal;
|
|
225
|
-
result.server_id = node.server;
|
|
226
|
-
|
|
227
|
-
// these are unused in dev, but it's easier to include them
|
|
228
|
-
result.imports = [];
|
|
229
|
-
result.stylesheets = [];
|
|
230
|
-
result.fonts = [];
|
|
231
|
-
|
|
232
|
-
/** @type {EnvironmentModuleNode[]} */
|
|
233
|
-
const module_nodes = [];
|
|
234
|
-
|
|
235
|
-
if (node.component) {
|
|
236
|
-
result.component = async () => {
|
|
237
|
-
const { module_node, module } = await resolve(
|
|
238
|
-
/** @type {string} */ (node.component)
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
module_nodes.push(module_node);
|
|
242
|
-
|
|
243
|
-
return module.default;
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (node.universal) {
|
|
248
|
-
if (node.page_options?.ssr === false) {
|
|
249
|
-
result.universal = /** @type {UniversalNode} */ (node.page_options);
|
|
250
|
-
} else {
|
|
251
|
-
// TODO: explain why the file was loaded on the server if we fail to load it
|
|
252
|
-
const { module, module_node } = await resolve(node.universal);
|
|
253
|
-
module_nodes.push(module_node);
|
|
254
|
-
result.universal = module;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (node.server) {
|
|
259
|
-
const { module } = await resolve(node.server);
|
|
260
|
-
result.server = module;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// in dev we inline all styles to avoid FOUC. this gets populated lazily so that
|
|
264
|
-
// components/stylesheets loaded via import() during `load` are included
|
|
265
|
-
result.inline_styles = async () => {
|
|
266
|
-
/** @type {Set<EnvironmentModuleNode>} */
|
|
267
|
-
const deps = new Set();
|
|
268
|
-
|
|
269
|
-
for (const module_node of module_nodes) {
|
|
270
|
-
await find_deps(vite_dev_server, module_node, deps);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/** @type {Record<string, string>} */
|
|
274
|
-
const styles = {};
|
|
275
|
-
|
|
276
|
-
for (const dep of deps) {
|
|
277
|
-
if (vite.isCSSRequest(dep.url) && !vite_css_query_regex.test(dep.url)) {
|
|
278
|
-
const inlineCssUrl = dep.url.includes('?')
|
|
279
|
-
? dep.url.replace('?', '?inline&')
|
|
280
|
-
: dep.url + '?inline';
|
|
281
|
-
try {
|
|
282
|
-
const mod = await runner.import(inlineCssUrl);
|
|
283
|
-
styles[dep.url] = mod.default;
|
|
284
|
-
} catch {
|
|
285
|
-
// this can happen with dynamically imported modules, I think
|
|
286
|
-
// because the Vite module graph doesn't distinguish between
|
|
287
|
-
// static and dynamic imports? TODO investigate, submit fix
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return styles;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
return result;
|
|
296
|
-
};
|
|
297
|
-
}),
|
|
298
|
-
prerendered_routes: new Set(),
|
|
299
|
-
get remotes() {
|
|
300
|
-
return Object.fromEntries(
|
|
301
|
-
get_remotes().map((remote) => [
|
|
302
|
-
remote.hash,
|
|
303
|
-
() => runner.import(remote.file).then((module) => ({ default: module }))
|
|
304
|
-
])
|
|
305
|
-
);
|
|
306
|
-
},
|
|
307
|
-
routes: compact(
|
|
308
|
-
manifest_data.routes.map((route) => {
|
|
309
|
-
if (!route.page && !route.endpoint) return null;
|
|
310
|
-
|
|
311
|
-
const endpoint = route.endpoint;
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
id: route.id,
|
|
315
|
-
pattern: route.pattern,
|
|
316
|
-
params: route.params,
|
|
317
|
-
page: route.page,
|
|
318
|
-
endpoint: endpoint
|
|
319
|
-
? async () => {
|
|
320
|
-
const url = path.resolve(root, endpoint.file);
|
|
321
|
-
return await loud_ssr_load_module(url);
|
|
322
|
-
}
|
|
323
|
-
: null,
|
|
324
|
-
endpoint_id: endpoint?.file
|
|
325
|
-
};
|
|
326
|
-
})
|
|
327
|
-
),
|
|
328
|
-
matchers: async () => {
|
|
329
|
-
if (!manifest_data.params) return {};
|
|
330
|
-
|
|
331
|
-
const url = path.resolve(root, manifest_data.params);
|
|
332
|
-
const module = await runner.import(url);
|
|
333
|
-
|
|
334
|
-
if (!module.params) {
|
|
335
|
-
throw new Error(
|
|
336
|
-
`${manifest_data.params} does not export \`params\` from \`defineParams\``
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return module.params;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
};
|
|
134
|
+
manifest = generate_manifest(
|
|
135
|
+
vite,
|
|
136
|
+
vite_dev_server,
|
|
137
|
+
runner,
|
|
138
|
+
svelte_config,
|
|
139
|
+
manifest_data,
|
|
140
|
+
root,
|
|
141
|
+
get_remotes
|
|
142
|
+
);
|
|
344
143
|
}
|
|
345
144
|
|
|
346
145
|
/** @param {Error} error */
|
|
@@ -442,7 +241,7 @@ export async function dev(
|
|
|
442
241
|
if (appTemplate !== 'index.html') {
|
|
443
242
|
vite_dev_server.watcher.on('change', (file) => {
|
|
444
243
|
if (file === appTemplate) {
|
|
445
|
-
|
|
244
|
+
hot.send({ type: 'full-reload' });
|
|
446
245
|
}
|
|
447
246
|
});
|
|
448
247
|
}
|
|
@@ -489,7 +288,7 @@ export async function dev(
|
|
|
489
288
|
next();
|
|
490
289
|
});
|
|
491
290
|
|
|
492
|
-
const env = vite.loadEnv(
|
|
291
|
+
const env = vite.loadEnv(vite_dev_server.config.mode, svelte_config.env.dir, '');
|
|
493
292
|
const emulator = await svelte_config.adapter?.emulate?.();
|
|
494
293
|
|
|
495
294
|
/** @type {Promise<void> | undefined} */
|
|
@@ -525,8 +324,8 @@ export async function dev(
|
|
|
525
324
|
);
|
|
526
325
|
const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory();
|
|
527
326
|
const allowed =
|
|
528
|
-
!
|
|
529
|
-
|
|
327
|
+
!vite_dev_server.config.server.fs.strict ||
|
|
328
|
+
vite_dev_server.config.server.fs.allow.some((dir) => file.startsWith(dir));
|
|
530
329
|
|
|
531
330
|
if (is_file && allowed) {
|
|
532
331
|
req.url = original_url;
|
|
@@ -572,6 +371,8 @@ export async function dev(
|
|
|
572
371
|
);
|
|
573
372
|
}
|
|
574
373
|
|
|
374
|
+
const { set_env } = await runner.import('<sveltekit:generated>/env/config.js');
|
|
375
|
+
set_env(env);
|
|
575
376
|
await runner.import(resolved_instrumentation);
|
|
576
377
|
}
|
|
577
378
|
|
|
@@ -580,7 +381,7 @@ export async function dev(
|
|
|
580
381
|
await runner.import(`${get_runtime_base(root)}/server/index.js`)
|
|
581
382
|
);
|
|
582
383
|
|
|
583
|
-
const { set_fix_stack_trace,
|
|
384
|
+
const { set_fix_stack_trace, format_response } = await runner.import(
|
|
584
385
|
`${get_runtime_base(root)}/server/internal.js`
|
|
585
386
|
);
|
|
586
387
|
set_fix_stack_trace(fix_stack_trace);
|
|
@@ -595,7 +396,7 @@ export async function dev(
|
|
|
595
396
|
read: (file) => createReadableStream(from_fs(file))
|
|
596
397
|
});
|
|
597
398
|
|
|
598
|
-
const request = getRequest({
|
|
399
|
+
const request = (svelte_config.adapter?.vite?.getRequest ?? getRequest)({
|
|
599
400
|
base,
|
|
600
401
|
request: req,
|
|
601
402
|
response: res
|
|
@@ -630,7 +431,7 @@ export async function dev(
|
|
|
630
431
|
throw new Error('Could not determine clientAddress');
|
|
631
432
|
},
|
|
632
433
|
read: (file) => {
|
|
633
|
-
if (file in manifest.
|
|
434
|
+
if (file in manifest.server_assets) {
|
|
634
435
|
return fs.readFileSync(from_fs(file));
|
|
635
436
|
}
|
|
636
437
|
|
|
@@ -647,12 +448,12 @@ export async function dev(
|
|
|
647
448
|
if (rendered.status === 404) {
|
|
648
449
|
// @ts-expect-error
|
|
649
450
|
serve_static_middleware.handle(req, res, () => {
|
|
650
|
-
|
|
651
|
-
setResponse(res, rendered);
|
|
451
|
+
log_dev_response(rendered.status, format_response(rendered.status, request));
|
|
452
|
+
(svelte_config.adapter?.vite?.setResponse ?? setResponse)(res, rendered);
|
|
652
453
|
});
|
|
653
454
|
} else {
|
|
654
|
-
|
|
655
|
-
setResponse(res, rendered);
|
|
455
|
+
log_dev_response(rendered.status, format_response(rendered.status, request));
|
|
456
|
+
(svelte_config.adapter?.vite?.setResponse ?? setResponse)(res, rendered);
|
|
656
457
|
}
|
|
657
458
|
} catch (e) {
|
|
658
459
|
const error = coalesce_to_error(e);
|
|
@@ -678,49 +479,6 @@ function remove_static_middlewares(server) {
|
|
|
678
479
|
}
|
|
679
480
|
}
|
|
680
481
|
|
|
681
|
-
/**
|
|
682
|
-
* @param {ViteDevServer} vite
|
|
683
|
-
* @param {EnvironmentModuleNode} node
|
|
684
|
-
* @param {Set<EnvironmentModuleNode>} deps
|
|
685
|
-
*/
|
|
686
|
-
async function find_deps(vite, node, deps) {
|
|
687
|
-
// since `transformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous.
|
|
688
|
-
// instead of using `await`, we resolve all branches in parallel.
|
|
689
|
-
/** @type {Promise<void>[]} */
|
|
690
|
-
const branches = [];
|
|
691
|
-
|
|
692
|
-
/** @param {EnvironmentModuleNode} node */
|
|
693
|
-
async function add(node) {
|
|
694
|
-
if (!deps.has(node)) {
|
|
695
|
-
deps.add(node);
|
|
696
|
-
await find_deps(vite, node, deps);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/** @param {string} url */
|
|
701
|
-
async function add_by_url(url) {
|
|
702
|
-
const node = await vite.environments.ssr.moduleGraph.getModuleByUrl(url);
|
|
703
|
-
|
|
704
|
-
if (node) {
|
|
705
|
-
await add(node);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
if (node.transformResult) {
|
|
710
|
-
if (node.transformResult.deps) {
|
|
711
|
-
node.transformResult.deps.forEach((url) => branches.push(add_by_url(url)));
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
if (node.transformResult.dynamicDeps) {
|
|
715
|
-
node.transformResult.dynamicDeps.forEach((url) => branches.push(add_by_url(url)));
|
|
716
|
-
}
|
|
717
|
-
} else {
|
|
718
|
-
node.importedModules.forEach((node) => branches.push(add(node)));
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
await Promise.all(branches);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
482
|
/**
|
|
725
483
|
* Determine if a file is being requested with the correct case,
|
|
726
484
|
* to ensure consistent behaviour between dev and prod and across
|