vite 4.4.10 → 4.5.0

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.

@@ -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-bb8a8339.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -11982,7 +11982,7 @@ const dataUrlRE = /^\s*data:/i;
11982
11982
  const isDataUrl = (url) => dataUrlRE.test(url);
11983
11983
  const virtualModuleRE = /^virtual-module:.*/;
11984
11984
  const virtualModulePrefix = 'virtual-module:';
11985
- const knownJsSrcRE = /\.(?:[jt]sx?|m[jt]s|vue|marko|svelte|astro|imba)(?:$|\?)/;
11985
+ const knownJsSrcRE = /\.(?:[jt]sx?|m[jt]s|vue|marko|svelte|astro|imba|mdx)(?:$|\?)/;
11986
11986
  const isJSRequest = (url) => {
11987
11987
  url = cleanUrl(url);
11988
11988
  if (knownJsSrcRE.test(url)) {
@@ -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;
@@ -28078,10 +28068,15 @@ function resolvePlugin(resolveOptions) {
28078
28068
  const targetWeb = !ssr || ssrTarget === 'webworker';
28079
28069
  // this is passed by @rollup/plugin-commonjs
28080
28070
  const isRequire = resolveOpts?.custom?.['node-resolve']?.isRequire ?? false;
28071
+ // end user can configure different conditions for ssr and client.
28072
+ // falls back to client conditions if no ssr conditions supplied
28073
+ const ssrConditions = resolveOptions.ssrConfig?.resolve?.conditions ||
28074
+ resolveOptions.conditions;
28081
28075
  const options = {
28082
28076
  isRequire,
28083
28077
  ...resolveOptions,
28084
28078
  scan: resolveOpts?.scan ?? resolveOptions.scan,
28079
+ conditions: ssr ? ssrConditions : resolveOptions.conditions,
28085
28080
  };
28086
28081
  const resolvedImports = resolveSubpathImports(id, importer, options, targetWeb);
28087
28082
  if (resolvedImports) {
@@ -38999,8 +38994,8 @@ function createCachedImport(imp) {
38999
38994
  return cached;
39000
38995
  };
39001
38996
  }
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; }));
38997
+ const importPostcssImport = createCachedImport(() => import('./dep-e4a495ce.js').then(function (n) { return n.i; }));
38998
+ const importPostcssModules = createCachedImport(() => import('./dep-98d4beff.js').then(function (n) { return n.i; }));
39004
38999
  const importPostcss = createCachedImport(() => import('postcss'));
39005
39000
  /**
39006
39001
  * @experimental
@@ -40138,11 +40133,13 @@ function createIsConfiguredAsSsrExternal(config) {
40138
40133
  const noExternalFilter = noExternal !== 'undefined' &&
40139
40134
  typeof noExternal !== 'boolean' &&
40140
40135
  createFilter(undefined, noExternal, { resolve: false });
40136
+ const targetConditions = config.ssr.resolve?.externalConditions || [];
40141
40137
  const resolveOptions = {
40142
40138
  ...config.resolve,
40143
40139
  root,
40144
40140
  isProduction: false,
40145
40141
  isBuild: true,
40142
+ conditions: targetConditions,
40146
40143
  };
40147
40144
  const isExternalizable = (id, importer, configuredAsExternal) => {
40148
40145
  if (!bareImportRE.test(id) || id.includes('\0')) {
@@ -44892,7 +44889,11 @@ function shouldExternalizeDep(resolvedId, rawId) {
44892
44889
  return false;
44893
44890
  }
44894
44891
  function isScannable(id) {
44895
- return JS_TYPES_RE.test(id) || htmlTypesRE.test(id);
44892
+ // From Vite 5, all optimizeDeps.extensions are scannable. We hardcode .marko for 4.5.0 to avoid
44893
+ // potential regressions. See https://github.com/vitejs/vite/pull/14543
44894
+ return (JS_TYPES_RE.test(id) ||
44895
+ htmlTypesRE.test(id) ||
44896
+ path$o.extname(id) === '.marko');
44896
44897
  }
44897
44898
  // esbuild v0.18 only transforms decorators when `experimentalDecorators` is set to `true`.
44898
44899
  // To preserve compat with the esbuild breaking change, we set `experimentalDecorators` to
@@ -55965,18 +55966,20 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
55965
55966
  };
55966
55967
  urlStack = urlStack.concat(url);
55967
55968
  const isCircular = (url) => urlStack.includes(url);
55968
- const { isProduction, resolve: { dedupe, preserveSymlinks }, root, } = server.config;
55969
+ const { isProduction, resolve: { dedupe, preserveSymlinks }, root, ssr, } = server.config;
55970
+ const overrideConditions = ssr.resolve?.externalConditions || [];
55969
55971
  const resolveOptions = {
55970
55972
  mainFields: ['main'],
55971
55973
  browserField: true,
55972
55974
  conditions: [],
55973
- overrideConditions: ['production', 'development'],
55975
+ overrideConditions: [...overrideConditions, 'production', 'development'],
55974
55976
  extensions: ['.js', '.cjs', '.json'],
55975
55977
  dedupe,
55976
55978
  preserveSymlinks,
55977
55979
  isBuild: false,
55978
55980
  isProduction,
55979
55981
  root,
55982
+ ssrConfig: ssr,
55980
55983
  };
55981
55984
  // Since dynamic imports can happen in parallel, we need to
55982
55985
  // account for multiple pending deps and duplicate imports.
@@ -56080,7 +56083,7 @@ async function nodeImport(id, importer, resolveOptions) {
56080
56083
  // @ts-expect-error jest only exists when running Jest
56081
56084
  typeof jest === 'undefined'
56082
56085
  ? { ...resolveOptions, tryEsmOnly: true }
56083
- : resolveOptions, false);
56086
+ : resolveOptions, false, undefined, true);
56084
56087
  if (!resolved) {
56085
56088
  const err = new Error(`Cannot find module '${id}' imported from '${importer}'`);
56086
56089
  err.code = 'ERR_MODULE_NOT_FOUND';
@@ -1,4 +1,4 @@
1
- import { E as getDefaultExportFromCjs } from './dep-3bba9c7e.js';
1
+ import { E as getDefaultExportFromCjs } from './dep-bb8a8339.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';
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-bb8a8339.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-bb8a8339.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-bb8a8339.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-bb8a8339.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-bb8a8339.js').then(function (n) { return n.J; });
895
895
  try {
896
896
  const server = await preview({
897
897
  root,
@@ -2269,6 +2269,22 @@ export declare interface SSROptions {
2269
2269
  * @experimental
2270
2270
  */
2271
2271
  optimizeDeps?: SsrDepOptimizationOptions;
2272
+ resolve?: {
2273
+ /**
2274
+ * Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
2275
+ *
2276
+ * Use this to override the default ssr conditions for the ssr build.
2277
+ *
2278
+ * @default rootConfig.resolve.conditions
2279
+ */
2280
+ conditions?: string[];
2281
+ /**
2282
+ * Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
2283
+ *
2284
+ * @default []
2285
+ */
2286
+ externalConditions?: string[];
2287
+ };
2272
2288
  }
2273
2289
 
2274
2290
  export declare type SSRTarget = 'node' | 'webworker';
@@ -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-bb8a8339.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-bb8a8339.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.5.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",