vite 8.1.2 → 8.1.4

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 { H as __require, z as __commonJSMin } from "./logger.js";
1
+ import { ft as __commonJSMin, pt as __require } from "./node.js";
2
2
  import { t as require_lib } from "./lib.js";
3
3
  //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.16/node_modules/postcss-import/lib/format-import-prelude.js
4
4
  var require_format_import_prelude = /* @__PURE__ */ __commonJSMin(((exports, module) => {
package/dist/node/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { N as VERSION, R as require_picocolors, W as __toESM, n as createLogger } from "./chunks/logger.js";
1
+ import { E as createBuilder, J as createLogger, dt as require_picocolors, lt as VERSION, mt as __toESM } from "./chunks/node.js";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { inspect } from "node:util";
@@ -703,7 +703,7 @@ const convertBase = (v) => {
703
703
  cli.option("-c, --config <file>", `[string] use specified config file`).option("--base <path>", `[string] public base path (default: /)`, { type: [convertBase] }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("--configLoader <loader>", `[string] use 'bundle' to bundle the config with Rolldown, or 'runner' (experimental) to process it on the fly, or 'native' (experimental) to load using the native runtime (default: bundle)`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
704
704
  cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--open [path]", `[boolean | string] open browser on startup`).option("--cors", `[boolean] enable CORS`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--force", `[boolean] force the optimizer to ignore the cache and re-bundle`).option("--experimentalBundle", `[boolean] use experimental full bundle mode (this is highly experimental)`).action(async (root, options) => {
705
705
  filterDuplicateOptions(options);
706
- const { createServer } = await import("./chunks/node.js").then((n) => n.M);
706
+ const { createServer } = await import("./chunks/node.js").then((n) => n.j);
707
707
  try {
708
708
  const server = await createServer({
709
709
  root,
@@ -760,7 +760,6 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
760
760
  });
761
761
  cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'baseline-widely-available')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option("--assetsDir <dir>", `[string] directory under outDir to place assets in (default: assets)`).option("--assetsInlineLimit <number>", `[number] static asset base64 inline threshold in bytes (default: 4096)`).option("--ssr [entry]", `[string] build specified entry for server-side rendering`).option("--sourcemap [output]", `[boolean | "inline" | "hidden"] output source maps for build (default: false)`).option("--minify [minifier]", "[boolean | \"oxc\" | \"terser\" | \"esbuild\"] enable/disable minification, or specify minifier to use (default: oxc)").option("--manifest [name]", `[boolean | string] emit build manifest json`).option("--ssrManifest [name]", `[boolean | string] emit ssr manifest json`).option("--emptyOutDir", `[boolean] force empty outDir when it's outside of root`).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(async (root, options) => {
762
762
  filterDuplicateOptions(options);
763
- const { createBuilder } = await import("./chunks/node.js").then((n) => n.E);
764
763
  const buildOptions = cleanGlobalCLIOptions(cleanBuilderCLIOptions(options));
765
764
  try {
766
765
  const builder = await createBuilder({
@@ -786,7 +785,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
786
785
  cli.command("optimize [root]", "pre-bundle dependencies (deprecated, the pre-bundle process runs automatically and does not need to be called)").option("--force", `[boolean] force the optimizer to ignore the cache and re-bundle`).action(async (root, options) => {
787
786
  filterDuplicateOptions(options);
788
787
  const { resolveConfig } = await import("./chunks/node.js").then((n) => n.f);
789
- const { optimizeDeps } = await import("./chunks/node.js").then((n) => n.k);
788
+ const { optimizeDeps } = await import("./chunks/node.js").then((n) => n.O);
790
789
  try {
791
790
  await optimizeDeps(await resolveConfig({
792
791
  root,
@@ -31,7 +31,7 @@ import { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownA
31
31
 
32
32
  //#region \0rolldown/runtime.js
33
33
  //#endregion
34
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.3.3_typescript@6.0.3_vite@packages+vite/node_modules/@vitejs/devtools/dist/cli-commands.d.ts
34
+ //#region ../../node_modules/.pnpm/@vitejs+devtools@0.3.4_typescript@6.0.3_vite@packages+vite/node_modules/@vitejs/devtools/dist/cli-commands.d.ts
35
35
  //#region src/node/cli-commands.d.ts
36
36
  interface StartOptions {
37
37
  root?: string;
@@ -41,7 +41,7 @@ interface StartOptions {
41
41
  open?: boolean;
42
42
  }
43
43
  //#endregion
44
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.3.3_typescript@6.0.3_vite@packages+vite/node_modules/@vitejs/devtools/dist/config.d.ts
44
+ //#region ../../node_modules/.pnpm/@vitejs+devtools@0.3.4_typescript@6.0.3_vite@packages+vite/node_modules/@vitejs/devtools/dist/config.d.ts
45
45
  //#region src/node/config.d.ts
46
46
  interface DevToolsConfig extends Partial<StartOptions> {
47
47
  enabled: boolean;
@@ -666,7 +666,7 @@ interface CommonServerOptions {
666
666
  * Set to `true` to allow all methods from any origin, or configure separately
667
667
  * using an object.
668
668
  *
669
- * @default false
669
+ * @default { origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/ }
670
670
  */
671
671
  cors?: CorsOptions | boolean;
672
672
  /**
@@ -1,3 +1,2 @@
1
- import { F as defaultAllowedOrigins, N as VERSION, _ as DEFAULT_SERVER_CONDITIONS, d as DEFAULT_CLIENT_MAIN_FIELDS, h as DEFAULT_EXTERNAL_CONDITIONS, n as createLogger, u as DEFAULT_CLIENT_CONDITIONS, v as DEFAULT_SERVER_MAIN_FIELDS } from "./chunks/logger.js";
2
- import { $ as mergeConfig, A as createServerHotChannel, B as send, C as fetchModule, D as createBuilder, F as searchForWorkspaceRoot, G as loadEnv, H as createServerModuleRunner, I as createIdResolver, J as transformWithEsbuild, K as resolveEnvPrefix, L as perEnvironmentState, N as formatPostcssSourceMap, O as optimizeDeps, P as preprocessCSS, Q as mergeAlias, R as isFileLoadingAllowed, S as DevEnvironment, T as build, U as createServerModuleRunnerTransport, V as ssrTransform, W as buildErrorMessage, X as createFilter, Y as perEnvironmentPlugin, Z as isCSSRequest, _ as runnerImport, a as minifySync, b as createRunnableDevEnvironment, c as parseAstAsync, d as isFetchableDevEnvironment, et as normalizePath, g as sortUserPlugins, h as resolveConfig, i as minify, j as createServer, l as parseSync, m as loadConfigFromFile, n as esbuildVersion, nt as rollupVersion, o as parse, p as defineConfig, q as transformWithOxc, r as esmExternalRequirePlugin, rt as withFilter, s as parseAst, t as Visitor, tt as rolldownVersion, u as createFetchableDevEnvironment, v as preview, w as BuildEnvironment, x as isRunnableDevEnvironment, z as isFileServingAllowed } from "./chunks/node.js";
1
+ import { $ as mergeConfig, A as createServer, B as ssrTransform, C as fetchModule, D as optimizeDeps, E as createBuilder, F as createIdResolver, G as resolveEnvPrefix, H as createServerModuleRunnerTransport, I as perEnvironmentState, J as createLogger, K as transformWithOxc, L as isFileLoadingAllowed, M as formatPostcssSourceMap, N as preprocessCSS, P as searchForWorkspaceRoot, Q as mergeAlias, R as isFileServingAllowed, S as DevEnvironment, T as build, U as buildErrorMessage, V as createServerModuleRunner, W as loadEnv, X as createFilter, Y as perEnvironmentPlugin, Z as isCSSRequest, _ as runnerImport, a as minifySync, at as DEFAULT_CLIENT_MAIN_FIELDS, b as createRunnableDevEnvironment, c as parseAstAsync, ct as DEFAULT_SERVER_MAIN_FIELDS, d as isFetchableDevEnvironment, et as normalizePath, g as sortUserPlugins, h as resolveConfig, i as minify, it as DEFAULT_CLIENT_CONDITIONS, k as createServerHotChannel, l as parseSync, lt as VERSION, m as loadConfigFromFile, n as esbuildVersion, nt as rollupVersion, o as parse, ot as DEFAULT_EXTERNAL_CONDITIONS, p as defineConfig, q as transformWithEsbuild, r as esmExternalRequirePlugin, rt as withFilter, s as parseAst, st as DEFAULT_SERVER_CONDITIONS, t as Visitor, tt as rolldownVersion, u as createFetchableDevEnvironment, ut as defaultAllowedOrigins, v as preview, w as BuildEnvironment, x as isRunnableDevEnvironment, z as send } from "./chunks/node.js";
3
2
  export { BuildEnvironment, DevEnvironment, Visitor, build, buildErrorMessage, createBuilder, createFetchableDevEnvironment, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, createServerModuleRunnerTransport, defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_EXTERNAL_CONDITIONS as defaultExternalConditions, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, esbuildVersion, esmExternalRequirePlugin, fetchModule, formatPostcssSourceMap, isCSSRequest, isFetchableDevEnvironment, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, minify, minifySync, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, parse, parseAst, parseAstAsync, parseSync, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rolldownVersion, rollupVersion, runnerImport, searchForWorkspaceRoot, send, sortUserPlugins, transformWithEsbuild, transformWithOxc, VERSION as version, withFilter };
@@ -1001,9 +1001,9 @@ function enableSourceMapSupport(runner) {
1001
1001
  //#endregion
1002
1002
  //#region src/module-runner/esmEvaluator.ts
1003
1003
  var ESModulesEvaluator = class {
1004
- startOffset = getAsyncFunctionDeclarationPaddingLineCount();
1004
+ startOffset = getAsyncFunctionDeclarationPaddingLineCount() + 1;
1005
1005
  async runInlinedModule(context, code) {
1006
- await new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, "\"use strict\";" + code)(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);
1006
+ await new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, "\"use strict\";\n" + code)(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);
1007
1007
  }
1008
1008
  runExternalModule(filepath) {
1009
1009
  return import(filepath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.1.2",
3
+ "version": "8.1.4",
4
4
  "description": "Native-ESM powered web dev build tool",
5
5
  "keywords": [
6
6
  "build-tool",
@@ -57,9 +57,9 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "lightningcss": "^1.32.0",
60
- "picomatch": "^4.0.4",
60
+ "picomatch": "^4.0.5",
61
61
  "postcss": "^8.5.16",
62
- "rolldown": "~1.1.3",
62
+ "rolldown": "~1.1.4",
63
63
  "tinyglobby": "^0.2.17"
64
64
  },
65
65
  "devDependencies": {
@@ -73,11 +73,11 @@
73
73
  "@types/escape-html": "^1.0.4",
74
74
  "@types/pnpapi": "^0.0.5",
75
75
  "@vercel/detect-agent": "^1.2.3",
76
- "@vitejs/devtools": "^0.3.3",
76
+ "@vitejs/devtools": "^0.3.4",
77
77
  "@vitest/utils": "4.1.9",
78
78
  "@voidzero-dev/vite-task-client": "^0.2.0",
79
79
  "artichokie": "^0.4.4",
80
- "baseline-browser-mapping": "^2.10.40",
80
+ "baseline-browser-mapping": "^2.10.42",
81
81
  "cac": "^7.0.0",
82
82
  "chokidar": "^3.6.0",
83
83
  "connect": "^3.7.0",
@@ -85,7 +85,7 @@
85
85
  "cors": "^2.8.6",
86
86
  "cross-spawn": "^7.0.6",
87
87
  "dotenv-expand": "^13.0.0",
88
- "es-module-lexer": "2.1.0",
88
+ "es-module-lexer": "^2.3.0",
89
89
  "esbuild": "^0.28.1",
90
90
  "escape-html": "^1.0.3",
91
91
  "estree-walker": "^3.0.3",
@@ -106,7 +106,7 @@
106
106
  "picocolors": "^1.1.1",
107
107
  "postcss-import": "^16.1.1",
108
108
  "postcss-load-config": "^6.0.1",
109
- "postcss-modules": "^6.0.1",
109
+ "postcss-modules": "^9.0.0",
110
110
  "premove": "^4.0.0",
111
111
  "resolve.exports": "^2.0.3",
112
112
  "rolldown-plugin-dts": "^0.26.0",
@@ -1,364 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import { readFileSync } from "node:fs";
3
- import path, { resolve } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import readline from "node:readline";
6
- //#region \0rolldown/runtime.js
7
- var __create = Object.create;
8
- var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __getProtoOf = Object.getPrototypeOf;
12
- var __hasOwnProp = Object.prototype.hasOwnProperty;
13
- var __esmMin = (fn, res, err) => () => {
14
- if (err) throw err[0];
15
- try {
16
- return fn && (res = fn(fn = 0)), res;
17
- } catch (e) {
18
- throw err = [e], e;
19
- }
20
- };
21
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
22
- var __exportAll = (all, no_symbols) => {
23
- let target = {};
24
- for (var name in all) __defProp(target, name, {
25
- get: all[name],
26
- enumerable: true
27
- });
28
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
29
- return target;
30
- };
31
- var __copyProps = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
33
- key = keys[i];
34
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
35
- get: ((k) => from[k]).bind(null, key),
36
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
37
- });
38
- }
39
- return to;
40
- };
41
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
42
- value: mod,
43
- enumerable: true
44
- }) : target, mod));
45
- var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
47
- //#endregion
48
- //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
49
- var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50
- let p = process || {}, argv = p.argv || [], env = p.env || {};
51
- let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
52
- let formatter = (open, close, replace = open) => (input) => {
53
- let string = "" + input, index = string.indexOf(close, open.length);
54
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
55
- };
56
- let replaceClose = (string, close, replace, index) => {
57
- let result = "", cursor = 0;
58
- do {
59
- result += string.substring(cursor, index) + replace;
60
- cursor = index + close.length;
61
- index = string.indexOf(close, cursor);
62
- } while (~index);
63
- return result + string.substring(cursor);
64
- };
65
- let createColors = (enabled = isColorSupported) => {
66
- let f = enabled ? formatter : () => String;
67
- return {
68
- isColorSupported: enabled,
69
- reset: f("\x1B[0m", "\x1B[0m"),
70
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
71
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
72
- italic: f("\x1B[3m", "\x1B[23m"),
73
- underline: f("\x1B[4m", "\x1B[24m"),
74
- inverse: f("\x1B[7m", "\x1B[27m"),
75
- hidden: f("\x1B[8m", "\x1B[28m"),
76
- strikethrough: f("\x1B[9m", "\x1B[29m"),
77
- black: f("\x1B[30m", "\x1B[39m"),
78
- red: f("\x1B[31m", "\x1B[39m"),
79
- green: f("\x1B[32m", "\x1B[39m"),
80
- yellow: f("\x1B[33m", "\x1B[39m"),
81
- blue: f("\x1B[34m", "\x1B[39m"),
82
- magenta: f("\x1B[35m", "\x1B[39m"),
83
- cyan: f("\x1B[36m", "\x1B[39m"),
84
- white: f("\x1B[37m", "\x1B[39m"),
85
- gray: f("\x1B[90m", "\x1B[39m"),
86
- bgBlack: f("\x1B[40m", "\x1B[49m"),
87
- bgRed: f("\x1B[41m", "\x1B[49m"),
88
- bgGreen: f("\x1B[42m", "\x1B[49m"),
89
- bgYellow: f("\x1B[43m", "\x1B[49m"),
90
- bgBlue: f("\x1B[44m", "\x1B[49m"),
91
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
92
- bgCyan: f("\x1B[46m", "\x1B[49m"),
93
- bgWhite: f("\x1B[47m", "\x1B[49m"),
94
- blackBright: f("\x1B[90m", "\x1B[39m"),
95
- redBright: f("\x1B[91m", "\x1B[39m"),
96
- greenBright: f("\x1B[92m", "\x1B[39m"),
97
- yellowBright: f("\x1B[93m", "\x1B[39m"),
98
- blueBright: f("\x1B[94m", "\x1B[39m"),
99
- magentaBright: f("\x1B[95m", "\x1B[39m"),
100
- cyanBright: f("\x1B[96m", "\x1B[39m"),
101
- whiteBright: f("\x1B[97m", "\x1B[39m"),
102
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
103
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
104
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
105
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
106
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
107
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
108
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
109
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
110
- };
111
- };
112
- module.exports = createColors();
113
- module.exports.createColors = createColors;
114
- }));
115
- //#endregion
116
- //#region src/node/constants.ts
117
- const { version } = JSON.parse(readFileSync(new URL("../../package.json", new URL("../../../src/node/constants.ts", import.meta.url))).toString());
118
- const ROLLUP_HOOKS = [
119
- "options",
120
- "buildStart",
121
- "buildEnd",
122
- "renderStart",
123
- "renderError",
124
- "renderChunk",
125
- "writeBundle",
126
- "generateBundle",
127
- "banner",
128
- "footer",
129
- "augmentChunkHash",
130
- "outputOptions",
131
- "intro",
132
- "outro",
133
- "closeBundle",
134
- "closeWatcher",
135
- "load",
136
- "moduleParsed",
137
- "watchChange",
138
- "resolveDynamicImport",
139
- "resolveId",
140
- "transform",
141
- "onLog"
142
- ];
143
- const VERSION = version;
144
- const DEFAULT_MAIN_FIELDS = [
145
- "browser",
146
- "module",
147
- "jsnext:main",
148
- "jsnext"
149
- ];
150
- const DEFAULT_CLIENT_MAIN_FIELDS = Object.freeze(DEFAULT_MAIN_FIELDS);
151
- const DEFAULT_SERVER_MAIN_FIELDS = Object.freeze(DEFAULT_MAIN_FIELDS.filter((f) => f !== "browser"));
152
- /**
153
- * A special condition that would be replaced with production or development
154
- * depending on NODE_ENV env variable
155
- */
156
- const DEV_PROD_CONDITION = `development|production`;
157
- const DEFAULT_CONDITIONS = [
158
- "module",
159
- "browser",
160
- "node",
161
- DEV_PROD_CONDITION
162
- ];
163
- const DEFAULT_CLIENT_CONDITIONS = Object.freeze(DEFAULT_CONDITIONS.filter((c) => c !== "node"));
164
- const DEFAULT_SERVER_CONDITIONS = Object.freeze(DEFAULT_CONDITIONS.filter((c) => c !== "browser"));
165
- const DEFAULT_EXTERNAL_CONDITIONS = Object.freeze(["node", "module-sync"]);
166
- const DEFAULT_EXTENSIONS = [
167
- ".mjs",
168
- ".js",
169
- ".mts",
170
- ".ts",
171
- ".jsx",
172
- ".tsx",
173
- ".json"
174
- ];
175
- /**
176
- * The browser versions that are included in the Baseline Widely Available on 2025-05-01.
177
- *
178
- * This value would be bumped on each major release of Vite.
179
- *
180
- * The value is generated by `pnpm generate-target` script.
181
- */
182
- const ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET = [
183
- "chrome111",
184
- "edge111",
185
- "firefox114",
186
- "safari16.4",
187
- "ios16.4"
188
- ];
189
- const DEFAULT_CONFIG_FILES = [
190
- "vite.config.js",
191
- "vite.config.mjs",
192
- "vite.config.ts",
193
- "vite.config.cjs",
194
- "vite.config.mts",
195
- "vite.config.cts"
196
- ];
197
- const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
198
- const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
199
- const OPTIMIZABLE_ENTRY_RE = /\.[cm]?[jt]s$/;
200
- const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
201
- /**
202
- * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
203
- */
204
- const FS_PREFIX = `/@fs/`;
205
- const CLIENT_PUBLIC_PATH = `/@vite/client`;
206
- const ENV_PUBLIC_PATH = `/@vite/env`;
207
- const VITE_PACKAGE_DIR = resolve(fileURLToPath(new URL("../../../src/node/constants.ts", import.meta.url)), "../../..");
208
- const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
209
- const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
210
- const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
211
- const KNOWN_ASSET_TYPES = [
212
- "apng",
213
- "bmp",
214
- "png",
215
- "jpe?g",
216
- "jfif",
217
- "pjpeg",
218
- "pjp",
219
- "gif",
220
- "svg",
221
- "ico",
222
- "webp",
223
- "avif",
224
- "cur",
225
- "jxl",
226
- "mp4",
227
- "webm",
228
- "ogg",
229
- "mp3",
230
- "wav",
231
- "flac",
232
- "aac",
233
- "opus",
234
- "mov",
235
- "m4a",
236
- "vtt",
237
- "woff2?",
238
- "eot",
239
- "ttf",
240
- "otf",
241
- "webmanifest",
242
- "pdf",
243
- "txt"
244
- ];
245
- const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`, "i");
246
- const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/;
247
- const loopbackHosts = /* @__PURE__ */ new Set([
248
- "localhost",
249
- "127.0.0.1",
250
- "::1",
251
- "0000:0000:0000:0000:0000:0000:0000:0001"
252
- ]);
253
- const wildcardHosts = /* @__PURE__ */ new Set([
254
- "0.0.0.0",
255
- "::",
256
- "0000:0000:0000:0000:0000:0000:0000:0000"
257
- ]);
258
- const DEFAULT_DEV_PORT = 5173;
259
- const DEFAULT_PREVIEW_PORT = 4173;
260
- const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
261
- const defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
262
- const METADATA_FILENAME = "_metadata.json";
263
- const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = "ERR_OPTIMIZE_DEPS_PROCESSING_ERROR";
264
- const ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR = "ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR";
265
- //#endregion
266
- //#region src/node/logger.ts
267
- var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
268
- const LogLevels = {
269
- silent: 0,
270
- error: 1,
271
- warn: 2,
272
- info: 3
273
- };
274
- let lastType;
275
- let lastMsg;
276
- let sameCount = 0;
277
- function clearScreen() {
278
- const repeatCount = process.stdout.rows - 2;
279
- const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
280
- console.log(blank);
281
- readline.cursorTo(process.stdout, 0, 0);
282
- readline.clearScreenDown(process.stdout);
283
- }
284
- let timeFormatter;
285
- function getTimeFormatter() {
286
- timeFormatter ??= new Intl.DateTimeFormat(void 0, {
287
- hour: "numeric",
288
- minute: "numeric",
289
- second: "numeric"
290
- });
291
- return timeFormatter;
292
- }
293
- function createLogger(level = "info", options = {}) {
294
- if (options.customLogger) return options.customLogger;
295
- const loggedErrors = /* @__PURE__ */ new WeakSet();
296
- const { prefix = "[vite]", allowClearScreen = true, console = globalThis.console } = options;
297
- const thresh = LogLevels[level];
298
- const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
299
- const clear = canClearScreen ? clearScreen : () => {};
300
- function format(type, msg, options = {}) {
301
- if (options.timestamp) {
302
- let tag = "";
303
- if (type === "info") tag = import_picocolors.default.cyan(import_picocolors.default.bold(prefix));
304
- else if (type === "warn") tag = import_picocolors.default.yellow(import_picocolors.default.bold(prefix));
305
- else tag = import_picocolors.default.red(import_picocolors.default.bold(prefix));
306
- const environment = options.environment ? options.environment + " " : "";
307
- return `${import_picocolors.default.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${environment}${msg}`;
308
- } else return msg;
309
- }
310
- function output(type, msg, options = {}) {
311
- if (thresh >= LogLevels[type]) {
312
- const method = type === "info" ? "log" : type;
313
- if (options.error) loggedErrors.add(options.error);
314
- if (canClearScreen) if (type === lastType && msg === lastMsg) {
315
- sameCount++;
316
- clear();
317
- console[method](format(type, msg, options), import_picocolors.default.yellow(`(x${sameCount + 1})`));
318
- } else {
319
- sameCount = 0;
320
- lastMsg = msg;
321
- lastType = type;
322
- if (options.clear) clear();
323
- console[method](format(type, msg, options));
324
- }
325
- else console[method](format(type, msg, options));
326
- }
327
- }
328
- const warnedMessages = /* @__PURE__ */ new Set();
329
- const logger = {
330
- hasWarned: false,
331
- info(msg, opts) {
332
- output("info", msg, opts);
333
- },
334
- warn(msg, opts) {
335
- logger.hasWarned = true;
336
- output("warn", msg, opts);
337
- },
338
- warnOnce(msg, opts) {
339
- if (warnedMessages.has(msg)) return;
340
- logger.hasWarned = true;
341
- output("warn", msg, opts);
342
- warnedMessages.add(msg);
343
- },
344
- error(msg, opts) {
345
- logger.hasWarned = true;
346
- output("error", msg, opts);
347
- },
348
- clearScreen(type) {
349
- if (thresh >= LogLevels[type]) clear();
350
- },
351
- hasErrorLogged(error) {
352
- return loggedErrors.has(error);
353
- }
354
- };
355
- return logger;
356
- }
357
- function printServerUrls(urls, optionsHost, info) {
358
- const colorUrl = (url) => import_picocolors.default.cyan(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
359
- for (const url of urls.local) info(` ${import_picocolors.default.green("➜")} ${import_picocolors.default.bold("Local")}: ${colorUrl(url)}`);
360
- for (const url of urls.network) info(` ${import_picocolors.default.green("➜")} ${import_picocolors.default.bold("Network")}: ${colorUrl(url)}`);
361
- if (urls.network.length === 0 && optionsHost === void 0) info(import_picocolors.default.dim(` ${import_picocolors.default.green("➜")} ${import_picocolors.default.bold("Network")}: use `) + import_picocolors.default.bold("--host") + import_picocolors.default.dim(" to expose"));
362
- }
363
- //#endregion
364
- export { OPTIMIZABLE_ENTRY_RE as A, __esmMin as B, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR as C, JS_TYPES_RE as D, FS_PREFIX as E, defaultAllowedOrigins as F, __require as H, loopbackHosts as I, wildcardHosts as L, SPECIAL_QUERY_RE as M, VERSION as N, KNOWN_ASSET_TYPES as O, VITE_PACKAGE_DIR as P, require_picocolors as R, ENV_PUBLIC_PATH as S, ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET as T, __toCommonJS as U, __exportAll as V, __toESM as W, DEFAULT_SERVER_CONDITIONS as _, CLIENT_ENTRY as a, DEV_PROD_CONDITION as b, DEFAULT_ASSETS_INLINE_LIMIT as c, DEFAULT_CLIENT_MAIN_FIELDS as d, DEFAULT_CONFIG_FILES as f, DEFAULT_PREVIEW_PORT as g, DEFAULT_EXTERNAL_CONDITIONS as h, CLIENT_DIR as i, ROLLUP_HOOKS as j, METADATA_FILENAME as k, DEFAULT_ASSETS_RE as l, DEFAULT_EXTENSIONS as m, createLogger as n, CLIENT_PUBLIC_PATH as o, DEFAULT_DEV_PORT as p, printServerUrls as r, CSS_LANGS_RE as s, LogLevels as t, DEFAULT_CLIENT_CONDITIONS as u, DEFAULT_SERVER_MAIN_FIELDS as v, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR as w, ENV_ENTRY as x, DEP_VERSION_RE as y, __commonJSMin as z };