@sveltejs/kit 1.0.0-next.584 → 1.0.0-next.586
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
CHANGED
|
@@ -117,8 +117,6 @@ export function resolve_symlinks(manifest, file) {
|
|
|
117
117
|
* @return {import('vite').UserConfig}
|
|
118
118
|
*/
|
|
119
119
|
export function get_build_setup_config({ config, ssr }) {
|
|
120
|
-
const prefix = `${config.kit.appDir}/immutable`;
|
|
121
|
-
|
|
122
120
|
return {
|
|
123
121
|
build: {
|
|
124
122
|
// don't use the default name to avoid collisions with 'static/manifest.json'
|
|
@@ -148,15 +146,6 @@ export function get_build_setup_config({ config, ssr }) {
|
|
|
148
146
|
// because they for example use esbuild.build with `platform: 'browser'`
|
|
149
147
|
'esm-env'
|
|
150
148
|
]
|
|
151
|
-
},
|
|
152
|
-
worker: {
|
|
153
|
-
rollupOptions: {
|
|
154
|
-
output: {
|
|
155
|
-
entryFileNames: `${prefix}/workers/[name]-[hash].js`,
|
|
156
|
-
chunkFileNames: `${prefix}/workers/chunks/[name]-[hash].js`,
|
|
157
|
-
hoistTransitiveImports: false
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
149
|
}
|
|
161
150
|
};
|
|
162
151
|
}
|
|
@@ -194,7 +183,16 @@ export function get_build_compile_config({ config, input, ssr, outDir }) {
|
|
|
194
183
|
},
|
|
195
184
|
target: ssr ? 'node16.14' : undefined
|
|
196
185
|
},
|
|
197
|
-
publicDir: ssr ? false : config.kit.files.assets
|
|
186
|
+
publicDir: ssr ? false : config.kit.files.assets,
|
|
187
|
+
worker: {
|
|
188
|
+
rollupOptions: {
|
|
189
|
+
output: {
|
|
190
|
+
entryFileNames: `${prefix}/workers/[name]-[hash].js`,
|
|
191
|
+
chunkFileNames: `${prefix}/workers/chunks/[name]-[hash].js`,
|
|
192
|
+
hoistTransitiveImports: false
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
198
196
|
};
|
|
199
197
|
}
|
|
200
198
|
|
|
@@ -354,9 +354,7 @@ function kit({ svelte_config }) {
|
|
|
354
354
|
* Clears the output directories.
|
|
355
355
|
*/
|
|
356
356
|
buildStart() {
|
|
357
|
-
if (vite_config.build.ssr)
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
357
|
+
if (vite_config.build.ssr) return;
|
|
360
358
|
|
|
361
359
|
// Reset for new build. Goes here because `build --watch` calls buildStart but not config
|
|
362
360
|
completed_build = false;
|
|
@@ -371,6 +369,16 @@ function kit({ svelte_config }) {
|
|
|
371
369
|
}
|
|
372
370
|
},
|
|
373
371
|
|
|
372
|
+
generateBundle() {
|
|
373
|
+
if (vite_config.build.ssr) return;
|
|
374
|
+
|
|
375
|
+
this.emitFile({
|
|
376
|
+
type: 'asset',
|
|
377
|
+
fileName: `${svelte_config.kit.appDir}/version.json`,
|
|
378
|
+
source: JSON.stringify({ version: svelte_config.kit.version.name })
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
|
|
374
382
|
/**
|
|
375
383
|
* Vite builds a single bundle. We need three bundles: client, server, and service worker.
|
|
376
384
|
* The user's package.json scripts will invoke the Vite CLI to execute the client build. We
|
|
@@ -379,9 +387,7 @@ function kit({ svelte_config }) {
|
|
|
379
387
|
writeBundle: {
|
|
380
388
|
sequential: true,
|
|
381
389
|
async handler(_options, bundle) {
|
|
382
|
-
if (vite_config.build.ssr)
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
390
|
+
if (vite_config.build.ssr) return;
|
|
385
391
|
|
|
386
392
|
const guard = module_guard(this, {
|
|
387
393
|
cwd: vite.normalizePath(process.cwd()),
|
|
@@ -401,11 +407,6 @@ function kit({ svelte_config }) {
|
|
|
401
407
|
verbose
|
|
402
408
|
});
|
|
403
409
|
|
|
404
|
-
fs.writeFileSync(
|
|
405
|
-
`${paths.client_out_dir}/${svelte_config.kit.appDir}/version.json`,
|
|
406
|
-
JSON.stringify({ version: svelte_config.kit.version.name })
|
|
407
|
-
);
|
|
408
|
-
|
|
409
410
|
const { assets, chunks } = collect_output(bundle);
|
|
410
411
|
log.info(
|
|
411
412
|
`Client build completed. Wrote ${chunks.length} chunks and ${assets.length} assets`
|
|
@@ -3,14 +3,4 @@
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<h1>{$page.status}</h1>
|
|
6
|
-
|
|
7
|
-
<pre>{$page.error.message}</pre>
|
|
8
|
-
|
|
9
|
-
<!-- TODO figure out what to do with frames/stacktraces in prod -->
|
|
10
|
-
<!-- frame is populated by Svelte in its CompileError and is a Rollup/Vite convention -->
|
|
11
|
-
{#if $page.error.frame}
|
|
12
|
-
<pre>{$page.error.frame}</pre>
|
|
13
|
-
{/if}
|
|
14
|
-
{#if $page.error.stack}
|
|
15
|
-
<pre>{$page.error.stack}</pre>
|
|
16
|
-
{/if}
|
|
6
|
+
<p>{$page.error?.message}</p>
|
|
@@ -8,10 +8,6 @@ import { normalize_path } from '../../utils/url.js';
|
|
|
8
8
|
* @type {Record<string, Set<string>>} */
|
|
9
9
|
const cookie_paths = {};
|
|
10
10
|
|
|
11
|
-
// default encoding functions for header cookie values
|
|
12
|
-
const encode = encodeURIComponent;
|
|
13
|
-
const decode = decodeURIComponent;
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* @param {Request} request
|
|
17
13
|
* @param {URL} url
|
|
@@ -20,23 +16,25 @@ const decode = decodeURIComponent;
|
|
|
20
16
|
*/
|
|
21
17
|
export function get_cookies(request, url, dev, trailing_slash) {
|
|
22
18
|
const header = request.headers.get('cookie') ?? '';
|
|
23
|
-
const initial_cookies = parse(header, { decode });
|
|
19
|
+
const initial_cookies = parse(header, { decode: (value) => value });
|
|
24
20
|
|
|
25
21
|
const normalized_url = normalize_path(url.pathname, trailing_slash);
|
|
26
22
|
// Emulate browser-behavior: if the cookie is set at '/foo/bar', its path is '/foo'
|
|
27
23
|
const default_path = normalized_url.split('/').slice(0, -1).join('/') || '/';
|
|
28
24
|
|
|
29
25
|
if (dev) {
|
|
26
|
+
// TODO this could theoretically be wrong if the cookie was set unencoded?
|
|
27
|
+
const initial_decoded_cookies = parse(header, { decode: decodeURIComponent });
|
|
30
28
|
// Remove all cookies that no longer exist according to the request
|
|
31
29
|
for (const name of Object.keys(cookie_paths)) {
|
|
32
30
|
cookie_paths[name] = new Set(
|
|
33
31
|
[...cookie_paths[name]].filter(
|
|
34
|
-
(path) => !path_matches(normalized_url, path) || name in
|
|
32
|
+
(path) => !path_matches(normalized_url, path) || name in initial_decoded_cookies
|
|
35
33
|
)
|
|
36
34
|
);
|
|
37
35
|
}
|
|
38
36
|
// Add all new cookies we might not have seen before
|
|
39
|
-
for (const name in
|
|
37
|
+
for (const name in initial_decoded_cookies) {
|
|
40
38
|
cookie_paths[name] = cookie_paths[name] ?? new Set();
|
|
41
39
|
if (![...cookie_paths[name]].some((path) => path_matches(normalized_url, path))) {
|
|
42
40
|
cookie_paths[name].add(default_path);
|
|
@@ -75,7 +73,7 @@ export function get_cookies(request, url, dev, trailing_slash) {
|
|
|
75
73
|
return c.value;
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
const decoder = opts?.decode ||
|
|
76
|
+
const decoder = opts?.decode || decodeURIComponent;
|
|
79
77
|
const req_cookies = parse(header, { decode: decoder });
|
|
80
78
|
const cookie = req_cookies[name]; // the decoded string or undefined
|
|
81
79
|
|
|
@@ -161,12 +159,10 @@ export function get_cookies(request, url, dev, trailing_slash) {
|
|
|
161
159
|
*/
|
|
162
160
|
function get_cookie_header(destination, header) {
|
|
163
161
|
/** @type {Record<string, string>} */
|
|
164
|
-
const combined_cookies = {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
combined_cookies[name] = encode(initial_cookies[name]);
|
|
169
|
-
}
|
|
162
|
+
const combined_cookies = {
|
|
163
|
+
// cookies sent by the user agent have lowest precedence
|
|
164
|
+
...initial_cookies
|
|
165
|
+
};
|
|
170
166
|
|
|
171
167
|
// cookies previous set during this event with cookies.set have higher precedence
|
|
172
168
|
for (const key in new_cookies) {
|
|
@@ -174,15 +170,15 @@ export function get_cookies(request, url, dev, trailing_slash) {
|
|
|
174
170
|
if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
|
|
175
171
|
if (!path_matches(destination.pathname, cookie.options.path)) continue;
|
|
176
172
|
|
|
177
|
-
const encoder = cookie.options.encode ||
|
|
173
|
+
const encoder = cookie.options.encode || encodeURIComponent;
|
|
178
174
|
combined_cookies[cookie.name] = encoder(cookie.value);
|
|
179
175
|
}
|
|
180
176
|
|
|
181
177
|
// explicit header has highest precedence
|
|
182
178
|
if (header) {
|
|
183
|
-
const parsed = parse(header, { decode });
|
|
179
|
+
const parsed = parse(header, { decode: (value) => value });
|
|
184
180
|
for (const name in parsed) {
|
|
185
|
-
combined_cookies[name] =
|
|
181
|
+
combined_cookies[name] = parsed[name];
|
|
186
182
|
}
|
|
187
183
|
}
|
|
188
184
|
|