@sveltejs/kit 1.0.0-next.3 → 1.0.0-next.301

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