@sveltejs/kit 1.0.0-next.29 → 1.0.0-next.292

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.
Files changed (82) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +24 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/client/singletons.js +13 -0
  7. package/assets/client/start.js +1523 -0
  8. package/assets/components/error.svelte +18 -2
  9. package/assets/env.js +8 -0
  10. package/assets/paths.js +13 -0
  11. package/assets/server/index.js +2797 -0
  12. package/dist/chunks/amp_hook.js +56 -0
  13. package/dist/chunks/cert.js +28154 -0
  14. package/dist/chunks/constants.js +663 -0
  15. package/dist/chunks/filesystem.js +110 -0
  16. package/dist/chunks/index.js +508 -0
  17. package/dist/chunks/index2.js +1307 -0
  18. package/dist/chunks/index3.js +118 -0
  19. package/dist/chunks/index4.js +196 -0
  20. package/dist/chunks/index5.js +242 -0
  21. package/dist/chunks/index6.js +15585 -0
  22. package/dist/chunks/index7.js +4207 -0
  23. package/dist/chunks/misc.js +3 -0
  24. package/dist/chunks/multipart-parser.js +449 -0
  25. package/dist/chunks/object.js +83 -0
  26. package/dist/chunks/sync.js +999 -0
  27. package/dist/chunks/url.js +56 -0
  28. package/dist/cli.js +1018 -85
  29. package/dist/hooks.js +28 -0
  30. package/dist/install-fetch.js +6518 -0
  31. package/dist/node.js +94 -0
  32. package/package.json +92 -54
  33. package/svelte-kit.js +2 -0
  34. package/types/ambient.d.ts +303 -0
  35. package/types/index.d.ts +166 -0
  36. package/types/internal.d.ts +318 -0
  37. package/types/private.d.ts +357 -0
  38. package/CHANGELOG.md +0 -332
  39. package/assets/runtime/app/navigation.js +0 -23
  40. package/assets/runtime/app/navigation.js.map +0 -1
  41. package/assets/runtime/app/paths.js +0 -2
  42. package/assets/runtime/app/paths.js.map +0 -1
  43. package/assets/runtime/app/stores.js +0 -78
  44. package/assets/runtime/app/stores.js.map +0 -1
  45. package/assets/runtime/internal/singletons.js +0 -15
  46. package/assets/runtime/internal/singletons.js.map +0 -1
  47. package/assets/runtime/internal/start.js +0 -591
  48. package/assets/runtime/internal/start.js.map +0 -1
  49. package/assets/runtime/utils-85ebcc60.js +0 -18
  50. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  51. package/dist/api.js +0 -44
  52. package/dist/api.js.map +0 -1
  53. package/dist/build.js +0 -246
  54. package/dist/build.js.map +0 -1
  55. package/dist/cli.js.map +0 -1
  56. package/dist/colors.js +0 -37
  57. package/dist/colors.js.map +0 -1
  58. package/dist/create_app.js +0 -580
  59. package/dist/create_app.js.map +0 -1
  60. package/dist/index.js +0 -368
  61. package/dist/index.js.map +0 -1
  62. package/dist/index2.js +0 -12035
  63. package/dist/index2.js.map +0 -1
  64. package/dist/index3.js +0 -549
  65. package/dist/index3.js.map +0 -1
  66. package/dist/index4.js +0 -74
  67. package/dist/index4.js.map +0 -1
  68. package/dist/index5.js +0 -464
  69. package/dist/index5.js.map +0 -1
  70. package/dist/index6.js +0 -735
  71. package/dist/index6.js.map +0 -1
  72. package/dist/logging.js +0 -43
  73. package/dist/logging.js.map +0 -1
  74. package/dist/package.js +0 -432
  75. package/dist/package.js.map +0 -1
  76. package/dist/renderer.js +0 -2425
  77. package/dist/renderer.js.map +0 -1
  78. package/dist/standard.js +0 -101
  79. package/dist/standard.js.map +0 -1
  80. package/dist/utils.js +0 -58
  81. package/dist/utils.js.map +0 -1
  82. package/svelte-kit +0 -3
@@ -0,0 +1,110 @@
1
+ import fs__default from 'fs';
2
+ import path__default from 'path';
3
+
4
+ /** @param {string} dir */
5
+ function mkdirp(dir) {
6
+ try {
7
+ fs__default.mkdirSync(dir, { recursive: true });
8
+ } catch (/** @type {any} */ e) {
9
+ if (e.code === 'EEXIST') return;
10
+ throw e;
11
+ }
12
+ }
13
+
14
+ /** @param {string} path */
15
+ function rimraf(path) {
16
+ (fs__default.rmSync || fs__default.rmdirSync)(path, { recursive: true, force: true });
17
+ }
18
+
19
+ /**
20
+ * @param {string} source
21
+ * @param {string} target
22
+ * @param {{
23
+ * filter?: (basename: string) => boolean;
24
+ * replace?: Record<string, string>;
25
+ * }} opts
26
+ */
27
+ function copy(source, target, opts = {}) {
28
+ if (!fs__default.existsSync(source)) return [];
29
+
30
+ /** @type {string[]} */
31
+ const files = [];
32
+
33
+ const prefix = posixify(target) + '/';
34
+
35
+ const regex = opts.replace
36
+ ? new RegExp(`\\b(${Object.keys(opts.replace).join('|')})\\b`, 'g')
37
+ : null;
38
+
39
+ /**
40
+ * @param {string} from
41
+ * @param {string} to
42
+ */
43
+ function go(from, to) {
44
+ if (opts.filter && !opts.filter(path__default.basename(from))) return;
45
+
46
+ const stats = fs__default.statSync(from);
47
+
48
+ if (stats.isDirectory()) {
49
+ fs__default.readdirSync(from).forEach((file) => {
50
+ go(path__default.join(from, file), path__default.join(to, file));
51
+ });
52
+ } else {
53
+ mkdirp(path__default.dirname(to));
54
+
55
+ if (opts.replace) {
56
+ const data = fs__default.readFileSync(from, 'utf-8');
57
+ fs__default.writeFileSync(
58
+ to,
59
+ data.replace(
60
+ /** @type {RegExp} */ (regex),
61
+ (match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]
62
+ )
63
+ );
64
+ } else {
65
+ fs__default.copyFileSync(from, to);
66
+ }
67
+
68
+ files.push(to === target ? posixify(path__default.basename(to)) : posixify(to).replace(prefix, ''));
69
+ }
70
+ }
71
+
72
+ go(source, target);
73
+
74
+ return files;
75
+ }
76
+
77
+ /**
78
+ * Get a list of all files in a directory
79
+ * @param {string} cwd - the directory to walk
80
+ * @param {boolean} [dirs] - whether to include directories in the result
81
+ */
82
+ function walk(cwd, dirs = false) {
83
+ /** @type {string[]} */
84
+ const all_files = [];
85
+
86
+ /** @param {string} dir */
87
+ function walk_dir(dir) {
88
+ const files = fs__default.readdirSync(path__default.join(cwd, dir));
89
+
90
+ for (const file of files) {
91
+ const joined = path__default.join(dir, file);
92
+ const stats = fs__default.statSync(path__default.join(cwd, joined));
93
+ if (stats.isDirectory()) {
94
+ if (dirs) all_files.push(joined);
95
+ walk_dir(joined);
96
+ } else {
97
+ all_files.push(joined);
98
+ }
99
+ }
100
+ }
101
+
102
+ return walk_dir(''), all_files;
103
+ }
104
+
105
+ /** @param {string} str */
106
+ function posixify(str) {
107
+ return str.replace(/\\/g, '/');
108
+ }
109
+
110
+ export { copy as c, mkdirp as m, posixify as p, rimraf as r, walk as w };
@@ -0,0 +1,508 @@
1
+ import path__default from 'path';
2
+ import { svelte } from '@sveltejs/vite-plugin-svelte';
3
+ import vite from 'vite';
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';
6
+ import fs__default from 'fs';
7
+ import { URL } from 'url';
8
+ import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
9
+ import { installFetch } from '../install-fetch.js';
10
+ import { update, init } from './sync.js';
11
+ import { getRequest, setResponse } from '../node.js';
12
+ import { sequence } from '../hooks.js';
13
+ import { p as posixify } from './filesystem.js';
14
+ import 'sade';
15
+ import 'child_process';
16
+ import 'net';
17
+ import 'os';
18
+ import 'querystring';
19
+ import 'node:http';
20
+ import 'node:https';
21
+ import 'node:zlib';
22
+ import 'node:stream';
23
+ import 'node:util';
24
+ import 'node:url';
25
+ import './misc.js';
26
+ import 'stream';
27
+
28
+ /**
29
+ * @param {import('types').ValidatedConfig} config
30
+ * @param {string} cwd
31
+ * @returns {Promise<import('vite').Plugin>}
32
+ */
33
+ async function create_plugin(config, cwd) {
34
+ const runtime = get_runtime_path(config);
35
+
36
+ /** @type {import('types').Handle} */
37
+ let amp;
38
+
39
+ if (config.kit.amp) {
40
+ process.env.VITE_SVELTEKIT_AMP = 'true';
41
+ amp = (await import('./amp_hook.js')).handle;
42
+ }
43
+
44
+ process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
45
+
46
+ /** @type {import('types').Respond} */
47
+ const respond = (await import(`${runtime}/server/index.js`)).respond;
48
+
49
+ return {
50
+ name: 'vite-plugin-svelte-kit',
51
+
52
+ configureServer(vite) {
53
+ installFetch();
54
+
55
+ /** @type {import('types').SSRManifest} */
56
+ let manifest;
57
+
58
+ function update_manifest() {
59
+ const { manifest_data } = update(config);
60
+
61
+ manifest = {
62
+ appDir: config.kit.appDir,
63
+ assets: new Set(manifest_data.assets.map((asset) => asset.file)),
64
+ _: {
65
+ mime: get_mime_lookup(manifest_data),
66
+ entry: {
67
+ file: `/@fs${runtime}/client/start.js`,
68
+ css: [],
69
+ js: []
70
+ },
71
+ nodes: manifest_data.components.map((id) => {
72
+ return async () => {
73
+ const url = id.startsWith('..') ? `/@fs${path__default.posix.resolve(id)}` : `/${id}`;
74
+
75
+ const module = /** @type {import('types').SSRComponent} */ (
76
+ await vite.ssrLoadModule(url)
77
+ );
78
+ const node = await vite.moduleGraph.getModuleByUrl(url);
79
+
80
+ if (!node) throw new Error(`Could not find node for ${url}`);
81
+
82
+ const deps = new Set();
83
+ find_deps(node, deps);
84
+
85
+ /** @type {Record<string, string>} */
86
+ const styles = {};
87
+
88
+ for (const dep of deps) {
89
+ const parsed = new URL(dep.url, 'http://localhost/');
90
+ const query = parsed.searchParams;
91
+
92
+ // TODO what about .scss files, etc?
93
+ if (
94
+ dep.file.endsWith('.css') ||
95
+ (query.has('svelte') && query.get('type') === 'style')
96
+ ) {
97
+ try {
98
+ const mod = await vite.ssrLoadModule(dep.url);
99
+ styles[dep.url] = mod.default;
100
+ } catch {
101
+ // this can happen with dynamically imported modules, I think
102
+ // because the Vite module graph doesn't distinguish between
103
+ // static and dynamic imports? TODO investigate, submit fix
104
+ }
105
+ }
106
+ }
107
+
108
+ return {
109
+ module,
110
+ entry: url.endsWith('.svelte') ? url : url + '?import',
111
+ css: [],
112
+ js: [],
113
+ // in dev we inline all styles to avoid FOUC
114
+ styles
115
+ };
116
+ };
117
+ }),
118
+ routes: manifest_data.routes.map((route) => {
119
+ if (route.type === 'page') {
120
+ return {
121
+ type: 'page',
122
+ key: route.key,
123
+ pattern: route.pattern,
124
+ params: get_params(route.params),
125
+ shadow: route.shadow
126
+ ? async () => {
127
+ const url = path__default.resolve(cwd, /** @type {string} */ (route.shadow));
128
+ return await vite.ssrLoadModule(url);
129
+ }
130
+ : null,
131
+ a: route.a.map((id) => manifest_data.components.indexOf(id)),
132
+ b: route.b.map((id) => manifest_data.components.indexOf(id))
133
+ };
134
+ }
135
+
136
+ return {
137
+ type: 'endpoint',
138
+ pattern: route.pattern,
139
+ params: get_params(route.params),
140
+ load: async () => {
141
+ const url = path__default.resolve(cwd, route.file);
142
+ return await vite.ssrLoadModule(url);
143
+ }
144
+ };
145
+ })
146
+ }
147
+ };
148
+ }
149
+
150
+ /** @param {Error} error */
151
+ function fix_stack_trace(error) {
152
+ // TODO https://github.com/vitejs/vite/issues/7045
153
+
154
+ // ideally vite would expose ssrRewriteStacktrace, but
155
+ // in lieu of that, we can implement it ourselves. we
156
+ // don't want to mutate the error object, because
157
+ // the stack trace could be 'fixed' multiple times,
158
+ // and Vite will fix stack traces before we even
159
+ // see them if they occur during ssrLoadModule
160
+ const original = error.stack;
161
+ vite.ssrFixStacktrace(error);
162
+ const fixed = error.stack;
163
+ error.stack = original;
164
+
165
+ return fixed;
166
+ }
167
+
168
+ update_manifest();
169
+
170
+ vite.watcher.on('add', update_manifest);
171
+ vite.watcher.on('remove', update_manifest);
172
+
173
+ const assets = config.kit.paths.assets ? SVELTE_KIT_ASSETS : config.kit.paths.base;
174
+ const asset_server = sirv(config.kit.files.assets, {
175
+ dev: true,
176
+ etag: true,
177
+ maxAge: 0,
178
+ extensions: []
179
+ });
180
+
181
+ return () => {
182
+ remove_html_middlewares(vite.middlewares);
183
+
184
+ vite.middlewares.use(async (req, res) => {
185
+ try {
186
+ if (!req.url || !req.method) throw new Error('Incomplete request');
187
+
188
+ const base = `${vite.config.server.https ? 'https' : 'http'}://${req.headers.host}`;
189
+
190
+ const decoded = decodeURI(new URL(base + req.url).pathname);
191
+
192
+ if (decoded.startsWith(assets)) {
193
+ const pathname = decoded.slice(assets.length);
194
+ const file = config.kit.files.assets + pathname;
195
+
196
+ if (fs__default.existsSync(file) && !fs__default.statSync(file).isDirectory()) {
197
+ req.url = encodeURI(pathname); // don't need query/hash
198
+ asset_server(req, res);
199
+ return;
200
+ }
201
+ }
202
+
203
+ if (req.url === '/favicon.ico') return not_found(res);
204
+
205
+ if (!decoded.startsWith(config.kit.paths.base)) return not_found(res);
206
+
207
+ /** @type {Partial<import('types').Hooks>} */
208
+ const user_hooks = resolve_entry(config.kit.files.hooks)
209
+ ? await vite.ssrLoadModule(`/${config.kit.files.hooks}`)
210
+ : {};
211
+
212
+ const handle = user_hooks.handle || (({ event, resolve }) => resolve(event));
213
+
214
+ /** @type {import('types').Hooks} */
215
+ const hooks = {
216
+ getSession: user_hooks.getSession || (() => ({})),
217
+ handle: amp ? sequence(amp, handle) : handle,
218
+ handleError:
219
+ user_hooks.handleError ||
220
+ (({ /** @type {Error & { frame?: string }} */ error }) => {
221
+ console.error($.bold().red(error.message));
222
+ if (error.frame) {
223
+ console.error($.gray(error.frame));
224
+ }
225
+ if (error.stack) {
226
+ console.error($.gray(error.stack));
227
+ }
228
+ }),
229
+ externalFetch: user_hooks.externalFetch || fetch
230
+ };
231
+
232
+ if (/** @type {any} */ (hooks).getContext) {
233
+ // TODO remove this for 1.0
234
+ throw new Error(
235
+ 'The getContext hook has been removed. See https://kit.svelte.dev/docs/hooks'
236
+ );
237
+ }
238
+
239
+ if (/** @type {any} */ (hooks).serverFetch) {
240
+ // TODO remove this for 1.0
241
+ throw new Error('The serverFetch hook has been renamed to externalFetch.');
242
+ }
243
+
244
+ // TODO the / prefix will probably fail if outDir is outside the cwd (which
245
+ // could be the case in a monorepo setup), but without it these modules
246
+ // can get loaded twice via different URLs, which causes failures. Might
247
+ // require changes to Vite to fix
248
+ const { default: root } = await vite.ssrLoadModule(
249
+ `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`
250
+ );
251
+
252
+ const paths = await vite.ssrLoadModule(
253
+ true
254
+ ? `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/runtime/paths.js`))}`
255
+ : `/@fs${runtime}/paths.js`
256
+ );
257
+
258
+ paths.set_paths({
259
+ base: config.kit.paths.base,
260
+ assets
261
+ });
262
+
263
+ let request;
264
+
265
+ try {
266
+ request = await getRequest(base, req);
267
+ } catch (/** @type {any} */ err) {
268
+ res.statusCode = err.status || 400;
269
+ return res.end(err.reason || 'Invalid request body');
270
+ }
271
+
272
+ const template = load_template(cwd, config);
273
+
274
+ const rendered = await respond(request, {
275
+ amp: config.kit.amp,
276
+ csp: config.kit.csp,
277
+ dev: true,
278
+ floc: config.kit.floc,
279
+ get_stack: (error) => {
280
+ return fix_stack_trace(error);
281
+ },
282
+ handle_error: (error, event) => {
283
+ hooks.handleError({
284
+ error: new Proxy(error, {
285
+ get: (target, property) => {
286
+ if (property === 'stack') {
287
+ return fix_stack_trace(error);
288
+ }
289
+
290
+ return Reflect.get(target, property, target);
291
+ }
292
+ }),
293
+ event,
294
+
295
+ // TODO remove for 1.0
296
+ // @ts-expect-error
297
+ get request() {
298
+ throw new Error(
299
+ 'request in handleError has been replaced with event. See https://github.com/sveltejs/kit/pull/3384 for details'
300
+ );
301
+ }
302
+ });
303
+ },
304
+ hooks,
305
+ hydrate: config.kit.browser.hydrate,
306
+ manifest,
307
+ method_override: config.kit.methodOverride,
308
+ paths: {
309
+ base: config.kit.paths.base,
310
+ assets
311
+ },
312
+ prefix: '',
313
+ prerender: config.kit.prerender.enabled,
314
+ read: (file) => fs__default.readFileSync(path__default.join(config.kit.files.assets, file)),
315
+ root,
316
+ router: config.kit.browser.router,
317
+ template: ({ head, body, assets, nonce }) => {
318
+ return (
319
+ template
320
+ .replace(/%svelte\.assets%/g, assets)
321
+ .replace(/%svelte\.nonce%/g, nonce)
322
+ // head and body must be replaced last, in case someone tries to sneak in %svelte.assets% etc
323
+ .replace('%svelte.head%', () => head)
324
+ .replace('%svelte.body%', () => body)
325
+ );
326
+ },
327
+ template_contains_nonce: template.includes('%svelte.nonce%'),
328
+ trailing_slash: config.kit.trailingSlash
329
+ });
330
+
331
+ if (rendered) {
332
+ setResponse(res, rendered);
333
+ } else {
334
+ not_found(res);
335
+ }
336
+ } catch (e) {
337
+ const error = coalesce_to_error(e);
338
+ vite.ssrFixStacktrace(error);
339
+ res.statusCode = 500;
340
+ res.end(error.stack);
341
+ }
342
+ });
343
+ };
344
+ }
345
+ };
346
+ }
347
+
348
+ /** @param {string[]} array */
349
+ function get_params(array) {
350
+ // given an array of params like `['x', 'y', 'z']` for
351
+ // src/routes/[x]/[y]/[z]/svelte, create a function
352
+ // that turns a RegExpExecArray into ({ x, y, z })
353
+
354
+ /** @param {RegExpExecArray} match */
355
+ const fn = (match) => {
356
+ /** @type {Record<string, string>} */
357
+ const params = {};
358
+ array.forEach((key, i) => {
359
+ if (key.startsWith('...')) {
360
+ params[key.slice(3)] = match[i + 1] || '';
361
+ } else {
362
+ params[key] = match[i + 1];
363
+ }
364
+ });
365
+ return params;
366
+ };
367
+
368
+ return fn;
369
+ }
370
+
371
+ /** @param {import('http').ServerResponse} res */
372
+ function not_found(res) {
373
+ res.statusCode = 404;
374
+ res.end('Not found');
375
+ }
376
+
377
+ /**
378
+ * @param {import('connect').Server} server
379
+ */
380
+ function remove_html_middlewares(server) {
381
+ const html_middlewares = [
382
+ 'viteIndexHtmlMiddleware',
383
+ 'vite404Middleware',
384
+ 'viteSpaFallbackMiddleware'
385
+ ];
386
+ for (let i = server.stack.length - 1; i > 0; i--) {
387
+ // @ts-expect-error using internals until https://github.com/vitejs/vite/pull/4640 is merged
388
+ if (html_middlewares.includes(server.stack[i].handle.name)) {
389
+ server.stack.splice(i, 1);
390
+ }
391
+ }
392
+ }
393
+
394
+ /**
395
+ * @param {import('vite').ModuleNode} node
396
+ * @param {Set<import('vite').ModuleNode>} deps
397
+ */
398
+ function find_deps(node, deps) {
399
+ for (const dep of node.importedModules) {
400
+ if (!deps.has(dep)) {
401
+ deps.add(dep);
402
+ find_deps(dep, deps);
403
+ }
404
+ }
405
+ }
406
+
407
+ /**
408
+ * @typedef {{
409
+ * cwd: string,
410
+ * port: number,
411
+ * host?: string,
412
+ * https: boolean,
413
+ * config: import('types').ValidatedConfig
414
+ * }} Options
415
+ * @typedef {import('types').SSRComponent} SSRComponent
416
+ */
417
+
418
+ /** @param {Options} opts */
419
+ async function dev({ cwd, port, host, https, config }) {
420
+ init(config);
421
+
422
+ const [vite_config] = deep_merge(
423
+ {
424
+ server: {
425
+ fs: {
426
+ allow: [
427
+ ...new Set([
428
+ config.kit.files.assets,
429
+ config.kit.files.lib,
430
+ config.kit.files.routes,
431
+ config.kit.outDir,
432
+ path__default.resolve(cwd, 'src'),
433
+ path__default.resolve(cwd, 'node_modules'),
434
+ path__default.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
435
+ ])
436
+ ]
437
+ },
438
+ strictPort: true
439
+ }
440
+ },
441
+ await config.kit.vite()
442
+ );
443
+
444
+ /** @type {[any, string[]]} */
445
+ const [merged_config, conflicts] = deep_merge(vite_config, {
446
+ configFile: false,
447
+ root: cwd,
448
+ resolve: {
449
+ alias: get_aliases(config)
450
+ },
451
+ build: {
452
+ rollupOptions: {
453
+ // Vite dependency crawler needs an explicit JS entry point
454
+ // eventhough server otherwise works without it
455
+ input: `${get_runtime_path(config)}/client/start.js`
456
+ }
457
+ },
458
+ plugins: [
459
+ svelte({
460
+ extensions: config.extensions,
461
+ // In AMP mode, we know that there are no conditional component imports. In that case, we
462
+ // don't need to include CSS for components that are imported but unused, so we can just
463
+ // include rendered CSS.
464
+ // This would also apply if hydrate and router are both false, but we don't know if one
465
+ // has been enabled at the page level, so we don't do anything there.
466
+ emitCss: !config.kit.amp,
467
+ compilerOptions: {
468
+ hydratable: !!config.kit.browser.hydrate
469
+ }
470
+ }),
471
+ await create_plugin(config, cwd)
472
+ ],
473
+ base: '/'
474
+ });
475
+
476
+ print_config_conflicts(conflicts, 'kit.vite.');
477
+
478
+ // optional config from command-line flags
479
+ // these should take precedence, but not print conflict warnings
480
+ if (host) {
481
+ merged_config.server.host = host;
482
+ }
483
+
484
+ // if https is already enabled then do nothing. it could be an object and we
485
+ // don't want to overwrite with a boolean
486
+ if (https && !merged_config.server.https) {
487
+ merged_config.server.https = https;
488
+ }
489
+
490
+ if (port) {
491
+ merged_config.server.port = port;
492
+ }
493
+
494
+ const server = await vite.createServer(merged_config);
495
+ await server.listen(port);
496
+
497
+ const address_info = /** @type {import('net').AddressInfo} */ (
498
+ /** @type {import('http').Server} */ (server.httpServer).address()
499
+ );
500
+
501
+ return {
502
+ address_info,
503
+ server_config: vite_config.server,
504
+ close: () => server.close()
505
+ };
506
+ }
507
+
508
+ export { dev };