vite 5.0.10 → 5.1.0-beta.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.
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 { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-R0I0XnyH.js';
5
+ import { y as colors, q as createLogger, r as resolveConfig } from './chunks/dep-7tgnmQn7.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -759,7 +759,7 @@ cli
759
759
  filterDuplicateOptions(options);
760
760
  // output structure is preserved even after bundling so require()
761
761
  // is ok here
762
- const { createServer } = await import('./chunks/dep-R0I0XnyH.js').then(function (n) { return n.A; });
762
+ const { createServer } = await import('./chunks/dep-7tgnmQn7.js').then(function (n) { return n.B; });
763
763
  try {
764
764
  const server = await createServer({
765
765
  root,
@@ -839,7 +839,7 @@ cli
839
839
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
840
840
  .action(async (root, options) => {
841
841
  filterDuplicateOptions(options);
842
- const { build } = await import('./chunks/dep-R0I0XnyH.js').then(function (n) { return n.C; });
842
+ const { build } = await import('./chunks/dep-7tgnmQn7.js').then(function (n) { return n.D; });
843
843
  const buildOptions = cleanOptions(options);
844
844
  try {
845
845
  await build({
@@ -867,7 +867,7 @@ cli
867
867
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
868
868
  .action(async (root, options) => {
869
869
  filterDuplicateOptions(options);
870
- const { optimizeDeps } = await import('./chunks/dep-R0I0XnyH.js').then(function (n) { return n.B; });
870
+ const { optimizeDeps } = await import('./chunks/dep-7tgnmQn7.js').then(function (n) { return n.C; });
871
871
  try {
872
872
  const config = await resolveConfig({
873
873
  root,
@@ -893,7 +893,7 @@ cli
893
893
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
894
894
  .action(async (root, options) => {
895
895
  filterDuplicateOptions(options);
896
- const { preview } = await import('./chunks/dep-R0I0XnyH.js').then(function (n) { return n.D; });
896
+ const { preview } = await import('./chunks/dep-7tgnmQn7.js').then(function (n) { return n.E; });
897
897
  try {
898
898
  const server = await preview({
899
899
  root,
@@ -98,6 +98,8 @@ const KNOWN_ASSET_TYPES = [
98
98
  'aac',
99
99
  'opus',
100
100
  'mov',
101
+ 'm4a',
102
+ 'vtt',
101
103
  // fonts
102
104
  'woff2?',
103
105
  'eot',
@@ -123,5 +125,7 @@ const wildcardHosts = new Set([
123
125
  ]);
124
126
  const DEFAULT_DEV_PORT = 5173;
125
127
  const DEFAULT_PREVIEW_PORT = 4173;
128
+ const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
129
+ const METADATA_FILENAME = '_metadata.json';
126
130
 
127
- export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
131
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
@@ -2240,7 +2240,7 @@ interface BuildOptions {
2240
2240
  * base64 strings. Default limit is `4096` (4 KiB). Set to `0` to disable.
2241
2241
  * @default 4096
2242
2242
  */
2243
- assetsInlineLimit?: number;
2243
+ assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
2244
2244
  /**
2245
2245
  * Whether to code-split CSS. When enabled, CSS in async chunks will be
2246
2246
  * inlined as strings in the chunk and inserted via dynamically created
@@ -2613,7 +2613,7 @@ type SSRTarget = 'node' | 'webworker';
2613
2613
  type SsrDepOptimizationOptions = DepOptimizationConfig;
2614
2614
  interface SSROptions {
2615
2615
  noExternal?: string | RegExp | (string | RegExp)[] | true;
2616
- external?: string[];
2616
+ external?: string[] | true;
2617
2617
  /**
2618
2618
  * Define the target for the ssr build. The browser field in package.json
2619
2619
  * is ignored for node but used if webworker is the target
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules } from './chunks/dep-R0I0XnyH.js';
3
- export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-R0I0XnyH.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-7tgnmQn7.js';
3
+ export { b as build, g as buildErrorMessage, j as createFilter, q as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, v as isFileServingAllowed, l as loadConfigFromFile, w as loadEnv, h as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, x as resolveEnvPrefix, u as searchForWorkspaceRoot, k as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-7tgnmQn7.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  export { VERSION as rollupVersion } from 'rollup';
@@ -115,7 +115,7 @@ function splitVendorChunkPlugin() {
115
115
  config(config) {
116
116
  let outputs = config?.build?.rollupOptions?.output;
117
117
  if (outputs) {
118
- outputs = Array.isArray(outputs) ? outputs : [outputs];
118
+ outputs = arraify(outputs);
119
119
  for (const output of outputs) {
120
120
  const viteManualChunks = createSplitVendorChunk(output, config);
121
121
  if (viteManualChunks) {
@@ -3658,7 +3658,7 @@ function splitVendorChunkPlugin() {
3658
3658
  config(config) {
3659
3659
  let outputs = config?.build?.rollupOptions?.output;
3660
3660
  if (outputs) {
3661
- outputs = Array.isArray(outputs) ? outputs : [outputs];
3661
+ outputs = arraify(outputs);
3662
3662
  for (const output of outputs) {
3663
3663
  const viteManualChunks = createSplitVendorChunk(output, config);
3664
3664
  if (viteManualChunks) {
@@ -5298,7 +5298,7 @@ const debug = createDebugger('vite:send', {
5298
5298
  onlyWhenFocused: true,
5299
5299
  });
5300
5300
  const alias = {
5301
- js: 'application/javascript',
5301
+ js: 'text/javascript',
5302
5302
  css: 'text/css',
5303
5303
  html: 'text/html',
5304
5304
  json: 'application/json',
@@ -5367,36 +5367,42 @@ function clearScreen() {
5367
5367
  readline.cursorTo(process.stdout, 0, 0);
5368
5368
  readline.clearScreenDown(process.stdout);
5369
5369
  }
5370
- function createLogger(level = 'info', options = {}) {
5371
- if (options.customLogger) {
5372
- return options.customLogger;
5373
- }
5374
- const timeFormatter = new Intl.DateTimeFormat(undefined, {
5370
+ // Only initialize the timeFormatter when the timestamp option is used, and
5371
+ // reuse it across all loggers
5372
+ let timeFormatter;
5373
+ function getTimeFormatter() {
5374
+ timeFormatter ??= new Intl.DateTimeFormat(undefined, {
5375
5375
  hour: 'numeric',
5376
5376
  minute: 'numeric',
5377
5377
  second: 'numeric',
5378
5378
  });
5379
+ return timeFormatter;
5380
+ }
5381
+ function createLogger(level = 'info', options = {}) {
5382
+ if (options.customLogger) {
5383
+ return options.customLogger;
5384
+ }
5379
5385
  const loggedErrors = new WeakSet();
5380
5386
  const { prefix = '[vite]', allowClearScreen = true } = options;
5381
5387
  const thresh = LogLevels[level];
5382
5388
  const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
5383
5389
  const clear = canClearScreen ? clearScreen : () => { };
5390
+ function format(type, msg, options = {}) {
5391
+ if (options.timestamp) {
5392
+ const tag = type === 'info'
5393
+ ? colors.cyan(colors.bold(prefix))
5394
+ : type === 'warn'
5395
+ ? colors.yellow(colors.bold(prefix))
5396
+ : colors.red(colors.bold(prefix));
5397
+ return `${colors.dim(getTimeFormatter().format(new Date()))} ${tag} ${msg}`;
5398
+ }
5399
+ else {
5400
+ return msg;
5401
+ }
5402
+ }
5384
5403
  function output(type, msg, options = {}) {
5385
5404
  if (thresh >= LogLevels[type]) {
5386
5405
  const method = type === 'info' ? 'log' : type;
5387
- const format = () => {
5388
- if (options.timestamp) {
5389
- const tag = type === 'info'
5390
- ? colors.cyan(colors.bold(prefix))
5391
- : type === 'warn'
5392
- ? colors.yellow(colors.bold(prefix))
5393
- : colors.red(colors.bold(prefix));
5394
- return `${colors.dim(timeFormatter.format(new Date()))} ${tag} ${msg}`;
5395
- }
5396
- else {
5397
- return msg;
5398
- }
5399
- };
5400
5406
  if (options.error) {
5401
5407
  loggedErrors.add(options.error);
5402
5408
  }
@@ -5404,7 +5410,7 @@ function createLogger(level = 'info', options = {}) {
5404
5410
  if (type === lastType && msg === lastMsg) {
5405
5411
  sameCount++;
5406
5412
  clear();
5407
- console[method](format(), colors.yellow(`(x${sameCount + 1})`));
5413
+ console[method](format(type, msg, options), colors.yellow(`(x${sameCount + 1})`));
5408
5414
  }
5409
5415
  else {
5410
5416
  sameCount = 0;
@@ -5413,11 +5419,11 @@ function createLogger(level = 'info', options = {}) {
5413
5419
  if (options.clear) {
5414
5420
  clear();
5415
5421
  }
5416
- console[method](format());
5422
+ console[method](format(type, msg, options));
5417
5423
  }
5418
5424
  }
5419
5425
  else {
5420
- console[method](format());
5426
+ console[method](format(type, msg, options));
5421
5427
  }
5422
5428
  }
5423
5429
  }
@@ -6008,13 +6014,13 @@ function expand (config) {
6008
6014
 
6009
6015
  var expand_1 = expand;
6010
6016
 
6011
- function getEnvFilesForMode(mode) {
6017
+ function getEnvFilesForMode(mode, envDir) {
6012
6018
  return [
6013
6019
  /** default file */ `.env`,
6014
6020
  /** local file */ `.env.local`,
6015
6021
  /** mode file */ `.env.${mode}`,
6016
6022
  /** mode local file */ `.env.${mode}.local`,
6017
- ];
6023
+ ].map((file) => path$3.join(envDir, file));
6018
6024
  }
6019
6025
  function loadEnv(mode, envDir, prefixes = 'VITE_') {
6020
6026
  if (mode === 'local') {
@@ -6023,9 +6029,8 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
6023
6029
  }
6024
6030
  prefixes = arraify(prefixes);
6025
6031
  const env = {};
6026
- const envFiles = getEnvFilesForMode(mode);
6027
- const parsed = Object.fromEntries(envFiles.flatMap((file) => {
6028
- const filePath = path$3.join(envDir, file);
6032
+ const envFiles = getEnvFilesForMode(mode, envDir);
6033
+ const parsed = Object.fromEntries(envFiles.flatMap((filePath) => {
6029
6034
  if (!tryStatSync(filePath)?.isFile())
6030
6035
  return [];
6031
6036
  return Object.entries(parse_1(fs$1.readFileSync(filePath)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.10",
3
+ "version": "5.1.0-beta.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -62,7 +62,7 @@
62
62
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
63
63
  "dependencies": {
64
64
  "esbuild": "^0.19.3",
65
- "postcss": "^8.4.32",
65
+ "postcss": "^8.4.33",
66
66
  "rollup": "^4.2.0"
67
67
  },
68
68
  "optionalDependencies": {
@@ -75,13 +75,13 @@
75
75
  "@rollup/plugin-alias": "^5.1.0",
76
76
  "@rollup/plugin-commonjs": "^25.0.7",
77
77
  "@rollup/plugin-dynamic-import-vars": "^2.1.2",
78
- "@rollup/plugin-json": "^6.0.1",
78
+ "@rollup/plugin-json": "^6.1.0",
79
79
  "@rollup/plugin-node-resolve": "15.2.3",
80
- "@rollup/plugin-typescript": "^11.1.5",
80
+ "@rollup/plugin-typescript": "^11.1.6",
81
81
  "@rollup/pluginutils": "^5.1.0",
82
82
  "@types/escape-html": "^1.0.4",
83
83
  "@types/pnpapi": "^0.0.5",
84
- "acorn": "^8.11.2",
84
+ "acorn": "^8.11.3",
85
85
  "acorn-walk": "^8.3.1",
86
86
  "cac": "^6.7.14",
87
87
  "chokidar": "^3.5.3",
@@ -99,34 +99,33 @@
99
99
  "etag": "^1.8.1",
100
100
  "fast-glob": "^3.3.2",
101
101
  "http-proxy": "^1.18.1",
102
- "json-stable-stringify": "^1.1.0",
103
102
  "launch-editor-middleware": "^2.6.1",
104
103
  "lightningcss": "^1.22.1",
105
104
  "magic-string": "^0.30.5",
106
105
  "micromatch": "^4.0.5",
107
106
  "mlly": "^1.4.2",
108
- "mrmime": "^1.0.1",
107
+ "mrmime": "^2.0.0",
109
108
  "okie": "^1.0.1",
110
109
  "open": "^8.4.2",
111
110
  "parse5": "^7.1.2",
112
111
  "periscopic": "^4.0.2",
113
112
  "picocolors": "^1.0.0",
114
113
  "picomatch": "^2.3.1",
115
- "postcss-import": "^15.1.0",
114
+ "postcss-import": "^16.0.0",
116
115
  "postcss-load-config": "^4.0.2",
117
116
  "postcss-modules": "^6.0.0",
118
117
  "resolve.exports": "^2.0.2",
119
118
  "rollup-plugin-dts": "^6.1.0",
120
119
  "rollup-plugin-license": "^3.2.0",
121
- "sirv": "^2.0.3",
120
+ "sirv": "^2.0.4",
122
121
  "source-map-support": "^0.5.21",
123
122
  "strip-ansi": "^7.1.0",
124
- "strip-literal": "^1.3.0",
125
- "tsconfck": "^3.0.0",
123
+ "strip-literal": "^2.0.0",
124
+ "tsconfck": "^3.0.1",
126
125
  "tslib": "^2.6.2",
127
126
  "types": "link:./types",
128
127
  "ufo": "^1.3.2",
129
- "ws": "^8.15.0"
128
+ "ws": "^8.16.0"
130
129
  },
131
130
  "peerDependencies": {
132
131
  "@types/node": "^18.0.0 || >=20.0.0",
@@ -20,10 +20,10 @@ export interface Update {
20
20
  path: string
21
21
  acceptedPath: string
22
22
  timestamp: number
23
- /**
24
- * @experimental internal
25
- */
26
- explicitImportRequired?: boolean | undefined
23
+ /** @internal */
24
+ explicitImportRequired: boolean
25
+ /** @internal */
26
+ isWithinCircularImport: boolean
27
27
  }
28
28
 
29
29
  export interface PrunePayload {
@@ -4,6 +4,8 @@ export interface ImportGlobOptions<
4
4
  > {
5
5
  /**
6
6
  * Import type for the import url.
7
+ *
8
+ * @deprecated Use `query` instead, e.g. `as: 'url'` -> `query: '?url', import: 'default'`
7
9
  */
8
10
  as?: AsType
9
11
  /**