@sveltejs/kit 1.0.0-next.342 → 1.0.0-next.343

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.
@@ -2,7 +2,7 @@ import path__default from 'path';
2
2
  import { svelte } from '@sveltejs/vite-plugin-svelte';
3
3
  import * as vite from 'vite';
4
4
  import { d as deep_merge } from './object.js';
5
- import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as get_aliases, p as print_config_conflicts } from '../cli.js';
5
+ import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as load_config, d as get_aliases, p as print_config_conflicts } from '../cli.js';
6
6
  import fs__default from 'fs';
7
7
  import { URL } from 'url';
8
8
  import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
@@ -451,13 +451,15 @@ const cwd = process.cwd();
451
451
  * port: number,
452
452
  * host?: string,
453
453
  * https: boolean,
454
- * config: import('types').ValidatedConfig
455
454
  * }} Options
456
455
  * @typedef {import('types').SSRComponent} SSRComponent
457
456
  */
458
457
 
459
458
  /** @param {Options} opts */
460
- async function dev({ port, host, https, config }) {
459
+ async function dev({ port, host, https }) {
460
+ /** @type {import('types').ValidatedConfig} */
461
+ const config = await load_config();
462
+
461
463
  init(config);
462
464
 
463
465
  const [vite_config] = deep_merge(
@@ -535,14 +537,9 @@ async function dev({ port, host, https, config }) {
535
537
  const server = await vite.createServer(merged_config);
536
538
  await server.listen(port);
537
539
 
538
- const address_info = /** @type {import('net').AddressInfo} */ (
539
- /** @type {import('http').Server} */ (server.httpServer).address()
540
- );
541
-
542
540
  return {
543
- address_info,
544
- server_config: vite_config.server,
545
- close: () => server.close()
541
+ server,
542
+ config
546
543
  };
547
544
  }
548
545
 
@@ -2,7 +2,7 @@ import fs__default, { readFileSync, writeFileSync } from 'fs';
2
2
  import path__default, { join, dirname } from 'path';
3
3
  import { p as posixify, m as mkdirp, r as rimraf } from './filesystem.js';
4
4
  import { all } from './sync.js';
5
- import { p as print_config_conflicts, b as get_aliases, r as resolve_entry, g as get_runtime_path, l as load_template } from '../cli.js';
5
+ import { p as print_config_conflicts, d as get_aliases, r as resolve_entry, g as get_runtime_path, l as load_template } from '../cli.js';
6
6
  import { g as generate_manifest } from './index3.js';
7
7
  import * as vite from 'vite';
8
8
  import { s } from './misc.js';
@@ -6,6 +6,7 @@ import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
6
6
  import { pathToFileURL } from 'url';
7
7
  import { getRequest, setResponse } from '../node.js';
8
8
  import { installPolyfills } from '../node/polyfills.js';
9
+ import { b as load_config } from '../cli.js';
9
10
  import 'querystring';
10
11
  import 'stream';
11
12
  import 'node:http';
@@ -16,6 +17,10 @@ import 'node:util';
16
17
  import 'node:url';
17
18
  import 'net';
18
19
  import 'crypto';
20
+ import 'sade';
21
+ import 'child_process';
22
+ import 'chokidar';
23
+ import 'os';
19
24
 
20
25
  /** @typedef {import('http').IncomingMessage} Req */
21
26
  /** @typedef {import('http').ServerResponse} Res */
@@ -37,14 +42,14 @@ const mutable = (dir) =>
37
42
  * @param {{
38
43
  * port: number;
39
44
  * host?: string;
40
- * config: import('types').ValidatedConfig;
41
45
  * https?: boolean;
42
46
  * cwd?: string;
43
47
  * }} opts
44
48
  */
45
- async function preview({ port, host, config, https: use_https = false }) {
49
+ async function preview({ port, host, https: use_https = false }) {
46
50
  installPolyfills();
47
51
 
52
+ const config = await load_config();
48
53
  const { paths } = config.kit;
49
54
  const base = paths.base;
50
55
  const assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;
@@ -172,7 +177,7 @@ async function preview({ port, host, config, https: use_https = false }) {
172
177
 
173
178
  return new Promise((fulfil) => {
174
179
  http_server.listen(port, host, () => {
175
- fulfil(http_server);
180
+ fulfil({ server: http_server, config });
176
181
  });
177
182
  });
178
183
  }
package/dist/cli.js CHANGED
@@ -904,7 +904,7 @@ async function launch(port, https, base) {
904
904
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
905
905
  }
906
906
 
907
- const prog = sade('svelte-kit').version('1.0.0-next.342');
907
+ const prog = sade('svelte-kit').version('1.0.0-next.343');
908
908
 
909
909
  prog
910
910
  .command('dev')
@@ -922,30 +922,34 @@ prog
922
922
  /** @type {() => Promise<void>} */
923
923
  let close;
924
924
 
925
- /** @param {import('types').ValidatedConfig} config */
926
- async function start(config) {
925
+ async function start() {
927
926
  const { dev } = await import('./chunks/index.js');
928
927
 
929
- const { address_info, server_config, close } = await dev({
928
+ const { server, config } = await dev({
930
929
  port,
931
930
  host,
932
- https,
933
- config
931
+ https
934
932
  });
935
933
 
934
+ const address_info = /** @type {import('net').AddressInfo} */ (
935
+ /** @type {import('http').Server} */ (server.httpServer).address()
936
+ );
937
+
938
+ const vite_config = server.config;
939
+
936
940
  welcome({
937
941
  port: address_info.port,
938
942
  host: address_info.address,
939
- https: !!(https || server_config.https),
940
- open: first && (open || !!server_config.open),
943
+ https: !!(https || vite_config.server.https),
944
+ open: first && (open || !!vite_config.server.open),
941
945
  base: config.kit.paths.base,
942
- loose: server_config.fs.strict === false,
943
- allow: server_config.fs.allow
946
+ loose: vite_config.server.fs.strict === false,
947
+ allow: vite_config.server.fs.allow
944
948
  });
945
949
 
946
950
  first = false;
947
951
 
948
- return close;
952
+ return server.close;
949
953
  }
950
954
 
951
955
  async function relaunch() {
@@ -953,9 +957,8 @@ prog
953
957
  relaunching = true;
954
958
 
955
959
  try {
956
- const updated_config = await load_config();
957
960
  await close();
958
- close = await start(updated_config);
961
+ close = await start();
959
962
 
960
963
  if (id !== uid) relaunch();
961
964
  } catch (e) {
@@ -975,8 +978,7 @@ prog
975
978
 
976
979
  process.env.NODE_ENV = process.env.NODE_ENV || 'development';
977
980
 
978
- const config = await load_config();
979
- close = await start(config);
981
+ close = await start();
980
982
 
981
983
  chokidar.watch('svelte.config.js', { ignoreInitial: true }).on('change', () => {
982
984
  if (relaunching) uid += 1;
@@ -1039,11 +1041,10 @@ prog
1039
1041
  await check_port(port);
1040
1042
 
1041
1043
  process.env.NODE_ENV = process.env.NODE_ENV || 'production';
1042
- const config = await load_config();
1043
1044
 
1044
1045
  const { preview } = await import('./chunks/index5.js');
1045
1046
 
1046
- await preview({ port, host, config, https });
1047
+ const { config } = await preview({ port, host, https });
1047
1048
 
1048
1049
  welcome({ port, host, https, open, base: config.kit.paths.base });
1049
1050
  } catch (error) {
@@ -1122,7 +1123,7 @@ async function check_port(port) {
1122
1123
  function welcome({ port, host, https, open, base, loose, allow, cwd }) {
1123
1124
  if (open) launch(port, https, base);
1124
1125
 
1125
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.342'}\n`));
1126
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.343'}\n`));
1126
1127
 
1127
1128
  const protocol = https ? 'https:' : 'http:';
1128
1129
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
@@ -1160,4 +1161,4 @@ function welcome({ port, host, https, open, base, loose, allow, cwd }) {
1160
1161
  console.log('\n');
1161
1162
  }
1162
1163
 
1163
- export { $, get_mime_lookup as a, get_aliases as b, coalesce_to_error as c, get_runtime_path as g, load_template as l, print_config_conflicts as p, resolve_entry as r };
1164
+ export { $, get_mime_lookup as a, load_config as b, coalesce_to_error as c, get_aliases as d, get_runtime_path as g, load_template as l, print_config_conflicts as p, resolve_entry as r };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.342",
3
+ "version": "1.0.0-next.343",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",