@sveltejs/kit 1.20.2 → 1.20.4

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.20.2",
3
+ "version": "1.20.4",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,6 @@
22
22
  "sade": "^1.8.1",
23
23
  "set-cookie-parser": "^2.6.0",
24
24
  "sirv": "^2.0.2",
25
- "tiny-glob": "^0.2.9",
26
25
  "undici": "~5.22.0"
27
26
  },
28
27
  "devDependencies": {
package/postinstall.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import glob from 'tiny-glob/sync.js';
4
3
  import { load_config } from './src/core/config/index.js';
4
+ import { list_files } from './src/core/utils.js';
5
5
  import * as sync from './src/core/sync/sync.js';
6
6
 
7
7
  try {
@@ -18,7 +18,7 @@ try {
18
18
  const packages = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces.packages;
19
19
 
20
20
  for (const directory of packages) {
21
- directories.push(...glob(directory, { cwd }).map((dir) => path.resolve(cwd, dir)));
21
+ directories.push(...list_files(directory).map((dir) => path.resolve(cwd, dir)));
22
22
  }
23
23
  } else {
24
24
  directories.push(cwd);
@@ -37,11 +37,11 @@ try {
37
37
  const config = await load_config();
38
38
  await sync.all(config, 'development');
39
39
  } catch (error) {
40
- console.log('Error while trying to sync SvelteKit config');
41
- console.log(error.stack);
40
+ console.error('Error while trying to sync SvelteKit config');
41
+ console.error(error);
42
42
  }
43
43
  }
44
44
  }
45
45
  } catch (error) {
46
- console.error(error.stack);
46
+ console.error(error);
47
47
  }
@@ -1,17 +1,18 @@
1
1
  import { existsSync, statSync, createReadStream, createWriteStream } from 'node:fs';
2
- import { join } from 'node:path/posix';
2
+ import { extname, join } from 'node:path/posix';
3
3
  import { pipeline } from 'node:stream';
4
4
  import { promisify } from 'node:util';
5
5
  import zlib from 'node:zlib';
6
- import glob from 'tiny-glob';
7
6
  import { copy, rimraf, mkdirp } from '../../utils/filesystem.js';
8
7
  import { generate_manifest } from '../generate_manifest/index.js';
9
8
  import { get_route_segments } from '../../utils/routing.js';
10
9
  import { get_env } from '../../exports/vite/utils.js';
11
10
  import generate_fallback from '../postbuild/fallback.js';
12
11
  import { write } from '../sync/utils.js';
12
+ import { list_files } from '../utils.js';
13
13
 
14
14
  const pipe = promisify(pipeline);
15
+ const extensions = ['html', 'js', 'mjs', 'json', 'css', 'svg', 'xml', 'wasm'];
15
16
 
16
17
  /**
17
18
  * Creates the Builder which is passed to adapters for building the application.
@@ -83,13 +84,7 @@ export function create_builder({
83
84
  return;
84
85
  }
85
86
 
86
- const files = await glob('**/*.{html,js,mjs,json,css,svg,xml,wasm}', {
87
- cwd: directory,
88
- dot: true,
89
- absolute: true,
90
- filesOnly: true
91
- });
92
-
87
+ const files = list_files(directory, (file) => extensions.includes(extname(file)));
93
88
  await Promise.all(
94
89
  files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
95
90
  );
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import mime from 'mime';
4
- import { runtime_directory } from '../../utils.js';
4
+ import { list_files, runtime_directory } from '../../utils.js';
5
5
  import { posixify } from '../../../utils/filesystem.js';
6
6
  import { parse_route_id } from '../../../utils/routing.js';
7
7
  import { sort_routes } from './sort.js';
@@ -468,28 +468,6 @@ function analyze(project_relative, file, component_extensions, module_extensions
468
468
  throw new Error(`Files and directories prefixed with + are reserved (saw ${project_relative})`);
469
469
  }
470
470
 
471
- /** @param {string} dir */
472
- function list_files(dir) {
473
- /** @type {string[]} */
474
- const files = [];
475
-
476
- /** @param {string} current */
477
- function walk(current) {
478
- for (const file of fs.readdirSync(path.resolve(dir, current))) {
479
- const child = path.posix.join(current, file);
480
- if (fs.statSync(path.resolve(dir, child)).isDirectory()) {
481
- walk(child);
482
- } else {
483
- files.push(child);
484
- }
485
- }
486
- }
487
-
488
- if (fs.existsSync(dir)) walk('');
489
-
490
- return files;
491
- }
492
-
493
471
  /**
494
472
  * @param {string} needle
495
473
  * @param {string} haystack
package/src/core/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import fs from 'node:fs';
1
2
  import path from 'node:path';
2
3
  import { fileURLToPath } from 'node:url';
3
4
  import colors from 'kleur';
@@ -56,3 +57,30 @@ export function get_mime_lookup(manifest_data) {
56
57
 
57
58
  return mime;
58
59
  }
60
+
61
+ /**
62
+ * @param {string} dir
63
+ * @param {(file: string) => boolean} [filter]
64
+ */
65
+ export function list_files(dir, filter) {
66
+ /** @type {string[]} */
67
+ const files = [];
68
+
69
+ /** @param {string} current */
70
+ function walk(current) {
71
+ for (const file of fs.readdirSync(path.resolve(dir, current))) {
72
+ const child = path.posix.join(current, file);
73
+ if (fs.statSync(path.resolve(dir, child)).isDirectory()) {
74
+ walk(child);
75
+ } else {
76
+ if (!filter || filter(child)) {
77
+ files.push(child);
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ if (fs.existsSync(dir)) walk('');
84
+
85
+ return files;
86
+ }
@@ -203,6 +203,12 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
203
203
  */
204
204
  return async (input, init) => {
205
205
  const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
206
+
207
+ const cloned_headers =
208
+ input instanceof Request && [...input.headers].length
209
+ ? new Headers(input.headers)
210
+ : init?.headers;
211
+
206
212
  let response = await event.fetch(input, init);
207
213
 
208
214
  const url = new URL(input instanceof Request ? input.url : input, event.url);
@@ -260,7 +266,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
260
266
  ? await stream_to_string(cloned_body)
261
267
  : init?.body
262
268
  ),
263
- request_headers: init?.headers,
269
+ request_headers: cloned_headers,
264
270
  response_body: body,
265
271
  response
266
272
  });
@@ -1,4 +1,4 @@
1
- import { SvelteComponent } from 'svelte/internal';
1
+ import { SvelteComponent } from 'svelte';
2
2
  import {
3
3
  Config,
4
4
  ServerLoad,
@@ -141,18 +141,17 @@ export function exec(match, params, matchers) {
141
141
 
142
142
  for (let i = 0; i < params.length; i += 1) {
143
143
  const param = params[i];
144
- const value = values[i - buffered];
144
+ let value = values[i - buffered];
145
145
 
146
146
  // in the `[[a=b]]/.../[...rest]` case, if one or more optional parameters
147
147
  // weren't matched, roll the skipped values into the rest
148
148
  if (param.chained && param.rest && buffered) {
149
- result[param.name] = values
149
+ value = values
150
150
  .slice(i - buffered, i + 1)
151
151
  .filter((s) => s)
152
152
  .join('/');
153
153
 
154
154
  buffered = 0;
155
- continue;
156
155
  }
157
156
 
158
157
  // if `value` is undefined, it means this is an optional or rest parameter
package/types/index.d.ts CHANGED
@@ -1468,7 +1468,7 @@ declare module '@sveltejs/kit' {
1468
1468
  status: number;
1469
1469
  data: T | undefined;
1470
1470
  }
1471
- import { SvelteComponent } from 'svelte/internal';
1471
+ import { SvelteComponent } from 'svelte';
1472
1472
 
1473
1473
  interface ServerModule {
1474
1474
  Server: typeof InternalServer;