vite 6.0.6 → 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.

@@ -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;
@@ -31297,7 +31301,7 @@ Object.defineProperty(${ssrModuleExportsKey}, "default", { enumerable: true, con
31297
31301
  for (let i = 0; i < statements.length - 1; i++) {
31298
31302
  const stmt = statements[i];
31299
31303
  if (code[stmt.end - 1] !== ";" && stmt.type !== "FunctionDeclaration" && stmt.type !== "ClassDeclaration" && stmt.type !== "BlockStatement" && stmt.type !== "ImportDeclaration") {
31300
- s.appendRight(stmt.end, ";");
31304
+ s.appendLeft(stmt.end, ";");
31301
31305
  }
31302
31306
  }
31303
31307
  },
@@ -41402,7 +41406,7 @@ async function traverseHtml(html, filePath, visitor) {
41402
41406
  }
41403
41407
  function getScriptInfo(node) {
41404
41408
  let src;
41405
- let sourceCodeLocation;
41409
+ let srcSourceCodeLocation;
41406
41410
  let isModule = false;
41407
41411
  let isAsync = false;
41408
41412
  let isIgnored = false;
@@ -41411,7 +41415,7 @@ function getScriptInfo(node) {
41411
41415
  if (p.name === "src") {
41412
41416
  if (!src) {
41413
41417
  src = p;
41414
- sourceCodeLocation = node.sourceCodeLocation?.attrs["src"];
41418
+ srcSourceCodeLocation = node.sourceCodeLocation?.attrs["src"];
41415
41419
  }
41416
41420
  } else if (p.name === "type" && p.value && p.value === "module") {
41417
41421
  isModule = true;
@@ -41421,7 +41425,7 @@ function getScriptInfo(node) {
41421
41425
  isIgnored = true;
41422
41426
  }
41423
41427
  }
41424
- return { src, sourceCodeLocation, isModule, isAsync, isIgnored };
41428
+ return { src, srcSourceCodeLocation, isModule, isAsync, isIgnored };
41425
41429
  }
41426
41430
  const attrValueStartRE = /=\s*(.)/;
41427
41431
  function overwriteAttrValue(s, sourceCodeLocation, newValue) {
@@ -41565,7 +41569,7 @@ function buildHtmlPlugin(config) {
41565
41569
  }
41566
41570
  let shouldRemove = false;
41567
41571
  if (node.nodeName === "script") {
41568
- const { src, sourceCodeLocation, isModule, isAsync, isIgnored } = getScriptInfo(node);
41572
+ const { src, srcSourceCodeLocation, isModule, isAsync, isIgnored } = getScriptInfo(node);
41569
41573
  if (isIgnored) {
41570
41574
  removeViteIgnoreAttr(s, node.sourceCodeLocation);
41571
41575
  } else {
@@ -41574,7 +41578,7 @@ function buildHtmlPlugin(config) {
41574
41578
  if (isPublicFile) {
41575
41579
  overwriteAttrValue(
41576
41580
  s,
41577
- sourceCodeLocation,
41581
+ srcSourceCodeLocation,
41578
41582
  partialEncodeURIPath(toOutputPublicFilePath(url))
41579
41583
  );
41580
41584
  }
@@ -42693,9 +42697,9 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
42693
42697
  return;
42694
42698
  }
42695
42699
  if (node.nodeName === "script") {
42696
- const { src, sourceCodeLocation, isModule, isIgnored } = getScriptInfo(node);
42700
+ const { src, srcSourceCodeLocation, isModule, isIgnored } = getScriptInfo(node);
42697
42701
  if (isIgnored) {
42698
- removeViteIgnoreAttr(s, sourceCodeLocation);
42702
+ removeViteIgnoreAttr(s, node.sourceCodeLocation);
42699
42703
  } else if (src) {
42700
42704
  const processedUrl = processNodeUrl(
42701
42705
  src.value,
@@ -42708,7 +42712,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
42708
42712
  !isModule
42709
42713
  );
42710
42714
  if (processedUrl !== src.value) {
42711
- overwriteAttrValue(s, sourceCodeLocation, processedUrl);
42715
+ overwriteAttrValue(s, srcSourceCodeLocation, processedUrl);
42712
42716
  }
42713
42717
  } else if (isModule && node.childNodes.length) {
42714
42718
  addInlineModule(node, "js");
@@ -47124,7 +47128,7 @@ class EnvironmentPluginContainer {
47124
47128
  const ctx = new ResolveIdContext(this, skip, skipCalls, scan);
47125
47129
  const mergedSkip = new Set(skip);
47126
47130
  for (const call of skipCalls ?? []) {
47127
- if (call.id === rawId && call.importer === importer) {
47131
+ if (call.called || call.id === rawId && call.importer === importer) {
47128
47132
  mergedSkip.add(call.plugin);
47129
47133
  }
47130
47134
  }
@@ -47292,10 +47296,26 @@ class PluginContext {
47292
47296
  return parseAst(code, opts);
47293
47297
  }
47294
47298
  async resolve(id, importer, options) {
47295
- const skipCalls = options?.skipSelf === false ? this._resolveSkipCalls : [
47296
- ...this._resolveSkipCalls || [],
47297
- { id, importer, plugin: this._plugin }
47298
- ];
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
+ }
47299
47319
  let out = await this._container.resolveId(id, importer, {
47300
47320
  attributes: options?.attributes,
47301
47321
  custom: options?.custom,
@@ -48617,7 +48637,7 @@ async function compileCSS(environment, id, code, workerController, urlReplacer)
48617
48637
  }
48618
48638
  } else if (message.type === "warning") {
48619
48639
  const warning = message;
48620
- let msg = `[vite:css] ${warning.text}`;
48640
+ let msg = `[vite:css][postcss] ${warning.text}`;
48621
48641
  msg += `
48622
48642
  ${generateCodeFrame(
48623
48643
  code,
@@ -48682,8 +48702,8 @@ function createCachedImport(imp) {
48682
48702
  return cached;
48683
48703
  };
48684
48704
  }
48685
- const importPostcssImport = createCachedImport(() => import('./dep-BGGf7Pd3.js').then(function (n) { return n.i; }));
48686
- const importPostcssModules = createCachedImport(() => import('./dep-Dt4uNHQP.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; }));
48687
48707
  const importPostcss = createCachedImport(() => import('postcss'));
48688
48708
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
48689
48709
  let alwaysFakeWorkerWorkerControllerCache;
@@ -48903,25 +48923,44 @@ async function doImportCSSReplace(rawUrl, matched, replacer) {
48903
48923
  }
48904
48924
  async function minifyCSS(css, config, inlined) {
48905
48925
  if (config.build.cssMinify === "lightningcss") {
48906
- const { code, warnings } = (await importLightningCSS()).transform({
48907
- ...config.css.lightningcss,
48908
- targets: convertTargets(config.build.cssTarget),
48909
- cssModules: void 0,
48910
- // TODO: Pass actual filename here, which can also be passed to esbuild's
48911
- // `sourcefile` option below to improve error messages
48912
- filename: defaultCssBundleName,
48913
- code: Buffer.from(css),
48914
- minify: true
48915
- });
48916
- if (warnings.length) {
48917
- config.logger.warn(
48918
- colors$1.yellow(
48919
- `warnings when minifying css:
48920
- ${warnings.map((w) => w.message).join("\n")}`
48921
- )
48922
- );
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;
48923
48963
  }
48924
- return decoder.decode(code) + (inlined ? "" : "\n");
48925
48964
  }
48926
48965
  try {
48927
48966
  const { code, warnings } = await transform$1(css, {
@@ -49774,6 +49813,16 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
49774
49813
  }
49775
49814
  throw e;
49776
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
+ }
49777
49826
  let css = decoder.decode(res.code);
49778
49827
  for (const dep of res.dependencies) {
49779
49828
  switch (dep.type) {
@@ -50619,7 +50668,7 @@ async function resolveBuildPlugins(config) {
50619
50668
  ],
50620
50669
  post: [
50621
50670
  buildImportAnalysisPlugin(config),
50622
- ...config.esbuild !== false ? [buildEsbuildPlugin(config)] : [],
50671
+ buildEsbuildPlugin(),
50623
50672
  terserPlugin(config),
50624
50673
  ...!config.isWorker ? [manifestPlugin(), ssrManifestPlugin(), buildReporterPlugin(config)] : [],
50625
50674
  buildLoadFallbackPlugin()
@@ -52380,12 +52429,30 @@ function fileToUrl(file, root) {
52380
52429
  }
52381
52430
  async function mapFiles(files, root) {
52382
52431
  if (!files.length) return [];
52383
- return await glob(files, {
52384
- absolute: true,
52385
- cwd: root,
52386
- expandDirectories: false,
52387
- ignore: ["**/.git/**", "**/node_modules/**"]
52388
- });
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;
52389
52456
  }
52390
52457
 
52391
52458
  class DevEnvironment extends BaseEnvironment {
@@ -1,4 +1,4 @@
1
- import { N as getDefaultExportFromCjs } from './dep-0AosnpPU.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-0AosnpPU.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-0AosnpPU.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-0AosnpPU.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-0AosnpPU.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-0AosnpPU.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-0AosnpPU.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,
@@ -2779,6 +2779,7 @@ type SkipInformation = {
2779
2779
  id: string;
2780
2780
  importer: string | undefined;
2781
2781
  plugin: Plugin;
2782
+ called?: boolean;
2782
2783
  };
2783
2784
  declare class EnvironmentPluginContainer {
2784
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-0AosnpPU.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-0AosnpPU.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.6",
3
+ "version": "6.0.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",