vite 6.0.5 → 6.0.7

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -9459,7 +9459,7 @@ function findNearestMainPackageData(basedir, packageCache) {
9459
9459
  ));
9460
9460
  }
9461
9461
  function loadPackageData(pkgPath) {
9462
- const data = JSON.parse(fs__default.readFileSync(pkgPath, "utf-8"));
9462
+ const data = JSON.parse(stripBomTag(fs__default.readFileSync(pkgPath, "utf-8")));
9463
9463
  const pkgDir = normalizePath$3(path$d.dirname(pkgPath));
9464
9464
  const { sideEffects } = data;
9465
9465
  let hasSideEffects;
@@ -12276,13 +12276,17 @@ const rollupToEsbuildFormatMap = {
12276
12276
  // but thankfully rollup does not do this optimization now
12277
12277
  iife: void 0
12278
12278
  };
12279
- const buildEsbuildPlugin = (config) => {
12279
+ const buildEsbuildPlugin = () => {
12280
12280
  return {
12281
12281
  name: "vite:esbuild-transpile",
12282
+ applyToEnvironment(environment) {
12283
+ return environment.config.esbuild !== false;
12284
+ },
12282
12285
  async renderChunk(code, chunk, opts) {
12283
12286
  if (opts.__vite_skip_esbuild__) {
12284
12287
  return null;
12285
12288
  }
12289
+ const config = this.environment.config;
12286
12290
  const options = resolveEsbuildTranspileOptions(config, opts.format);
12287
12291
  if (!options) {
12288
12292
  return null;
@@ -31133,23 +31137,28 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
31133
31137
  function defineImport(index, importNode, metadata) {
31134
31138
  const source = importNode.source.value;
31135
31139
  deps.add(source);
31140
+ const metadataArg = (metadata?.importedNames?.length ?? 0) > 0 ? `, ${JSON.stringify(metadata)}` : "";
31136
31141
  const importId = `__vite_ssr_import_${uid++}__`;
31137
- if (metadata && (metadata.importedNames == null || metadata.importedNames.length === 0)) {
31138
- metadata = void 0;
31139
- }
31140
- const metadataStr = metadata ? `, ${JSON.stringify(metadata)}` : "";
31141
- s.update(
31142
- importNode.start,
31143
- importNode.end,
31144
- `const ${importId} = await ${ssrImportKey}(${JSON.stringify(
31145
- source
31146
- )}${metadataStr});
31147
- `
31148
- );
31149
- if (importNode.start === index) {
31150
- hoistIndex = importNode.end;
31151
- } else {
31142
+ const transformedImport = `const ${importId} = await ${ssrImportKey}(${JSON.stringify(
31143
+ source
31144
+ )}${metadataArg});`;
31145
+ s.update(importNode.start, importNode.end, transformedImport);
31146
+ const nonWhitespaceRegex = /\S/g;
31147
+ nonWhitespaceRegex.lastIndex = index;
31148
+ nonWhitespaceRegex.exec(code);
31149
+ if (importNode.start > nonWhitespaceRegex.lastIndex) {
31152
31150
  s.move(importNode.start, importNode.end, index);
31151
+ } else {
31152
+ hoistIndex = importNode.end;
31153
+ }
31154
+ let linesSpanned = 1;
31155
+ for (let i = importNode.start; i < importNode.end; i++) {
31156
+ if (code[i] === "\n") {
31157
+ linesSpanned++;
31158
+ }
31159
+ }
31160
+ if (linesSpanned > 1) {
31161
+ s.prependRight(importNode.end, "\n".repeat(linesSpanned - 1));
31153
31162
  }
31154
31163
  return importId;
31155
31164
  }
@@ -31292,7 +31301,7 @@ Object.defineProperty(${ssrModuleExportsKey}, "default", { enumerable: true, con
31292
31301
  for (let i = 0; i < statements.length - 1; i++) {
31293
31302
  const stmt = statements[i];
31294
31303
  if (code[stmt.end - 1] !== ";" && stmt.type !== "FunctionDeclaration" && stmt.type !== "ClassDeclaration" && stmt.type !== "BlockStatement" && stmt.type !== "ImportDeclaration") {
31295
- s.appendRight(stmt.end, ";");
31304
+ s.appendLeft(stmt.end, ";");
31296
31305
  }
31297
31306
  }
31298
31307
  },
@@ -41397,7 +41406,7 @@ async function traverseHtml(html, filePath, visitor) {
41397
41406
  }
41398
41407
  function getScriptInfo(node) {
41399
41408
  let src;
41400
- let sourceCodeLocation;
41409
+ let srcSourceCodeLocation;
41401
41410
  let isModule = false;
41402
41411
  let isAsync = false;
41403
41412
  let isIgnored = false;
@@ -41406,7 +41415,7 @@ function getScriptInfo(node) {
41406
41415
  if (p.name === "src") {
41407
41416
  if (!src) {
41408
41417
  src = p;
41409
- sourceCodeLocation = node.sourceCodeLocation?.attrs["src"];
41418
+ srcSourceCodeLocation = node.sourceCodeLocation?.attrs["src"];
41410
41419
  }
41411
41420
  } else if (p.name === "type" && p.value && p.value === "module") {
41412
41421
  isModule = true;
@@ -41416,7 +41425,7 @@ function getScriptInfo(node) {
41416
41425
  isIgnored = true;
41417
41426
  }
41418
41427
  }
41419
- return { src, sourceCodeLocation, isModule, isAsync, isIgnored };
41428
+ return { src, srcSourceCodeLocation, isModule, isAsync, isIgnored };
41420
41429
  }
41421
41430
  const attrValueStartRE = /=\s*(.)/;
41422
41431
  function overwriteAttrValue(s, sourceCodeLocation, newValue) {
@@ -41560,7 +41569,7 @@ function buildHtmlPlugin(config) {
41560
41569
  }
41561
41570
  let shouldRemove = false;
41562
41571
  if (node.nodeName === "script") {
41563
- const { src, sourceCodeLocation, isModule, isAsync, isIgnored } = getScriptInfo(node);
41572
+ const { src, srcSourceCodeLocation, isModule, isAsync, isIgnored } = getScriptInfo(node);
41564
41573
  if (isIgnored) {
41565
41574
  removeViteIgnoreAttr(s, node.sourceCodeLocation);
41566
41575
  } else {
@@ -41569,7 +41578,7 @@ function buildHtmlPlugin(config) {
41569
41578
  if (isPublicFile) {
41570
41579
  overwriteAttrValue(
41571
41580
  s,
41572
- sourceCodeLocation,
41581
+ srcSourceCodeLocation,
41573
41582
  partialEncodeURIPath(toOutputPublicFilePath(url))
41574
41583
  );
41575
41584
  }
@@ -42688,9 +42697,9 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
42688
42697
  return;
42689
42698
  }
42690
42699
  if (node.nodeName === "script") {
42691
- const { src, sourceCodeLocation, isModule, isIgnored } = getScriptInfo(node);
42700
+ const { src, srcSourceCodeLocation, isModule, isIgnored } = getScriptInfo(node);
42692
42701
  if (isIgnored) {
42693
- removeViteIgnoreAttr(s, sourceCodeLocation);
42702
+ removeViteIgnoreAttr(s, node.sourceCodeLocation);
42694
42703
  } else if (src) {
42695
42704
  const processedUrl = processNodeUrl(
42696
42705
  src.value,
@@ -42703,7 +42712,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
42703
42712
  !isModule
42704
42713
  );
42705
42714
  if (processedUrl !== src.value) {
42706
- overwriteAttrValue(s, sourceCodeLocation, processedUrl);
42715
+ overwriteAttrValue(s, srcSourceCodeLocation, processedUrl);
42707
42716
  }
42708
42717
  } else if (isModule && node.childNodes.length) {
42709
42718
  addInlineModule(node, "js");
@@ -47119,7 +47128,7 @@ class EnvironmentPluginContainer {
47119
47128
  const ctx = new ResolveIdContext(this, skip, skipCalls, scan);
47120
47129
  const mergedSkip = new Set(skip);
47121
47130
  for (const call of skipCalls ?? []) {
47122
- if (call.id === rawId && call.importer === importer) {
47131
+ if (call.called || call.id === rawId && call.importer === importer) {
47123
47132
  mergedSkip.add(call.plugin);
47124
47133
  }
47125
47134
  }
@@ -47287,10 +47296,26 @@ class PluginContext {
47287
47296
  return parseAst(code, opts);
47288
47297
  }
47289
47298
  async resolve(id, importer, options) {
47290
- const skipCalls = options?.skipSelf === false ? this._resolveSkipCalls : [
47291
- ...this._resolveSkipCalls || [],
47292
- { id, importer, plugin: this._plugin }
47293
- ];
47299
+ let skipCalls;
47300
+ if (options?.skipSelf === false) {
47301
+ skipCalls = this._resolveSkipCalls;
47302
+ } else if (this._resolveSkipCalls) {
47303
+ const skipCallsTemp = [...this._resolveSkipCalls];
47304
+ const sameCallIndex = this._resolveSkipCalls.findIndex(
47305
+ (c) => c.id === id && c.importer === importer && c.plugin === this._plugin
47306
+ );
47307
+ if (sameCallIndex !== -1) {
47308
+ skipCallsTemp[sameCallIndex] = {
47309
+ ...skipCallsTemp[sameCallIndex],
47310
+ called: true
47311
+ };
47312
+ } else {
47313
+ skipCallsTemp.push({ id, importer, plugin: this._plugin });
47314
+ }
47315
+ skipCalls = skipCallsTemp;
47316
+ } else {
47317
+ skipCalls = [{ id, importer, plugin: this._plugin }];
47318
+ }
47294
47319
  let out = await this._container.resolveId(id, importer, {
47295
47320
  attributes: options?.attributes,
47296
47321
  custom: options?.custom,
@@ -48612,7 +48637,7 @@ async function compileCSS(environment, id, code, workerController, urlReplacer)
48612
48637
  }
48613
48638
  } else if (message.type === "warning") {
48614
48639
  const warning = message;
48615
- let msg = `[vite:css] ${warning.text}`;
48640
+ let msg = `[vite:css][postcss] ${warning.text}`;
48616
48641
  msg += `
48617
48642
  ${generateCodeFrame(
48618
48643
  code,
@@ -48677,8 +48702,8 @@ function createCachedImport(imp) {
48677
48702
  return cached;
48678
48703
  };
48679
48704
  }
48680
- const importPostcssImport = createCachedImport(() => import('./dep-CrWUFq3l.js').then(function (n) { return n.i; }));
48681
- const importPostcssModules = createCachedImport(() => import('./dep-pSQn2Hds.js').then(function (n) { return n.i; }));
48705
+ const importPostcssImport = createCachedImport(() => import('./dep-Cpceb51t.js').then(function (n) { return n.i; }));
48706
+ const importPostcssModules = createCachedImport(() => import('./dep-DB1BmmOk.js').then(function (n) { return n.i; }));
48682
48707
  const importPostcss = createCachedImport(() => import('postcss'));
48683
48708
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
48684
48709
  let alwaysFakeWorkerWorkerControllerCache;
@@ -48898,25 +48923,44 @@ async function doImportCSSReplace(rawUrl, matched, replacer) {
48898
48923
  }
48899
48924
  async function minifyCSS(css, config, inlined) {
48900
48925
  if (config.build.cssMinify === "lightningcss") {
48901
- const { code, warnings } = (await importLightningCSS()).transform({
48902
- ...config.css.lightningcss,
48903
- targets: convertTargets(config.build.cssTarget),
48904
- cssModules: void 0,
48905
- // TODO: Pass actual filename here, which can also be passed to esbuild's
48906
- // `sourcefile` option below to improve error messages
48907
- filename: defaultCssBundleName,
48908
- code: Buffer.from(css),
48909
- minify: true
48910
- });
48911
- if (warnings.length) {
48912
- config.logger.warn(
48913
- colors$1.yellow(
48914
- `warnings when minifying css:
48915
- ${warnings.map((w) => w.message).join("\n")}`
48916
- )
48917
- );
48926
+ try {
48927
+ const { code, warnings } = (await importLightningCSS()).transform({
48928
+ ...config.css.lightningcss,
48929
+ targets: convertTargets(config.build.cssTarget),
48930
+ cssModules: void 0,
48931
+ // TODO: Pass actual filename here, which can also be passed to esbuild's
48932
+ // `sourcefile` option below to improve error messages
48933
+ filename: defaultCssBundleName,
48934
+ code: Buffer.from(css),
48935
+ minify: true
48936
+ });
48937
+ if (warnings.length) {
48938
+ const messages = warnings.map(
48939
+ (warning) => `${warning.message}
48940
+ ` + generateCodeFrame(css, {
48941
+ line: warning.loc.line,
48942
+ column: warning.loc.column - 1
48943
+ // 1-based
48944
+ })
48945
+ );
48946
+ config.logger.warn(
48947
+ colors$1.yellow(`warnings when minifying css:
48948
+ ${messages.join("\n")}`)
48949
+ );
48950
+ }
48951
+ return decoder.decode(code) + (inlined ? "" : "\n");
48952
+ } catch (e) {
48953
+ e.message = `[lightningcss minify] ${e.message}`;
48954
+ if (e.loc) {
48955
+ e.loc = {
48956
+ line: e.loc.line,
48957
+ column: e.loc.column - 1
48958
+ // 1-based
48959
+ };
48960
+ e.frame = generateCodeFrame(css, e.loc);
48961
+ }
48962
+ throw e;
48918
48963
  }
48919
- return decoder.decode(code) + (inlined ? "" : "\n");
48920
48964
  }
48921
48965
  try {
48922
48966
  const { code, warnings } = await transform$1(css, {
@@ -49713,8 +49757,7 @@ const importLightningCSS = createCachedImport(() => import('lightningcss'));
49713
49757
  async function compileLightningCSS(id, src, environment, urlReplacer) {
49714
49758
  const { config } = environment;
49715
49759
  const deps = /* @__PURE__ */ new Set();
49716
- const filename = cleanUrl(path$d.relative(config.root, id));
49717
- const toAbsolute = (filePath) => path$d.isAbsolute(filePath) ? filePath : path$d.join(config.root, filePath);
49760
+ const filename = id.replace("\0", NULL_BYTE_PLACEHOLDER);
49718
49761
  let res;
49719
49762
  try {
49720
49763
  res = styleAttrRE.test(id) ? (await importLightningCSS()).transformStyleAttribute({
@@ -49726,15 +49769,14 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
49726
49769
  }) : await (await importLightningCSS()).bundleAsync({
49727
49770
  ...config.css.lightningcss,
49728
49771
  filename,
49772
+ // projectRoot is needed to get stable hash when using CSS modules
49773
+ projectRoot: config.root,
49729
49774
  resolver: {
49730
49775
  read(filePath) {
49731
49776
  if (filePath === filename) {
49732
49777
  return src;
49733
49778
  }
49734
- if (!filePath.endsWith(".css")) {
49735
- return src;
49736
- }
49737
- return fs__default.readFileSync(toAbsolute(filePath), "utf-8");
49779
+ return fs__default.readFileSync(filePath, "utf-8");
49738
49780
  },
49739
49781
  async resolve(id2, from) {
49740
49782
  const publicFile = checkPublicFile(
@@ -49746,7 +49788,7 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
49746
49788
  }
49747
49789
  const resolved = await getAtImportResolvers(
49748
49790
  environment.getTopLevelConfig()
49749
- ).css(environment, id2, toAbsolute(from));
49791
+ ).css(environment, id2, from);
49750
49792
  if (resolved) {
49751
49793
  deps.add(resolved);
49752
49794
  return resolved;
@@ -49761,14 +49803,26 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
49761
49803
  });
49762
49804
  } catch (e) {
49763
49805
  e.message = `[lightningcss] ${e.message}`;
49764
- e.loc = {
49765
- file: toAbsolute(e.fileName),
49766
- line: e.loc.line,
49767
- column: e.loc.column - 1
49768
- // 1-based
49769
- };
49806
+ if (e.loc) {
49807
+ e.loc = {
49808
+ file: e.fileName.replace(NULL_BYTE_PLACEHOLDER, "\0"),
49809
+ line: e.loc.line,
49810
+ column: e.loc.column - 1
49811
+ // 1-based
49812
+ };
49813
+ }
49770
49814
  throw e;
49771
49815
  }
49816
+ for (const warning of res.warnings) {
49817
+ let msg = `[vite:css][lightningcss] ${warning.message}`;
49818
+ msg += `
49819
+ ${generateCodeFrame(src, {
49820
+ line: warning.loc.line,
49821
+ column: warning.loc.column - 1
49822
+ // 1-based
49823
+ })}`;
49824
+ environment.logger.warn(colors$1.yellow(msg));
49825
+ }
49772
49826
  let css = decoder.decode(res.code);
49773
49827
  for (const dep of res.dependencies) {
49774
49828
  switch (dep.type) {
@@ -49777,7 +49831,10 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
49777
49831
  if (skipUrlReplacer(dep.url)) {
49778
49832
  replaceUrl = dep.url;
49779
49833
  } else if (urlReplacer) {
49780
- replaceUrl = await urlReplacer(dep.url, toAbsolute(dep.loc.filePath));
49834
+ replaceUrl = await urlReplacer(
49835
+ dep.url,
49836
+ dep.loc.filePath.replace(NULL_BYTE_PLACEHOLDER, "\0")
49837
+ );
49781
49838
  } else {
49782
49839
  replaceUrl = dep.url;
49783
49840
  }
@@ -50611,7 +50668,7 @@ async function resolveBuildPlugins(config) {
50611
50668
  ],
50612
50669
  post: [
50613
50670
  buildImportAnalysisPlugin(config),
50614
- ...config.esbuild !== false ? [buildEsbuildPlugin(config)] : [],
50671
+ buildEsbuildPlugin(),
50615
50672
  terserPlugin(config),
50616
50673
  ...!config.isWorker ? [manifestPlugin(), ssrManifestPlugin(), buildReporterPlugin(config)] : [],
50617
50674
  buildLoadFallbackPlugin()
@@ -51382,10 +51439,11 @@ async function fetchModule(environment, url, importer, options = {}) {
51382
51439
  if (url.startsWith("data:") || isBuiltin(url)) {
51383
51440
  return { externalize: url, type: "builtin" };
51384
51441
  }
51385
- if (isExternalUrl(url)) {
51442
+ const isFileUrl = url.startsWith("file://");
51443
+ if (isExternalUrl(url) && !isFileUrl) {
51386
51444
  return { externalize: url, type: "network" };
51387
51445
  }
51388
- if (importer && url[0] !== "." && url[0] !== "/") {
51446
+ if (!isFileUrl && importer && url[0] !== "." && url[0] !== "/") {
51389
51447
  const { isProduction, root } = environment.config;
51390
51448
  const { externalConditions, dedupe, preserveSymlinks } = environment.config.resolve;
51391
51449
  const resolved = tryNodeResolve(url, importer, {
@@ -51413,7 +51471,7 @@ async function fetchModule(environment, url, importer, options = {}) {
51413
51471
  const type = isFilePathESM(resolved.id, environment.config.packageCache) ? "module" : "commonjs";
51414
51472
  return { externalize: file, type };
51415
51473
  }
51416
- if (!importer) {
51474
+ if (isFileUrl || !importer) {
51417
51475
  const resolved = await environment.pluginContainer.resolveId(url);
51418
51476
  if (!resolved) {
51419
51477
  throw new Error(`[vite] cannot find entry point module '${url}'.`);
@@ -51421,8 +51479,8 @@ async function fetchModule(environment, url, importer, options = {}) {
51421
51479
  url = normalizeResolvedIdToUrl(environment, url, resolved);
51422
51480
  }
51423
51481
  url = unwrapId$1(url);
51424
- let mod = await environment.moduleGraph.getModuleByUrl(url);
51425
- const cached = !!mod?.transformResult;
51482
+ const mod = await environment.moduleGraph.ensureEntryFromUrl(url);
51483
+ const cached = !!mod.transformResult;
51426
51484
  if (options.cached && cached) {
51427
51485
  return { cache: true };
51428
51486
  }
@@ -51432,12 +51490,6 @@ async function fetchModule(environment, url, importer, options = {}) {
51432
51490
  `[vite] transform failed for module '${url}'${importer ? ` imported from '${importer}'` : ""}.`
51433
51491
  );
51434
51492
  }
51435
- mod ??= await environment.moduleGraph.getModuleByUrl(url);
51436
- if (!mod) {
51437
- throw new Error(
51438
- `[vite] cannot find module '${url}' ${importer ? ` imported from '${importer}'` : ""}.`
51439
- );
51440
- }
51441
51493
  if (options.inlineSourceMap !== false) {
51442
51494
  result = inlineSourceMap(mod, result, options.startOffset);
51443
51495
  }
@@ -52377,12 +52429,30 @@ function fileToUrl(file, root) {
52377
52429
  }
52378
52430
  async function mapFiles(files, root) {
52379
52431
  if (!files.length) return [];
52380
- return await glob(files, {
52381
- absolute: true,
52382
- cwd: root,
52383
- expandDirectories: false,
52384
- ignore: ["**/.git/**", "**/node_modules/**"]
52385
- });
52432
+ const result = [];
52433
+ const globs = [];
52434
+ for (const file of files) {
52435
+ if (isDynamicPattern(file)) {
52436
+ globs.push(file);
52437
+ } else {
52438
+ if (path$d.isAbsolute(file)) {
52439
+ result.push(file);
52440
+ } else {
52441
+ result.push(path$d.resolve(root, file));
52442
+ }
52443
+ }
52444
+ }
52445
+ if (globs.length) {
52446
+ result.push(
52447
+ ...await glob(globs, {
52448
+ absolute: true,
52449
+ cwd: root,
52450
+ expandDirectories: false,
52451
+ ignore: ["**/.git/**", "**/node_modules/**"]
52452
+ })
52453
+ );
52454
+ }
52455
+ return result;
52386
52456
  }
52387
52457
 
52388
52458
  class DevEnvironment extends BaseEnvironment {
@@ -1,4 +1,4 @@
1
- import { N as getDefaultExportFromCjs } from './dep-BZMjGe_U.js';
1
+ import { N as getDefaultExportFromCjs } from './dep-BJP6rrE_.js';
2
2
  import require$$0 from 'path';
3
3
  import { l as lib } from './dep-3RmXg9uo.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { O as commonjsGlobal, N as getDefaultExportFromCjs } from './dep-BZMjGe_U.js';
1
+ import { O as commonjsGlobal, N as getDefaultExportFromCjs } from './dep-BJP6rrE_.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 { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-BZMjGe_U.js';
5
+ import { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-BJP6rrE_.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -740,7 +740,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
740
740
  `[boolean] force the optimizer to ignore the cache and re-bundle`
741
741
  ).action(async (root, options) => {
742
742
  filterDuplicateOptions(options);
743
- const { createServer } = await import('./chunks/dep-BZMjGe_U.js').then(function (n) { return n.Q; });
743
+ const { createServer } = await import('./chunks/dep-BJP6rrE_.js').then(function (n) { return n.Q; });
744
744
  try {
745
745
  const server = await createServer({
746
746
  root,
@@ -833,7 +833,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
833
833
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
834
834
  async (root, options) => {
835
835
  filterDuplicateOptions(options);
836
- const { createBuilder } = await import('./chunks/dep-BZMjGe_U.js').then(function (n) { return n.R; });
836
+ const { createBuilder } = await import('./chunks/dep-BJP6rrE_.js').then(function (n) { return n.R; });
837
837
  const buildOptions = cleanGlobalCLIOptions(
838
838
  cleanBuilderCLIOptions(options)
839
839
  );
@@ -868,7 +868,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
868
868
  ).action(
869
869
  async (root, options) => {
870
870
  filterDuplicateOptions(options);
871
- const { optimizeDeps } = await import('./chunks/dep-BZMjGe_U.js').then(function (n) { return n.P; });
871
+ const { optimizeDeps } = await import('./chunks/dep-BJP6rrE_.js').then(function (n) { return n.P; });
872
872
  try {
873
873
  const config = await resolveConfig(
874
874
  {
@@ -894,7 +894,7 @@ ${e.stack}`),
894
894
  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(
895
895
  async (root, options) => {
896
896
  filterDuplicateOptions(options);
897
- const { preview } = await import('./chunks/dep-BZMjGe_U.js').then(function (n) { return n.S; });
897
+ const { preview } = await import('./chunks/dep-BJP6rrE_.js').then(function (n) { return n.S; });
898
898
  try {
899
899
  const server = await preview({
900
900
  root,
@@ -2464,16 +2464,15 @@ interface PackageData {
2464
2464
  interface BuildEnvironmentOptions {
2465
2465
  /**
2466
2466
  * Compatibility transform target. The transform is performed with esbuild
2467
- * and the lowest supported target is es2015/es6. Note this only handles
2468
- * syntax transformation and does not cover polyfills (except for dynamic
2469
- * import)
2467
+ * and the lowest supported target is es2015. Note this only handles
2468
+ * syntax transformation and does not cover polyfills
2470
2469
  *
2471
- * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
2472
- * transpile targeting browsers that natively support dynamic es module imports.
2473
- * https://caniuse.com/es6-module-dynamic-import
2470
+ * Default: 'modules' - transpile targeting browsers that natively support
2471
+ * dynamic es module imports and `import.meta`
2472
+ * (Chrome 87+, Firefox 78+, Safari 14+, Edge 88+).
2474
2473
  *
2475
2474
  * Another special value is 'esnext' - which only performs minimal transpiling
2476
- * (for minification compat) and assumes native dynamic imports support.
2475
+ * (for minification compat).
2477
2476
  *
2478
2477
  * For custom targets, see https://esbuild.github.io/api/#target and
2479
2478
  * https://esbuild.github.io/content-types/#javascript for more details.
@@ -2780,6 +2779,7 @@ type SkipInformation = {
2780
2779
  id: string;
2781
2780
  importer: string | undefined;
2782
2781
  plugin: Plugin;
2782
+ called?: boolean;
2783
2783
  };
2784
2784
  declare class EnvironmentPluginContainer {
2785
2785
  environment: Environment;
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-BZMjGe_U.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BZMjGe_U.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BJP6rrE_.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BJP6rrE_.js';
4
4
  export { 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';
@@ -183,7 +183,6 @@ declare class ModuleRunner {
183
183
  private readonly envProxy;
184
184
  private readonly transport;
185
185
  private readonly resetSourceMapSupport?;
186
- private readonly root;
187
186
  private readonly concurrentModuleNodePromises;
188
187
  private closed;
189
188
  constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
@@ -272,8 +271,9 @@ interface ModuleRunnerHmr {
272
271
  interface ModuleRunnerOptions {
273
272
  /**
274
273
  * Root of the project
274
+ * @deprecated not used and to be removed
275
275
  */
276
- root: string;
276
+ root?: string;
277
277
  /**
278
278
  * A set of methods to communicate with the server.
279
279
  */
@@ -85,11 +85,7 @@ const isAbsolute = function(p) {
85
85
  }, dirname = function(p) {
86
86
  const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
87
87
  return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
88
- };
89
- function normalizeAbsoluteUrl(url, root) {
90
- return url = slash(url), url.startsWith("file://") && (url = decodeURI(url.slice(isWindows ? 8 : 7))), url.startsWith(root) && (url = url.slice(root.length - 1)), url;
91
- }
92
- const decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
88
+ }, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
93
89
  function encodePathChars(filepath) {
94
90
  return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf(`
95
91
  `) !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
@@ -1072,9 +1068,7 @@ class ESModulesEvaluator {
1072
1068
  }
1073
1069
  class ModuleRunner {
1074
1070
  constructor(options, evaluator = new ESModulesEvaluator(), debug) {
1075
- this.options = options, this.evaluator = evaluator, this.debug = debug;
1076
- const root = this.options.root;
1077
- if (this.root = root[root.length - 1] === "/" ? root : `${root}/`, this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules(), this.transport = normalizeModuleRunnerTransport(options.transport), options.hmr !== !1) {
1071
+ if (this.options = options, this.evaluator = evaluator, this.debug = debug, this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules(), this.transport = normalizeModuleRunnerTransport(options.transport), options.hmr !== !1) {
1078
1072
  const optionsHmr = options.hmr ?? !0, resolvedHmrLogger = optionsHmr === !0 || optionsHmr.logger === void 0 ? hmrLogger : optionsHmr.logger === !1 ? silentConsole : optionsHmr.logger;
1079
1073
  if (this.hmrClient = new HMRClient(
1080
1074
  resolvedHmrLogger,
@@ -1100,7 +1094,6 @@ class ModuleRunner {
1100
1094
  });
1101
1095
  transport;
1102
1096
  resetSourceMapSupport;
1103
- root;
1104
1097
  concurrentModuleNodePromises = /* @__PURE__ */ new Map();
1105
1098
  closed = !1;
1106
1099
  /**
@@ -1177,7 +1170,6 @@ ${getStack()}`
1177
1170
  }
1178
1171
  }
1179
1172
  async cachedModule(url, importer) {
1180
- url = normalizeAbsoluteUrl(url, this.root);
1181
1173
  let cached = this.concurrentModuleNodePromises.get(url);
1182
1174
  if (cached)
1183
1175
  this.debug?.("[module runner] using cached module info for", url);
@@ -3484,7 +3484,7 @@ function resolvePackageData(pkgName, basedir, preserveSymlinks = false, packageC
3484
3484
  return null;
3485
3485
  }
3486
3486
  function loadPackageData(pkgPath) {
3487
- const data = JSON.parse(fs$1.readFileSync(pkgPath, "utf-8"));
3487
+ const data = JSON.parse(stripBomTag(fs$1.readFileSync(pkgPath, "utf-8")));
3488
3488
  const pkgDir = normalizePath(path$1.dirname(pkgPath));
3489
3489
  const { sideEffects } = data;
3490
3490
  let hasSideEffects;
@@ -3766,6 +3766,12 @@ function normalizeSingleAlias({
3766
3766
  }
3767
3767
  return alias;
3768
3768
  }
3769
+ function stripBomTag(content) {
3770
+ if (content.charCodeAt(0) === 65279) {
3771
+ return content.slice(1);
3772
+ }
3773
+ return content;
3774
+ }
3769
3775
 
3770
3776
  const CSS_LANGS_RE = (
3771
3777
  // eslint-disable-next-line regexp/no-unused-capturing-group
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.5",
3
+ "version": "6.0.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -72,7 +72,7 @@
72
72
  "funding": "https://github.com/vitejs/vite?sponsor=1",
73
73
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
74
74
  "dependencies": {
75
- "esbuild": "0.24.0",
75
+ "esbuild": "^0.24.2",
76
76
  "postcss": "^8.4.49",
77
77
  "rollup": "^4.23.0"
78
78
  },
@@ -6,7 +6,7 @@ import type DartSass from 'sass'
6
6
  import type SassEmbedded from 'sass-embedded'
7
7
  // @ts-ignore `less` may not be installed
8
8
  import type Less from 'less'
9
- // @ts-ignore `less` may not be installed
9
+ // @ts-ignore `stylus` may not be installed
10
10
  import type Stylus from 'stylus'
11
11
 
12
12
  /* eslint-enable @typescript-eslint/ban-ts-comment */
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/ban-ts-comment */
2
2
 
3
- // @ts-ignore `sass` may not be installed
3
+ // @ts-ignore `lightningcss` may not be installed
4
4
  import type Lightningcss from 'lightningcss'
5
5
 
6
6
  /* eslint-enable @typescript-eslint/ban-ts-comment */