vite 5.1.2 → 5.1.3

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 { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-Glf1enhJ.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-stQc5rCc.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-Glf1enhJ.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-stQc5rCc.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';
@@ -32071,8 +32071,8 @@ function createCachedImport(imp) {
32071
32071
  return cached;
32072
32072
  };
32073
32073
  }
32074
- const importPostcssImport = createCachedImport(() => import('./dep-vBYKhUMg.js').then(function (n) { return n.i; }));
32075
- const importPostcssModules = createCachedImport(() => import('./dep-7WSsXf4P.js').then(function (n) { return n.i; }));
32074
+ const importPostcssImport = createCachedImport(() => import('./dep-ZEDYRkoC.js').then(function (n) { return n.i; }));
32075
+ const importPostcssModules = createCachedImport(() => import('./dep-PB-S7R_m.js').then(function (n) { return n.i; }));
32076
32076
  const importPostcss = createCachedImport(() => import('postcss'));
32077
32077
  const preprocessorWorkerControllerCache = new WeakMap();
32078
32078
  let alwaysFakeWorkerWorkerControllerCache;
@@ -56197,6 +56197,7 @@ let SOURCEMAPPING_URL = 'sourceMa';
56197
56197
  SOURCEMAPPING_URL += 'ppingURL';
56198
56198
  const VITE_RUNTIME_SOURCEMAPPING_SOURCE = '//# sourceMappingSource=vite-runtime';
56199
56199
  const VITE_RUNTIME_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
56200
+ const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, 'gm');
56200
56201
  function inlineSourceMap(mod, result, processSourceMap) {
56201
56202
  const map = result.map;
56202
56203
  let code = result.code;
@@ -56205,8 +56206,8 @@ function inlineSourceMap(mod, result, processSourceMap) {
56205
56206
  code.includes(VITE_RUNTIME_SOURCEMAPPING_SOURCE))
56206
56207
  return result;
56207
56208
  // to reduce the payload size, we only inline vite node source map, because it's also the only one we use
56208
- const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, 'gm');
56209
- while (OTHER_SOURCE_MAP_REGEXP.test(code))
56209
+ OTHER_SOURCE_MAP_REGEXP.lastIndex = 0;
56210
+ if (OTHER_SOURCE_MAP_REGEXP.test(code))
56210
56211
  code = code.replace(OTHER_SOURCE_MAP_REGEXP, '');
56211
56212
  const sourceMap = Buffer.from(JSON.stringify(processSourceMap?.(map) || map), 'utf-8').toString('base64');
56212
56213
  result.code = `${code.trimEnd()}\n//# sourceURL=${mod.id}\n${VITE_RUNTIME_SOURCEMAPPING_SOURCE}\n//# ${VITE_RUNTIME_SOURCEMAPPING_URL};base64,${sourceMap}\n`;
@@ -63261,12 +63262,11 @@ function cachedTransformMiddleware(server) {
63261
63262
  if (ifNoneMatch) {
63262
63263
  const moduleByEtag = server.moduleGraph.getModuleByEtag(ifNoneMatch);
63263
63264
  if (moduleByEtag?.transformResult?.etag === ifNoneMatch) {
63264
- // For direct CSS requests, if the same CSS file is imported in a module,
63265
+ // For CSS requests, if the same CSS file is imported in a module,
63265
63266
  // the browser sends the request for the direct CSS request with the etag
63266
63267
  // from the imported CSS module. We ignore the etag in this case.
63267
- const mixedEtag = !req.headers.accept?.includes('text/css') &&
63268
- isDirectRequest(moduleByEtag.url);
63269
- if (!mixedEtag) {
63268
+ const maybeMixedEtag = isCSSRequest(req.url);
63269
+ if (!maybeMixedEtag) {
63270
63270
  debugCache?.(`[304] ${prettifyUrl(req.url, server.config.root)}`);
63271
63271
  res.statusCode = 304;
63272
63272
  return res.end();
@@ -63355,12 +63355,23 @@ function transformMiddleware(server) {
63355
63355
  // Strip valid id prefix. This is prepended to resolved Ids that are
63356
63356
  // not valid browser import specifiers by the importAnalysis plugin.
63357
63357
  url = unwrapId(url);
63358
- // for CSS, we need to differentiate between normal CSS requests and
63359
- // imports
63360
- if (isCSSRequest(url) &&
63361
- !isDirectRequest(url) &&
63362
- req.headers.accept?.includes('text/css')) {
63363
- url = injectQuery(url, 'direct');
63358
+ // for CSS, we differentiate between normal CSS requests and imports
63359
+ if (isCSSRequest(url)) {
63360
+ if (req.headers.accept?.includes('text/css') &&
63361
+ !isDirectRequest(url)) {
63362
+ url = injectQuery(url, 'direct');
63363
+ }
63364
+ // check if we can return 304 early for CSS requests. These aren't handled
63365
+ // by the cachedTransformMiddleware due to the browser possibly mixing the
63366
+ // etags of direct and imported CSS
63367
+ const ifNoneMatch = req.headers['if-none-match'];
63368
+ if (ifNoneMatch &&
63369
+ (await server.moduleGraph.getModuleByUrl(url, false))
63370
+ ?.transformResult?.etag === ifNoneMatch) {
63371
+ debugCache?.(`[304] ${prettifyUrl(url, server.config.root)}`);
63372
+ res.statusCode = 304;
63373
+ return res.end();
63374
+ }
63364
63375
  }
63365
63376
  // resolve, load and transform using the plugin container
63366
63377
  const result = await transformRequest(url, server, {
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-Glf1enhJ.js';
5
+ import { c as colors, a as createLogger, r as resolveConfig } from './chunks/dep-stQc5rCc.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-Glf1enhJ.js').then(function (n) { return n.E; });
760
+ const { createServer } = await import('./chunks/dep-stQc5rCc.js').then(function (n) { return n.E; });
761
761
  try {
762
762
  const server = await createServer({
763
763
  root,
@@ -836,7 +836,7 @@ cli
836
836
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
837
837
  .action(async (root, options) => {
838
838
  filterDuplicateOptions(options);
839
- const { build } = await import('./chunks/dep-Glf1enhJ.js').then(function (n) { return n.F; });
839
+ const { build } = await import('./chunks/dep-stQc5rCc.js').then(function (n) { return n.F; });
840
840
  const buildOptions = cleanOptions(options);
841
841
  try {
842
842
  await build({
@@ -863,7 +863,7 @@ cli
863
863
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
864
864
  .action(async (root, options) => {
865
865
  filterDuplicateOptions(options);
866
- const { optimizeDeps } = await import('./chunks/dep-Glf1enhJ.js').then(function (n) { return n.D; });
866
+ const { optimizeDeps } = await import('./chunks/dep-stQc5rCc.js').then(function (n) { return n.D; });
867
867
  try {
868
868
  const config = await resolveConfig({
869
869
  root,
@@ -889,7 +889,7 @@ cli
889
889
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
890
890
  .action(async (root, options) => {
891
891
  filterDuplicateOptions(options);
892
- const { preview } = await import('./chunks/dep-Glf1enhJ.js').then(function (n) { return n.G; });
892
+ const { preview } = await import('./chunks/dep-stQc5rCc.js').then(function (n) { return n.G; });
893
893
  try {
894
894
  const server = await preview({
895
895
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, b as arraify } from './chunks/dep-Glf1enhJ.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-Glf1enhJ.js';
2
+ import { i as isInNodeModules, b as arraify } from './chunks/dep-stQc5rCc.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-stQc5rCc.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';
@@ -1381,13 +1381,16 @@ class ViteRuntime {
1381
1381
  if (mod.exports)
1382
1382
  return this.processImport(mod.exports, fetchedModule, metadata);
1383
1383
  }
1384
- const getStack = () => `stack:\n${[...callstack, moduleId]
1385
- .reverse()
1386
- .map((p) => ` - ${p}`)
1387
- .join('\n')}`;
1388
1384
  let debugTimer;
1389
- if (this.debug)
1390
- debugTimer = setTimeout(() => this.debug(`[vite-runtime] module ${moduleId} takes over 2s to load.\n${getStack()}`), 2000);
1385
+ if (this.debug) {
1386
+ debugTimer = setTimeout(() => {
1387
+ const getStack = () => `stack:\n${[...callstack, moduleId]
1388
+ .reverse()
1389
+ .map((p) => ` - ${p}`)
1390
+ .join('\n')}`;
1391
+ this.debug(`[vite-runtime] module ${moduleId} takes over 2s to load.\n${getStack()}`);
1392
+ }, 2000);
1393
+ }
1391
1394
  try {
1392
1395
  // cached module
1393
1396
  if (mod.promise)
@@ -1417,7 +1420,7 @@ class ViteRuntime {
1417
1420
  this.debug?.('[vite-runtime] fetching', id);
1418
1421
  // fast return for established externalized patterns
1419
1422
  const fetchedModule = id.startsWith('data:')
1420
- ? { externalize: id, type: 'builtin' }
1423
+ ? ({ externalize: id, type: 'builtin' })
1421
1424
  : await this.options.fetchModule(id, importer);
1422
1425
  // base moduleId on "file" and not on id
1423
1426
  // if `import(variable)` is called it's possible that it doesn't have an extension for example
@@ -1604,7 +1607,7 @@ class ESModulesRunner {
1604
1607
  // source map should already be inlined by Vite
1605
1608
  '"use strict";' + code);
1606
1609
  await initModule(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey]);
1607
- Object.freeze(context[ssrModuleExportsKey]);
1610
+ Object.seal(context[ssrModuleExportsKey]);
1608
1611
  }
1609
1612
  runExternalModule(filepath) {
1610
1613
  return import(filepath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",