vite 6.0.0-alpha.0 → 6.0.0-alpha.10

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.
@@ -2956,9 +2956,9 @@ const isObject$2 = val => val && typeof val === 'object' && !Array.isArray(val);
2956
2956
  * @api public
2957
2957
  */
2958
2958
 
2959
- const picomatch$1 = (glob, options, returnState = false) => {
2959
+ const picomatch$2 = (glob, options, returnState = false) => {
2960
2960
  if (Array.isArray(glob)) {
2961
- const fns = glob.map(input => picomatch$1(input, options, returnState));
2961
+ const fns = glob.map(input => picomatch$2(input, options, returnState));
2962
2962
  const arrayMatcher = str => {
2963
2963
  for (const isMatch of fns) {
2964
2964
  const state = isMatch(str);
@@ -2978,8 +2978,8 @@ const picomatch$1 = (glob, options, returnState = false) => {
2978
2978
  const opts = options || {};
2979
2979
  const posix = utils.isWindows(options);
2980
2980
  const regex = isState
2981
- ? picomatch$1.compileRe(glob, options)
2982
- : picomatch$1.makeRe(glob, options, false, true);
2981
+ ? picomatch$2.compileRe(glob, options)
2982
+ : picomatch$2.makeRe(glob, options, false, true);
2983
2983
 
2984
2984
  const state = regex.state;
2985
2985
  delete regex.state;
@@ -2987,11 +2987,11 @@ const picomatch$1 = (glob, options, returnState = false) => {
2987
2987
  let isIgnored = () => false;
2988
2988
  if (opts.ignore) {
2989
2989
  const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
2990
- isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
2990
+ isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
2991
2991
  }
2992
2992
 
2993
2993
  const matcher = (input, returnObject = false) => {
2994
- const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
2994
+ const { isMatch, match, output } = picomatch$2.test(input, regex, options, { glob, posix });
2995
2995
  const result = { glob, state, regex, posix, input, output, match, isMatch };
2996
2996
 
2997
2997
  if (typeof opts.onResult === 'function') {
@@ -3041,7 +3041,7 @@ const picomatch$1 = (glob, options, returnState = false) => {
3041
3041
  * @api public
3042
3042
  */
3043
3043
 
3044
- picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
3044
+ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
3045
3045
  if (typeof input !== 'string') {
3046
3046
  throw new TypeError('Expected input to be a string');
3047
3047
  }
@@ -3062,7 +3062,7 @@ picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
3062
3062
 
3063
3063
  if (match === false || opts.capture === true) {
3064
3064
  if (opts.matchBase === true || opts.basename === true) {
3065
- match = picomatch$1.matchBase(input, regex, options, posix);
3065
+ match = picomatch$2.matchBase(input, regex, options, posix);
3066
3066
  } else {
3067
3067
  match = regex.exec(output);
3068
3068
  }
@@ -3085,8 +3085,8 @@ picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
3085
3085
  * @api public
3086
3086
  */
3087
3087
 
3088
- picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3089
- const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
3088
+ picomatch$2.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3089
+ const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
3090
3090
  return regex.test(path$1.basename(input));
3091
3091
  };
3092
3092
 
@@ -3107,7 +3107,7 @@ picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options))
3107
3107
  * @api public
3108
3108
  */
3109
3109
 
3110
- picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
3110
+ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
3111
3111
 
3112
3112
  /**
3113
3113
  * Parse a glob pattern to create the source string for a regular
@@ -3123,8 +3123,8 @@ picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)
3123
3123
  * @api public
3124
3124
  */
3125
3125
 
3126
- picomatch$1.parse = (pattern, options) => {
3127
- if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
3126
+ picomatch$2.parse = (pattern, options) => {
3127
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
3128
3128
  return parse$1(pattern, { ...options, fastpaths: false });
3129
3129
  };
3130
3130
 
@@ -3155,7 +3155,7 @@ picomatch$1.parse = (pattern, options) => {
3155
3155
  * @api public
3156
3156
  */
3157
3157
 
3158
- picomatch$1.scan = (input, options) => scan(input, options);
3158
+ picomatch$2.scan = (input, options) => scan(input, options);
3159
3159
 
3160
3160
  /**
3161
3161
  * Compile a regular expression from the `state` object returned by the
@@ -3169,7 +3169,7 @@ picomatch$1.scan = (input, options) => scan(input, options);
3169
3169
  * @api public
3170
3170
  */
3171
3171
 
3172
- picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
3172
+ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
3173
3173
  if (returnOutput === true) {
3174
3174
  return state.output;
3175
3175
  }
@@ -3183,7 +3183,7 @@ picomatch$1.compileRe = (state, options, returnOutput = false, returnState = fal
3183
3183
  source = `^(?!${source}).*$`;
3184
3184
  }
3185
3185
 
3186
- const regex = picomatch$1.toRegex(source, options);
3186
+ const regex = picomatch$2.toRegex(source, options);
3187
3187
  if (returnState === true) {
3188
3188
  regex.state = state;
3189
3189
  }
@@ -3210,7 +3210,7 @@ picomatch$1.compileRe = (state, options, returnOutput = false, returnState = fal
3210
3210
  * @api public
3211
3211
  */
3212
3212
 
3213
- picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3213
+ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3214
3214
  if (!input || typeof input !== 'string') {
3215
3215
  throw new TypeError('Expected a non-empty string');
3216
3216
  }
@@ -3225,7 +3225,7 @@ picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = f
3225
3225
  parsed = parse$1(input, options);
3226
3226
  }
3227
3227
 
3228
- return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
3228
+ return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
3229
3229
  };
3230
3230
 
3231
3231
  /**
@@ -3245,7 +3245,7 @@ picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = f
3245
3245
  * @api public
3246
3246
  */
3247
3247
 
3248
- picomatch$1.toRegex = (source, options) => {
3248
+ picomatch$2.toRegex = (source, options) => {
3249
3249
  try {
3250
3250
  const opts = options || {};
3251
3251
  return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
@@ -3260,17 +3260,17 @@ picomatch$1.toRegex = (source, options) => {
3260
3260
  * @return {Object}
3261
3261
  */
3262
3262
 
3263
- picomatch$1.constants = constants;
3263
+ picomatch$2.constants = constants;
3264
3264
 
3265
3265
  /**
3266
3266
  * Expose "picomatch"
3267
3267
  */
3268
3268
 
3269
- var picomatch_1 = picomatch$1;
3269
+ var picomatch_1 = picomatch$2;
3270
3270
 
3271
3271
  var picomatch = picomatch_1;
3272
3272
 
3273
- var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
3273
+ var picomatch$1 = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
3274
3274
 
3275
3275
  // Helper since Typescript can't detect readonly arrays with Array.isArray
3276
3276
  function isArray(arg) {
@@ -3310,7 +3310,7 @@ const createFilter$1 = function createFilter(include, exclude, options) {
3310
3310
  test: (what) => {
3311
3311
  // this refactor is a tad overly verbose but makes for easy debugging
3312
3312
  const pattern = getMatcherString(id, resolutionBase);
3313
- const fn = pm(pattern, { dot: true });
3313
+ const fn = picomatch$1(pattern, { dot: true });
3314
3314
  const result = fn(what);
3315
3315
  return result;
3316
3316
  }
@@ -5241,21 +5241,29 @@ class MagicString {
5241
5241
  if (searchValue.global) {
5242
5242
  const matches = matchAll(searchValue, this.original);
5243
5243
  matches.forEach((match) => {
5244
- if (match.index != null)
5244
+ if (match.index != null) {
5245
+ const replacement = getReplacement(match, this.original);
5246
+ if (replacement !== match[0]) {
5247
+ this.overwrite(
5248
+ match.index,
5249
+ match.index + match[0].length,
5250
+ replacement
5251
+ );
5252
+ }
5253
+ }
5254
+ });
5255
+ } else {
5256
+ const match = this.original.match(searchValue);
5257
+ if (match && match.index != null) {
5258
+ const replacement = getReplacement(match, this.original);
5259
+ if (replacement !== match[0]) {
5245
5260
  this.overwrite(
5246
5261
  match.index,
5247
5262
  match.index + match[0].length,
5248
- getReplacement(match, this.original),
5263
+ replacement
5249
5264
  );
5250
- });
5251
- } else {
5252
- const match = this.original.match(searchValue);
5253
- if (match && match.index != null)
5254
- this.overwrite(
5255
- match.index,
5256
- match.index + match[0].length,
5257
- getReplacement(match, this.original),
5258
- );
5265
+ }
5266
+ }
5259
5267
  }
5260
5268
  return this;
5261
5269
  }
@@ -5287,7 +5295,9 @@ class MagicString {
5287
5295
  index !== -1;
5288
5296
  index = original.indexOf(string, index + stringLength)
5289
5297
  ) {
5290
- this.overwrite(index, index + stringLength, replacement);
5298
+ const previous = original.slice(index, index + stringLength);
5299
+ if (previous !== replacement)
5300
+ this.overwrite(index, index + stringLength, replacement);
5291
5301
  }
5292
5302
 
5293
5303
  return this;
@@ -5425,12 +5435,14 @@ function createLogger(level = 'info', options = {}) {
5425
5435
  const clear = canClearScreen ? clearScreen : () => { };
5426
5436
  function format(type, msg, options = {}) {
5427
5437
  if (options.timestamp) {
5428
- const tag = type === 'info'
5429
- ? colors.cyan(colors.bold(prefix))
5438
+ const color = type === 'info'
5439
+ ? colors.cyan
5430
5440
  : type === 'warn'
5431
- ? colors.yellow(colors.bold(prefix))
5432
- : colors.red(colors.bold(prefix));
5433
- return `${colors.dim(getTimeFormatter().format(new Date()))} ${tag} ${msg}`;
5441
+ ? colors.yellow
5442
+ : colors.red;
5443
+ const tag = color(colors.bold(prefix));
5444
+ const environment = options.environment ? options.environment + ' ' : '';
5445
+ return `${colors.dim(getTimeFormatter().format(new Date()))} ${tag} ${environment}${msg}`;
5434
5446
  }
5435
5447
  else {
5436
5448
  return msg;
@@ -5558,18 +5570,55 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
5558
5570
  return searchForWorkspaceRoot(dir, root);
5559
5571
  }
5560
5572
 
5573
+ const safeModulePathsCache = new WeakMap();
5574
+ function isSafeModulePath(config, filePath) {
5575
+ let safeModulePaths = safeModulePathsCache.get(config);
5576
+ if (!safeModulePaths) {
5577
+ safeModulePaths = new Set();
5578
+ safeModulePathsCache.set(config, safeModulePaths);
5579
+ }
5580
+ return safeModulePaths.has(filePath);
5581
+ }
5582
+ const fsDenyGlobCache = new WeakMap();
5583
+ function fsDenyGlob(config, filePath) {
5584
+ let matcher = fsDenyGlobCache.get(config);
5585
+ if (!matcher) {
5586
+ (matcher = picomatch$1(
5587
+ // matchBase: true does not work as it's documented
5588
+ // https://github.com/micromatch/picomatch/issues/89
5589
+ // convert patterns without `/` on our side for now
5590
+ config.server.fs.deny.map((pattern) => pattern.includes('/') ? pattern : `**/${pattern}`), {
5591
+ matchBase: false,
5592
+ nocase: true,
5593
+ dot: true,
5594
+ })),
5595
+ fsDenyGlobCache.set(config, matcher);
5596
+ }
5597
+ return matcher(filePath);
5598
+ }
5561
5599
  /**
5562
5600
  * Check if the url is allowed to be served, via the `server.fs` config.
5601
+ * @deprecate use isFileLoadingAllowed
5563
5602
  */
5564
5603
  function isFileServingAllowed(url, server) {
5565
- if (!server.config.server.fs.strict)
5604
+ const { config } = server;
5605
+ if (!config.server.fs.strict)
5606
+ return true;
5607
+ const filePath = fsPathFromUrl(url);
5608
+ return isFileLoadingAllowed(config, filePath);
5609
+ }
5610
+ function isUriInFilePath(uri, filePath) {
5611
+ return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
5612
+ }
5613
+ function isFileLoadingAllowed(config, filePath) {
5614
+ const { fs } = config.server;
5615
+ if (!fs.strict)
5566
5616
  return true;
5567
- const file = fsPathFromUrl(url);
5568
- if (server._fsDenyGlob(file))
5617
+ if (fsDenyGlob(config, filePath))
5569
5618
  return false;
5570
- if (server._safeModulesPath.has(file))
5619
+ if (isSafeModulePath(config, filePath))
5571
5620
  return true;
5572
- if (server.config.server.fs.allow.some((uri) => isSameFileUri(uri, file) || isParentDirectory(uri, file)))
5621
+ if (fs.allow.some((uri) => isUriInFilePath(uri, filePath)))
5573
5622
  return true;
5574
5623
  return false;
5575
5624
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-alpha.10",
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.24.1",
84
+ "@babel/parser": "^7.24.5",
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",
@@ -106,7 +106,7 @@
106
106
  "dep-types": "link:./src/types",
107
107
  "dotenv": "^16.4.5",
108
108
  "dotenv-expand": "^11.0.6",
109
- "es-module-lexer": "^1.5.0",
109
+ "es-module-lexer": "^1.5.2",
110
110
  "escape-html": "^1.0.3",
111
111
  "estree-walker": "^3.0.3",
112
112
  "etag": "^1.8.1",
@@ -114,7 +114,7 @@
114
114
  "http-proxy": "^1.18.1",
115
115
  "launch-editor-middleware": "^2.6.1",
116
116
  "lightningcss": "^1.24.1",
117
- "magic-string": "^0.30.8",
117
+ "magic-string": "^0.30.10",
118
118
  "micromatch": "^4.0.5",
119
119
  "mlly": "^1.6.1",
120
120
  "mrmime": "^2.0.0",
@@ -131,15 +131,16 @@
131
131
  "rollup-plugin-dts": "^6.1.0",
132
132
  "rollup-plugin-esbuild": "^6.1.1",
133
133
  "rollup-plugin-license": "^3.3.1",
134
+ "sass": "^1.76.0",
134
135
  "sirv": "^2.0.4",
135
136
  "source-map-support": "^0.5.21",
136
137
  "strip-ansi": "^7.1.0",
137
- "strip-literal": "^2.0.0",
138
+ "strip-literal": "^2.1.0",
138
139
  "tsconfck": "^3.0.3",
139
140
  "tslib": "^2.6.2",
140
141
  "types": "link:./types",
141
142
  "ufo": "^1.5.3",
142
- "ws": "^8.16.0"
143
+ "ws": "^8.17.0"
143
144
  },
144
145
  "peerDependencies": {
145
146
  "@types/node": "^18.0.0 || >=20.0.0",