vite 4.3.0-beta.7 → 4.3.0-beta.8

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.

package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-f1f8facc.js';
5
+ import { C as picocolorsExports, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-c7e79736.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -728,7 +728,7 @@ cli
728
728
  filterDuplicateOptions(options);
729
729
  // output structure is preserved even after bundling so require()
730
730
  // is ok here
731
- const { createServer } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.G; });
731
+ const { createServer } = await import('./chunks/dep-c7e79736.js').then(function (n) { return n.H; });
732
732
  try {
733
733
  const server = await createServer({
734
734
  root,
@@ -806,7 +806,7 @@ cli
806
806
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
807
807
  .action(async (root, options) => {
808
808
  filterDuplicateOptions(options);
809
- const { build } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.F; });
809
+ const { build } = await import('./chunks/dep-c7e79736.js').then(function (n) { return n.G; });
810
810
  const buildOptions = cleanOptions(options);
811
811
  try {
812
812
  await build({
@@ -834,7 +834,7 @@ cli
834
834
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
835
835
  .action(async (root, options) => {
836
836
  filterDuplicateOptions(options);
837
- const { optimizeDeps } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.E; });
837
+ const { optimizeDeps } = await import('./chunks/dep-c7e79736.js').then(function (n) { return n.F; });
838
838
  try {
839
839
  const config = await resolveConfig({
840
840
  root,
@@ -860,7 +860,7 @@ cli
860
860
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
861
861
  .action(async (root, options) => {
862
862
  filterDuplicateOptions(options);
863
- const { preview } = await import('./chunks/dep-f1f8facc.js').then(function (n) { return n.H; });
863
+ const { preview } = await import('./chunks/dep-c7e79736.js').then(function (n) { return n.I; });
864
864
  try {
865
865
  const server = await preview({
866
866
  root,
@@ -1199,6 +1199,11 @@ export declare const isCSSRequest: (request: string) => boolean;
1199
1199
 
1200
1200
  export declare function isDepsOptimizerEnabled(config: ResolvedConfig, ssr: boolean): boolean;
1201
1201
 
1202
+ /**
1203
+ * Check if the url is allowed to be served, via the `server.fs` config.
1204
+ */
1205
+ export declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
1206
+
1202
1207
  export declare interface JsonOptions {
1203
1208
  /**
1204
1209
  * Generate a named export for every property of the JSON object
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-f1f8facc.js';
2
- export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-f1f8facc.js';
1
+ import { i as isInNodeModules } from './chunks/dep-c7e79736.js';
2
+ export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-c7e79736.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
@@ -11,12 +11,16 @@ var require$$0 = require('tty');
11
11
  var require$$1 = require('util');
12
12
  var require$$0$1 = require('path');
13
13
  var require$$0$2 = require('crypto');
14
- var require$$1$1 = require('fs');
14
+ var fs$2 = require('fs');
15
15
  var readline = require('node:readline');
16
16
  var require$$2 = require('os');
17
17
 
18
18
  const { version: version$2 } = JSON.parse(fs$1.readFileSync(new URL('../../package.json', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString());
19
19
  const VERSION = version$2;
20
+ /**
21
+ * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
22
+ */
23
+ const FS_PREFIX = `/@fs/`;
20
24
  const VITE_PACKAGE_DIR = path$3.resolve(
21
25
  // import.meta.url is `dist/node/constants.js` after bundle
22
26
  node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))), '../../..');
@@ -3341,11 +3345,39 @@ function testCaseInsensitiveFS() {
3341
3345
  }
3342
3346
  return fs$1.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs'));
3343
3347
  }
3344
- testCaseInsensitiveFS();
3348
+ const isCaseInsensitiveFS = testCaseInsensitiveFS();
3345
3349
  const isWindows = os$1.platform() === 'win32';
3350
+ const VOLUME_RE = /^[A-Z]:/i;
3346
3351
  function normalizePath(id) {
3347
3352
  return path$3.posix.normalize(isWindows ? slash(id) : id);
3348
3353
  }
3354
+ function fsPathFromId(id) {
3355
+ const fsPath = normalizePath(id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id);
3356
+ return fsPath[0] === '/' || fsPath.match(VOLUME_RE) ? fsPath : `/${fsPath}`;
3357
+ }
3358
+ function fsPathFromUrl(url) {
3359
+ return fsPathFromId(cleanUrl(url));
3360
+ }
3361
+ /**
3362
+ * Check if dir is a parent of file
3363
+ *
3364
+ * Warning: parameters are not validated, only works with normalized absolute paths
3365
+ *
3366
+ * @param dir - normalized absolute path
3367
+ * @param file - normalized absolute path
3368
+ * @returns true if dir is a parent of file
3369
+ */
3370
+ function isParentDirectory(dir, file) {
3371
+ if (dir[dir.length - 1] !== '/') {
3372
+ dir = `${dir}/`;
3373
+ }
3374
+ return (file.startsWith(dir) ||
3375
+ (isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
3376
+ }
3377
+ const postfixRE = /[?#].*$/s;
3378
+ function cleanUrl(url) {
3379
+ return url.replace(postfixRE, '');
3380
+ }
3349
3381
  function isObject(value) {
3350
3382
  return Object.prototype.toString.call(value) === '[object Object]';
3351
3383
  }
@@ -3596,7 +3628,7 @@ var etag_1 = etag;
3596
3628
  */
3597
3629
 
3598
3630
  var crypto = require$$0$2;
3599
- var Stats = require$$1$1.Stats;
3631
+ var Stats = fs$2.Stats;
3600
3632
 
3601
3633
  /**
3602
3634
  * Module variables.
@@ -3920,6 +3952,22 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
3920
3952
  return searchForWorkspaceRoot(dir, root);
3921
3953
  }
3922
3954
 
3955
+ /**
3956
+ * Check if the url is allowed to be served, via the `server.fs` config.
3957
+ */
3958
+ function isFileServingAllowed(url, server) {
3959
+ if (!server.config.server.fs.strict)
3960
+ return true;
3961
+ const file = fsPathFromUrl(url);
3962
+ if (server._fsDenyGlob(file))
3963
+ return false;
3964
+ if (server.moduleGraph.safeModulesPath.has(file))
3965
+ return true;
3966
+ if (server.config.server.fs.allow.some((dir) => isParentDirectory(dir, file)))
3967
+ return true;
3968
+ return false;
3969
+ }
3970
+
3923
3971
  var mainExports = {};
3924
3972
  var main$1 = {
3925
3973
  get exports(){ return mainExports; },
@@ -4000,7 +4048,7 @@ var require$$3 = {
4000
4048
  engines: engines
4001
4049
  };
4002
4050
 
4003
- const fs = require$$1$1;
4051
+ const fs = fs$2;
4004
4052
  const path = require$$0$1;
4005
4053
  const os = require$$2;
4006
4054
  const packageJson = require$$3;
@@ -4238,6 +4286,7 @@ exports.rollupVersion = rollup.VERSION;
4238
4286
  exports.createFilter = createFilter;
4239
4287
  exports.createLogger = createLogger;
4240
4288
  exports.isCSSRequest = isCSSRequest;
4289
+ exports.isFileServingAllowed = isFileServingAllowed;
4241
4290
  exports.loadEnv = loadEnv;
4242
4291
  exports.mergeAlias = mergeAlias;
4243
4292
  exports.mergeConfig = mergeConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.3.0-beta.7",
3
+ "version": "4.3.0-beta.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -86,6 +86,7 @@
86
86
  "@rollup/plugin-typescript": "^11.0.0",
87
87
  "@rollup/pluginutils": "^5.0.2",
88
88
  "@types/pnpapi": "^0.0.2",
89
+ "@types/escape-html": "^1.0.0",
89
90
  "acorn": "^8.8.2",
90
91
  "acorn-walk": "^8.2.0",
91
92
  "cac": "^6.7.14",
@@ -100,6 +101,7 @@
100
101
  "dotenv": "^16.0.3",
101
102
  "dotenv-expand": "^9.0.0",
102
103
  "es-module-lexer": "^1.2.0",
104
+ "escape-html": "^1.0.3",
103
105
  "estree-walker": "^3.0.3",
104
106
  "etag": "^1.8.1",
105
107
  "fast-glob": "^3.2.12",