vite 6.0.0-alpha.20 → 6.0.0-alpha.22

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.
@@ -17435,8 +17435,7 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
17435
17435
  } else if (key === "assetsInclude" && rootPath === "") {
17436
17436
  merged[key] = [].concat(existing, value);
17437
17437
  continue;
17438
- } else if (key === "noExternal" && // TODO: environments
17439
- rootPath === "ssr" && (existing === true || value === true)) {
17438
+ } else if (key === "noExternal" && (rootPath === "ssr" || rootPath === "resolve") && (existing === true || value === true)) {
17440
17439
  merged[key] = true;
17441
17440
  continue;
17442
17441
  } else if (key === "plugins" && rootPath === "worker") {
@@ -18012,6 +18011,7 @@ function buildReporterPlugin(config) {
18012
18011
  return {
18013
18012
  name: "vite:reporter",
18014
18013
  sharedDuringBuild: true,
18014
+ perEnvironmentStartEndDuringDev: true,
18015
18015
  transform(_, id) {
18016
18016
  modulesReporter(this).register(id);
18017
18017
  },
@@ -20319,6 +20319,7 @@ function assetPlugin(config) {
20319
20319
  registerCustomMime();
20320
20320
  return {
20321
20321
  name: "vite:asset",
20322
+ perEnvironmentStartEndDuringDev: true,
20322
20323
  buildStart() {
20323
20324
  assetCache.set(this.environment, /* @__PURE__ */ new Map());
20324
20325
  generatedAssetsMap.set(this.environment, /* @__PURE__ */ new Map());
@@ -20536,6 +20537,7 @@ function manifestPlugin() {
20536
20537
  });
20537
20538
  return {
20538
20539
  name: "vite:manifest",
20540
+ perEnvironmentStartEndDuringDev: true,
20539
20541
  applyToEnvironment(environment) {
20540
20542
  return !!environment.config.build.manifest;
20541
20543
  },
@@ -22840,7 +22842,12 @@ const util = require$$0$5;
22840
22842
  const braces$1 = braces_1;
22841
22843
  const picomatch$2 = picomatch$3;
22842
22844
  const utils$b = utils$k;
22843
- const isEmptyString = val => val === '' || val === './';
22845
+
22846
+ const isEmptyString = v => v === '' || v === './';
22847
+ const hasBraces = v => {
22848
+ const index = v.indexOf('{');
22849
+ return index > -1 && v.indexOf('}', index) > -1;
22850
+ };
22844
22851
 
22845
22852
  /**
22846
22853
  * Returns an array of strings that match one or more glob patterns.
@@ -23281,7 +23288,7 @@ micromatch$1.parse = (patterns, options) => {
23281
23288
 
23282
23289
  micromatch$1.braces = (pattern, options) => {
23283
23290
  if (typeof pattern !== 'string') throw new TypeError('Expected a string');
23284
- if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
23291
+ if ((options && options.nobrace === true) || !hasBraces(pattern)) {
23285
23292
  return [pattern];
23286
23293
  }
23287
23294
  return braces$1(pattern, options);
@@ -23300,6 +23307,8 @@ micromatch$1.braceExpand = (pattern, options) => {
23300
23307
  * Expose micromatch
23301
23308
  */
23302
23309
 
23310
+ // exposed for tests
23311
+ micromatch$1.hasBraces = hasBraces;
23303
23312
  var micromatch_1 = micromatch$1;
23304
23313
 
23305
23314
  var micromatch$2 = /*@__PURE__*/getDefaultExportFromCjs(micromatch_1);
@@ -36883,7 +36892,7 @@ class ScanEnvironment extends BaseEnvironment {
36883
36892
  this,
36884
36893
  this.plugins
36885
36894
  );
36886
- await this._pluginContainer.buildStart({});
36895
+ await this._pluginContainer.buildStart();
36887
36896
  }
36888
36897
  }
36889
36898
  function devToScanEnvironment(environment) {
@@ -57718,6 +57727,14 @@ class ModuleNode {
57718
57727
  _get(prop) {
57719
57728
  return this._clientModule?.[prop] ?? this._ssrModule?.[prop];
57720
57729
  }
57730
+ _set(prop, value) {
57731
+ if (this._clientModule) {
57732
+ this._clientModule[prop] = value;
57733
+ }
57734
+ if (this._ssrModule) {
57735
+ this._ssrModule[prop] = value;
57736
+ }
57737
+ }
57721
57738
  _wrapModuleSet(prop, module) {
57722
57739
  if (!module) {
57723
57740
  return /* @__PURE__ */ new Set();
@@ -57749,12 +57766,21 @@ class ModuleNode {
57749
57766
  get url() {
57750
57767
  return this._get("url");
57751
57768
  }
57769
+ set url(value) {
57770
+ this._set("url", value);
57771
+ }
57752
57772
  get id() {
57753
57773
  return this._get("id");
57754
57774
  }
57775
+ set id(value) {
57776
+ this._set("id", value);
57777
+ }
57755
57778
  get file() {
57756
57779
  return this._get("file");
57757
57780
  }
57781
+ set file(value) {
57782
+ this._set("file", value);
57783
+ }
57758
57784
  get type() {
57759
57785
  return this._get("type");
57760
57786
  }
@@ -57917,22 +57943,24 @@ class ModuleGraph {
57917
57943
  }
57918
57944
  getModulesByFile(file) {
57919
57945
  const clientModules = this._client.getModulesByFile(file);
57946
+ const ssrModules = this._ssr.getModulesByFile(file);
57947
+ if (!clientModules && !ssrModules) {
57948
+ return void 0;
57949
+ }
57950
+ const result = /* @__PURE__ */ new Set();
57920
57951
  if (clientModules) {
57921
- return new Set(
57922
- [...clientModules].map(
57923
- (mod) => this.getBackwardCompatibleBrowserModuleNode(mod)
57924
- )
57925
- );
57952
+ for (const mod of clientModules) {
57953
+ result.add(this.getBackwardCompatibleBrowserModuleNode(mod));
57954
+ }
57926
57955
  }
57927
- const ssrModules = this._ssr.getModulesByFile(file);
57928
57956
  if (ssrModules) {
57929
- return new Set(
57930
- [...ssrModules].map(
57931
- (mod) => this.getBackwardCompatibleServerModuleNode(mod)
57932
- )
57933
- );
57957
+ for (const mod of ssrModules) {
57958
+ if (!this._client.getModuleById(mod.id)) {
57959
+ result.add(this.getBackwardCompatibleBrowserModuleNode(mod));
57960
+ }
57961
+ }
57934
57962
  }
57935
- return void 0;
57963
+ return result;
57936
57964
  }
57937
57965
  onFileChange(file) {
57938
57966
  this._client.onFileChange(file);
@@ -57981,7 +58009,8 @@ class ModuleGraph {
57981
58009
  this._client.invalidateAll();
57982
58010
  this._ssr.invalidateAll();
57983
58011
  }
57984
- /* TODO: I don't know if we need to implement this method (or how to do it yet)
58012
+ /* TODO: It seems there isn't usage of this method in the ecosystem
58013
+ Waiting to check if we really need this for backwards compatibility
57985
58014
  async updateModuleInfo(
57986
58015
  module: ModuleNode,
57987
58016
  importedModules: Set<string | ModuleNode>,
@@ -57992,22 +58021,7 @@ class ModuleGraph {
57992
58021
  ssr?: boolean,
57993
58022
  staticImportedUrls?: Set<string>, // internal
57994
58023
  ): Promise<Set<ModuleNode> | undefined> {
57995
- const modules = await this._getModuleGraph(
57996
- module.environment,
57997
- ).updateModuleInfo(
57998
- module,
57999
- importedModules, // ?
58000
- importedBindings,
58001
- acceptedModules, // ?
58002
- acceptedExports,
58003
- isSelfAccepting,
58004
- staticImportedUrls,
58005
- )
58006
- return modules
58007
- ? new Set(
58008
- [...modules].map((mod) => this.getBackwardCompatibleModuleNode(mod)!),
58009
- )
58010
- : undefined
58024
+ // Not implemented
58011
58025
  }
58012
58026
  */
58013
58027
  async ensureEntryFromUrl(rawUrl, ssr, setIsSelfAccepting = true) {
@@ -58090,9 +58104,9 @@ function createBackwardCompatibleModuleSet(moduleGraph, prop, module) {
58090
58104
  );
58091
58105
  });
58092
58106
  }
58093
- // TODO: should we implement all the set methods?
58094
- // missing: add, clear, delete, difference, intersection, isDisjointFrom,
58095
- // isSubsetOf, isSupersetOf, symmetricDifference, union
58107
+ // There are several methods missing. We can implement them if downstream
58108
+ // projects are relying on them: add, clear, delete, difference, intersection,
58109
+ // sDisjointFrom, isSubsetOf, isSupersetOf, symmetricDifference, union
58096
58110
  };
58097
58111
  }
58098
58112
  function createBackwardCompatibleModuleMap(moduleGraph, prop, getModuleMap) {
@@ -58111,6 +58125,16 @@ function createBackwardCompatibleModuleMap(moduleGraph, prop, getModuleMap) {
58111
58125
  ssrModule
58112
58126
  );
58113
58127
  },
58128
+ set(key, mod) {
58129
+ const clientModule = mod._clientModule;
58130
+ if (clientModule) {
58131
+ moduleGraph._client[prop].set(key, clientModule);
58132
+ }
58133
+ const ssrModule = mod._ssrModule;
58134
+ if (ssrModule) {
58135
+ moduleGraph._ssr[prop].set(key, ssrModule);
58136
+ }
58137
+ },
58114
58138
  keys() {
58115
58139
  return getModuleMap().keys();
58116
58140
  },
@@ -58702,7 +58726,7 @@ async function _createServer(inlineConfig = {}, options) {
58702
58726
  if (serverInited) return;
58703
58727
  if (initingServer) return initingServer;
58704
58728
  initingServer = async function() {
58705
- await server.environments.client.pluginContainer.buildStart({});
58729
+ await environments.client.pluginContainer.buildStart();
58706
58730
  await Promise.all(
58707
58731
  Object.values(server.environments).map(
58708
58732
  (environment) => environment.depsOptimizer?.init()
@@ -58788,6 +58812,7 @@ function resolvedAllowDir(root, dir) {
58788
58812
  function resolveServerOptions(root, raw, logger) {
58789
58813
  const server = {
58790
58814
  preTransformRequests: true,
58815
+ perEnvironmentBuildStartEnd: false,
58791
58816
  ...raw,
58792
58817
  sourcemapIgnoreList: raw?.sourcemapIgnoreList === false ? () => false : raw?.sourcemapIgnoreList || isInNodeModules$1,
58793
58818
  middlewareMode: raw?.middlewareMode || false
@@ -61558,7 +61583,6 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
61558
61583
  clientInjectionsPlugin(config),
61559
61584
  cssAnalysisPlugin(config),
61560
61585
  importAnalysisPlugin(config)
61561
- // TODO: loadFallbackPlugin(config),
61562
61586
  ]
61563
61587
  ].filter(Boolean);
61564
61588
  }
@@ -61675,6 +61699,7 @@ class EnvironmentPluginContainer {
61675
61699
  moduleGraph;
61676
61700
  watchFiles = /* @__PURE__ */ new Set();
61677
61701
  minimalContext;
61702
+ _started = false;
61678
61703
  _closed = false;
61679
61704
  _updateModuleLoadAddedImports(id, addedImports) {
61680
61705
  const module = this.moduleGraph?.getModuleById(id);
@@ -61720,11 +61745,12 @@ class EnvironmentPluginContainer {
61720
61745
  return this._pluginContextMap.get(plugin);
61721
61746
  }
61722
61747
  // parallel, ignores returns
61723
- async hookParallel(hookName, context, args) {
61748
+ async hookParallel(hookName, context, args, condition) {
61724
61749
  const parallelPromises = [];
61725
61750
  for (const plugin of this.getSortedPlugins(hookName)) {
61726
61751
  const hook = plugin[hookName];
61727
61752
  if (!hook) continue;
61753
+ if (condition && !condition(plugin)) continue;
61728
61754
  const handler = getHookHandler(hook);
61729
61755
  if (hook.sequential) {
61730
61756
  await Promise.all(parallelPromises);
@@ -61737,18 +61763,31 @@ class EnvironmentPluginContainer {
61737
61763
  await Promise.all(parallelPromises);
61738
61764
  }
61739
61765
  async buildStart(_options) {
61740
- await this.handleHookPromise(
61766
+ if (this._started) {
61767
+ await this._started;
61768
+ return;
61769
+ }
61770
+ this._started = this.handleHookPromise(
61741
61771
  this.hookParallel(
61742
61772
  "buildStart",
61743
61773
  (plugin) => this._getPluginContext(plugin),
61744
- () => [this.options]
61774
+ () => [this.options],
61775
+ (plugin) => this.environment.name === "client" || plugin.perEnvironmentStartEndDuringDev === true
61745
61776
  )
61746
61777
  );
61778
+ await this._started;
61779
+ this._started = true;
61747
61780
  }
61748
61781
  async resolveId(rawId, importer = join$2(
61749
61782
  this.environment.config.root,
61750
61783
  "index.html"
61751
61784
  ), options) {
61785
+ if (!this._started) {
61786
+ this.buildStart();
61787
+ }
61788
+ if (this._started !== true) {
61789
+ await this._started;
61790
+ }
61752
61791
  const skip = options?.skip;
61753
61792
  const scan = !!options?.scan;
61754
61793
  const ssr = this.environment.config.consumer === "server";
@@ -61890,7 +61929,8 @@ class EnvironmentPluginContainer {
61890
61929
  await this.hookParallel(
61891
61930
  "buildEnd",
61892
61931
  (plugin) => this._getPluginContext(plugin),
61893
- () => []
61932
+ () => [],
61933
+ (plugin) => this.environment.name === "client" || plugin.perEnvironmentStartEndDuringDev !== true
61894
61934
  );
61895
61935
  await this.hookParallel(
61896
61936
  "closeBundle",
@@ -62234,11 +62274,19 @@ class PluginContainer {
62234
62274
  get options() {
62235
62275
  return this.environments.client.pluginContainer.options;
62236
62276
  }
62277
+ // For backward compatibility, buildStart and watchChange are called only for the client environment
62278
+ // buildStart is called per environment for a plugin with the perEnvironmentStartEndDuring dev flag
62237
62279
  async buildStart(_options) {
62238
62280
  this.environments.client.pluginContainer.buildStart(
62239
62281
  _options
62240
62282
  );
62241
62283
  }
62284
+ async watchChange(id, change) {
62285
+ this.environments.client.pluginContainer.watchChange(
62286
+ id,
62287
+ change
62288
+ );
62289
+ }
62242
62290
  async resolveId(rawId, importer, options) {
62243
62291
  return this._getPluginContainer(options).resolveId(rawId, importer, options);
62244
62292
  }
@@ -62248,8 +62296,6 @@ class PluginContainer {
62248
62296
  async transform(code, id, options) {
62249
62297
  return this._getPluginContainer(options).transform(code, id, options);
62250
62298
  }
62251
- async watchChange(_id, _change) {
62252
- }
62253
62299
  async close() {
62254
62300
  }
62255
62301
  }
@@ -63255,8 +63301,8 @@ function createCachedImport(imp) {
63255
63301
  return cached;
63256
63302
  };
63257
63303
  }
63258
- const importPostcssImport = createCachedImport(() => import('./dep-BVDN2Cqw.js').then(function (n) { return n.i; }));
63259
- const importPostcssModules = createCachedImport(() => import('./dep-D1nw2wDG.js').then(function (n) { return n.i; }));
63304
+ const importPostcssImport = createCachedImport(() => import('./dep-BzHfSPcV.js').then(function (n) { return n.i; }));
63305
+ const importPostcssModules = createCachedImport(() => import('./dep-DGaPvi2R.js').then(function (n) { return n.i; }));
63260
63306
  const importPostcss = createCachedImport(() => import('postcss'));
63261
63307
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
63262
63308
  let alwaysFakeWorkerWorkerControllerCache;
@@ -66508,7 +66554,6 @@ class EnvironmentModuleNode {
66508
66554
  * Resolved file system path + query
66509
66555
  */
66510
66556
  id = null;
66511
- // TODO: remove null
66512
66557
  file = null;
66513
66558
  type;
66514
66559
  info;
@@ -66864,7 +66909,6 @@ class DevEnvironment extends BaseEnvironment {
66864
66909
  */
66865
66910
  _pluginContainer;
66866
66911
  /**
66867
- * TODO: should this be public?
66868
66912
  * @internal
66869
66913
  */
66870
66914
  _closing = false;
@@ -67579,11 +67623,10 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
67579
67623
  config.root ? path$n.resolve(config.root) : process.cwd()
67580
67624
  );
67581
67625
  checkBadCharactersInPath(resolvedRoot, logger);
67582
- const { entries, force, ...deprecatedClientOptimizeDepsConfig } = config.optimizeDeps ?? {};
67583
67626
  const configEnvironmentsClient = config.environments.client;
67584
67627
  configEnvironmentsClient.dev ??= {};
67585
67628
  configEnvironmentsClient.dev.optimizeDeps = mergeConfig(
67586
- deprecatedClientOptimizeDepsConfig,
67629
+ config.optimizeDeps ?? {},
67587
67630
  configEnvironmentsClient.dev.optimizeDeps ?? {}
67588
67631
  );
67589
67632
  const deprecatedSsrOptimizeDepsConfig = config.ssr?.optimizeDeps ?? {};
@@ -67644,16 +67687,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
67644
67687
  config.resolve,
67645
67688
  logger
67646
67689
  );
67647
- const resolvedConfigEnvironmentsClient = resolvedEnvironments.client;
67648
- const patchedOptimizeDeps = resolvedConfigEnvironmentsClient.dev?.optimizeDeps;
67649
- const backwardCompatibleOptimizeDeps = {
67650
- holdUntilCrawlEnd: true,
67651
- ...patchedOptimizeDeps,
67652
- esbuildOptions: {
67653
- preserveSymlinks: resolvedDefaultEnvironmentResolve.preserveSymlinks,
67654
- ...patchedOptimizeDeps.esbuildOptions
67655
- }
67656
- };
67690
+ const backwardCompatibleOptimizeDeps = resolvedEnvironments.client.dev.optimizeDeps;
67657
67691
  const resolvedDevEnvironmentOptions = resolveDevEnvironmentOptions(
67658
67692
  config.dev,
67659
67693
  resolvedDefaultEnvironmentResolve.preserveSymlinks,
@@ -67917,6 +67951,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
67917
67951
  resolved.ssr.optimizeDeps,
67918
67952
  "ssr."
67919
67953
  );
67954
+ if (resolved.environments.ssr) {
67955
+ resolved.environments.ssr.build.emitAssets = resolved.build.ssrEmitAssets || resolved.build.emitAssets;
67956
+ }
67920
67957
  debug?.(`using resolved config: %O`, {
67921
67958
  ...resolved,
67922
67959
  plugins: resolved.plugins.map((p) => p.name),
@@ -1,4 +1,4 @@
1
- import { J as getDefaultExportFromCjs } from './dep-CpuHsFvF.js';
1
+ import { J as getDefaultExportFromCjs } from './dep-1C5gbBiU.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-IQS-Za7F.js';
@@ -1,4 +1,4 @@
1
- import { K as commonjsGlobal, J as getDefaultExportFromCjs } from './dep-CpuHsFvF.js';
1
+ import { K as commonjsGlobal, J as getDefaultExportFromCjs } from './dep-1C5gbBiU.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__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { I as colors, A as createLogger, r as resolveConfig } from './chunks/dep-CpuHsFvF.js';
5
+ import { I as colors, A as createLogger, r as resolveConfig } from './chunks/dep-1C5gbBiU.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -736,7 +736,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
736
736
  `[boolean] force the optimizer to ignore the cache and re-bundle`
737
737
  ).action(async (root, options) => {
738
738
  filterDuplicateOptions(options);
739
- const { createServer } = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.M; });
739
+ const { createServer } = await import('./chunks/dep-1C5gbBiU.js').then(function (n) { return n.M; });
740
740
  try {
741
741
  const server = await createServer({
742
742
  root,
@@ -829,7 +829,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
829
829
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as builder.entireApp`).action(
830
830
  async (root, options) => {
831
831
  filterDuplicateOptions(options);
832
- const build = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.N; });
832
+ const build = await import('./chunks/dep-1C5gbBiU.js').then(function (n) { return n.N; });
833
833
  const buildOptions = cleanGlobalCLIOptions(
834
834
  cleanBuilderCLIOptions(options)
835
835
  );
@@ -884,7 +884,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
884
884
  ).action(
885
885
  async (root, options) => {
886
886
  filterDuplicateOptions(options);
887
- const { optimizeDeps } = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.L; });
887
+ const { optimizeDeps } = await import('./chunks/dep-1C5gbBiU.js').then(function (n) { return n.L; });
888
888
  try {
889
889
  const config = await resolveConfig(
890
890
  {
@@ -910,7 +910,7 @@ ${e.stack}`),
910
910
  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(
911
911
  async (root, options) => {
912
912
  filterDuplicateOptions(options);
913
- const { preview } = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.O; });
913
+ const { preview } = await import('./chunks/dep-1C5gbBiU.js').then(function (n) { return n.O; });
914
914
  try {
915
915
  const server = await preview({
916
916
  root,
@@ -1094,11 +1094,15 @@ declare class ModuleNode {
1094
1094
  _ssrModule: EnvironmentModuleNode | undefined;
1095
1095
  constructor(moduleGraph: ModuleGraph, clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode);
1096
1096
  _get<T extends keyof EnvironmentModuleNode>(prop: T): EnvironmentModuleNode[T];
1097
+ _set<T extends keyof EnvironmentModuleNode>(prop: T, value: EnvironmentModuleNode[T]): void;
1097
1098
  _wrapModuleSet(prop: ModuleSetNames, module: EnvironmentModuleNode | undefined): Set<ModuleNode>;
1098
1099
  _getModuleSetUnion(prop: 'importedModules' | 'importers'): Set<ModuleNode>;
1099
1100
  get url(): string;
1101
+ set url(value: string);
1100
1102
  get id(): string | null;
1103
+ set id(value: string | null);
1101
1104
  get file(): string | null;
1105
+ set file(value: string | null);
1102
1106
  get type(): 'js' | 'css';
1103
1107
  get info(): ModuleInfo | undefined;
1104
1108
  get meta(): Record<string, any> | undefined;
@@ -2090,6 +2094,7 @@ declare class EnvironmentPluginContainer {
2090
2094
  moduleGraph: EnvironmentModuleGraph | undefined;
2091
2095
  watchFiles: Set<string>;
2092
2096
  minimalContext: MinimalPluginContext;
2097
+ private _started;
2093
2098
  private _closed;
2094
2099
  private _updateModuleLoadAddedImports;
2095
2100
  private _getAddedImports;
@@ -2126,6 +2131,9 @@ declare class PluginContainer {
2126
2131
  private _getPluginContainer;
2127
2132
  get options(): InputOptions;
2128
2133
  buildStart(_options?: InputOptions): Promise<void>;
2134
+ watchChange(id: string, change: {
2135
+ event: 'create' | 'update' | 'delete';
2136
+ }): Promise<void>;
2129
2137
  resolveId(rawId: string, importer?: string, options?: {
2130
2138
  attributes?: Record<string, string>;
2131
2139
  custom?: CustomPluginOptions;
@@ -2146,9 +2154,6 @@ declare class PluginContainer {
2146
2154
  mappings: '';
2147
2155
  } | null;
2148
2156
  }>;
2149
- watchChange(_id: string, _change: {
2150
- event: 'create' | 'update' | 'delete';
2151
- }): Promise<void>;
2152
2157
  close(): Promise<void>;
2153
2158
  }
2154
2159
 
@@ -2786,6 +2791,13 @@ interface ServerOptions extends CommonServerOptions {
2786
2791
  * sourcemap path and returns whether to ignore the source path.
2787
2792
  */
2788
2793
  sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
2794
+ /**
2795
+ * Backward compatibility. The buildStart and buildEnd hooks were called only once for all
2796
+ * environments. This option enables per-environment buildStart and buildEnd hooks.
2797
+ * @default false
2798
+ * @experimental
2799
+ */
2800
+ perEnvironmentBuildStartEnd?: boolean;
2789
2801
  /**
2790
2802
  * Run HMR tasks, by default the HMR propagation is done in parallel for all environments
2791
2803
  * @experimental
@@ -2902,7 +2914,6 @@ interface ViteDevServer {
2902
2914
  transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
2903
2915
  /**
2904
2916
  * Transform module code into SSR format.
2905
- * TODO: expose this to any environment?
2906
2917
  */
2907
2918
  ssrTransform(code: string, inMap: SourceMap | {
2908
2919
  mappings: '';
@@ -3320,6 +3331,14 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
3320
3331
  * @experimental
3321
3332
  */
3322
3333
  sharedDuringBuild?: boolean;
3334
+ /**
3335
+ * Opt-in this plugin into per-environment buildStart and buildEnd during dev.
3336
+ * For backward-compatibility, the buildStart hook is called only once during
3337
+ * dev, for the client environment. Plugins can opt-in to be called
3338
+ * per-environment, aligning with the build hook behavior.
3339
+ * @experimental
3340
+ */
3341
+ perEnvironmentStartEndDuringDev?: boolean;
3323
3342
  /**
3324
3343
  * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
3325
3344
  * is still subject to the `order` property in the hook object.
@@ -3450,13 +3469,7 @@ interface SSROptions {
3450
3469
  /**
3451
3470
  * Define the target for the ssr build. The browser field in package.json
3452
3471
  * is ignored for node but used if webworker is the target
3453
- *
3454
- * if (ssr.target === 'webworker') {
3455
- * build.rollupOptions.entryFileNames = '[name].js'
3456
- * build.rollupOptions.inlineDynamicImports = (typeof input === 'string' || Object.keys(input).length === 1))
3457
- * webCompatible = true
3458
- * }
3459
- *
3472
+ * This option may be replaced by the experimental `environmentOptions.webCompatible`
3460
3473
  * @default 'node'
3461
3474
  */
3462
3475
  target?: SSRTarget;
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-CpuHsFvF.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-CpuHsFvF.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-1C5gbBiU.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-1C5gbBiU.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
@@ -123,6 +123,7 @@ declare class ModuleRunner {
123
123
  private readonly transport;
124
124
  private readonly resetSourceMapSupport?;
125
125
  private readonly root;
126
+ private readonly moduleInfoCache;
126
127
  private destroyed;
127
128
  constructor(options: ModuleRunnerOptions, evaluator: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
128
129
  /**
@@ -148,6 +149,7 @@ declare class ModuleRunner {
148
149
  private isCircularImport;
149
150
  private cachedRequest;
150
151
  private cachedModule;
152
+ private getModuleInformation;
151
153
  protected directRequest(id: string, mod: ModuleCache, _callstack: string[]): Promise<any>;
152
154
  }
153
155
 
@@ -875,6 +875,7 @@ class ModuleRunner {
875
875
  transport;
876
876
  resetSourceMapSupport;
877
877
  root;
878
+ moduleInfoCache = /* @__PURE__ */ new Map();
878
879
  destroyed = !1;
879
880
  /**
880
881
  * URL to execute. Accepts file path, server path or id relative to the root.
@@ -959,6 +960,13 @@ ${getStack()}`
959
960
  }
960
961
  }
961
962
  async cachedModule(url, importer) {
963
+ const cacheKey = `${url}~~${importer}`;
964
+ let cached = this.moduleInfoCache.get(cacheKey);
965
+ return cached || (cached = this.getModuleInformation(url, importer).finally(() => {
966
+ this.moduleInfoCache.delete(cacheKey);
967
+ }), this.moduleInfoCache.set(cacheKey, cached)), cached;
968
+ }
969
+ async getModuleInformation(url, importer) {
962
970
  if (this.destroyed)
963
971
  throw new Error("Vite module runner has been destroyed.");
964
972
  this.debug?.("[module runner] fetching", url), url = normalizeAbsoluteUrl(url, this.root);
@@ -3503,8 +3503,7 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
3503
3503
  } else if (key === "assetsInclude" && rootPath === "") {
3504
3504
  merged[key] = [].concat(existing, value);
3505
3505
  continue;
3506
- } else if (key === "noExternal" && // TODO: environments
3507
- rootPath === "ssr" && (existing === true || value === true)) {
3506
+ } else if (key === "noExternal" && (rootPath === "ssr" || rootPath === "resolve") && (existing === true || value === true)) {
3508
3507
  merged[key] = true;
3509
3508
  continue;
3510
3509
  } else if (key === "plugins" && rootPath === "worker") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.0-alpha.20",
3
+ "version": "6.0.0-alpha.22",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.3.0",
84
- "@babel/parser": "^7.25.3",
84
+ "@babel/parser": "^7.25.4",
85
85
  "@jridgewell/trace-mapping": "^0.3.25",
86
86
  "@polka/compression": "^1.0.0-next.25",
87
87
  "@rollup/plugin-alias": "^5.1.0",
@@ -112,7 +112,7 @@
112
112
  "launch-editor-middleware": "^2.8.1",
113
113
  "lightningcss": "^1.26.0",
114
114
  "magic-string": "^0.30.11",
115
- "micromatch": "^4.0.7",
115
+ "micromatch": "^4.0.8",
116
116
  "mlly": "^1.7.1",
117
117
  "mrmime": "^2.0.0",
118
118
  "nanoid": "^5.0.7",
@@ -136,7 +136,7 @@
136
136
  "strip-ansi": "^7.1.0",
137
137
  "strip-literal": "^2.1.0",
138
138
  "tsconfck": "^3.1.1",
139
- "tslib": "^2.6.3",
139
+ "tslib": "^2.7.0",
140
140
  "types": "link:./types",
141
141
  "ufo": "^1.5.4",
142
142
  "ws": "^8.18.0"