vite 5.0.0-beta.15 → 5.0.0-beta.16

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.
@@ -20,11 +20,11 @@ import require$$1$1 from 'http';
20
20
  import require$$0$7 from 'stream';
21
21
  import require$$2 from 'os';
22
22
  import require$$2$1 from 'child_process';
23
+ import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, VITE_PACKAGE_DIR, ASYNC_DISPOSE, DEFAULT_DEV_PORT, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
23
24
  import os$4 from 'node:os';
24
25
  import { exec } from 'node:child_process';
25
26
  import { createHash as createHash$2 } from 'node:crypto';
26
27
  import { promises } from 'node:dns';
27
- import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
28
28
  import require$$0$a from 'crypto';
29
29
  import { Buffer as Buffer$1 } from 'node:buffer';
30
30
  import require$$0$8, { createRequire as createRequire$2 } from 'module';
@@ -38479,8 +38479,8 @@ function createCachedImport(imp) {
38479
38479
  return cached;
38480
38480
  };
38481
38481
  }
38482
- const importPostcssImport = createCachedImport(() => import('./dep-01ZZG1lv.js').then(function (n) { return n.i; }));
38483
- const importPostcssModules = createCachedImport(() => import('./dep-dhvB1mwU.js').then(function (n) { return n.i; }));
38482
+ const importPostcssImport = createCachedImport(() => import('./dep-ayAPZ1OT.js').then(function (n) { return n.i; }));
38483
+ const importPostcssModules = createCachedImport(() => import('./dep-wO2juHOz.js').then(function (n) { return n.i; }));
38484
38484
  const importPostcss = createCachedImport(() => import('postcss'));
38485
38485
  /**
38486
38486
  * @experimental
@@ -39757,7 +39757,6 @@ function optimizedDepsPlugin(config) {
39757
39757
  // something unexpected has happened. In this case, Vite
39758
39758
  // returns an empty response that will error.
39759
39759
  throwProcessingError(id);
39760
- return;
39761
39760
  }
39762
39761
  const newMetadata = depsOptimizer.metadata;
39763
39762
  if (metadata !== newMetadata) {
@@ -47731,10 +47730,14 @@ async function loadAndTransform(id, url, server, options, timestamp, mod, resolv
47731
47730
  }
47732
47731
  if (code == null) {
47733
47732
  const isPublicFile = checkPublicFile(url, config);
47733
+ let publicDirName = path$o.relative(config.root, config.publicDir);
47734
+ if (publicDirName[0] !== '.')
47735
+ publicDirName = '/' + publicDirName;
47734
47736
  const msg = isPublicFile
47735
- ? `This file is in /public and will be copied as-is during build without ` +
47736
- `going through the plugin transforms, and therefore should not be ` +
47737
- `imported from source code. It can only be referenced via HTML tags.`
47737
+ ? `This file is in ${publicDirName} and will be copied as-is during ` +
47738
+ `build without going through the plugin transforms, and therefore ` +
47739
+ `should not be imported from source code. It can only be referenced ` +
47740
+ `via HTML tags.`
47738
47741
  : `Does the file exist?`;
47739
47742
  const importerMod = server.moduleGraph.idToModuleMap
47740
47743
  .get(id)
@@ -54910,31 +54913,33 @@ function createWebSocketServer(server, config, httpsOptions) {
54910
54913
  });
54911
54914
  });
54912
54915
  },
54916
+ [ASYNC_DISPOSE]() {
54917
+ return this.close();
54918
+ },
54913
54919
  };
54914
54920
  }
54915
54921
 
54916
54922
  // this middleware is only active when (base !== '/')
54917
- function baseMiddleware({ config, }) {
54923
+ function baseMiddleware(rawBase, middlewareMode) {
54918
54924
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
54919
54925
  return function viteBaseMiddleware(req, res, next) {
54920
54926
  const url = req.url;
54921
- const parsed = new URL(url, 'http://vitejs.dev');
54922
- const path = parsed.pathname || '/';
54923
- const base = config.rawBase;
54924
- if (path.startsWith(base)) {
54927
+ const pathname = cleanUrl(url);
54928
+ const base = rawBase;
54929
+ if (pathname.startsWith(base)) {
54925
54930
  // rewrite url to remove base. this ensures that other middleware does
54926
54931
  // not need to consider base being prepended or not
54927
54932
  req.url = stripBase(url, base);
54928
54933
  return next();
54929
54934
  }
54930
54935
  // skip redirect and error fallback on middleware mode, #4057
54931
- if (config.server.middlewareMode) {
54936
+ if (middlewareMode) {
54932
54937
  return next();
54933
54938
  }
54934
- if (path === '/' || path === '/index.html') {
54939
+ if (pathname === '/' || pathname === '/index.html') {
54935
54940
  // redirect root visit to based url with search and hash
54936
54941
  res.writeHead(302, {
54937
- Location: base + (parsed.search || '') + (parsed.hash || ''),
54942
+ Location: base + url.slice(pathname.length),
54938
54943
  });
54939
54944
  res.end();
54940
54945
  return;
@@ -57110,19 +57115,7 @@ function doesProxyContextMatchUrl(context, url) {
57110
57115
  }
57111
57116
 
57112
57117
  const debug$6 = createDebugger('vite:html-fallback');
57113
- function htmlFallbackMiddleware(root, spaFallback, mounted = false) {
57114
- // When this middleware is mounted on a route, we need to re-assign `req.url` with a
57115
- // leading `.` to signal a relative rewrite. Returning with a leading `/` returns a
57116
- // buggy `req.url`. e.g.:
57117
- //
57118
- // mount /foo/bar:
57119
- // req.url = /index.html
57120
- // final = /foo/barindex.html
57121
- //
57122
- // mount /foo/bar:
57123
- // req.url = ./index.html
57124
- // final = /foo/bar/index.html
57125
- const prepend = mounted ? '.' : '';
57118
+ function htmlFallbackMiddleware(root, spaFallback) {
57126
57119
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
57127
57120
  return function viteHtmlFallbackMiddleware(req, res, next) {
57128
57121
  if (
@@ -57146,7 +57139,7 @@ function htmlFallbackMiddleware(root, spaFallback, mounted = false) {
57146
57139
  const filePath = path$o.join(root, pathname);
57147
57140
  if (fs$l.existsSync(filePath)) {
57148
57141
  debug$6?.(`Rewriting ${req.method} ${req.url} to ${url}`);
57149
- req.url = prepend + url;
57142
+ req.url = url;
57150
57143
  return next();
57151
57144
  }
57152
57145
  }
@@ -57156,7 +57149,7 @@ function htmlFallbackMiddleware(root, spaFallback, mounted = false) {
57156
57149
  if (fs$l.existsSync(filePath)) {
57157
57150
  const newUrl = url + 'index.html';
57158
57151
  debug$6?.(`Rewriting ${req.method} ${req.url} to ${newUrl}`);
57159
- req.url = prepend + newUrl;
57152
+ req.url = newUrl;
57160
57153
  return next();
57161
57154
  }
57162
57155
  }
@@ -57166,13 +57159,13 @@ function htmlFallbackMiddleware(root, spaFallback, mounted = false) {
57166
57159
  if (fs$l.existsSync(filePath)) {
57167
57160
  const newUrl = url + '.html';
57168
57161
  debug$6?.(`Rewriting ${req.method} ${req.url} to ${newUrl}`);
57169
- req.url = prepend + newUrl;
57162
+ req.url = newUrl;
57170
57163
  return next();
57171
57164
  }
57172
57165
  }
57173
57166
  if (spaFallback) {
57174
57167
  debug$6?.(`Rewriting ${req.method} ${req.url} to /index.html`);
57175
- req.url = prepend + '/index.html';
57168
+ req.url = '/index.html';
57176
57169
  }
57177
57170
  next();
57178
57171
  };
@@ -58449,6 +58442,9 @@ async function _createServer(inlineConfig = {}, options) {
58449
58442
  }
58450
58443
  server.resolvedUrls = null;
58451
58444
  },
58445
+ [ASYNC_DISPOSE]() {
58446
+ return this.close();
58447
+ },
58452
58448
  printUrls() {
58453
58449
  if (server.resolvedUrls) {
58454
58450
  printServerUrls(server.resolvedUrls, serverConfig.host, config.logger.info);
@@ -58561,7 +58557,7 @@ async function _createServer(inlineConfig = {}, options) {
58561
58557
  }
58562
58558
  // base
58563
58559
  if (config.base !== '/') {
58564
- middlewares.use(baseMiddleware(server));
58560
+ middlewares.use(baseMiddleware(config.rawBase, middlewareMode));
58565
58561
  }
58566
58562
  // open in editor support
58567
58563
  middlewares.use('/__open-in-editor', launchEditorMiddleware$1());
@@ -61306,14 +61302,7 @@ function createPluginHookUtils(plugins) {
61306
61302
  }
61307
61303
  function getSortedPluginHooks(hookName) {
61308
61304
  const plugins = getSortedPlugins(hookName);
61309
- return plugins
61310
- .map((p) => {
61311
- const hook = p[hookName];
61312
- return typeof hook === 'object' && 'handler' in hook
61313
- ? hook.handler
61314
- : hook;
61315
- })
61316
- .filter(Boolean);
61305
+ return plugins.map((p) => getHookHandler(p[hookName])).filter(Boolean);
61317
61306
  }
61318
61307
  return {
61319
61308
  getSortedPlugins,
@@ -61342,6 +61331,9 @@ function getSortedPluginsByHook(hookName, plugins) {
61342
61331
  }
61343
61332
  return [...pre, ...normal, ...post];
61344
61333
  }
61334
+ function getHookHandler(hook) {
61335
+ return (typeof hook === 'object' ? hook.handler : hook);
61336
+ }
61345
61337
 
61346
61338
  /**
61347
61339
  * This file is refactored into TypeScript based on
@@ -61421,9 +61413,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
61421
61413
  const hook = plugin[hookName];
61422
61414
  if (!hook)
61423
61415
  continue;
61424
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
61425
- // @ts-ignore hook is not a primitive
61426
- const handler = 'handler' in hook ? hook.handler : hook;
61416
+ const handler = getHookHandler(hook);
61427
61417
  if (hook.sequential) {
61428
61418
  await Promise.all(parallelPromises);
61429
61419
  parallelPromises.length = 0;
@@ -61781,9 +61771,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
61781
61771
  continue;
61782
61772
  ctx._activePlugin = plugin;
61783
61773
  const pluginResolveStart = debugPluginResolve ? performance.now() : 0;
61784
- const handler = 'handler' in plugin.resolveId
61785
- ? plugin.resolveId.handler
61786
- : plugin.resolveId;
61774
+ const handler = getHookHandler(plugin.resolveId);
61787
61775
  const result = await handleHookPromise(handler.call(ctx, rawId, importer, {
61788
61776
  attributes: options?.attributes ?? {},
61789
61777
  custom: options?.custom,
@@ -61830,7 +61818,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
61830
61818
  if (!plugin.load)
61831
61819
  continue;
61832
61820
  ctx._activePlugin = plugin;
61833
- const handler = 'handler' in plugin.load ? plugin.load.handler : plugin.load;
61821
+ const handler = getHookHandler(plugin.load);
61834
61822
  const result = await handleHookPromise(handler.call(ctx, id, { ssr }));
61835
61823
  if (result != null) {
61836
61824
  if (isObject$1(result)) {
@@ -61856,9 +61844,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
61856
61844
  ctx._activeCode = code;
61857
61845
  const start = debugPluginTransform ? performance.now() : 0;
61858
61846
  let result;
61859
- const handler = 'handler' in plugin.transform
61860
- ? plugin.transform.handler
61861
- : plugin.transform;
61847
+ const handler = getHookHandler(plugin.transform);
61862
61848
  try {
61863
61849
  result = await handleHookPromise(handler.call(ctx, code, id, { ssr }));
61864
61850
  }
@@ -61903,6 +61889,9 @@ async function createPluginContainer(config, moduleGraph, watcher) {
61903
61889
  await hookParallel('buildEnd', () => ctx, () => []);
61904
61890
  await hookParallel('closeBundle', () => ctx, () => []);
61905
61891
  },
61892
+ [ASYNC_DISPOSE]() {
61893
+ return this.close();
61894
+ },
61906
61895
  };
61907
61896
  return container;
61908
61897
  }
@@ -62616,6 +62605,9 @@ async function createDepsOptimizer(config, server) {
62616
62605
  resetRegisteredIds,
62617
62606
  ensureFirstRun,
62618
62607
  close,
62608
+ [ASYNC_DISPOSE]() {
62609
+ return this.close();
62610
+ },
62619
62611
  options: getDepOptimizationConfig(config, ssr),
62620
62612
  };
62621
62613
  depsOptimizerMap.set(config, depsOptimizer);
@@ -63150,6 +63142,7 @@ async function createDevSsrDepsOptimizer(config) {
63150
63142
  resetRegisteredIds: () => { },
63151
63143
  ensureFirstRun: () => { },
63152
63144
  close: async () => { },
63145
+ [ASYNC_DISPOSE]: async () => { },
63153
63146
  options: config.ssr.optimizeDeps,
63154
63147
  };
63155
63148
  devSsrDepsOptimizerMap.set(config, depsOptimizer);
@@ -65127,7 +65120,7 @@ function injectSsrFlagToHooks(plugin) {
65127
65120
  function wrapSsrResolveId(hook) {
65128
65121
  if (!hook)
65129
65122
  return;
65130
- const fn = 'handler' in hook ? hook.handler : hook;
65123
+ const fn = getHookHandler(hook);
65131
65124
  const handler = function (id, importer, options) {
65132
65125
  return fn.call(this, id, importer, injectSsrFlag(options));
65133
65126
  };
@@ -65144,7 +65137,7 @@ function wrapSsrResolveId(hook) {
65144
65137
  function wrapSsrLoad(hook) {
65145
65138
  if (!hook)
65146
65139
  return;
65147
- const fn = 'handler' in hook ? hook.handler : hook;
65140
+ const fn = getHookHandler(hook);
65148
65141
  const handler = function (id, ...args) {
65149
65142
  // @ts-expect-error: Receiving options param to be future-proof if Rollup adds it
65150
65143
  return fn.call(this, id, injectSsrFlag(args[0]));
@@ -65162,7 +65155,7 @@ function wrapSsrLoad(hook) {
65162
65155
  function wrapSsrTransform(hook) {
65163
65156
  if (!hook)
65164
65157
  return;
65165
- const fn = 'handler' in hook ? hook.handler : hook;
65158
+ const fn = getHookHandler(hook);
65166
65159
  const handler = function (code, importer, ...args) {
65167
65160
  // @ts-expect-error: Receiving options param to be future-proof if Rollup adds it
65168
65161
  return fn.call(this, code, importer, injectSsrFlag(args[0]));
@@ -65485,7 +65478,10 @@ async function preview(inlineConfig = {}) {
65485
65478
  app.use(proxyMiddleware(httpServer, proxy, config));
65486
65479
  }
65487
65480
  app.use(compression());
65488
- const previewBase = config.base === './' || config.base === '' ? '/' : config.base;
65481
+ // base
65482
+ if (config.base !== '/') {
65483
+ app.use(baseMiddleware(config.rawBase, false));
65484
+ }
65489
65485
  // static assets
65490
65486
  const headers = config.preview.headers;
65491
65487
  const viteAssetMiddleware = (...args) => sirv(distDir, {
@@ -65504,23 +65500,22 @@ async function preview(inlineConfig = {}) {
65504
65500
  return shouldServeFile(filePath, distDir);
65505
65501
  },
65506
65502
  })(...args);
65507
- app.use(previewBase, viteAssetMiddleware);
65503
+ app.use(viteAssetMiddleware);
65508
65504
  // html fallback
65509
65505
  if (config.appType === 'spa' || config.appType === 'mpa') {
65510
- app.use(previewBase, htmlFallbackMiddleware(distDir, config.appType === 'spa', previewBase !== '/'));
65506
+ app.use(htmlFallbackMiddleware(distDir, config.appType === 'spa'));
65511
65507
  }
65512
65508
  // apply post server hooks from plugins
65513
65509
  postHooks.forEach((fn) => fn && fn());
65514
65510
  if (config.appType === 'spa' || config.appType === 'mpa') {
65515
65511
  // transform index.html
65516
- app.use(previewBase, indexHtmlMiddleware(distDir, server));
65512
+ app.use(indexHtmlMiddleware(distDir, server));
65517
65513
  // handle 404s
65518
- app.use(previewBase, notFoundMiddleware());
65514
+ app.use(notFoundMiddleware());
65519
65515
  }
65520
65516
  const hostname = await resolveHostname(options.host);
65521
65517
  const port = options.port ?? DEFAULT_PREVIEW_PORT;
65522
- const protocol = options.https ? 'https' : 'http';
65523
- const serverPort = await httpServerStart(httpServer, {
65518
+ await httpServerStart(httpServer, {
65524
65519
  port,
65525
65520
  strictPort: options.strictPort,
65526
65521
  host: hostname.host,
@@ -65528,10 +65523,11 @@ async function preview(inlineConfig = {}) {
65528
65523
  });
65529
65524
  server.resolvedUrls = await resolveServerUrls(httpServer, config.preview, config);
65530
65525
  if (options.open) {
65531
- const path = typeof options.open === 'string' ? options.open : previewBase;
65532
- openBrowser(path.startsWith('http')
65533
- ? path
65534
- : new URL(path, `${protocol}://${hostname.name}:${serverPort}`).href, true, logger);
65526
+ const url = server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
65527
+ if (url) {
65528
+ const path = typeof options.open === 'string' ? new URL(options.open, url).href : url;
65529
+ openBrowser(path, true, logger);
65530
+ }
65535
65531
  }
65536
65532
  return server;
65537
65533
  }
@@ -65565,7 +65561,7 @@ const promisifiedRealpath = promisify$4(fs$l.realpath);
65565
65561
  function defineConfig(config) {
65566
65562
  return config;
65567
65563
  }
65568
- async function resolveConfig(inlineConfig, command, defaultMode = 'development', defaultNodeEnv = 'development') {
65564
+ async function resolveConfig(inlineConfig, command, defaultMode = 'development', defaultNodeEnv = 'development', isPreview = false) {
65569
65565
  let config = inlineConfig;
65570
65566
  let configFileDependencies = [];
65571
65567
  let mode = inlineConfig.mode || defaultMode;
@@ -65579,7 +65575,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
65579
65575
  const configEnv = {
65580
65576
  mode,
65581
65577
  command,
65582
- ssrBuild: !!config.build?.ssr,
65578
+ isSsrBuild: !!config.build?.ssr,
65579
+ isPreview,
65583
65580
  };
65584
65581
  let { configFile } = config;
65585
65582
  if (configFile !== false) {
@@ -66157,7 +66154,7 @@ async function runConfigHook(config, plugins, configEnv) {
66157
66154
  let conf = config;
66158
66155
  for (const p of getSortedPluginsByHook('config', plugins)) {
66159
66156
  const hook = p.config;
66160
- const handler = hook && 'handler' in hook ? hook.handler : hook;
66157
+ const handler = getHookHandler(hook);
66161
66158
  if (handler) {
66162
66159
  const res = await handler(conf, configEnv);
66163
66160
  if (res) {
@@ -1,4 +1,4 @@
1
- import { y as getDefaultExportFromCjs } from './dep-Kf16Z54K.js';
1
+ import { y as getDefaultExportFromCjs } from './dep-WN9UKUor.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-8a-6Quh6.js';
@@ -1,4 +1,4 @@
1
- import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-Kf16Z54K.js';
1
+ import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-WN9UKUor.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-Kf16Z54K.js';
5
+ import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-WN9UKUor.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -759,7 +759,7 @@ cli
759
759
  filterDuplicateOptions(options);
760
760
  // output structure is preserved even after bundling so require()
761
761
  // is ok here
762
- const { createServer } = await import('./chunks/dep-Kf16Z54K.js').then(function (n) { return n.A; });
762
+ const { createServer } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.A; });
763
763
  try {
764
764
  const server = await createServer({
765
765
  root,
@@ -839,7 +839,7 @@ cli
839
839
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
840
840
  .action(async (root, options) => {
841
841
  filterDuplicateOptions(options);
842
- const { build } = await import('./chunks/dep-Kf16Z54K.js').then(function (n) { return n.C; });
842
+ const { build } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.C; });
843
843
  const buildOptions = cleanOptions(options);
844
844
  try {
845
845
  await build({
@@ -867,7 +867,7 @@ cli
867
867
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
868
868
  .action(async (root, options) => {
869
869
  filterDuplicateOptions(options);
870
- const { optimizeDeps } = await import('./chunks/dep-Kf16Z54K.js').then(function (n) { return n.B; });
870
+ const { optimizeDeps } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.B; });
871
871
  try {
872
872
  const config = await resolveConfig({
873
873
  root,
@@ -893,7 +893,7 @@ cli
893
893
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
894
894
  .action(async (root, options) => {
895
895
  filterDuplicateOptions(options);
896
- const { preview } = await import('./chunks/dep-Kf16Z54K.js').then(function (n) { return n.D; });
896
+ const { preview } = await import('./chunks/dep-WN9UKUor.js').then(function (n) { return n.D; });
897
897
  try {
898
898
  const server = await preview({
899
899
  root,
@@ -122,5 +122,6 @@ const wildcardHosts = new Set([
122
122
  ]);
123
123
  const DEFAULT_DEV_PORT = 5173;
124
124
  const DEFAULT_PREVIEW_PORT = 4173;
125
+ const ASYNC_DISPOSE = Symbol.asyncDispose || Symbol.for('Symbol.asyncDispose');
125
126
 
126
- export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
127
+ export { ASYNC_DISPOSE, CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
@@ -6,6 +6,7 @@ export { VERSION as rollupVersion } from 'rollup';
6
6
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
7
7
  import * as http from 'node:http';
8
8
  import { OutgoingHttpHeaders, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, Server, ServerResponse } from 'node:http';
9
+ import { Http2SecureServer } from 'node:http2';
9
10
  import * as fs from 'node:fs';
10
11
  import * as events from 'node:events';
11
12
  import { EventEmitter } from 'node:events';
@@ -716,7 +717,7 @@ interface PreviewServer {
716
717
  /**
717
718
  * native Node http server instance
718
719
  */
719
- httpServer: http.Server;
720
+ httpServer: HttpServer;
720
721
  /**
721
722
  * The resolved urls Vite prints on the CLI.
722
723
  * null before server is listening.
@@ -837,7 +838,7 @@ declare class ModuleGraph {
837
838
  * https:
838
839
  */
839
840
 
840
- interface PluginContainer {
841
+ interface PluginContainer extends AsyncDisposable {
841
842
  options: InputOptions;
842
843
  getModuleInfo(id: string): ModuleInfo | null;
843
844
  buildStart(options: InputOptions): Promise<void>;
@@ -1398,7 +1399,7 @@ declare namespace WebSocket {
1398
1399
  }
1399
1400
 
1400
1401
  type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
1401
- interface WebSocketServer {
1402
+ interface WebSocketServer extends AsyncDisposable {
1402
1403
  /**
1403
1404
  * Listen on port and host
1404
1405
  */
@@ -1552,7 +1553,8 @@ interface FileSystemServeOptions {
1552
1553
  deny?: string[];
1553
1554
  }
1554
1555
  type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
1555
- interface ViteDevServer {
1556
+ type HttpServer = http.Server | Http2SecureServer;
1557
+ interface ViteDevServer extends AsyncDisposable {
1556
1558
  /**
1557
1559
  * The resolved vite config object
1558
1560
  */
@@ -1570,7 +1572,7 @@ interface ViteDevServer {
1570
1572
  * native Node http server instance
1571
1573
  * will be null in middleware mode
1572
1574
  */
1573
- httpServer: http.Server | null;
1575
+ httpServer: HttpServer | null;
1574
1576
  /**
1575
1577
  * chokidar watcher instance
1576
1578
  * https:
@@ -2423,7 +2425,7 @@ type ExportsData = {
2423
2425
  exports: readonly string[];
2424
2426
  jsxLoader?: boolean;
2425
2427
  };
2426
- interface DepsOptimizer {
2428
+ interface DepsOptimizer extends AsyncDisposable {
2427
2429
  metadata: DepOptimizationMetadata;
2428
2430
  scanProcessing?: Promise<void>;
2429
2431
  registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
@@ -2924,6 +2926,9 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
2924
2926
  }) => Promise<rollup.TransformResult> | rollup.TransformResult>;
2925
2927
  }
2926
2928
  type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
2929
+ type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
2930
+ [P in K]: NonNullable<Plugin[P]>;
2931
+ };
2927
2932
 
2928
2933
  interface JsonOptions {
2929
2934
  /**
@@ -2942,10 +2947,8 @@ interface JsonOptions {
2942
2947
  interface ConfigEnv {
2943
2948
  command: 'build' | 'serve';
2944
2949
  mode: string;
2945
- /**
2946
- * @experimental
2947
- */
2948
- ssrBuild?: boolean;
2950
+ isSsrBuild?: boolean;
2951
+ isPreview?: boolean;
2949
2952
  }
2950
2953
  /**
2951
2954
  * spa: include SPA fallback middleware and configure sirv with `single: true` in preview
@@ -3210,11 +3213,11 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3210
3213
  experimental: ExperimentalOptions;
3211
3214
  } & PluginHookUtils>;
3212
3215
  interface PluginHookUtils {
3213
- getSortedPlugins: (hookName: keyof Plugin) => Plugin[];
3216
+ getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
3214
3217
  getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
3215
3218
  }
3216
3219
  type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
3217
- declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string): Promise<ResolvedConfig>;
3220
+ declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean): Promise<ResolvedConfig>;
3218
3221
  declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
3219
3222
  declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
3220
3223
  path: string;
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules } from './chunks/dep-Kf16Z54K.js';
3
- export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-Kf16Z54K.js';
2
+ import { i as isInNodeModules } from './chunks/dep-WN9UKUor.js';
3
+ export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-WN9UKUor.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  export { VERSION as rollupVersion } from 'rollup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.0-beta.15",
3
+ "version": "5.0.0-beta.16",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",