@sveltejs/kit 1.15.6 → 1.15.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.15.6",
3
+ "version": "1.15.7",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -162,7 +162,7 @@ export function create_builder({
162
162
  relative_path: relativePath,
163
163
  routes: subset
164
164
  ? subset.map((route) => /** @type {import('types').RouteData} */ (lookup.get(route)))
165
- : route_data
165
+ : route_data.filter((route) => prerender_map.get(route.id) !== true)
166
166
  });
167
167
  },
168
168
 
@@ -201,17 +201,33 @@ const options = object(
201
201
  return input;
202
202
  }),
203
203
 
204
- handleHttpError: validate('fail', (input, keypath) => {
205
- if (typeof input === 'function') return input;
206
- if (['fail', 'warn', 'ignore'].includes(input)) return input;
207
- throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
208
- }),
204
+ handleHttpError: validate(
205
+ (/** @type {any} */ { message }) => {
206
+ throw new Error(
207
+ message +
208
+ `\nTo suppress or handle this error, implement \`handleHttpError\` in https://kit.svelte.dev/docs/configuration#prerender`
209
+ );
210
+ },
211
+ (input, keypath) => {
212
+ if (typeof input === 'function') return input;
213
+ if (['fail', 'warn', 'ignore'].includes(input)) return input;
214
+ throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
215
+ }
216
+ ),
209
217
 
210
- handleMissingId: validate('fail', (input, keypath) => {
211
- if (typeof input === 'function') return input;
212
- if (['fail', 'warn', 'ignore'].includes(input)) return input;
213
- throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
214
- }),
218
+ handleMissingId: validate(
219
+ (/** @type {any} */ { message }) => {
220
+ throw new Error(
221
+ message +
222
+ `\nTo suppress or handle this error, implement \`handleMissingId\` in https://kit.svelte.dev/docs/configuration#prerender`
223
+ );
224
+ },
225
+ (input, keypath) => {
226
+ if (typeof input === 'function') return input;
227
+ if (['fail', 'warn', 'ignore'].includes(input)) return input;
228
+ throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
229
+ }
230
+ ),
215
231
 
216
232
  origin: validate('http://sveltekit-prerender', (input, keypath) => {
217
233
  assert_string(input, keypath);
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { installPolyfills } from '../../exports/node/polyfills.js';
@@ -338,7 +338,22 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
338
338
  }
339
339
 
340
340
  if (response.status === 200) {
341
- mkdirp(dirname(dest));
341
+ if (existsSync(dest) && statSync(dest).isDirectory()) {
342
+ throw new Error(
343
+ `Cannot save ${decoded} as it is already a directory. See https://kit.svelte.dev/docs/page-options#prerender-route-conflicts for more information`
344
+ );
345
+ }
346
+
347
+ const dir = dirname(dest);
348
+
349
+ if (existsSync(dir) && !statSync(dir).isDirectory()) {
350
+ const parent = decoded.split('/').slice(0, -1).join('/');
351
+ throw new Error(
352
+ `Cannot save ${decoded} as ${parent} is already a file. See https://kit.svelte.dev/docs/page-options#prerender-route-conflicts for more information`
353
+ );
354
+ }
355
+
356
+ mkdirp(dir);
342
357
 
343
358
  log.info(`${response.status} ${decoded}`);
344
359
  writeFileSync(dest, body);
@@ -29,14 +29,12 @@ if (DEV) {
29
29
  // We use just the filename as the method name sometimes does not appear on the CI.
30
30
  const url = input instanceof Request ? input.url : input.toString();
31
31
  const stack_array = /** @type {string} */ (new Error().stack).split('\n');
32
- // We need to do some Firefox-specific cutoff because it (impressively) maintains the stack
33
- // across events and for example traces a `fetch` call triggered from a button back
34
- // to the creation of the event listener and the element creation itself,
32
+ // We need to do a cutoff because Safari and Firefox maintain the stack
33
+ // across events and for example traces a `fetch` call triggered from a button
34
+ // back to the creation of the event listener and the element creation itself,
35
35
  // where at some point client.js will show up, leading to false positives.
36
- const firefox_cutoff = stack_array.findIndex((a) => a.includes('*listen@'));
37
- const stack = stack_array
38
- .slice(0, firefox_cutoff !== -1 ? firefox_cutoff : undefined)
39
- .join('\n');
36
+ const cutoff = stack_array.findIndex((a) => a.includes('load@') || a.includes('at load'));
37
+ const stack = stack_array.slice(0, cutoff + 2).join('\n');
40
38
 
41
39
  const heuristic = can_inspect_stack_trace
42
40
  ? stack.includes('src/runtime/client/client.js')
@@ -292,10 +292,9 @@ export async function render_response({
292
292
  const blocks = [];
293
293
 
294
294
  const properties = [
295
- `env: ${s(public_env)}`,
296
295
  paths.assets && `assets: ${s(paths.assets)}`,
297
296
  `base: ${base_expression}`,
298
- `element: document.currentScript.parentElement`
297
+ `env: ${s(public_env)}`
299
298
  ].filter(Boolean);
300
299
 
301
300
  if (chunks) {
@@ -318,7 +317,9 @@ export async function render_response({
318
317
  ${properties.join(',\n\t\t\t\t\t\t')}
319
318
  };`);
320
319
 
321
- const args = [`app`, `${global}.element`];
320
+ const args = [`app`, `element`];
321
+
322
+ blocks.push(`const element = document.currentScript.parentElement;`);
322
323
 
323
324
  if (page_config.ssr) {
324
325
  const serialized = { form: 'null', error: 'null' };