vite 5.3.5 → 5.4.0-beta.1

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 { B as getDefaultExportFromCjs } from './dep-mCdpKltl.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-gy9yrVx2.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';
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 { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-mCdpKltl.js';
5
+ import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-gy9yrVx2.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -730,7 +730,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
730
730
  `[boolean] force the optimizer to ignore the cache and re-bundle`
731
731
  ).action(async (root, options) => {
732
732
  filterDuplicateOptions(options);
733
- const { createServer } = await import('./chunks/dep-mCdpKltl.js').then(function (n) { return n.E; });
733
+ const { createServer } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.E; });
734
734
  try {
735
735
  const server = await createServer({
736
736
  root,
@@ -822,7 +822,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
822
822
  `[boolean] force empty outDir when it's outside of root`
823
823
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
824
824
  filterDuplicateOptions(options);
825
- const { build } = await import('./chunks/dep-mCdpKltl.js').then(function (n) { return n.F; });
825
+ const { build } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.F; });
826
826
  const buildOptions = cleanOptions(options);
827
827
  try {
828
828
  await build({
@@ -851,7 +851,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
851
851
  ).action(
852
852
  async (root, options) => {
853
853
  filterDuplicateOptions(options);
854
- const { optimizeDeps } = await import('./chunks/dep-mCdpKltl.js').then(function (n) { return n.D; });
854
+ const { optimizeDeps } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.D; });
855
855
  try {
856
856
  const config = await resolveConfig(
857
857
  {
@@ -877,7 +877,7 @@ ${e.stack}`),
877
877
  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(
878
878
  async (root, options) => {
879
879
  filterDuplicateOptions(options);
880
- const { preview } = await import('./chunks/dep-mCdpKltl.js').then(function (n) { return n.G; });
880
+ const { preview } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.G; });
881
881
  try {
882
882
  const server = await preview({
883
883
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-mCdpKltl.js';
3
- export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-mCdpKltl.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-gy9yrVx2.js';
3
+ export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-gy9yrVx2.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import { existsSync, readFileSync } from 'node:fs';
@@ -316,9 +316,7 @@ class ModuleCacheMap extends Map {
316
316
  const mod = this.get(moduleId);
317
317
  if (mod.map) return mod.map;
318
318
  if (!mod.meta || !("code" in mod.meta)) return null;
319
- const mapString = mod.meta.code.match(
320
- VITE_RUNTIME_SOURCEMAPPING_REGEXP
321
- )?.[1];
319
+ const mapString = VITE_RUNTIME_SOURCEMAPPING_REGEXP.exec(mod.meta.code)?.[1];
322
320
  if (!mapString) return null;
323
321
  const baseFile = mod.meta.file || moduleId.split("?")[0];
324
322
  return mod.map = new DecodedMap(JSON.parse(decodeBase64(mapString)), baseFile), mod.map;
@@ -28,92 +28,13 @@ const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
28
28
  path$3.resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
29
29
  path$3.dirname(CLIENT_ENTRY);
30
30
 
31
- const comma = ','.charCodeAt(0);
32
- const semicolon = ';'.charCodeAt(0);
33
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
34
- const intToChar = new Uint8Array(64); // 64 possible chars.
35
- const charToInt = new Uint8Array(128); // z is 122 in ASCII
36
- for (let i = 0; i < chars.length; i++) {
37
- const c = chars.charCodeAt(i);
38
- intToChar[i] = c;
39
- charToInt[c] = i;
40
- }
41
- // Provide a fallback for older environments.
42
- const td = typeof TextDecoder !== 'undefined'
43
- ? /* #__PURE__ */ new TextDecoder()
44
- : typeof Buffer !== 'undefined'
45
- ? {
46
- decode(buf) {
47
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
48
- return out.toString();
49
- },
50
- }
51
- : {
52
- decode(buf) {
53
- let out = '';
54
- for (let i = 0; i < buf.length; i++) {
55
- out += String.fromCharCode(buf[i]);
56
- }
57
- return out;
58
- },
59
- };
60
- function encode(decoded) {
61
- const state = new Int32Array(5);
62
- const bufLength = 1024 * 16;
63
- const subLength = bufLength - 36;
64
- const buf = new Uint8Array(bufLength);
65
- const sub = buf.subarray(0, subLength);
66
- let pos = 0;
67
- let out = '';
68
- for (let i = 0; i < decoded.length; i++) {
69
- const line = decoded[i];
70
- if (i > 0) {
71
- if (pos === bufLength) {
72
- out += td.decode(buf);
73
- pos = 0;
74
- }
75
- buf[pos++] = semicolon;
76
- }
77
- if (line.length === 0)
78
- continue;
79
- state[0] = 0;
80
- for (let j = 0; j < line.length; j++) {
81
- const segment = line[j];
82
- // We can push up to 5 ints, each int can take at most 7 chars, and we
83
- // may push a comma.
84
- if (pos > subLength) {
85
- out += td.decode(sub);
86
- buf.copyWithin(0, subLength, pos);
87
- pos -= subLength;
88
- }
89
- if (j > 0)
90
- buf[pos++] = comma;
91
- pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
92
- if (segment.length === 1)
93
- continue;
94
- pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
95
- pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
96
- pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
97
- if (segment.length === 4)
98
- continue;
99
- pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
100
- }
101
- }
102
- return out + td.decode(buf.subarray(0, pos));
103
- }
104
- function encodeInteger(buf, pos, state, segment, j) {
105
- const next = segment[j];
106
- let num = next - state[j];
107
- state[j] = next;
108
- num = num < 0 ? (-num << 1) | 1 : num << 1;
109
- do {
110
- let clamped = num & 0b011111;
111
- num >>>= 5;
112
- if (num > 0)
113
- clamped |= 0b100000;
114
- buf[pos++] = intToChar[clamped];
115
- } while (num > 0);
116
- return pos;
31
+ const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
32
+ const intToChar$1 = new Uint8Array(64); // 64 possible chars.
33
+ const charToInt$1 = new Uint8Array(128); // z is 122 in ASCII
34
+ for (let i = 0; i < chars$1.length; i++) {
35
+ const c = chars$1.charCodeAt(i);
36
+ intToChar$1[i] = c;
37
+ charToInt$1[c] = i;
117
38
  }
118
39
 
119
40
  function getDefaultExportFromCjs (x) {
@@ -785,6 +706,8 @@ function requireBrowser () {
785
706
  return false;
786
707
  }
787
708
 
709
+ let m;
710
+
788
711
  // Is webkit? http://stackoverflow.com/a/16459606/376773
789
712
  // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
790
713
  return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
@@ -792,7 +715,7 @@ function requireBrowser () {
792
715
  (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
793
716
  // Is firefox >= v31?
794
717
  // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
795
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
718
+ (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
796
719
  // Double check webkit in userAgent just in case we are in a worker
797
720
  (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
798
721
  }
@@ -3505,6 +3428,9 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
3505
3428
  ...backwardCompatibleWorkerPlugins(value)
3506
3429
  ];
3507
3430
  continue;
3431
+ } else if (key === "server" && rootPath === "server.hmr") {
3432
+ merged[key] = value;
3433
+ continue;
3508
3434
  }
3509
3435
  if (Array.isArray(existing) || Array.isArray(value)) {
3510
3436
  merged[key] = [...arraify(existing), ...arraify(value)];
@@ -4038,6 +3964,99 @@ function stattag (stat) {
4038
3964
 
4039
3965
  var getEtag = /*@__PURE__*/getDefaultExportFromCjs(etag_1);
4040
3966
 
3967
+ const comma = ','.charCodeAt(0);
3968
+ const semicolon = ';'.charCodeAt(0);
3969
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
3970
+ const intToChar = new Uint8Array(64); // 64 possible chars.
3971
+ const charToInt = new Uint8Array(128); // z is 122 in ASCII
3972
+ for (let i = 0; i < chars.length; i++) {
3973
+ const c = chars.charCodeAt(i);
3974
+ intToChar[i] = c;
3975
+ charToInt[c] = i;
3976
+ }
3977
+ function encodeInteger(builder, num, relative) {
3978
+ let delta = num - relative;
3979
+ delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
3980
+ do {
3981
+ let clamped = delta & 0b011111;
3982
+ delta >>>= 5;
3983
+ if (delta > 0)
3984
+ clamped |= 0b100000;
3985
+ builder.write(intToChar[clamped]);
3986
+ } while (delta > 0);
3987
+ return num;
3988
+ }
3989
+
3990
+ const bufLength = 1024 * 16;
3991
+ // Provide a fallback for older environments.
3992
+ const td = typeof TextDecoder !== 'undefined'
3993
+ ? /* #__PURE__ */ new TextDecoder()
3994
+ : typeof Buffer !== 'undefined'
3995
+ ? {
3996
+ decode(buf) {
3997
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
3998
+ return out.toString();
3999
+ },
4000
+ }
4001
+ : {
4002
+ decode(buf) {
4003
+ let out = '';
4004
+ for (let i = 0; i < buf.length; i++) {
4005
+ out += String.fromCharCode(buf[i]);
4006
+ }
4007
+ return out;
4008
+ },
4009
+ };
4010
+ class StringWriter {
4011
+ constructor() {
4012
+ this.pos = 0;
4013
+ this.out = '';
4014
+ this.buffer = new Uint8Array(bufLength);
4015
+ }
4016
+ write(v) {
4017
+ const { buffer } = this;
4018
+ buffer[this.pos++] = v;
4019
+ if (this.pos === bufLength) {
4020
+ this.out += td.decode(buffer);
4021
+ this.pos = 0;
4022
+ }
4023
+ }
4024
+ flush() {
4025
+ const { buffer, out, pos } = this;
4026
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
4027
+ }
4028
+ }
4029
+ function encode(decoded) {
4030
+ const writer = new StringWriter();
4031
+ let sourcesIndex = 0;
4032
+ let sourceLine = 0;
4033
+ let sourceColumn = 0;
4034
+ let namesIndex = 0;
4035
+ for (let i = 0; i < decoded.length; i++) {
4036
+ const line = decoded[i];
4037
+ if (i > 0)
4038
+ writer.write(semicolon);
4039
+ if (line.length === 0)
4040
+ continue;
4041
+ let genColumn = 0;
4042
+ for (let j = 0; j < line.length; j++) {
4043
+ const segment = line[j];
4044
+ if (j > 0)
4045
+ writer.write(comma);
4046
+ genColumn = encodeInteger(writer, segment[0], genColumn);
4047
+ if (segment.length === 1)
4048
+ continue;
4049
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
4050
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
4051
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
4052
+ if (segment.length === 4)
4053
+ continue;
4054
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
4055
+ }
4056
+ }
4057
+ return writer.flush();
4058
+ }
4059
+
4041
4060
  class BitSet {
4042
4061
  constructor(arg) {
4043
4062
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -4793,8 +4812,10 @@ class MagicString {
4793
4812
  update(start, end, content, options) {
4794
4813
  if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
4795
4814
 
4796
- while (start < 0) start += this.original.length;
4797
- while (end < 0) end += this.original.length;
4815
+ if (this.original.length !== 0) {
4816
+ while (start < 0) start += this.original.length;
4817
+ while (end < 0) end += this.original.length;
4818
+ }
4798
4819
 
4799
4820
  if (end > this.original.length) throw new Error('end is out of bounds');
4800
4821
  if (start === end)
@@ -4890,8 +4911,10 @@ class MagicString {
4890
4911
  }
4891
4912
 
4892
4913
  remove(start, end) {
4893
- while (start < 0) start += this.original.length;
4894
- while (end < 0) end += this.original.length;
4914
+ if (this.original.length !== 0) {
4915
+ while (start < 0) start += this.original.length;
4916
+ while (end < 0) end += this.original.length;
4917
+ }
4895
4918
 
4896
4919
  if (start === end) return this;
4897
4920
 
@@ -4914,8 +4937,10 @@ class MagicString {
4914
4937
  }
4915
4938
 
4916
4939
  reset(start, end) {
4917
- while (start < 0) start += this.original.length;
4918
- while (end < 0) end += this.original.length;
4940
+ if (this.original.length !== 0) {
4941
+ while (start < 0) start += this.original.length;
4942
+ while (end < 0) end += this.original.length;
4943
+ }
4919
4944
 
4920
4945
  if (start === end) return this;
4921
4946
 
@@ -4977,8 +5002,10 @@ class MagicString {
4977
5002
  }
4978
5003
 
4979
5004
  slice(start = 0, end = this.original.length) {
4980
- while (start < 0) start += this.original.length;
4981
- while (end < 0) end += this.original.length;
5005
+ if (this.original.length !== 0) {
5006
+ while (start < 0) start += this.original.length;
5007
+ while (end < 0) end += this.original.length;
5008
+ }
4982
5009
 
4983
5010
  let result = '';
4984
5011
 
package/index.cjs CHANGED
@@ -1,12 +1,9 @@
1
- /* eslint-disable no-restricted-globals */
2
-
3
1
  warnCjsUsage()
4
2
 
5
3
  // type utils
6
4
  module.exports.defineConfig = (config) => config
7
5
 
8
6
  // proxy cjs utils (sync functions)
9
- // eslint-disable-next-line n/no-missing-require -- will be generated by build
10
7
  Object.assign(module.exports, require('./dist/node-cjs/publicUtils.cjs'))
11
8
 
12
9
  // async functions, can be redirect from ESM build
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.3.5",
3
+ "version": "5.4.0-beta.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -73,7 +73,7 @@
73
73
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
74
74
  "dependencies": {
75
75
  "esbuild": "^0.21.3",
76
- "postcss": "^8.4.39",
76
+ "postcss": "^8.4.40",
77
77
  "rollup": "^4.13.0"
78
78
  },
79
79
  "optionalDependencies": {
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.3.0",
84
- "@babel/parser": "^7.24.8",
84
+ "@babel/parser": "^7.25.0",
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",
@@ -99,7 +99,7 @@
99
99
  "convert-source-map": "^2.0.0",
100
100
  "cors": "^2.8.5",
101
101
  "cross-spawn": "^7.0.3",
102
- "debug": "^4.3.5",
102
+ "debug": "^4.3.6",
103
103
  "dep-types": "link:./src/types",
104
104
  "dotenv": "^16.4.5",
105
105
  "dotenv-expand": "^11.0.6",
@@ -111,7 +111,7 @@
111
111
  "http-proxy": "^1.18.1",
112
112
  "launch-editor-middleware": "^2.8.0",
113
113
  "lightningcss": "^1.25.1",
114
- "magic-string": "^0.30.10",
114
+ "magic-string": "^0.30.11",
115
115
  "micromatch": "^4.0.7",
116
116
  "mlly": "^1.7.1",
117
117
  "mrmime": "^2.0.0",
@@ -129,6 +129,7 @@
129
129
  "rollup-plugin-esbuild": "^6.1.1",
130
130
  "rollup-plugin-license": "^3.5.2",
131
131
  "sass": "^1.77.8",
132
+ "sass-embedded": "^1.77.8",
132
133
  "sirv": "^2.0.4",
133
134
  "source-map-support": "^0.5.21",
134
135
  "strip-ansi": "^7.1.0",
@@ -144,6 +145,7 @@
144
145
  "less": "*",
145
146
  "lightningcss": "^1.21.0",
146
147
  "sass": "*",
148
+ "sass-embedded": "*",
147
149
  "stylus": "*",
148
150
  "sugarss": "*",
149
151
  "terser": "^5.4.0"
@@ -155,6 +157,9 @@
155
157
  "sass": {
156
158
  "optional": true
157
159
  },
160
+ "sass-embedded": {
161
+ "optional": true
162
+ },
158
163
  "stylus": {
159
164
  "optional": true
160
165
  },