vite 5.2.12 → 5.2.14

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-BKbDVx1T.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-p3C6MpSJ.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-BKbDVx1T.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-p3C6MpSJ.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-IQS-Za7F.js';
@@ -31506,6 +31506,7 @@ function getAttrSourceCodeLocation(node, attrKey) {
31506
31506
  return node.sourceCodeLocation.attrs[attrKey];
31507
31507
  }
31508
31508
 
31509
+ const decoder = new TextDecoder();
31509
31510
  function resolveCSSOptions(options) {
31510
31511
  if (options?.transformer === 'lightningcss') {
31511
31512
  return {
@@ -32413,8 +32414,8 @@ function createCachedImport(imp) {
32413
32414
  return cached;
32414
32415
  };
32415
32416
  }
32416
- const importPostcssImport = createCachedImport(() => import('./dep-BjBhdnU2.js').then(function (n) { return n.i; }));
32417
- const importPostcssModules = createCachedImport(() => import('./dep-Cf9MWKOi.js').then(function (n) { return n.i; }));
32417
+ const importPostcssImport = createCachedImport(() => import('./dep-DnKw-oY6.js').then(function (n) { return n.i; }));
32418
+ const importPostcssModules = createCachedImport(() => import('./dep-5EEx826O.js').then(function (n) { return n.i; }));
32418
32419
  const importPostcss = createCachedImport(() => import('postcss'));
32419
32420
  const preprocessorWorkerControllerCache = new WeakMap();
32420
32421
  let alwaysFakeWorkerWorkerControllerCache;
@@ -32655,8 +32656,11 @@ async function minifyCSS(css, config, inlined) {
32655
32656
  .map((w) => w.message)
32656
32657
  .join('\n')}`));
32657
32658
  }
32659
+ // NodeJS res.code = Buffer
32660
+ // Deno res.code = Uint8Array
32661
+ // For correct decode compiled css need to use TextDecoder
32658
32662
  // LightningCSS output does not return a linebreak at the end
32659
- return code.toString() + (inlined ? '' : '\n');
32663
+ return decoder.decode(code) + (inlined ? '' : '\n');
32660
32664
  }
32661
32665
  try {
32662
32666
  const { code, warnings } = await transform$2(css, {
@@ -33256,7 +33260,6 @@ function isPreProcessor(lang) {
33256
33260
  return lang && preprocessorSet.has(lang);
33257
33261
  }
33258
33262
  const importLightningCSS = createCachedImport(() => import('lightningcss'));
33259
- const decoder = new TextDecoder();
33260
33263
  async function compileLightningCSS(id, src, config, urlReplacer) {
33261
33264
  const deps = new Set();
33262
33265
  // Relative path is needed to get stable hash when using CSS modules
@@ -33322,6 +33325,9 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
33322
33325
  const replaceUrl = await urlReplacer(dep.url, id);
33323
33326
  css = css.replace(dep.placeholder, () => replaceUrl);
33324
33327
  }
33328
+ else {
33329
+ css = css.replace(dep.placeholder, () => dep.url);
33330
+ }
33325
33331
  break;
33326
33332
  default:
33327
33333
  throw new Error(`Unsupported dependency type: ${dep.type}`);
@@ -64883,6 +64889,10 @@ function transformMiddleware(server) {
64883
64889
  if (publicDirInRoot && url.startsWith(publicPath)) {
64884
64890
  warnAboutExplicitPublicPathInUrl(url);
64885
64891
  }
64892
+ if ((rawRE.test(url) || urlRE.test(url)) &&
64893
+ !ensureServingAccess(url, server, res, next)) {
64894
+ return;
64895
+ }
64886
64896
  if (isJSRequest(url) ||
64887
64897
  isImportRequest(url) ||
64888
64898
  isCSSRequest(url) ||
@@ -68012,7 +68022,54 @@ function buildImportAnalysisPlugin(config) {
68012
68022
  return null;
68013
68023
  },
68014
68024
  generateBundle({ format }, bundle) {
68015
- if (format !== 'es' || ssr || isWorker) {
68025
+ if (format !== 'es') {
68026
+ return;
68027
+ }
68028
+ if (ssr || isWorker) {
68029
+ const removedPureCssFiles = removedPureCssFilesCache.get(config);
68030
+ if (removedPureCssFiles && removedPureCssFiles.size > 0) {
68031
+ for (const file in bundle) {
68032
+ const chunk = bundle[file];
68033
+ if (chunk.type === 'chunk' && chunk.code.includes('import')) {
68034
+ const code = chunk.code;
68035
+ let imports;
68036
+ try {
68037
+ imports = parse$g(code)[0].filter((i) => i.d > -1);
68038
+ }
68039
+ catch (e) {
68040
+ const loc = numberToPos(code, e.idx);
68041
+ this.error({
68042
+ name: e.name,
68043
+ message: e.message,
68044
+ stack: e.stack,
68045
+ cause: e.cause,
68046
+ pos: e.idx,
68047
+ loc: { ...loc, file: chunk.fileName },
68048
+ frame: generateCodeFrame(code, loc),
68049
+ });
68050
+ }
68051
+ for (const imp of imports) {
68052
+ const { n: name, s: start, e: end, ss: expStart, se: expEnd, } = imp;
68053
+ let url = name;
68054
+ if (!url) {
68055
+ const rawUrl = code.slice(start, end);
68056
+ if (rawUrl[0] === `"` && rawUrl[rawUrl.length - 1] === `"`)
68057
+ url = rawUrl.slice(1, -1);
68058
+ }
68059
+ if (!url)
68060
+ continue;
68061
+ const normalizedFile = path$o.posix.join(path$o.posix.dirname(chunk.fileName), url);
68062
+ if (removedPureCssFiles.has(normalizedFile)) {
68063
+ // remove with Promise.resolve({}) while preserving source map location
68064
+ chunk.code =
68065
+ chunk.code.slice(0, expStart) +
68066
+ `Promise.resolve({${''.padEnd(expEnd - expStart - 19, ' ')}})` +
68067
+ chunk.code.slice(expEnd);
68068
+ }
68069
+ }
68070
+ }
68071
+ }
68072
+ }
68016
68073
  return;
68017
68074
  }
68018
68075
  for (const file in bundle) {
@@ -68950,7 +69007,7 @@ function escapeId(id) {
68950
69007
  return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
68951
69008
  }
68952
69009
  const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
68953
- const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(partialEncodeURIPath(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
69010
+ const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(partialEncodeURIPath(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI`);
68954
69011
  const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
68955
69012
  const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
68956
69013
  const relativeUrlMechanisms = {
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 { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-BKbDVx1T.js';
5
+ import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-p3C6MpSJ.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-BKbDVx1T.js').then(function (n) { return n.E; });
760
+ const { createServer } = await import('./chunks/dep-p3C6MpSJ.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-BKbDVx1T.js').then(function (n) { return n.F; });
839
+ const { build } = await import('./chunks/dep-p3C6MpSJ.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-BKbDVx1T.js').then(function (n) { return n.D; });
866
+ const { optimizeDeps } = await import('./chunks/dep-p3C6MpSJ.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-BKbDVx1T.js').then(function (n) { return n.G; });
892
+ const { preview } = await import('./chunks/dep-p3C6MpSJ.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, a as arraify } from './chunks/dep-BKbDVx1T.js';
3
- export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BKbDVx1T.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-p3C6MpSJ.js';
3
+ export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-p3C6MpSJ.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.2.12",
3
+ "version": "5.2.14",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",