vite 6.0.0-alpha.19 → 6.0.0-alpha.20

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.
@@ -38,6 +38,20 @@ for (let i = 0; i < chars.length; i++) {
38
38
  intToChar[i] = c;
39
39
  charToInt[c] = i;
40
40
  }
41
+ function encodeInteger(builder, num, relative) {
42
+ let delta = num - relative;
43
+ delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
44
+ do {
45
+ let clamped = delta & 0b011111;
46
+ delta >>>= 5;
47
+ if (delta > 0)
48
+ clamped |= 0b100000;
49
+ builder.write(intToChar[clamped]);
50
+ } while (delta > 0);
51
+ return num;
52
+ }
53
+
54
+ const bufLength = 1024 * 16;
41
55
  // Provide a fallback for older environments.
42
56
  const td = typeof TextDecoder !== 'undefined'
43
57
  ? /* #__PURE__ */ new TextDecoder()
@@ -57,63 +71,54 @@ const td = typeof TextDecoder !== 'undefined'
57
71
  return out;
58
72
  },
59
73
  };
74
+ class StringWriter {
75
+ constructor() {
76
+ this.pos = 0;
77
+ this.out = '';
78
+ this.buffer = new Uint8Array(bufLength);
79
+ }
80
+ write(v) {
81
+ const { buffer } = this;
82
+ buffer[this.pos++] = v;
83
+ if (this.pos === bufLength) {
84
+ this.out += td.decode(buffer);
85
+ this.pos = 0;
86
+ }
87
+ }
88
+ flush() {
89
+ const { buffer, out, pos } = this;
90
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
91
+ }
92
+ }
60
93
  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 = '';
94
+ const writer = new StringWriter();
95
+ let sourcesIndex = 0;
96
+ let sourceLine = 0;
97
+ let sourceColumn = 0;
98
+ let namesIndex = 0;
68
99
  for (let i = 0; i < decoded.length; i++) {
69
100
  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
- }
101
+ if (i > 0)
102
+ writer.write(semicolon);
77
103
  if (line.length === 0)
78
104
  continue;
79
- state[0] = 0;
105
+ let genColumn = 0;
80
106
  for (let j = 0; j < line.length; j++) {
81
107
  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
108
  if (j > 0)
90
- buf[pos++] = comma;
91
- pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
109
+ writer.write(comma);
110
+ genColumn = encodeInteger(writer, segment[0], genColumn);
92
111
  if (segment.length === 1)
93
112
  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
113
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
114
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
115
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
97
116
  if (segment.length === 4)
98
117
  continue;
99
- pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
118
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
100
119
  }
101
120
  }
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;
121
+ return writer.flush();
117
122
  }
118
123
 
119
124
  function getDefaultExportFromCjs (x) {
@@ -785,6 +790,8 @@ function requireBrowser () {
785
790
  return false;
786
791
  }
787
792
 
793
+ let m;
794
+
788
795
  // Is webkit? http://stackoverflow.com/a/16459606/376773
789
796
  // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
790
797
  return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
@@ -792,7 +799,7 @@ function requireBrowser () {
792
799
  (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
793
800
  // Is firefox >= v31?
794
801
  // 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) ||
802
+ (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
796
803
  // Double check webkit in userAgent just in case we are in a worker
797
804
  (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
798
805
  }
@@ -2968,9 +2975,9 @@ const isObject$2 = val => val && typeof val === 'object' && !Array.isArray(val);
2968
2975
  * @api public
2969
2976
  */
2970
2977
 
2971
- const picomatch$2 = (glob, options, returnState = false) => {
2978
+ const picomatch$1 = (glob, options, returnState = false) => {
2972
2979
  if (Array.isArray(glob)) {
2973
- const fns = glob.map(input => picomatch$2(input, options, returnState));
2980
+ const fns = glob.map(input => picomatch$1(input, options, returnState));
2974
2981
  const arrayMatcher = str => {
2975
2982
  for (const isMatch of fns) {
2976
2983
  const state = isMatch(str);
@@ -2990,8 +2997,8 @@ const picomatch$2 = (glob, options, returnState = false) => {
2990
2997
  const opts = options || {};
2991
2998
  const posix = utils.isWindows(options);
2992
2999
  const regex = isState
2993
- ? picomatch$2.compileRe(glob, options)
2994
- : picomatch$2.makeRe(glob, options, false, true);
3000
+ ? picomatch$1.compileRe(glob, options)
3001
+ : picomatch$1.makeRe(glob, options, false, true);
2995
3002
 
2996
3003
  const state = regex.state;
2997
3004
  delete regex.state;
@@ -2999,11 +3006,11 @@ const picomatch$2 = (glob, options, returnState = false) => {
2999
3006
  let isIgnored = () => false;
3000
3007
  if (opts.ignore) {
3001
3008
  const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
3002
- isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
3009
+ isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
3003
3010
  }
3004
3011
 
3005
3012
  const matcher = (input, returnObject = false) => {
3006
- const { isMatch, match, output } = picomatch$2.test(input, regex, options, { glob, posix });
3013
+ const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
3007
3014
  const result = { glob, state, regex, posix, input, output, match, isMatch };
3008
3015
 
3009
3016
  if (typeof opts.onResult === 'function') {
@@ -3053,7 +3060,7 @@ const picomatch$2 = (glob, options, returnState = false) => {
3053
3060
  * @api public
3054
3061
  */
3055
3062
 
3056
- picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
3063
+ picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
3057
3064
  if (typeof input !== 'string') {
3058
3065
  throw new TypeError('Expected input to be a string');
3059
3066
  }
@@ -3074,7 +3081,7 @@ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
3074
3081
 
3075
3082
  if (match === false || opts.capture === true) {
3076
3083
  if (opts.matchBase === true || opts.basename === true) {
3077
- match = picomatch$2.matchBase(input, regex, options, posix);
3084
+ match = picomatch$1.matchBase(input, regex, options, posix);
3078
3085
  } else {
3079
3086
  match = regex.exec(output);
3080
3087
  }
@@ -3097,8 +3104,8 @@ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
3097
3104
  * @api public
3098
3105
  */
3099
3106
 
3100
- picomatch$2.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3101
- const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
3107
+ picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3108
+ const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
3102
3109
  return regex.test(path$1.basename(input));
3103
3110
  };
3104
3111
 
@@ -3119,7 +3126,7 @@ picomatch$2.matchBase = (input, glob, options, posix = utils.isWindows(options))
3119
3126
  * @api public
3120
3127
  */
3121
3128
 
3122
- picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
3129
+ picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
3123
3130
 
3124
3131
  /**
3125
3132
  * Parse a glob pattern to create the source string for a regular
@@ -3135,8 +3142,8 @@ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)
3135
3142
  * @api public
3136
3143
  */
3137
3144
 
3138
- picomatch$2.parse = (pattern, options) => {
3139
- if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
3145
+ picomatch$1.parse = (pattern, options) => {
3146
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
3140
3147
  return parse$1(pattern, { ...options, fastpaths: false });
3141
3148
  };
3142
3149
 
@@ -3167,7 +3174,7 @@ picomatch$2.parse = (pattern, options) => {
3167
3174
  * @api public
3168
3175
  */
3169
3176
 
3170
- picomatch$2.scan = (input, options) => scan(input, options);
3177
+ picomatch$1.scan = (input, options) => scan(input, options);
3171
3178
 
3172
3179
  /**
3173
3180
  * Compile a regular expression from the `state` object returned by the
@@ -3181,7 +3188,7 @@ picomatch$2.scan = (input, options) => scan(input, options);
3181
3188
  * @api public
3182
3189
  */
3183
3190
 
3184
- picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
3191
+ picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
3185
3192
  if (returnOutput === true) {
3186
3193
  return state.output;
3187
3194
  }
@@ -3195,7 +3202,7 @@ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = fal
3195
3202
  source = `^(?!${source}).*$`;
3196
3203
  }
3197
3204
 
3198
- const regex = picomatch$2.toRegex(source, options);
3205
+ const regex = picomatch$1.toRegex(source, options);
3199
3206
  if (returnState === true) {
3200
3207
  regex.state = state;
3201
3208
  }
@@ -3222,7 +3229,7 @@ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = fal
3222
3229
  * @api public
3223
3230
  */
3224
3231
 
3225
- picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3232
+ picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3226
3233
  if (!input || typeof input !== 'string') {
3227
3234
  throw new TypeError('Expected a non-empty string');
3228
3235
  }
@@ -3237,7 +3244,7 @@ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = f
3237
3244
  parsed = parse$1(input, options);
3238
3245
  }
3239
3246
 
3240
- return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
3247
+ return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
3241
3248
  };
3242
3249
 
3243
3250
  /**
@@ -3257,7 +3264,7 @@ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = f
3257
3264
  * @api public
3258
3265
  */
3259
3266
 
3260
- picomatch$2.toRegex = (source, options) => {
3267
+ picomatch$1.toRegex = (source, options) => {
3261
3268
  try {
3262
3269
  const opts = options || {};
3263
3270
  return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
@@ -3272,17 +3279,17 @@ picomatch$2.toRegex = (source, options) => {
3272
3279
  * @return {Object}
3273
3280
  */
3274
3281
 
3275
- picomatch$2.constants = constants;
3282
+ picomatch$1.constants = constants;
3276
3283
 
3277
3284
  /**
3278
3285
  * Expose "picomatch"
3279
3286
  */
3280
3287
 
3281
- var picomatch_1 = picomatch$2;
3288
+ var picomatch_1 = picomatch$1;
3282
3289
 
3283
3290
  var picomatch = picomatch_1;
3284
3291
 
3285
- var picomatch$1 = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
3292
+ var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
3286
3293
 
3287
3294
  // Helper since Typescript can't detect readonly arrays with Array.isArray
3288
3295
  function isArray(arg) {
@@ -3322,7 +3329,7 @@ const createFilter$1 = function createFilter(include, exclude, options) {
3322
3329
  test: (what) => {
3323
3330
  // this refactor is a tad overly verbose but makes for easy debugging
3324
3331
  const pattern = getMatcherString(id, resolutionBase);
3325
- const fn = picomatch$1(pattern, { dot: true });
3332
+ const fn = pm(pattern, { dot: true });
3326
3333
  const result = fn(what);
3327
3334
  return result;
3328
3335
  }
@@ -3506,6 +3513,9 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
3506
3513
  ...backwardCompatibleWorkerPlugins(value)
3507
3514
  ];
3508
3515
  continue;
3516
+ } else if (key === "server" && rootPath === "server.hmr") {
3517
+ merged[key] = value;
3518
+ continue;
3509
3519
  }
3510
3520
  if (Array.isArray(existing) || Array.isArray(value)) {
3511
3521
  merged[key] = [...arraify(existing), ...arraify(value)];
@@ -4794,8 +4804,10 @@ class MagicString {
4794
4804
  update(start, end, content, options) {
4795
4805
  if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
4796
4806
 
4797
- while (start < 0) start += this.original.length;
4798
- while (end < 0) end += this.original.length;
4807
+ if (this.original.length !== 0) {
4808
+ while (start < 0) start += this.original.length;
4809
+ while (end < 0) end += this.original.length;
4810
+ }
4799
4811
 
4800
4812
  if (end > this.original.length) throw new Error('end is out of bounds');
4801
4813
  if (start === end)
@@ -4891,8 +4903,10 @@ class MagicString {
4891
4903
  }
4892
4904
 
4893
4905
  remove(start, end) {
4894
- while (start < 0) start += this.original.length;
4895
- while (end < 0) end += this.original.length;
4906
+ if (this.original.length !== 0) {
4907
+ while (start < 0) start += this.original.length;
4908
+ while (end < 0) end += this.original.length;
4909
+ }
4896
4910
 
4897
4911
  if (start === end) return this;
4898
4912
 
@@ -4915,8 +4929,10 @@ class MagicString {
4915
4929
  }
4916
4930
 
4917
4931
  reset(start, end) {
4918
- while (start < 0) start += this.original.length;
4919
- while (end < 0) end += this.original.length;
4932
+ if (this.original.length !== 0) {
4933
+ while (start < 0) start += this.original.length;
4934
+ while (end < 0) end += this.original.length;
4935
+ }
4920
4936
 
4921
4937
  if (start === end) return this;
4922
4938
 
@@ -4978,8 +4994,10 @@ class MagicString {
4978
4994
  }
4979
4995
 
4980
4996
  slice(start = 0, end = this.original.length) {
4981
- while (start < 0) start += this.original.length;
4982
- while (end < 0) end += this.original.length;
4997
+ if (this.original.length !== 0) {
4998
+ while (start < 0) start += this.original.length;
4999
+ while (end < 0) end += this.original.length;
5000
+ }
4983
5001
 
4984
5002
  let result = '';
4985
5003
 
@@ -5525,35 +5543,6 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
5525
5543
  return searchForWorkspaceRoot(dir, root);
5526
5544
  }
5527
5545
 
5528
- const safeModulePathsCache = /* @__PURE__ */ new WeakMap();
5529
- function isSafeModulePath(config, filePath) {
5530
- let safeModulePaths = safeModulePathsCache.get(config);
5531
- if (!safeModulePaths) {
5532
- safeModulePaths = /* @__PURE__ */ new Set();
5533
- safeModulePathsCache.set(config, safeModulePaths);
5534
- }
5535
- return safeModulePaths.has(filePath);
5536
- }
5537
- const fsDenyGlobCache = /* @__PURE__ */ new WeakMap();
5538
- function fsDenyGlob(config, filePath) {
5539
- let matcher = fsDenyGlobCache.get(config);
5540
- if (!matcher) {
5541
- matcher = picomatch$1(
5542
- // matchBase: true does not work as it's documented
5543
- // https://github.com/micromatch/picomatch/issues/89
5544
- // convert patterns without `/` on our side for now
5545
- config.server.fs.deny.map(
5546
- (pattern) => pattern.includes("/") ? pattern : `**/${pattern}`
5547
- ),
5548
- {
5549
- matchBase: false,
5550
- nocase: true,
5551
- dot: true
5552
- }
5553
- ), fsDenyGlobCache.set(config, matcher);
5554
- }
5555
- return matcher(filePath);
5556
- }
5557
5546
  function isFileServingAllowed(url, server) {
5558
5547
  const { config } = server;
5559
5548
  if (!config.server.fs.strict) return true;
@@ -5566,8 +5555,8 @@ function isUriInFilePath(uri, filePath) {
5566
5555
  function isFileLoadingAllowed(config, filePath) {
5567
5556
  const { fs } = config.server;
5568
5557
  if (!fs.strict) return true;
5569
- if (fsDenyGlob(config, filePath)) return false;
5570
- if (isSafeModulePath(config, filePath)) return true;
5558
+ if (config.fsDenyGlob(filePath)) return false;
5559
+ if (config.safeModulePaths.has(filePath)) return true;
5571
5560
  if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
5572
5561
  return false;
5573
5562
  }
package/index.cjs CHANGED
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-restricted-globals */
2
-
3
1
  warnCjsUsage()
4
2
 
5
3
  // type utils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.0-alpha.19",
3
+ "version": "6.0.0-alpha.20",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -73,15 +73,15 @@
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",
77
- "rollup": "^4.13.0"
76
+ "postcss": "^8.4.41",
77
+ "rollup": "^4.20.0"
78
78
  },
79
79
  "optionalDependencies": {
80
80
  "fsevents": "~2.3.3"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.3.0",
84
- "@babel/parser": "^7.24.8",
84
+ "@babel/parser": "^7.25.3",
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",
@@ -109,12 +109,13 @@
109
109
  "etag": "^1.8.1",
110
110
  "fast-glob": "^3.3.2",
111
111
  "http-proxy": "^1.18.1",
112
- "launch-editor-middleware": "^2.8.0",
113
- "lightningcss": "^1.25.1",
114
- "magic-string": "^0.30.10",
112
+ "launch-editor-middleware": "^2.8.1",
113
+ "lightningcss": "^1.26.0",
114
+ "magic-string": "^0.30.11",
115
115
  "micromatch": "^4.0.7",
116
116
  "mlly": "^1.7.1",
117
117
  "mrmime": "^2.0.0",
118
+ "nanoid": "^5.0.7",
118
119
  "open": "^8.4.2",
119
120
  "parse5": "^7.1.2",
120
121
  "pathe": "^1.1.2",
@@ -129,6 +130,7 @@
129
130
  "rollup-plugin-esbuild": "^6.1.1",
130
131
  "rollup-plugin-license": "^3.5.2",
131
132
  "sass": "^1.77.8",
133
+ "sass-embedded": "^1.77.8",
132
134
  "sirv": "^2.0.4",
133
135
  "source-map-support": "^0.5.21",
134
136
  "strip-ansi": "^7.1.0",
@@ -144,6 +146,7 @@
144
146
  "less": "*",
145
147
  "lightningcss": "^1.21.0",
146
148
  "sass": "*",
149
+ "sass-embedded": "*",
147
150
  "stylus": "*",
148
151
  "sugarss": "*",
149
152
  "terser": "^5.4.0"
@@ -155,6 +158,9 @@
155
158
  "sass": {
156
159
  "optional": true
157
160
  },
161
+ "sass-embedded": {
162
+ "optional": true
163
+ },
158
164
  "stylus": {
159
165
  "optional": true
160
166
  },
@@ -3,7 +3,7 @@ import type {
3
3
  FullReloadPayload,
4
4
  PrunePayload,
5
5
  UpdatePayload,
6
- } from './hotPayload'
6
+ } from './hmrPayload'
7
7
 
8
8
  export interface CustomEventMap {
9
9
  'vite:beforeUpdate': UpdatePayload
File without changes