@sveltejs/kit 3.0.0-next.25 → 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 +5 -7
- package/src/core/adapt/builder.js +127 -31
- package/src/core/adapt/index.js +3 -0
- package/src/core/config/index.js +4 -7
- package/src/core/env.js +36 -8
- 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 +2 -2
- package/src/core/sync/create_manifest_data/index.js +0 -1
- package/src/core/sync/write_app_manifest.js +3 -2
- package/src/exports/public.d.ts +100 -48
- package/src/exports/vite/build/index.js +1173 -0
- package/src/exports/vite/build/remote.js +4 -4
- package/src/exports/vite/dev/generate_manifest.js +308 -0
- package/src/exports/vite/dev/index.js +28 -284
- package/src/exports/vite/index.js +117 -1308
- package/src/exports/vite/plugins/env-vars.js +11 -34
- package/src/exports/vite/plugins/guard.js +19 -7
- 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 +1 -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/requested.js +31 -15
- package/src/runtime/app/state/client.svelte.js +3 -1
- package/src/runtime/client/client.js +39 -194
- 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 +243 -245
- package/src/runtime/server/data/index.js +3 -10
- package/src/runtime/server/fetch.js +13 -15
- package/src/runtime/server/index.js +8 -7
- package/src/runtime/server/internal.js +1 -2
- package/src/runtime/server/page/index.js +10 -15
- package/src/runtime/server/page/load_data.js +2 -2
- package/src/runtime/server/page/render.js +8 -13
- package/src/runtime/server/page/respond_with_error.js +4 -5
- package/src/runtime/server/page/server_routing.js +21 -27
- package/src/runtime/server/remote-functions.js +14 -14
- package/src/runtime/server/respond.js +17 -40
- package/src/runtime/server/state.js +1 -0
- package/src/runtime/server/utils.js +4 -4
- package/src/runtime/shared.js +9 -0
- package/src/types/ambient-private.d.ts +1 -2
- package/src/types/internal.d.ts +49 -6
- package/src/utils/filesystem.js +43 -27
- package/src/version.js +1 -1
- package/types/index.d.ts +215 -92
- package/types/index.d.ts.map +6 -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,6 +83,7 @@ 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
89
|
* Log a response to the console, routed through Vite's logger so that it
|
|
@@ -103,53 +99,6 @@ export async function dev(
|
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
|
|
106
|
-
/**
|
|
107
|
-
* @param {string} url
|
|
108
|
-
* @returns {Promise<Record<string, any>>}
|
|
109
|
-
*/
|
|
110
|
-
async function loud_ssr_load_module(url) {
|
|
111
|
-
try {
|
|
112
|
-
return await runner.import(url);
|
|
113
|
-
} catch (/** @type {any} */ err) {
|
|
114
|
-
const msg = vite.buildErrorMessage(err, [
|
|
115
|
-
styleText('red', `Internal server error: ${err.message}`)
|
|
116
|
-
]);
|
|
117
|
-
|
|
118
|
-
if (!vite_dev_server.config.logger.hasErrorLogged(err)) {
|
|
119
|
-
vite_dev_server.config.logger.error(msg, { error: err });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// TODO this is inadequate — it doesn't reliably show the overlay on every page load,
|
|
123
|
-
// and when it does appear it may immediately vanish. `vite.hot.send` broadcasts
|
|
124
|
-
// to all connected clients, even ones that are unaffected by the error.
|
|
125
|
-
// we need a more considered approach
|
|
126
|
-
vite_dev_server.hot.send({
|
|
127
|
-
type: 'error',
|
|
128
|
-
err: /** @type {ErrorPayload['err']} */ ({
|
|
129
|
-
...err,
|
|
130
|
-
// these properties are non-enumerable and will
|
|
131
|
-
// not be serialized unless we explicitly include them
|
|
132
|
-
message: err.message,
|
|
133
|
-
stack: err.stack ?? ''
|
|
134
|
-
})
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** @param {string} id */
|
|
142
|
-
async function resolve(id) {
|
|
143
|
-
const url = id.startsWith('..') ? to_fs(path.resolve(id)) : `/${id}`;
|
|
144
|
-
|
|
145
|
-
const module = await loud_ssr_load_module(url);
|
|
146
|
-
|
|
147
|
-
const module_node = await vite_dev_server.environments.ssr.moduleGraph.getModuleByUrl(url);
|
|
148
|
-
if (!module_node) throw new Error(`Could not find node for ${url}`);
|
|
149
|
-
|
|
150
|
-
return { module, module_node, url };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
102
|
async function update_manifest() {
|
|
154
103
|
try {
|
|
155
104
|
manifest_data = create_manifest_data(svelte_config, root);
|
|
@@ -160,18 +109,18 @@ export async function dev(
|
|
|
160
109
|
routes: manifest_data.routes,
|
|
161
110
|
params_path: manifest_data.params,
|
|
162
111
|
root,
|
|
163
|
-
load: (file) => loud_ssr_load_module(file)
|
|
112
|
+
load: (file) => loud_ssr_load_module(vite, vite_dev_server, runner, file)
|
|
164
113
|
});
|
|
165
114
|
|
|
166
115
|
if (manifest_error) {
|
|
167
116
|
manifest_error = null;
|
|
168
|
-
|
|
117
|
+
hot.send({ type: 'full-reload' });
|
|
169
118
|
}
|
|
170
119
|
} catch (error) {
|
|
171
120
|
manifest_error = /** @type {Error} */ (error);
|
|
172
121
|
|
|
173
122
|
console.error(styleText(['bold', 'red'], manifest_error.message));
|
|
174
|
-
|
|
123
|
+
hot.send({
|
|
175
124
|
type: 'error',
|
|
176
125
|
err: {
|
|
177
126
|
message: manifest_error.message ?? 'Invalid routes',
|
|
@@ -182,179 +131,15 @@ export async function dev(
|
|
|
182
131
|
return;
|
|
183
132
|
}
|
|
184
133
|
|
|
185
|
-
manifest =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
imports: [],
|
|
195
|
-
stylesheets: [],
|
|
196
|
-
fonts: [],
|
|
197
|
-
uses_env_dynamic_public: true,
|
|
198
|
-
nodes:
|
|
199
|
-
svelte_config.router.resolution === 'client'
|
|
200
|
-
? undefined
|
|
201
|
-
: manifest_data.nodes.map((node, i) => {
|
|
202
|
-
if (node.component || node.universal) {
|
|
203
|
-
return `${svelte_config.paths.base}${to_fs(svelte_config.outDir)}/generated/dev/client/nodes/${i}.js`;
|
|
204
|
-
}
|
|
205
|
-
}),
|
|
206
|
-
// `css` is not necessary in dev, as the JS file from `nodes` will reference the CSS file
|
|
207
|
-
routes:
|
|
208
|
-
svelte_config.router.resolution === 'client'
|
|
209
|
-
? undefined
|
|
210
|
-
: compact(
|
|
211
|
-
manifest_data.routes.map((route) => {
|
|
212
|
-
if (!route.page) return;
|
|
213
|
-
|
|
214
|
-
return {
|
|
215
|
-
id: route.id,
|
|
216
|
-
pattern: route.pattern,
|
|
217
|
-
params: route.params,
|
|
218
|
-
layouts: route.page.layouts.map((l) =>
|
|
219
|
-
l !== undefined ? [!!manifest_data.nodes[l].server, l] : undefined
|
|
220
|
-
),
|
|
221
|
-
errors: route.page.errors,
|
|
222
|
-
leaf: [!!manifest_data.nodes[route.page.leaf].server, route.page.leaf]
|
|
223
|
-
};
|
|
224
|
-
})
|
|
225
|
-
)
|
|
226
|
-
},
|
|
227
|
-
server_assets: new Proxy(
|
|
228
|
-
{},
|
|
229
|
-
{
|
|
230
|
-
has: (_, /** @type {string} */ file) => fs.existsSync(from_fs(file)),
|
|
231
|
-
get: (_, /** @type {string} */ file) => fs.statSync(from_fs(file)).size
|
|
232
|
-
}
|
|
233
|
-
),
|
|
234
|
-
nodes: manifest_data.nodes.map((node, index) => {
|
|
235
|
-
return async () => {
|
|
236
|
-
const result = /** @type {SSRNode} */ ({});
|
|
237
|
-
result.index = index;
|
|
238
|
-
result.universal_id = node.universal;
|
|
239
|
-
result.server_id = node.server;
|
|
240
|
-
|
|
241
|
-
// these are unused in dev, but it's easier to include them
|
|
242
|
-
result.imports = [];
|
|
243
|
-
result.stylesheets = [];
|
|
244
|
-
result.fonts = [];
|
|
245
|
-
|
|
246
|
-
/** @type {EnvironmentModuleNode[]} */
|
|
247
|
-
const module_nodes = [];
|
|
248
|
-
|
|
249
|
-
if (node.component) {
|
|
250
|
-
result.component = async () => {
|
|
251
|
-
const { module_node, module } = await resolve(
|
|
252
|
-
/** @type {string} */ (node.component)
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
module_nodes.push(module_node);
|
|
256
|
-
|
|
257
|
-
return module.default;
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (node.universal) {
|
|
262
|
-
if (node.page_options?.ssr === false) {
|
|
263
|
-
result.universal = /** @type {UniversalNode} */ (node.page_options);
|
|
264
|
-
} else {
|
|
265
|
-
// TODO: explain why the file was loaded on the server if we fail to load it
|
|
266
|
-
const { module, module_node } = await resolve(node.universal);
|
|
267
|
-
module_nodes.push(module_node);
|
|
268
|
-
result.universal = module;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (node.server) {
|
|
273
|
-
const { module } = await resolve(node.server);
|
|
274
|
-
result.server = module;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// in dev we inline all styles to avoid FOUC. this gets populated lazily so that
|
|
278
|
-
// components/stylesheets loaded via import() during `load` are included
|
|
279
|
-
result.inline_styles = async () => {
|
|
280
|
-
/** @type {Set<EnvironmentModuleNode>} */
|
|
281
|
-
const deps = new Set();
|
|
282
|
-
|
|
283
|
-
for (const module_node of module_nodes) {
|
|
284
|
-
await find_deps(vite_dev_server, module_node, deps);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/** @type {Record<string, string>} */
|
|
288
|
-
const styles = {};
|
|
289
|
-
|
|
290
|
-
for (const dep of deps) {
|
|
291
|
-
if (vite.isCSSRequest(dep.url) && !vite_css_query_regex.test(dep.url)) {
|
|
292
|
-
const inlineCssUrl = dep.url.includes('?')
|
|
293
|
-
? dep.url.replace('?', '?inline&')
|
|
294
|
-
: dep.url + '?inline';
|
|
295
|
-
try {
|
|
296
|
-
const mod = await runner.import(inlineCssUrl);
|
|
297
|
-
styles[dep.url] = mod.default;
|
|
298
|
-
} catch {
|
|
299
|
-
// this can happen with dynamically imported modules, I think
|
|
300
|
-
// because the Vite module graph doesn't distinguish between
|
|
301
|
-
// static and dynamic imports? TODO investigate, submit fix
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return styles;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
return result;
|
|
310
|
-
};
|
|
311
|
-
}),
|
|
312
|
-
prerendered_routes: new Set(),
|
|
313
|
-
get remotes() {
|
|
314
|
-
return Object.fromEntries(
|
|
315
|
-
get_remotes().map((remote) => [
|
|
316
|
-
remote.hash,
|
|
317
|
-
() => runner.import(remote.file).then((module) => ({ default: module }))
|
|
318
|
-
])
|
|
319
|
-
);
|
|
320
|
-
},
|
|
321
|
-
routes: compact(
|
|
322
|
-
manifest_data.routes.map((route) => {
|
|
323
|
-
if (!route.page && !route.endpoint) return null;
|
|
324
|
-
|
|
325
|
-
const endpoint = route.endpoint;
|
|
326
|
-
|
|
327
|
-
return {
|
|
328
|
-
id: route.id,
|
|
329
|
-
pattern: route.pattern,
|
|
330
|
-
params: route.params,
|
|
331
|
-
page: route.page,
|
|
332
|
-
endpoint: endpoint
|
|
333
|
-
? async () => {
|
|
334
|
-
const url = path.resolve(root, endpoint.file);
|
|
335
|
-
return await loud_ssr_load_module(url);
|
|
336
|
-
}
|
|
337
|
-
: null,
|
|
338
|
-
endpoint_id: endpoint?.file
|
|
339
|
-
};
|
|
340
|
-
})
|
|
341
|
-
),
|
|
342
|
-
matchers: async () => {
|
|
343
|
-
if (!manifest_data.params) return {};
|
|
344
|
-
|
|
345
|
-
const url = path.resolve(root, manifest_data.params);
|
|
346
|
-
const module = await runner.import(url);
|
|
347
|
-
|
|
348
|
-
if (!module.params) {
|
|
349
|
-
throw new Error(
|
|
350
|
-
`${manifest_data.params} does not export \`params\` from \`defineParams\``
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return module.params;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
};
|
|
134
|
+
manifest = generate_manifest(
|
|
135
|
+
vite,
|
|
136
|
+
vite_dev_server,
|
|
137
|
+
runner,
|
|
138
|
+
svelte_config,
|
|
139
|
+
manifest_data,
|
|
140
|
+
root,
|
|
141
|
+
get_remotes
|
|
142
|
+
);
|
|
358
143
|
}
|
|
359
144
|
|
|
360
145
|
/** @param {Error} error */
|
|
@@ -456,7 +241,7 @@ export async function dev(
|
|
|
456
241
|
if (appTemplate !== 'index.html') {
|
|
457
242
|
vite_dev_server.watcher.on('change', (file) => {
|
|
458
243
|
if (file === appTemplate) {
|
|
459
|
-
|
|
244
|
+
hot.send({ type: 'full-reload' });
|
|
460
245
|
}
|
|
461
246
|
});
|
|
462
247
|
}
|
|
@@ -503,7 +288,7 @@ export async function dev(
|
|
|
503
288
|
next();
|
|
504
289
|
});
|
|
505
290
|
|
|
506
|
-
const env = vite.loadEnv(
|
|
291
|
+
const env = vite.loadEnv(vite_dev_server.config.mode, svelte_config.env.dir, '');
|
|
507
292
|
const emulator = await svelte_config.adapter?.emulate?.();
|
|
508
293
|
|
|
509
294
|
/** @type {Promise<void> | undefined} */
|
|
@@ -539,8 +324,8 @@ export async function dev(
|
|
|
539
324
|
);
|
|
540
325
|
const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory();
|
|
541
326
|
const allowed =
|
|
542
|
-
!
|
|
543
|
-
|
|
327
|
+
!vite_dev_server.config.server.fs.strict ||
|
|
328
|
+
vite_dev_server.config.server.fs.allow.some((dir) => file.startsWith(dir));
|
|
544
329
|
|
|
545
330
|
if (is_file && allowed) {
|
|
546
331
|
req.url = original_url;
|
|
@@ -586,6 +371,8 @@ export async function dev(
|
|
|
586
371
|
);
|
|
587
372
|
}
|
|
588
373
|
|
|
374
|
+
const { set_env } = await runner.import('<sveltekit:generated>/env/config.js');
|
|
375
|
+
set_env(env);
|
|
589
376
|
await runner.import(resolved_instrumentation);
|
|
590
377
|
}
|
|
591
378
|
|
|
@@ -609,7 +396,7 @@ export async function dev(
|
|
|
609
396
|
read: (file) => createReadableStream(from_fs(file))
|
|
610
397
|
});
|
|
611
398
|
|
|
612
|
-
const request = getRequest({
|
|
399
|
+
const request = (svelte_config.adapter?.vite?.getRequest ?? getRequest)({
|
|
613
400
|
base,
|
|
614
401
|
request: req,
|
|
615
402
|
response: res
|
|
@@ -644,7 +431,7 @@ export async function dev(
|
|
|
644
431
|
throw new Error('Could not determine clientAddress');
|
|
645
432
|
},
|
|
646
433
|
read: (file) => {
|
|
647
|
-
if (file in manifest.
|
|
434
|
+
if (file in manifest.server_assets) {
|
|
648
435
|
return fs.readFileSync(from_fs(file));
|
|
649
436
|
}
|
|
650
437
|
|
|
@@ -662,11 +449,11 @@ export async function dev(
|
|
|
662
449
|
// @ts-expect-error
|
|
663
450
|
serve_static_middleware.handle(req, res, () => {
|
|
664
451
|
log_dev_response(rendered.status, format_response(rendered.status, request));
|
|
665
|
-
setResponse(res, rendered);
|
|
452
|
+
(svelte_config.adapter?.vite?.setResponse ?? setResponse)(res, rendered);
|
|
666
453
|
});
|
|
667
454
|
} else {
|
|
668
455
|
log_dev_response(rendered.status, format_response(rendered.status, request));
|
|
669
|
-
setResponse(res, rendered);
|
|
456
|
+
(svelte_config.adapter?.vite?.setResponse ?? setResponse)(res, rendered);
|
|
670
457
|
}
|
|
671
458
|
} catch (e) {
|
|
672
459
|
const error = coalesce_to_error(e);
|
|
@@ -692,49 +479,6 @@ function remove_static_middlewares(server) {
|
|
|
692
479
|
}
|
|
693
480
|
}
|
|
694
481
|
|
|
695
|
-
/**
|
|
696
|
-
* @param {ViteDevServer} vite
|
|
697
|
-
* @param {EnvironmentModuleNode} node
|
|
698
|
-
* @param {Set<EnvironmentModuleNode>} deps
|
|
699
|
-
*/
|
|
700
|
-
async function find_deps(vite, node, deps) {
|
|
701
|
-
// since `transformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous.
|
|
702
|
-
// instead of using `await`, we resolve all branches in parallel.
|
|
703
|
-
/** @type {Promise<void>[]} */
|
|
704
|
-
const branches = [];
|
|
705
|
-
|
|
706
|
-
/** @param {EnvironmentModuleNode} node */
|
|
707
|
-
async function add(node) {
|
|
708
|
-
if (!deps.has(node)) {
|
|
709
|
-
deps.add(node);
|
|
710
|
-
await find_deps(vite, node, deps);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
/** @param {string} url */
|
|
715
|
-
async function add_by_url(url) {
|
|
716
|
-
const node = await vite.environments.ssr.moduleGraph.getModuleByUrl(url);
|
|
717
|
-
|
|
718
|
-
if (node) {
|
|
719
|
-
await add(node);
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
if (node.transformResult) {
|
|
724
|
-
if (node.transformResult.deps) {
|
|
725
|
-
node.transformResult.deps.forEach((url) => branches.push(add_by_url(url)));
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
if (node.transformResult.dynamicDeps) {
|
|
729
|
-
node.transformResult.dynamicDeps.forEach((url) => branches.push(add_by_url(url)));
|
|
730
|
-
}
|
|
731
|
-
} else {
|
|
732
|
-
node.importedModules.forEach((node) => branches.push(add(node)));
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
await Promise.all(branches);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
482
|
/**
|
|
739
483
|
* Determine if a file is being requested with the correct case,
|
|
740
484
|
* to ensure consistent behaviour between dev and prod and across
|