@sveltejs/kit 1.0.0-next.30 → 1.0.0-next.300

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