@sveltejs/kit 2.3.1 → 2.3.2
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
|
@@ -424,7 +424,7 @@ async function kit({ svelte_config }) {
|
|
|
424
424
|
case env_dynamic_public:
|
|
425
425
|
// populate `$env/dynamic/public` from `window`
|
|
426
426
|
if (browser) {
|
|
427
|
-
return `export const env = ${global}.env
|
|
427
|
+
return `export const env = ${global}.env;`;
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
return create_dynamic_module(
|
|
@@ -297,11 +297,21 @@ export async function render_response({
|
|
|
297
297
|
|
|
298
298
|
const blocks = [];
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
300
|
+
// when serving a prerendered page in an app that uses $env/dynamic/public, we must
|
|
301
|
+
// import the env.js module so that it evaluates before any user code can evaluate.
|
|
302
|
+
// TODO revert to using top-level await once https://bugs.webkit.org/show_bug.cgi?id=242740 is fixed
|
|
303
|
+
// https://github.com/sveltejs/kit/pull/11601
|
|
304
|
+
const load_env_eagerly = client.uses_env_dynamic_public && state.prerendering;
|
|
305
|
+
|
|
306
|
+
const properties = [`base: ${base_expression}`];
|
|
307
|
+
|
|
308
|
+
if (paths.assets) {
|
|
309
|
+
properties.push(`assets: ${s(paths.assets)}`);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (client.uses_env_dynamic_public) {
|
|
313
|
+
properties.push(`env: ${load_env_eagerly ? 'null' : s(public_env)}`);
|
|
314
|
+
}
|
|
305
315
|
|
|
306
316
|
if (chunks) {
|
|
307
317
|
blocks.push('const deferred = new Map();');
|
|
@@ -319,6 +329,7 @@ export async function render_response({
|
|
|
319
329
|
}`);
|
|
320
330
|
}
|
|
321
331
|
|
|
332
|
+
// create this before declaring `data`, which may contain references to `${global}`
|
|
322
333
|
blocks.push(`${global} = {
|
|
323
334
|
${properties.join(',\n\t\t\t\t\t\t')}
|
|
324
335
|
};`);
|
|
@@ -358,15 +369,29 @@ export async function render_response({
|
|
|
358
369
|
hydrate.push(`params: ${devalue.uneval(event.params)}`, `route: ${s(event.route)}`);
|
|
359
370
|
}
|
|
360
371
|
|
|
361
|
-
|
|
372
|
+
const indent = '\t'.repeat(load_env_eagerly ? 7 : 6);
|
|
373
|
+
args.push(`{\n${indent}\t${hydrate.join(`,\n${indent}\t`)}\n${indent}}`);
|
|
362
374
|
}
|
|
363
375
|
|
|
364
|
-
|
|
376
|
+
if (load_env_eagerly) {
|
|
377
|
+
blocks.push(`import(${s(`${base}/${options.app_dir}/env.js`)}).then(({ env }) => {
|
|
378
|
+
${global}.env = env;
|
|
379
|
+
|
|
380
|
+
Promise.all([
|
|
381
|
+
import(${s(prefixed(client.start))}),
|
|
382
|
+
import(${s(prefixed(client.app))})
|
|
383
|
+
]).then(([kit, app]) => {
|
|
384
|
+
kit.start(${args.join(', ')});
|
|
385
|
+
});
|
|
386
|
+
});`);
|
|
387
|
+
} else {
|
|
388
|
+
blocks.push(`Promise.all([
|
|
365
389
|
import(${s(prefixed(client.start))}),
|
|
366
390
|
import(${s(prefixed(client.app))})
|
|
367
391
|
]).then(([kit, app]) => {
|
|
368
392
|
kit.start(${args.join(', ')});
|
|
369
393
|
});`);
|
|
394
|
+
}
|
|
370
395
|
|
|
371
396
|
if (options.service_worker) {
|
|
372
397
|
const opts = __SVELTEKIT_DEV__ ? ", { type: 'module' }" : '';
|
|
@@ -113,6 +113,10 @@ export async function respond(request, options, manifest, state) {
|
|
|
113
113
|
return get_public_env(request);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
if (decoded.startsWith(`/${options.app_dir}`)) {
|
|
117
|
+
return text('Not found', { status: 404 });
|
|
118
|
+
}
|
|
119
|
+
|
|
116
120
|
const is_data_request = has_data_suffix(decoded);
|
|
117
121
|
/** @type {boolean[] | undefined} */
|
|
118
122
|
let invalidated_data_nodes;
|
package/src/version.js
CHANGED