vite 5.1.0-beta.6 → 5.1.0-beta.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.
@@ -32002,8 +32002,8 @@ function createCachedImport(imp) {
32002
32002
  return cached;
32003
32003
  };
32004
32004
  }
32005
- const importPostcssImport = createCachedImport(() => import('./dep-0ozvs92U.js').then(function (n) { return n.i; }));
32006
- const importPostcssModules = createCachedImport(() => import('./dep-4a4aOlj8.js').then(function (n) { return n.i; }));
32005
+ const importPostcssImport = createCachedImport(() => import('./dep-ma2Y1b9q.js').then(function (n) { return n.i; }));
32006
+ const importPostcssModules = createCachedImport(() => import('./dep-go6jvlFO.js').then(function (n) { return n.i; }));
32007
32007
  const importPostcss = createCachedImport(() => import('postcss'));
32008
32008
  const preprocessorWorkerControllerCache = new WeakMap();
32009
32009
  let alwaysFakeWorkerWorkerControllerCache;
@@ -46850,9 +46850,11 @@ const cachedFsUtilsMap = new WeakMap();
46850
46850
  function getFsUtils(config) {
46851
46851
  let fsUtils = cachedFsUtilsMap.get(config);
46852
46852
  if (!fsUtils) {
46853
- if (config.command !== 'serve' || !config.server.fs.cachedChecks) {
46854
- // cached fsUtils is only used in the dev server for now, and only when the watcher isn't configured
46855
- // we can support custom ignored patterns later
46853
+ if (config.command !== 'serve' ||
46854
+ config.server.fs.cachedChecks === false ||
46855
+ config.server.watch?.ignored) {
46856
+ // cached fsUtils is only used in the dev server for now
46857
+ // it is enabled by default only when there aren't custom watcher ignored patterns configured
46856
46858
  fsUtils = commonFsUtils;
46857
46859
  }
46858
46860
  else if (!config.resolve.preserveSymlinks &&
@@ -46931,11 +46933,11 @@ function createCachedFsUtils(config) {
46931
46933
  return;
46932
46934
  }
46933
46935
  if (nextDirentCache.type === 'directory_maybe_symlink') {
46934
- dirPath ??= pathUntilPart(root, parts, i);
46936
+ dirPath ??= pathUntilPart(root, parts, i + 1);
46935
46937
  const isSymlink = fs$l
46936
46938
  .lstatSync(dirPath, { throwIfNoEntry: false })
46937
46939
  ?.isSymbolicLink();
46938
- direntCache.type = isSymlink ? 'symlink' : 'directory';
46940
+ nextDirentCache.type = isSymlink ? 'symlink' : 'directory';
46939
46941
  }
46940
46942
  direntCache = nextDirentCache;
46941
46943
  }
@@ -50935,15 +50937,16 @@ function orderedDependencies(deps) {
50935
50937
  return Object.fromEntries(depsList);
50936
50938
  }
50937
50939
  function globEntries(pattern, config) {
50940
+ const rootPattern = glob.convertPathToPattern(config.root);
50938
50941
  return glob(pattern, {
50939
50942
  cwd: config.root,
50940
50943
  ignore: [
50941
- '**/node_modules/**',
50942
- `**/${config.build.outDir}/**`,
50944
+ `${rootPattern}/**/node_modules/**`,
50945
+ `${rootPattern}/**/${config.build.outDir}/**`,
50943
50946
  // if there aren't explicit entries, also ignore other common folders
50944
50947
  ...(config.optimizeDeps.entries
50945
50948
  ? []
50946
- : [`**/__tests__/**`, `**/coverage/**`]),
50949
+ : [`${rootPattern}/**/__tests__/**`, `${rootPattern}/**/coverage/**`]),
50947
50950
  ],
50948
50951
  absolute: true,
50949
50952
  suppressErrors: true, // suppress EACCES errors
@@ -53371,12 +53374,37 @@ function transformRequest(url, server, options = {}) {
53371
53374
  async function doTransform(url, server, options, timestamp) {
53372
53375
  url = removeTimestampQuery(url);
53373
53376
  const { config, pluginContainer } = server;
53374
- const prettyUrl = debugCache$1 ? prettifyUrl(url, config.root) : '';
53375
53377
  const ssr = !!options.ssr;
53376
53378
  if (ssr && isDepsOptimizerEnabled(config, true)) {
53377
53379
  await initDevSsrDepsOptimizer(config, server);
53378
53380
  }
53379
- const module = await server.moduleGraph.getModuleByUrl(url, ssr);
53381
+ let module = await server.moduleGraph.getModuleByUrl(url, ssr);
53382
+ if (module) {
53383
+ // try use cache from url
53384
+ const cached = await getCachedTransformResult(url, module, server, ssr, timestamp);
53385
+ if (cached)
53386
+ return cached;
53387
+ }
53388
+ const resolved = module
53389
+ ? undefined
53390
+ : (await pluginContainer.resolveId(url, undefined, { ssr })) ?? undefined;
53391
+ // resolve
53392
+ const id = module?.id ?? resolved?.id ?? url;
53393
+ module ??= server.moduleGraph.getModuleById(id);
53394
+ if (module) {
53395
+ // if a different url maps to an existing loaded id, make sure we relate this url to the id
53396
+ await server.moduleGraph._ensureEntryFromUrl(url, ssr, undefined, resolved);
53397
+ // try use cache from id
53398
+ const cached = await getCachedTransformResult(url, module, server, ssr, timestamp);
53399
+ if (cached)
53400
+ return cached;
53401
+ }
53402
+ const result = loadAndTransform(id, url, server, options, timestamp, module, resolved);
53403
+ getDepsOptimizer(config, ssr)?.delayDepsOptimizerUntil(id, () => result);
53404
+ return result;
53405
+ }
53406
+ async function getCachedTransformResult(url, module, server, ssr, timestamp) {
53407
+ const prettyUrl = debugCache$1 ? prettifyUrl(url, server.config.root) : '';
53380
53408
  // tries to handle soft invalidation of the module if available,
53381
53409
  // returns a boolean true is successful, or false if no handling is needed
53382
53410
  const softInvalidatedTransformResult = module &&
@@ -53391,14 +53419,6 @@ async function doTransform(url, server, options, timestamp) {
53391
53419
  debugCache$1?.(`[memory] ${prettyUrl}`);
53392
53420
  return cached;
53393
53421
  }
53394
- const resolved = module
53395
- ? undefined
53396
- : (await pluginContainer.resolveId(url, undefined, { ssr })) ?? undefined;
53397
- // resolve
53398
- const id = module?.id ?? resolved?.id ?? url;
53399
- const result = loadAndTransform(id, url, server, options, timestamp, module, resolved);
53400
- getDepsOptimizer(config, ssr)?.delayDepsOptimizerUntil(id, () => result);
53401
- return result;
53402
53422
  }
53403
53423
  async function loadAndTransform(id, url, server, options, timestamp, mod, resolved) {
53404
53424
  const { config, pluginContainer, moduleGraph } = server;
@@ -64603,7 +64623,7 @@ function resolveServerOptions(root, raw, logger) {
64603
64623
  strict: server.fs?.strict ?? true,
64604
64624
  allow: allowDirs,
64605
64625
  deny,
64606
- cachedChecks: server.fs?.cachedChecks ?? true,
64626
+ cachedChecks: server.fs?.cachedChecks,
64607
64627
  };
64608
64628
  if (server.origin?.endsWith('/')) {
64609
64629
  server.origin = server.origin.slice(0, -1);
@@ -67436,6 +67456,24 @@ const promisifiedRealpath = promisify$4(fs$l.realpath);
67436
67456
  function defineConfig(config) {
67437
67457
  return config;
67438
67458
  }
67459
+ /**
67460
+ * Check and warn if `path` includes characters that don't work well in Vite,
67461
+ * such as `#` and `?`.
67462
+ */
67463
+ function checkBadCharactersInPath(path, logger) {
67464
+ const badChars = [];
67465
+ if (path.includes('#')) {
67466
+ badChars.push('#');
67467
+ }
67468
+ if (path.includes('?')) {
67469
+ badChars.push('?');
67470
+ }
67471
+ if (badChars.length > 0) {
67472
+ const charString = badChars.map((c) => `"${c}"`).join(' and ');
67473
+ const inflectedChars = badChars.length > 1 ? 'characters' : 'character';
67474
+ logger.warn(colors$1.yellow(`The project root contains the ${charString} ${inflectedChars} (${colors$1.cyan(path)}), which may not work when running Vite. Consider renaming the directory to remove the characters.`));
67475
+ }
67476
+ }
67439
67477
  async function resolveConfig(inlineConfig, command, defaultMode = 'development', defaultNodeEnv = 'development', isPreview = false) {
67440
67478
  let config = inlineConfig;
67441
67479
  let configFileDependencies = [];
@@ -67492,9 +67530,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
67492
67530
  });
67493
67531
  // resolve root
67494
67532
  const resolvedRoot = normalizePath$3(config.root ? path$o.resolve(config.root) : process.cwd());
67495
- if (resolvedRoot.includes('#')) {
67496
- logger.warn(colors$1.yellow(`The project root contains the "#" character (${colors$1.cyan(resolvedRoot)}), which may not work when running Vite. Consider renaming the directory to remove the "#".`));
67497
- }
67533
+ checkBadCharactersInPath(resolvedRoot, logger);
67498
67534
  const clientAlias = [
67499
67535
  {
67500
67536
  find: /^\/?@vite\/env/,
@@ -68053,7 +68089,7 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
68053
68089
  resolved.build.commonjsOptions.include = undefined;
68054
68090
  }
68055
68091
  resolved.logger.warn(colors$1.yellow(`(!) Experimental ${optimizeDepsPath}optimizeDeps.disabled and deps pre-bundling during build were removed in Vite 5.1.
68056
- To disable the deps optimizer, set ${optimizeDepsPath}optimizeDeps.noDiscovery to true and ${optimizeDepsPath}optimizeDeps.include as undefined or empty.
68092
+ To disable the deps optimizer, set ${optimizeDepsPath}optimizeDeps.noDiscovery to true and ${optimizeDepsPath}optimizeDeps.include as undefined or empty.
68057
68093
  Please remove ${optimizeDepsPath}optimizeDeps.disabled from your config.
68058
68094
  ${commonjsPluginDisabled
68059
68095
  ? 'Empty config.build.commonjsOptions.include will be ignored to support CJS during build. This config should also be removed.'
@@ -1,4 +1,4 @@
1
- import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-ZX7UfftI.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-G1t0FnMB.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -1,4 +1,4 @@
1
- import { B as getDefaultExportFromCjs } from './dep-ZX7UfftI.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-G1t0FnMB.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-8a-6Quh6.js';
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 { c as colors, a as createLogger, r as resolveConfig } from './chunks/dep-ZX7UfftI.js';
5
+ import { c as colors, a as createLogger, r as resolveConfig } from './chunks/dep-G1t0FnMB.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -757,7 +757,7 @@ cli
757
757
  filterDuplicateOptions(options);
758
758
  // output structure is preserved even after bundling so require()
759
759
  // is ok here
760
- const { createServer } = await import('./chunks/dep-ZX7UfftI.js').then(function (n) { return n.E; });
760
+ const { createServer } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.E; });
761
761
  try {
762
762
  const server = await createServer({
763
763
  root,
@@ -837,7 +837,7 @@ cli
837
837
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
838
838
  .action(async (root, options) => {
839
839
  filterDuplicateOptions(options);
840
- const { build } = await import('./chunks/dep-ZX7UfftI.js').then(function (n) { return n.F; });
840
+ const { build } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.F; });
841
841
  const buildOptions = cleanOptions(options);
842
842
  try {
843
843
  await build({
@@ -865,7 +865,7 @@ cli
865
865
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
866
866
  .action(async (root, options) => {
867
867
  filterDuplicateOptions(options);
868
- const { optimizeDeps } = await import('./chunks/dep-ZX7UfftI.js').then(function (n) { return n.D; });
868
+ const { optimizeDeps } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.D; });
869
869
  try {
870
870
  const config = await resolveConfig({
871
871
  root,
@@ -891,7 +891,7 @@ cli
891
891
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
892
892
  .action(async (root, options) => {
893
893
  filterDuplicateOptions(options);
894
- const { preview } = await import('./chunks/dep-ZX7UfftI.js').then(function (n) { return n.G; });
894
+ const { preview } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.G; });
895
895
  try {
896
896
  const server = await preview({
897
897
  root,
@@ -1645,10 +1645,10 @@ interface FileSystemServeOptions {
1645
1645
  */
1646
1646
  deny?: string[];
1647
1647
  /**
1648
- * Enable caching of fs calls.
1648
+ * Enable caching of fs calls. It is enabled by default if no custom watch ignored patterns are provided.
1649
1649
  *
1650
1650
  * @experimental
1651
- * @default true
1651
+ * @default undefined
1652
1652
  */
1653
1653
  cachedChecks?: boolean;
1654
1654
  }
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, b as arraify } from './chunks/dep-ZX7UfftI.js';
3
- export { f as build, j as buildErrorMessage, u as createFilter, a as createLogger, e as createServer, d as defineConfig, k as fetchModule, g as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ZX7UfftI.js';
2
+ import { i as isInNodeModules, b as arraify } from './chunks/dep-G1t0FnMB.js';
3
+ export { f as build, j as buildErrorMessage, u as createFilter, a as createLogger, e as createServer, d as defineConfig, k as fetchModule, g as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-G1t0FnMB.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.1.0-beta.6",
3
+ "version": "5.1.0-beta.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",