vite 4.4.10 → 4.4.12

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.

@@ -13819,8 +13819,8 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
13819
13819
  }
13820
13820
 
13821
13821
  const debug$f = createDebugger('vite:esbuild');
13822
- // IIFE content looks like `var MyLib = function() {`. Spaces are removed when minified
13823
- const IIFE_BEGIN_RE = /(const|var)\s+\S+\s*=\s*function\(\)\s*\{.*"use strict";/s;
13822
+ const INJECT_HELPERS_IIFE_RE = /^(.*?)((?:const|var)\s+\S+\s*=\s*function\s*\([^)]*\)\s*\{\s*"use strict";)/s;
13823
+ const INJECT_HELPERS_UMD_RE = /^(.*?)(\(function\([^)]*\)\s*\{.+?amd.+?function\([^)]*\)\s*\{\s*"use strict";)/s;
13824
13824
  const validExtensionRE = /\.\w+$/;
13825
13825
  const jsxExtensionsRE = /\.(?:j|t)sx\b/;
13826
13826
  let server;
@@ -14053,26 +14053,16 @@ const buildEsbuildPlugin = (config) => {
14053
14053
  if (config.build.lib) {
14054
14054
  // #7188, esbuild adds helpers out of the UMD and IIFE wrappers, and the
14055
14055
  // names are minified potentially causing collision with other globals.
14056
- // We inject the helpers inside the wrappers.
14057
- // e.g. turn:
14058
- // <esbuild helpers> (function(){ /*actual content/* })()
14059
- // into:
14060
- // (function(){ <esbuild helpers> /*actual content/* })()
14061
- // Not using regex because it's too hard to rule out performance issues like #8738 #8099 #10900 #14065
14062
- // Instead, using plain string index manipulation (indexOf, slice) which is simple and performant
14056
+ // We use a regex to inject the helpers inside the wrappers.
14063
14057
  // We don't need to create a MagicString here because both the helpers and
14064
14058
  // the headers don't modify the sourcemap
14065
- const esbuildCode = res.code;
14066
- const contentIndex = opts.format === 'iife'
14067
- ? esbuildCode.match(IIFE_BEGIN_RE)?.index || 0
14068
- : opts.format === 'umd'
14069
- ? esbuildCode.indexOf(`(function(`) // same for minified or not
14070
- : 0;
14071
- if (contentIndex > 0) {
14072
- const esbuildHelpers = esbuildCode.slice(0, contentIndex);
14073
- res.code = esbuildCode
14074
- .slice(contentIndex)
14075
- .replace(`"use strict";`, `"use strict";` + esbuildHelpers);
14059
+ const injectHelpers = opts.format === 'umd'
14060
+ ? INJECT_HELPERS_UMD_RE
14061
+ : opts.format === 'iife'
14062
+ ? INJECT_HELPERS_IIFE_RE
14063
+ : undefined;
14064
+ if (injectHelpers) {
14065
+ res.code = res.code.replace(injectHelpers, (_, helpers, header) => header + helpers);
14076
14066
  }
14077
14067
  }
14078
14068
  return res;
@@ -38999,8 +38989,8 @@ function createCachedImport(imp) {
38999
38989
  return cached;
39000
38990
  };
39001
38991
  }
39002
- const importPostcssImport = createCachedImport(() => import('./dep-fdea5ef1.js').then(function (n) { return n.i; }));
39003
- const importPostcssModules = createCachedImport(() => import('./dep-809640fa.js').then(function (n) { return n.i; }));
38992
+ const importPostcssImport = createCachedImport(() => import('./dep-2bac6217.js').then(function (n) { return n.i; }));
38993
+ const importPostcssModules = createCachedImport(() => import('./dep-cadf9240.js').then(function (n) { return n.i; }));
39004
38994
  const importPostcss = createCachedImport(() => import('postcss'));
39005
38995
  /**
39006
38996
  * @experimental
@@ -64565,7 +64555,6 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
64565
64555
  const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
64566
64556
  const { config, moduleGraph, watcher } = server;
64567
64557
  const base = config.base || '/';
64568
- htmlPath = decodeURI(htmlPath);
64569
64558
  let proxyModulePath;
64570
64559
  let proxyModuleUrl;
64571
64560
  const trailingSlash = htmlPath.endsWith('/');
@@ -64585,7 +64574,9 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
64585
64574
  }
64586
64575
  const s = new MagicString(html);
64587
64576
  let inlineModuleIndex = -1;
64588
- const proxyCacheUrl = cleanUrl(proxyModulePath).replace(normalizePath$3(config.root), '');
64577
+ // The key to the proxyHtml cache is decoded, as it will be compared
64578
+ // against decoded URLs by the HTML plugins.
64579
+ const proxyCacheUrl = decodeURI(cleanUrl(proxyModulePath).replace(normalizePath$3(config.root), ''));
64589
64580
  const styleUrl = [];
64590
64581
  const addInlineModule = (node, ext) => {
64591
64582
  inlineModuleIndex++;
@@ -64708,7 +64699,13 @@ function indexHtmlMiddleware(server) {
64708
64699
  function preTransformRequest(server, url, base) {
64709
64700
  if (!server.config.server.preTransformRequests)
64710
64701
  return;
64711
- url = unwrapId(stripBase(url, base));
64702
+ try {
64703
+ url = unwrapId(stripBase(decodeURI(url), base));
64704
+ }
64705
+ catch {
64706
+ // ignore
64707
+ return;
64708
+ }
64712
64709
  // transform all url as non-ssr as html includes client-side assets only
64713
64710
  server.transformRequest(url).catch((e) => {
64714
64711
  if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP ||
@@ -1,4 +1,4 @@
1
- import { E as getDefaultExportFromCjs } from './dep-3bba9c7e.js';
1
+ import { E as getDefaultExportFromCjs } from './dep-063880ad.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-c423598f.js';
@@ -1,4 +1,4 @@
1
- import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-3bba9c7e.js';
1
+ import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-063880ad.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
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, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-3bba9c7e.js';
5
+ import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-063880ad.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -758,7 +758,7 @@ cli
758
758
  filterDuplicateOptions(options);
759
759
  // output structure is preserved even after bundling so require()
760
760
  // is ok here
761
- const { createServer } = await import('./chunks/dep-3bba9c7e.js').then(function (n) { return n.I; });
761
+ const { createServer } = await import('./chunks/dep-063880ad.js').then(function (n) { return n.I; });
762
762
  try {
763
763
  const server = await createServer({
764
764
  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-3bba9c7e.js').then(function (n) { return n.H; });
839
+ const { build } = await import('./chunks/dep-063880ad.js').then(function (n) { return n.H; });
840
840
  const buildOptions = cleanOptions(options);
841
841
  try {
842
842
  await build({
@@ -864,7 +864,7 @@ cli
864
864
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
865
865
  .action(async (root, options) => {
866
866
  filterDuplicateOptions(options);
867
- const { optimizeDeps } = await import('./chunks/dep-3bba9c7e.js').then(function (n) { return n.G; });
867
+ const { optimizeDeps } = await import('./chunks/dep-063880ad.js').then(function (n) { return n.G; });
868
868
  try {
869
869
  const config = await resolveConfig({
870
870
  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-3bba9c7e.js').then(function (n) { return n.J; });
894
+ const { preview } = await import('./chunks/dep-063880ad.js').then(function (n) { return n.J; });
895
895
  try {
896
896
  const server = await preview({
897
897
  root,
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-3bba9c7e.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-3bba9c7e.js';
1
+ import { i as isInNodeModules } from './chunks/dep-063880ad.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-063880ad.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.4.10",
3
+ "version": "4.4.12",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",