@sveltejs/kit 2.63.0 → 3.0.0-next.1
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 +17 -22
- package/src/cli.js +19 -16
- package/src/core/adapt/builder.js +25 -77
- package/src/core/adapt/index.js +6 -4
- package/src/core/config/index.js +12 -84
- package/src/core/config/options.js +36 -46
- package/src/core/env.js +5 -130
- package/src/core/generate_manifest/find_server_assets.js +3 -2
- package/src/core/generate_manifest/index.js +11 -3
- package/src/core/postbuild/analyse.js +19 -16
- package/src/core/postbuild/fallback.js +0 -3
- package/src/core/postbuild/prerender.js +18 -17
- package/src/core/postbuild/queue.js +3 -4
- package/src/core/sync/create_manifest_data/index.js +16 -18
- package/src/core/sync/sync.js +30 -25
- package/src/core/sync/utils.js +0 -15
- package/src/core/sync/write_ambient.js +3 -54
- package/src/core/sync/write_client_manifest.js +8 -9
- package/src/core/sync/write_env.js +5 -1
- package/src/core/sync/write_non_ambient.js +7 -7
- package/src/core/sync/write_root.js +40 -88
- package/src/core/sync/write_server.js +16 -23
- package/src/core/sync/write_tsconfig.js +28 -24
- package/src/core/sync/write_types/index.js +31 -25
- package/src/core/utils.js +14 -11
- package/src/exports/index.js +8 -21
- package/src/exports/node/index.js +8 -13
- package/src/exports/public.d.ts +35 -76
- package/src/exports/vite/build/build_server.js +14 -11
- package/src/exports/vite/build/remote.js +6 -7
- package/src/exports/vite/build/utils.js +7 -5
- package/src/exports/vite/dev/index.js +30 -31
- package/src/exports/vite/index.js +938 -732
- package/src/exports/vite/module_ids.js +1 -6
- package/src/exports/vite/options.js +17 -0
- package/src/exports/vite/preview/index.js +3 -5
- package/src/exports/vite/static_analysis/index.js +11 -5
- package/src/exports/vite/utils.js +9 -45
- package/src/runtime/app/env/internal.js +3 -0
- package/src/runtime/app/env/public/client.js +0 -6
- package/src/runtime/app/env/public/server.js +0 -6
- package/src/runtime/app/environment/index.js +3 -7
- package/src/runtime/app/server/index.js +4 -2
- package/src/runtime/app/server/remote/form.js +0 -51
- package/src/runtime/app/server/remote/query.js +0 -7
- package/src/runtime/app/server/remote/shared.js +4 -3
- package/src/runtime/app/state/client.js +1 -12
- package/src/runtime/client/client.js +1 -1
- package/src/runtime/client/constants.js +0 -1
- package/src/runtime/client/remote-functions/form.svelte.js +0 -31
- package/src/runtime/client/remote-functions/query/index.js +2 -2
- package/src/runtime/client/remote-functions/query/instance.svelte.js +1 -2
- package/src/runtime/client/remote-functions/query-batch.svelte.js +2 -2
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +5 -8
- package/src/runtime/client/utils.js +8 -10
- package/src/runtime/components/{svelte-5/layout.svelte → layout.svelte} +1 -1
- package/src/runtime/form-utils.js +4 -41
- package/src/runtime/server/cookie.js +21 -37
- package/src/runtime/server/env_module.js +1 -3
- package/src/runtime/server/fetch.js +6 -10
- package/src/runtime/server/index.js +3 -9
- package/src/runtime/server/page/render.js +32 -44
- package/src/runtime/server/page/types.d.ts +4 -2
- package/src/runtime/server/respond.js +2 -2
- package/src/runtime/server/utils.js +2 -4
- package/src/runtime/shared-server.js +0 -22
- package/src/runtime/shared.js +0 -15
- package/src/types/global-private.d.ts +5 -1
- package/src/types/internal.d.ts +3 -8
- package/src/utils/css.js +3 -19
- package/src/utils/filesystem.js +1 -30
- package/src/utils/http.js +0 -21
- package/src/utils/import.js +7 -6
- package/src/utils/os.js +7 -0
- package/src/utils/path.js +23 -0
- package/src/utils/shared-iterator.js +3 -0
- package/src/utils/streaming.js +2 -4
- package/src/utils/url.js +1 -1
- package/src/utils/vite.js +28 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +45 -138
- package/types/index.d.ts.map +1 -8
- package/src/exports/vite/build/build_service_worker.js +0 -165
- package/src/runtime/app/environment/types.d.ts +0 -19
- package/src/runtime/components/svelte-4/error.svelte +0 -6
- package/src/runtime/components/svelte-4/layout.svelte +0 -1
- package/src/runtime/env/dynamic/private.js +0 -1
- package/src/runtime/env/dynamic/public.js +0 -1
- package/src/types/synthetic/$env+dynamic+private.md +0 -43
- package/src/types/synthetic/$env+dynamic+public.md +0 -46
- package/src/types/synthetic/$env+static+private.md +0 -31
- package/src/types/synthetic/$env+static+public.md +0 -31
- package/src/utils/env.js +0 -13
- package/src/utils/promise.js +0 -29
- /package/src/runtime/components/{svelte-5/error.svelte → error.svelte} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import { AssetDependencies, ManifestData, SSRNode, ValidatedKitConfig } from 'types' */
|
|
2
|
-
/** @import { Manifest,
|
|
2
|
+
/** @import { Manifest, Rolldown } from 'vite' */
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import { mkdirp } from '../../../utils/filesystem.js';
|
|
5
5
|
import {
|
|
@@ -24,6 +24,7 @@ import { escape_for_interpolation } from '../../../utils/escape.js';
|
|
|
24
24
|
* @param {null} client_manifest
|
|
25
25
|
* @param {null} assets_path
|
|
26
26
|
* @param {null} client_chunks
|
|
27
|
+
* @param {string} root
|
|
27
28
|
* @returns {void}
|
|
28
29
|
*/
|
|
29
30
|
/**
|
|
@@ -34,7 +35,8 @@ import { escape_for_interpolation } from '../../../utils/escape.js';
|
|
|
34
35
|
* @param {Manifest} server_manifest
|
|
35
36
|
* @param {Manifest} client_manifest
|
|
36
37
|
* @param {string} assets_path
|
|
37
|
-
* @param {
|
|
38
|
+
* @param {Rolldown.RolldownOutput['output']} client_chunks
|
|
39
|
+
* @param {string} root
|
|
38
40
|
* @returns {void}
|
|
39
41
|
*/
|
|
40
42
|
/**
|
|
@@ -44,8 +46,8 @@ import { escape_for_interpolation } from '../../../utils/escape.js';
|
|
|
44
46
|
* @param {Manifest} server_manifest
|
|
45
47
|
* @param {Manifest | null} client_manifest
|
|
46
48
|
* @param {string | null} assets_path
|
|
47
|
-
* @param {
|
|
48
|
-
* @
|
|
49
|
+
* @param {Rolldown.RolldownOutput['output'] | null} client_chunks
|
|
50
|
+
* @param {string} root
|
|
49
51
|
*/
|
|
50
52
|
export function build_server_nodes(
|
|
51
53
|
out,
|
|
@@ -54,7 +56,8 @@ export function build_server_nodes(
|
|
|
54
56
|
server_manifest,
|
|
55
57
|
client_manifest,
|
|
56
58
|
assets_path,
|
|
57
|
-
client_chunks
|
|
59
|
+
client_chunks,
|
|
60
|
+
root
|
|
58
61
|
) {
|
|
59
62
|
mkdirp(`${out}/server/nodes`);
|
|
60
63
|
mkdirp(`${out}/server/stylesheets`);
|
|
@@ -156,7 +159,7 @@ export function build_server_nodes(
|
|
|
156
159
|
exports.push(
|
|
157
160
|
'let component_cache;',
|
|
158
161
|
`export const component = async () => component_cache ??= (await import('../${
|
|
159
|
-
resolve_symlinks(server_manifest, node.component).chunk.file
|
|
162
|
+
resolve_symlinks(server_manifest, node.component, root).chunk.file
|
|
160
163
|
}')).default;`
|
|
161
164
|
);
|
|
162
165
|
}
|
|
@@ -166,7 +169,7 @@ export function build_server_nodes(
|
|
|
166
169
|
exports.push(`export const universal = ${s(node.page_options, null, 2)};`);
|
|
167
170
|
} else {
|
|
168
171
|
imports.push(
|
|
169
|
-
`import * as universal from '../${resolve_symlinks(server_manifest, node.universal).chunk.file}';`
|
|
172
|
+
`import * as universal from '../${resolve_symlinks(server_manifest, node.universal, root).chunk.file}';`
|
|
170
173
|
);
|
|
171
174
|
// TODO: when building for analysis, explain why the file was loaded on the server if we fail to load it
|
|
172
175
|
exports.push('export { universal };');
|
|
@@ -176,7 +179,7 @@ export function build_server_nodes(
|
|
|
176
179
|
|
|
177
180
|
if (node.server) {
|
|
178
181
|
imports.push(
|
|
179
|
-
`import * as server from '../${resolve_symlinks(server_manifest, node.server).chunk.file}';`
|
|
182
|
+
`import * as server from '../${resolve_symlinks(server_manifest, node.server, root).chunk.file}';`
|
|
180
183
|
);
|
|
181
184
|
exports.push('export { server };');
|
|
182
185
|
exports.push(`export const server_id = ${s(node.server)};`);
|
|
@@ -188,7 +191,7 @@ export function build_server_nodes(
|
|
|
188
191
|
kit.output.bundleStrategy === 'split'
|
|
189
192
|
) {
|
|
190
193
|
const entry_path = `${normalizePath(kit.outDir)}/generated/client-optimized/nodes/${i}.js`;
|
|
191
|
-
const entry = find_deps(client_manifest, entry_path, true);
|
|
194
|
+
const entry = find_deps(client_manifest, entry_path, true, root);
|
|
192
195
|
|
|
193
196
|
// Eagerly load client stylesheets and fonts imported by the SSR-ed page to avoid FOUC.
|
|
194
197
|
// However, if it is not used during SSR (not present in the server manifest),
|
|
@@ -197,13 +200,13 @@ export function build_server_nodes(
|
|
|
197
200
|
/** @type {AssetDependencies | undefined} */
|
|
198
201
|
let component;
|
|
199
202
|
if (node.component) {
|
|
200
|
-
component = find_deps(server_manifest, node.component, true);
|
|
203
|
+
component = find_deps(server_manifest, node.component, true, root);
|
|
201
204
|
}
|
|
202
205
|
|
|
203
206
|
/** @type {AssetDependencies | undefined} */
|
|
204
207
|
let universal;
|
|
205
208
|
if (node.universal) {
|
|
206
|
-
universal = find_deps(server_manifest, node.universal, true);
|
|
209
|
+
universal = find_deps(server_manifest, node.universal, true, root);
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
/** @type {Set<string>} */
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
/** @import { ServerMetadata } from 'types' */
|
|
2
|
-
/** @import {
|
|
2
|
+
/** @import { Rolldown } from 'vite' */
|
|
3
3
|
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { Parser } from 'acorn';
|
|
7
7
|
import MagicString from 'magic-string';
|
|
8
|
-
import { posixify } from '../../../utils/
|
|
9
|
-
import { import_peer } from '../../../utils/import.js';
|
|
8
|
+
import { posixify } from '../../../utils/os.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
11
|
+
* @param {typeof import('vite')} vite
|
|
12
12
|
* @param {string} out
|
|
13
13
|
* @param {Array<{ hash: string, file: string }>} remotes
|
|
14
14
|
* @param {ServerMetadata} metadata
|
|
15
15
|
* @param {string} cwd
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {Rolldown.RolldownOutput} server_bundle
|
|
17
17
|
* @param {NonNullable<import('vitest/config').ViteUserConfig['build']>['sourcemap']} sourcemap
|
|
18
18
|
*/
|
|
19
19
|
export async function treeshake_prerendered_remotes(
|
|
20
|
+
vite,
|
|
20
21
|
out,
|
|
21
22
|
remotes,
|
|
22
23
|
metadata,
|
|
@@ -26,8 +27,6 @@ export async function treeshake_prerendered_remotes(
|
|
|
26
27
|
) {
|
|
27
28
|
if (remotes.length === 0) return;
|
|
28
29
|
|
|
29
|
-
const vite = /** @type {typeof import('vite')} */ (await import_peer('vite'));
|
|
30
|
-
|
|
31
30
|
for (const remote of remotes) {
|
|
32
31
|
const exports_map = metadata.remotes.get(remote.hash);
|
|
33
32
|
if (!exports_map) continue;
|
|
@@ -90,7 +89,7 @@ export async function treeshake_prerendered_remotes(
|
|
|
90
89
|
const stubbed = modified_code.toString();
|
|
91
90
|
fs.writeFileSync(chunk_path, stubbed);
|
|
92
91
|
|
|
93
|
-
const bundle = /** @type {import('vite').
|
|
92
|
+
const bundle = /** @type {import('vite').Rolldown.RolldownOutput} */ (
|
|
94
93
|
await vite.build({
|
|
95
94
|
configFile: false,
|
|
96
95
|
build: {
|
|
@@ -7,9 +7,10 @@ import { normalizePath } from 'vite';
|
|
|
7
7
|
* @param {import('vite').Manifest} manifest
|
|
8
8
|
* @param {string} entry
|
|
9
9
|
* @param {boolean} add_dynamic_css
|
|
10
|
+
* @param {string} root
|
|
10
11
|
* @returns {import('types').AssetDependencies}
|
|
11
12
|
*/
|
|
12
|
-
export function find_deps(manifest, entry, add_dynamic_css) {
|
|
13
|
+
export function find_deps(manifest, entry, add_dynamic_css, root) {
|
|
13
14
|
/** @type {Set<string>} */
|
|
14
15
|
const seen = new Set();
|
|
15
16
|
|
|
@@ -35,7 +36,7 @@ export function find_deps(manifest, entry, add_dynamic_css) {
|
|
|
35
36
|
if (seen.has(current)) return;
|
|
36
37
|
seen.add(current);
|
|
37
38
|
|
|
38
|
-
const { chunk } = resolve_symlinks(manifest, current);
|
|
39
|
+
const { chunk } = resolve_symlinks(manifest, current, root);
|
|
39
40
|
|
|
40
41
|
if (add_js) imports.add(chunk.file);
|
|
41
42
|
|
|
@@ -81,7 +82,7 @@ export function find_deps(manifest, entry, add_dynamic_css) {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
const { chunk, file } = resolve_symlinks(manifest, entry);
|
|
85
|
+
const { chunk, file } = resolve_symlinks(manifest, entry, root);
|
|
85
86
|
|
|
86
87
|
traverse(file, true, entry, 0);
|
|
87
88
|
|
|
@@ -101,10 +102,11 @@ export function find_deps(manifest, entry, add_dynamic_css) {
|
|
|
101
102
|
/**
|
|
102
103
|
* @param {import('vite').Manifest} manifest
|
|
103
104
|
* @param {string} file
|
|
105
|
+
* @param {string} root
|
|
104
106
|
*/
|
|
105
|
-
export function resolve_symlinks(manifest, file) {
|
|
107
|
+
export function resolve_symlinks(manifest, file, root) {
|
|
106
108
|
while (!manifest[file]) {
|
|
107
|
-
const next = normalizePath(path.relative(
|
|
109
|
+
const next = normalizePath(path.relative(root, fs.realpathSync(file)));
|
|
108
110
|
if (next === file) throw new Error(`Could not find file "${file}" in Vite manifest`);
|
|
109
111
|
file = next;
|
|
110
112
|
}
|
|
@@ -2,27 +2,26 @@
|
|
|
2
2
|
/** @import { PrerenderOption, UniversalNode } from 'types' */
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import process from 'node:process';
|
|
6
5
|
import { URL } from 'node:url';
|
|
7
6
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
8
|
-
import
|
|
7
|
+
import { styleText } from 'node:util';
|
|
9
8
|
import sirv from 'sirv';
|
|
10
9
|
import { isCSSRequest, loadEnv, buildErrorMessage } from 'vite';
|
|
11
10
|
import { createReadableStream, getRequest, setResponse } from '../../../exports/node/index.js';
|
|
12
|
-
import { installPolyfills } from '../../../exports/node/polyfills.js';
|
|
13
11
|
import { coalesce_to_error } from '../../../utils/error.js';
|
|
14
|
-
import {
|
|
12
|
+
import { resolve_entry } from '../../../utils/filesystem.js';
|
|
13
|
+
import { from_fs, to_fs } from '../../../utils/vite.js';
|
|
14
|
+
import { posixify } from '../../../utils/os.js';
|
|
15
15
|
import { load_error_page } from '../../../core/config/index.js';
|
|
16
16
|
import { SVELTE_KIT_ASSETS } from '../../../constants.js';
|
|
17
17
|
import * as sync from '../../../core/sync/sync.js';
|
|
18
|
-
import { get_mime_lookup,
|
|
18
|
+
import { get_mime_lookup, get_runtime_base } from '../../../core/utils.js';
|
|
19
19
|
import { compact } from '../../../utils/array.js';
|
|
20
20
|
import { is_chrome_devtools_request, not_found } from '../utils.js';
|
|
21
21
|
import { SCHEME } from '../../../utils/url.js';
|
|
22
22
|
import { check_feature } from '../../../utils/features.js';
|
|
23
23
|
import { escape_html } from '../../../utils/escape.js';
|
|
24
24
|
|
|
25
|
-
const cwd = process.cwd();
|
|
26
25
|
// vite-specifc queries that we should skip handling for css urls
|
|
27
26
|
const vite_css_query_regex = /(?:\?|&)(?:raw|url|inline)(?:&|$)/;
|
|
28
27
|
|
|
@@ -31,11 +30,11 @@ const vite_css_query_regex = /(?:\?|&)(?:raw|url|inline)(?:&|$)/;
|
|
|
31
30
|
* @param {import('vite').ResolvedConfig} vite_config
|
|
32
31
|
* @param {import('types').ValidatedConfig} svelte_config
|
|
33
32
|
* @param {() => Array<{ hash: string, file: string }>} get_remotes
|
|
33
|
+
* @param {string} root The project root directory
|
|
34
|
+
* @param {import('@sveltejs/kit').Adapter | undefined} adapter
|
|
34
35
|
* @return {Promise<Promise<() => void>>}
|
|
35
36
|
*/
|
|
36
|
-
export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
37
|
-
installPolyfills();
|
|
38
|
-
|
|
37
|
+
export async function dev(vite, vite_config, svelte_config, get_remotes, root, adapter) {
|
|
39
38
|
/** @type {AsyncLocalStorage<{ event: RequestEvent, config: any, prerender: PrerenderOption }>} */
|
|
40
39
|
const async_local_storage = new AsyncLocalStorage();
|
|
41
40
|
|
|
@@ -43,12 +42,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
43
42
|
const context = async_local_storage.getStore();
|
|
44
43
|
if (!context || context.prerender === true) return;
|
|
45
44
|
|
|
46
|
-
check_feature(
|
|
47
|
-
/** @type {string} */ (context.event.route.id),
|
|
48
|
-
context.config,
|
|
49
|
-
label,
|
|
50
|
-
svelte_config.kit.adapter
|
|
51
|
-
);
|
|
45
|
+
check_feature(/** @type {string} */ (context.event.route.id), context.config, label, adapter);
|
|
52
46
|
};
|
|
53
47
|
|
|
54
48
|
const fetch = globalThis.fetch;
|
|
@@ -62,7 +56,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
62
56
|
return fetch(info, init);
|
|
63
57
|
};
|
|
64
58
|
|
|
65
|
-
sync.init(svelte_config,
|
|
59
|
+
sync.init(svelte_config, root);
|
|
66
60
|
|
|
67
61
|
/** @type {import('types').ManifestData} */
|
|
68
62
|
let manifest_data;
|
|
@@ -76,9 +70,10 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
76
70
|
async function loud_ssr_load_module(url) {
|
|
77
71
|
try {
|
|
78
72
|
return await vite.ssrLoadModule(url, { fixStacktrace: true });
|
|
79
|
-
} catch (/** @type {
|
|
80
|
-
const
|
|
81
|
-
|
|
73
|
+
} catch (/** @type {any} */ err) {
|
|
74
|
+
const msg = buildErrorMessage(err, [
|
|
75
|
+
styleText('red', `Internal server error: ${err.message}`)
|
|
76
|
+
]);
|
|
82
77
|
|
|
83
78
|
if (!vite.config.logger.hasErrorLogged(err)) {
|
|
84
79
|
vite.config.logger.error(msg, { error: err });
|
|
@@ -113,7 +108,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
113
108
|
|
|
114
109
|
function update_manifest() {
|
|
115
110
|
try {
|
|
116
|
-
({ manifest_data } = sync.create(svelte_config));
|
|
111
|
+
({ manifest_data } = sync.create(svelte_config, root));
|
|
117
112
|
|
|
118
113
|
if (manifest_error) {
|
|
119
114
|
manifest_error = null;
|
|
@@ -122,7 +117,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
122
117
|
} catch (error) {
|
|
123
118
|
manifest_error = /** @type {Error} */ (error);
|
|
124
119
|
|
|
125
|
-
console.error(
|
|
120
|
+
console.error(styleText(['bold', 'red'], manifest_error.message));
|
|
126
121
|
vite.ws.send({
|
|
127
122
|
type: 'error',
|
|
128
123
|
err: {
|
|
@@ -141,7 +136,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
141
136
|
mimeTypes: get_mime_lookup(manifest_data),
|
|
142
137
|
_: {
|
|
143
138
|
client: {
|
|
144
|
-
start: `${
|
|
139
|
+
start: `${get_runtime_base(root)}/client/entry.js`,
|
|
145
140
|
app: `${to_fs(svelte_config.kit.outDir)}/generated/client/app.js`,
|
|
146
141
|
imports: [],
|
|
147
142
|
stylesheets: [],
|
|
@@ -284,7 +279,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
284
279
|
page: route.page,
|
|
285
280
|
endpoint: endpoint
|
|
286
281
|
? async () => {
|
|
287
|
-
const url = path.resolve(
|
|
282
|
+
const url = path.resolve(root, endpoint.file);
|
|
288
283
|
return await loud_ssr_load_module(url);
|
|
289
284
|
}
|
|
290
285
|
: null,
|
|
@@ -298,7 +293,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
298
293
|
|
|
299
294
|
for (const key in manifest_data.matchers) {
|
|
300
295
|
const file = manifest_data.matchers[key];
|
|
301
|
-
const url = path.resolve(
|
|
296
|
+
const url = path.resolve(root, file);
|
|
302
297
|
const module = await vite.ssrLoadModule(url, { fixStacktrace: true });
|
|
303
298
|
|
|
304
299
|
if (module.match) {
|
|
@@ -368,7 +363,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
368
363
|
// Don't run for a single file if the whole manifest is about to get updated
|
|
369
364
|
// Unless it's a file where the trailing slash page option might have changed
|
|
370
365
|
if (timeout || restarting || !/\+(page|layout|server).*$/.test(file)) return;
|
|
371
|
-
sync.update(svelte_config, manifest_data, file);
|
|
366
|
+
sync.update(svelte_config, manifest_data, file, root);
|
|
372
367
|
});
|
|
373
368
|
|
|
374
369
|
const { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.kit.files;
|
|
@@ -391,7 +386,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
391
386
|
file.startsWith(serviceWorker) ||
|
|
392
387
|
file.startsWith(hooks.server)
|
|
393
388
|
) {
|
|
394
|
-
sync.server(svelte_config);
|
|
389
|
+
sync.server(svelte_config, root);
|
|
395
390
|
}
|
|
396
391
|
});
|
|
397
392
|
|
|
@@ -441,7 +436,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
441
436
|
});
|
|
442
437
|
|
|
443
438
|
const env = loadEnv(vite_config.mode, svelte_config.kit.env.dir, '');
|
|
444
|
-
const emulator = await
|
|
439
|
+
const emulator = await adapter?.emulate?.();
|
|
445
440
|
|
|
446
441
|
return () => {
|
|
447
442
|
const serve_static_middleware = vite.middlewares.stack.find(
|
|
@@ -463,7 +458,9 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
463
458
|
}`;
|
|
464
459
|
|
|
465
460
|
const decoded = decodeURI(new URL(base + req.url).pathname);
|
|
466
|
-
const file = posixify(
|
|
461
|
+
const file = posixify(
|
|
462
|
+
path.resolve(root, decoded.slice(svelte_config.kit.paths.base.length + 1))
|
|
463
|
+
);
|
|
467
464
|
const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory();
|
|
468
465
|
const allowed =
|
|
469
466
|
!vite_config.server.fs.strict ||
|
|
@@ -510,11 +507,13 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
510
507
|
|
|
511
508
|
// we have to import `Server` before calling `set_assets`
|
|
512
509
|
const { Server } = /** @type {import('types').ServerModule} */ (
|
|
513
|
-
await vite.ssrLoadModule(`${
|
|
510
|
+
await vite.ssrLoadModule(`${get_runtime_base(root)}/server/index.js`, {
|
|
511
|
+
fixStacktrace: true
|
|
512
|
+
})
|
|
514
513
|
);
|
|
515
514
|
|
|
516
515
|
const { set_fix_stack_trace } = await vite.ssrLoadModule(
|
|
517
|
-
`${
|
|
516
|
+
`${get_runtime_base(root)}/shared-server.js`
|
|
518
517
|
);
|
|
519
518
|
set_fix_stack_trace(fix_stack_trace);
|
|
520
519
|
|
|
@@ -534,7 +533,7 @@ export async function dev(vite, vite_config, svelte_config, get_remotes) {
|
|
|
534
533
|
});
|
|
535
534
|
|
|
536
535
|
if (manifest_error) {
|
|
537
|
-
console.error(
|
|
536
|
+
console.error(styleText(['bold', 'red'], manifest_error.message));
|
|
538
537
|
|
|
539
538
|
const error_page = load_error_page(svelte_config);
|
|
540
539
|
|