@sveltejs/kit 1.0.0-next.33 → 1.0.0-next.332

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