vite 6.1.0-beta.2 → 6.1.0

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.
@@ -1,4 +1,4 @@
1
- import { P as getDefaultExportFromCjs } from './dep-De0zV__s.js';
1
+ import { P as getDefaultExportFromCjs } from './dep-CfG9u7Cn.js';
2
2
  import require$$0 from 'path';
3
3
  import { l as lib } from './dep-3RmXg9uo.js';
4
4
 
@@ -10210,7 +10210,7 @@ async function resolveHostname(optionsHost) {
10210
10210
  }
10211
10211
  return { host, name };
10212
10212
  }
10213
- async function resolveServerUrls(server, options, config) {
10213
+ async function resolveServerUrls(server, options, httpsOptions, config) {
10214
10214
  const address = server.address();
10215
10215
  const isAddressInfo = (x) => x?.address;
10216
10216
  if (!isAddressInfo(address)) {
@@ -10250,8 +10250,46 @@ async function resolveServerUrls(server, options, config) {
10250
10250
  }
10251
10251
  });
10252
10252
  }
10253
+ const cert = httpsOptions?.cert && !Array.isArray(httpsOptions.cert) ? new crypto$2.X509Certificate(httpsOptions.cert) : undefined;
10254
+ const hostnameFromCert = cert?.subjectAltName ? extractHostnamesFromSubjectAltName(cert.subjectAltName) : [];
10255
+ if (hostnameFromCert.length > 0) {
10256
+ const existings = /* @__PURE__ */ new Set([...local, ...network]);
10257
+ local.push(
10258
+ ...hostnameFromCert.map((hostname2) => `https://${hostname2}:${port}${base}`).filter((url) => !existings.has(url))
10259
+ );
10260
+ }
10253
10261
  return { local, network };
10254
10262
  }
10263
+ function extractHostnamesFromSubjectAltName(subjectAltName) {
10264
+ const hostnames = [];
10265
+ let remaining = subjectAltName;
10266
+ while (remaining) {
10267
+ const nameEndIndex = remaining.indexOf(":");
10268
+ const name = remaining.slice(0, nameEndIndex);
10269
+ remaining = remaining.slice(nameEndIndex + 1);
10270
+ if (!remaining) break;
10271
+ const isQuoted = remaining[0] === '"';
10272
+ let value;
10273
+ if (isQuoted) {
10274
+ const endQuoteIndex = remaining.indexOf('"', 1);
10275
+ value = JSON.parse(remaining.slice(0, endQuoteIndex + 1));
10276
+ remaining = remaining.slice(endQuoteIndex + 1);
10277
+ } else {
10278
+ const maybeEndIndex = remaining.indexOf(",");
10279
+ const endIndex = maybeEndIndex === -1 ? remaining.length : maybeEndIndex;
10280
+ value = remaining.slice(0, endIndex);
10281
+ remaining = remaining.slice(endIndex);
10282
+ }
10283
+ remaining = remaining.slice(
10284
+ /* for , */
10285
+ 1
10286
+ ).trimStart();
10287
+ if (name === "DNS" && value !== "[::1]") {
10288
+ hostnames.push(value.replace("*", "vite"));
10289
+ }
10290
+ }
10291
+ return hostnames;
10292
+ }
10255
10293
  function arraify(target) {
10256
10294
  return Array.isArray(target) ? target : [target];
10257
10295
  }
@@ -13699,6 +13737,7 @@ function manifestPlugin() {
13699
13737
  manifest: {},
13700
13738
  outputCount: 0,
13701
13739
  reset() {
13740
+ this.manifest = {};
13702
13741
  this.outputCount = 0;
13703
13742
  }
13704
13743
  };
@@ -17989,7 +18028,9 @@ class ScanEnvironment extends BaseEnvironment {
17989
18028
  this._plugins = await resolveEnvironmentPlugins(this);
17990
18029
  this._pluginContainer = await createEnvironmentPluginContainer(
17991
18030
  this,
17992
- this.plugins
18031
+ this.plugins,
18032
+ undefined,
18033
+ false
17993
18034
  );
17994
18035
  }
17995
18036
  }
@@ -18625,6 +18666,11 @@ function isDepOptimizationDisabled(optimizeDeps2) {
18625
18666
  }
18626
18667
  async function optimizeDeps(config, force = config.optimizeDeps.force, asCommand = false) {
18627
18668
  const log = asCommand ? config.logger.info : debug$c;
18669
+ config.logger.warn(
18670
+ colors$1.yellow(
18671
+ "manually calling optimizeDeps is deprecated. This is done automatically and does not need to be called manually."
18672
+ )
18673
+ );
18628
18674
  const environment = new ScanEnvironment("client", config);
18629
18675
  await environment.init();
18630
18676
  const cachedMetadata = await loadCachedDepOptimizationMetadata(
@@ -43945,6 +43991,7 @@ async function _createServer(inlineConfig = {}, options) {
43945
43991
  server.resolvedUrls = await resolveServerUrls(
43946
43992
  httpServer,
43947
43993
  config.server,
43994
+ httpsOptions,
43948
43995
  config
43949
43996
  );
43950
43997
  if (!isRestart && config.server.open) server.openBrowser();
@@ -44306,6 +44353,10 @@ function resolveServerOptions(root, raw, logger) {
44306
44353
  )
44307
44354
  );
44308
44355
  }
44356
+ if (process.env.__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS && Array.isArray(server.allowedHosts)) {
44357
+ const additionalHost = process.env.__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS;
44358
+ server.allowedHosts = [...server.allowedHosts, additionalHost];
44359
+ }
44309
44360
  return server;
44310
44361
  }
44311
44362
  async function restartServer(server) {
@@ -47287,11 +47338,12 @@ function throwClosedServerError() {
47287
47338
  err.code = ERR_CLOSED_SERVER;
47288
47339
  throw err;
47289
47340
  }
47290
- async function createEnvironmentPluginContainer(environment, plugins, watcher) {
47341
+ async function createEnvironmentPluginContainer(environment, plugins, watcher, autoStart = true) {
47291
47342
  const container = new EnvironmentPluginContainer(
47292
47343
  environment,
47293
47344
  plugins,
47294
- watcher
47345
+ watcher,
47346
+ autoStart
47295
47347
  );
47296
47348
  await container.resolveRollupOptions();
47297
47349
  return container;
@@ -47300,10 +47352,11 @@ class EnvironmentPluginContainer {
47300
47352
  /**
47301
47353
  * @internal use `createEnvironmentPluginContainer` instead
47302
47354
  */
47303
- constructor(environment, plugins, watcher) {
47355
+ constructor(environment, plugins, watcher, autoStart = true) {
47304
47356
  this.environment = environment;
47305
47357
  this.plugins = plugins;
47306
47358
  this.watcher = watcher;
47359
+ this._started = !autoStart;
47307
47360
  this.minimalContext = new MinimalPluginContext(
47308
47361
  { rollupVersion, watchMode: true },
47309
47362
  environment
@@ -48048,7 +48101,9 @@ function createIdResolver(config, options) {
48048
48101
  // Ignore sideEffects and other computations as we only need the id
48049
48102
  idOnly: true
48050
48103
  })
48051
- ]
48104
+ ],
48105
+ undefined,
48106
+ false
48052
48107
  );
48053
48108
  pluginContainerMap.set(environment, pluginContainer);
48054
48109
  }
@@ -48060,7 +48115,9 @@ function createIdResolver(config, options) {
48060
48115
  if (!pluginContainer) {
48061
48116
  pluginContainer = await createEnvironmentPluginContainer(
48062
48117
  environment,
48063
- [alias$1({ entries: environment.config.resolve.alias })]
48118
+ [alias$1({ entries: environment.config.resolve.alias })],
48119
+ undefined,
48120
+ false
48064
48121
  );
48065
48122
  aliasOnlyPluginContainerMap.set(environment, pluginContainer);
48066
48123
  }
@@ -49062,8 +49119,8 @@ function createCachedImport(imp) {
49062
49119
  return cached;
49063
49120
  };
49064
49121
  }
49065
- const importPostcssImport = createCachedImport(() => import('./dep-C64BF_qg.js').then(function (n) { return n.i; }));
49066
- const importPostcssModules = createCachedImport(() => import('./dep-B-U7Afbv.js').then(function (n) { return n.i; }));
49122
+ const importPostcssImport = createCachedImport(() => import('./dep-BUK8RJ2R.js').then(function (n) { return n.i; }));
49123
+ const importPostcssModules = createCachedImport(() => import('./dep-DWzCYIjV.js').then(function (n) { return n.i; }));
49067
49124
  const importPostcss = createCachedImport(() => import('postcss'));
49068
49125
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
49069
49126
  let alwaysFakeWorkerWorkerControllerCache;
@@ -53291,12 +53348,9 @@ async function preview(inlineConfig = {}) {
53291
53348
  `The directory "${clientOutDir}" does not exist. Did you build your project?`
53292
53349
  );
53293
53350
  }
53351
+ const httpsOptions = await resolveHttpsConfig(config.server.https);
53294
53352
  const app = connect$1();
53295
- const httpServer = await resolveHttpServer(
53296
- config.preview,
53297
- app,
53298
- await resolveHttpsConfig(config.preview.https)
53299
- );
53353
+ const httpServer = await resolveHttpServer(config.preview, app, httpsOptions);
53300
53354
  setClientErrorHandler(httpServer, config.logger);
53301
53355
  const options = config.preview;
53302
53356
  const logger = config.logger;
@@ -53394,6 +53448,7 @@ async function preview(inlineConfig = {}) {
53394
53448
  server.resolvedUrls = await resolveServerUrls(
53395
53449
  httpServer,
53396
53450
  config.preview,
53451
+ httpsOptions,
53397
53452
  config
53398
53453
  );
53399
53454
  if (options.open) {
@@ -54239,9 +54294,9 @@ function sortUserPlugins(plugins) {
54239
54294
  return [prePlugins, normalPlugins, postPlugins];
54240
54295
  }
54241
54296
  async function loadConfigFromFile(configEnv, configFile, configRoot = process.cwd(), logLevel, customLogger, configLoader = "bundle") {
54242
- if (configLoader !== "bundle" && configLoader !== "runner") {
54297
+ if (configLoader !== "bundle" && configLoader !== "runner" && configLoader !== "native") {
54243
54298
  throw new Error(
54244
- `Unsupported configLoader: ${configLoader}. Accepted values are 'bundle' and 'runner'.`
54299
+ `Unsupported configLoader: ${configLoader}. Accepted values are 'bundle', 'runner', and 'native'.`
54245
54300
  );
54246
54301
  }
54247
54302
  const start = performance.now();
@@ -54262,7 +54317,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
54262
54317
  return null;
54263
54318
  }
54264
54319
  try {
54265
- const resolver = configLoader === "bundle" ? bundleAndLoadConfigFile : importConfigFile;
54320
+ const resolver = configLoader === "bundle" ? bundleAndLoadConfigFile : configLoader === "runner" ? runnerImportConfigFile : nativeImportConfigFile;
54266
54321
  const { configExport, dependencies } = await resolver(resolvedPath);
54267
54322
  debug?.(`config file loaded in ${getTime()}`);
54268
54323
  const config = await (typeof configExport === "function" ? configExport(configEnv) : configExport);
@@ -54284,7 +54339,14 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
54284
54339
  throw e;
54285
54340
  }
54286
54341
  }
54287
- async function importConfigFile(resolvedPath) {
54342
+ async function nativeImportConfigFile(resolvedPath) {
54343
+ const module = await import(pathToFileURL$1(resolvedPath).href + "?t=" + Date.now());
54344
+ return {
54345
+ configExport: module.default,
54346
+ dependencies: []
54347
+ };
54348
+ }
54349
+ async function runnerImportConfigFile(resolvedPath) {
54288
54350
  const { module, dependencies } = await runnerImport(resolvedPath);
54289
54351
  return {
54290
54352
  configExport: module.default,
@@ -1,4 +1,4 @@
1
- import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-De0zV__s.js';
1
+ import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-CfG9u7Cn.js';
2
2
  import require$$0$2 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__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-De0zV__s.js';
5
+ import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-CfG9u7Cn.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -738,14 +738,14 @@ cli.option("-c, --config <file>", `[string] use specified config file`).option("
738
738
  type: [convertBase]
739
739
  }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option(
740
740
  "--configLoader <loader>",
741
- `[string] use 'bundle' to bundle the config with esbuild or 'runner' (experimental) to process it on the fly (default: bundle)`
741
+ `[string] use 'bundle' to bundle the config with esbuild, or 'runner' (experimental) to process it on the fly, or 'native' (experimental) to load using the native runtime (default: bundle)`
742
742
  ).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
743
743
  cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--open [path]", `[boolean | string] open browser on startup`).option("--cors", `[boolean] enable CORS`).option("--strictPort", `[boolean] exit if specified port is already in use`).option(
744
744
  "--force",
745
745
  `[boolean] force the optimizer to ignore the cache and re-bundle`
746
746
  ).action(async (root, options) => {
747
747
  filterDuplicateOptions(options);
748
- const { createServer } = await import('./chunks/dep-De0zV__s.js').then(function (n) { return n.S; });
748
+ const { createServer } = await import('./chunks/dep-CfG9u7Cn.js').then(function (n) { return n.S; });
749
749
  try {
750
750
  const server = await createServer({
751
751
  root,
@@ -839,7 +839,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
839
839
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
840
840
  async (root, options) => {
841
841
  filterDuplicateOptions(options);
842
- const { createBuilder } = await import('./chunks/dep-De0zV__s.js').then(function (n) { return n.T; });
842
+ const { createBuilder } = await import('./chunks/dep-CfG9u7Cn.js').then(function (n) { return n.T; });
843
843
  const buildOptions = cleanGlobalCLIOptions(
844
844
  cleanBuilderCLIOptions(options)
845
845
  );
@@ -869,13 +869,16 @@ ${e.stack}`),
869
869
  }
870
870
  }
871
871
  );
872
- cli.command("optimize [root]", "pre-bundle dependencies").option(
872
+ cli.command(
873
+ "optimize [root]",
874
+ "pre-bundle dependencies (deprecated, the pre-bundle process runs automatically and does not need to be called)"
875
+ ).option(
873
876
  "--force",
874
877
  `[boolean] force the optimizer to ignore the cache and re-bundle`
875
878
  ).action(
876
879
  async (root, options) => {
877
880
  filterDuplicateOptions(options);
878
- const { optimizeDeps } = await import('./chunks/dep-De0zV__s.js').then(function (n) { return n.R; });
881
+ const { optimizeDeps } = await import('./chunks/dep-CfG9u7Cn.js').then(function (n) { return n.R; });
879
882
  try {
880
883
  const config = await resolveConfig(
881
884
  {
@@ -902,7 +905,7 @@ ${e.stack}`),
902
905
  cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
903
906
  async (root, options) => {
904
907
  filterDuplicateOptions(options);
905
- const { preview } = await import('./chunks/dep-De0zV__s.js').then(function (n) { return n.U; });
908
+ const { preview } = await import('./chunks/dep-CfG9u7Cn.js').then(function (n) { return n.U; });
906
909
  try {
907
910
  const server = await preview({
908
911
  root,
@@ -1025,6 +1025,8 @@ interface DepOptimizationMetadata {
1025
1025
  /**
1026
1026
  * Scan and optimize dependencies within a project.
1027
1027
  * Used by Vite CLI when running `vite optimize`.
1028
+ *
1029
+ * @deprecated the optimization process runs automatically and does not need to be called
1028
1030
  */
1029
1031
  declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
1030
1032
 
@@ -3962,7 +3964,7 @@ interface ResolvedWorkerOptions {
3962
3964
  interface InlineConfig extends UserConfig {
3963
3965
  configFile?: string | false;
3964
3966
  /** @experimental */
3965
- configLoader?: 'bundle' | 'runner';
3967
+ configLoader?: 'bundle' | 'runner' | 'native';
3966
3968
  envFile?: false;
3967
3969
  forceOptimizeDeps?: boolean;
3968
3970
  }
@@ -4024,7 +4026,7 @@ declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 's
4024
4026
 
4025
4027
  ): Promise<ResolvedConfig>;
4026
4028
  declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
4027
- declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger, configLoader?: 'bundle' | 'runner'): Promise<{
4029
+ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger, configLoader?: 'bundle' | 'runner' | 'native'): Promise<{
4028
4030
  path: string;
4029
4031
  config: UserConfig;
4030
4032
  dependencies: string[];
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-De0zV__s.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-De0zV__s.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-CfG9u7Cn.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-CfG9u7Cn.js';
4
4
  export { defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.1.0-beta.2",
3
+ "version": "6.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",