vite 6.0.0-beta.1 → 6.0.0-beta.10

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,22 +2,19 @@ import path from 'node:path';
2
2
  import fs__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { I as colors, A as createLogger, r as resolveConfig } from './chunks/dep-BZ_CwQkz.js';
5
+ import { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-DiRA7B7B.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
9
9
  import 'node:util';
10
10
  import 'node:module';
11
- import 'tty';
12
11
  import 'esbuild';
13
12
  import 'path';
14
13
  import 'fs';
15
- import 'node:events';
16
- import 'node:stream';
17
- import 'node:string_decoder';
18
14
  import 'node:child_process';
19
15
  import 'node:http';
20
16
  import 'node:https';
17
+ import 'tty';
21
18
  import 'util';
22
19
  import 'net';
23
20
  import 'url';
@@ -31,18 +28,20 @@ import 'node:dns';
31
28
  import 'vite/module-runner';
32
29
  import 'rollup/parseAst';
33
30
  import 'module';
31
+ import 'node:readline';
32
+ import 'node:process';
33
+ import 'node:buffer';
34
+ import 'node:events';
35
+ import 'crypto';
34
36
  import 'node:assert';
35
37
  import 'node:v8';
36
38
  import 'node:worker_threads';
37
- import 'crypto';
38
- import 'node:buffer';
39
- import 'node:readline';
40
39
  import 'zlib';
41
40
  import 'buffer';
42
41
  import 'https';
43
42
  import 'tls';
44
43
  import 'assert';
45
- import 'querystring';
44
+ import 'node:querystring';
46
45
  import 'node:zlib';
47
46
 
48
47
  function toArr(any) {
@@ -705,10 +704,15 @@ function cleanGlobalCLIOptions(options) {
705
704
  delete ret.filter;
706
705
  delete ret.m;
707
706
  delete ret.mode;
707
+ delete ret.w;
708
708
  if ("sourcemap" in ret) {
709
709
  const sourcemap = ret.sourcemap;
710
710
  ret.sourcemap = sourcemap === "true" ? true : sourcemap === "false" ? false : ret.sourcemap;
711
711
  }
712
+ if ("watch" in ret) {
713
+ const watch = ret.watch;
714
+ ret.watch = watch ? {} : void 0;
715
+ }
712
716
  return ret;
713
717
  }
714
718
  function cleanBuilderCLIOptions(options) {
@@ -736,7 +740,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
736
740
  `[boolean] force the optimizer to ignore the cache and re-bundle`
737
741
  ).action(async (root, options) => {
738
742
  filterDuplicateOptions(options);
739
- const { createServer } = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.M; });
743
+ const { createServer } = await import('./chunks/dep-DiRA7B7B.js').then(function (n) { return n.Q; });
740
744
  try {
741
745
  const server = await createServer({
742
746
  root,
@@ -826,10 +830,10 @@ cli.command("build [root]", "build for production").option("--target <target>",
826
830
  ).option("--manifest [name]", `[boolean | string] emit build manifest json`).option("--ssrManifest [name]", `[boolean | string] emit ssr manifest json`).option(
827
831
  "--emptyOutDir",
828
832
  `[boolean] force empty outDir when it's outside of root`
829
- ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as builder.entireApp`).action(
833
+ ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
830
834
  async (root, options) => {
831
835
  filterDuplicateOptions(options);
832
- const build = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.N; });
836
+ const { createBuilder } = await import('./chunks/dep-DiRA7B7B.js').then(function (n) { return n.R; });
833
837
  const buildOptions = cleanGlobalCLIOptions(
834
838
  cleanBuilderCLIOptions(options)
835
839
  );
@@ -842,30 +846,10 @@ cli.command("build [root]", "build for production").option("--target <target>",
842
846
  logLevel: options.logLevel,
843
847
  clearScreen: options.clearScreen,
844
848
  build: buildOptions,
845
- ...options.app ? { builder: { entireApp: true } } : {}
846
- };
847
- const patchConfig = (resolved) => {
848
- if (resolved.builder.entireApp) {
849
- return;
850
- }
851
- const environmentName = resolved.build.ssr ? "ssr" : "client";
852
- resolved.build = {
853
- ...resolved.environments[environmentName].build
854
- };
849
+ ...options.app ? { builder: {} } : {}
855
850
  };
856
- const config = await build.resolveConfigToBuild(
857
- inlineConfig,
858
- patchConfig
859
- );
860
- if (config.builder.entireApp) {
861
- const builder = await build.createBuilderWithResolvedConfig(
862
- inlineConfig,
863
- config
864
- );
865
- await builder.buildApp();
866
- } else {
867
- await build.buildWithResolvedConfig(config);
868
- }
851
+ const builder = await createBuilder(inlineConfig, null);
852
+ await builder.buildApp();
869
853
  } catch (e) {
870
854
  createLogger(options.logLevel).error(
871
855
  colors.red(`error during build:
@@ -884,7 +868,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
884
868
  ).action(
885
869
  async (root, options) => {
886
870
  filterDuplicateOptions(options);
887
- const { optimizeDeps } = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.L; });
871
+ const { optimizeDeps } = await import('./chunks/dep-DiRA7B7B.js').then(function (n) { return n.P; });
888
872
  try {
889
873
  const config = await resolveConfig(
890
874
  {
@@ -910,7 +894,7 @@ ${e.stack}`),
910
894
  cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
911
895
  async (root, options) => {
912
896
  filterDuplicateOptions(options);
913
- const { preview } = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.O; });
897
+ const { preview } = await import('./chunks/dep-DiRA7B7B.js').then(function (n) { return n.S; });
914
898
  try {
915
899
  const server = await preview({
916
900
  root,
@@ -6,6 +6,7 @@ const { version } = JSON.parse(
6
6
  readFileSync(new URL("../../package.json", import.meta.url)).toString()
7
7
  );
8
8
  const ROLLUP_HOOKS = [
9
+ "options",
9
10
  "buildStart",
10
11
  "buildEnd",
11
12
  "renderStart",
@@ -30,7 +31,8 @@ const ROLLUP_HOOKS = [
30
31
  "resolveDynamicImport",
31
32
  "resolveId",
32
33
  "shouldTransformCachedModule",
33
- "transform"
34
+ "transform",
35
+ "onLog"
34
36
  ];
35
37
  const VERSION = version;
36
38
  const DEFAULT_MAIN_FIELDS = [
@@ -40,6 +42,18 @@ const DEFAULT_MAIN_FIELDS = [
40
42
  // moment still uses this...
41
43
  "jsnext"
42
44
  ];
45
+ const DEFAULT_CLIENT_MAIN_FIELDS = Object.freeze(DEFAULT_MAIN_FIELDS);
46
+ const DEFAULT_SERVER_MAIN_FIELDS = Object.freeze(
47
+ DEFAULT_MAIN_FIELDS.filter((f) => f !== "browser")
48
+ );
49
+ const DEV_PROD_CONDITION = `development|production`;
50
+ const DEFAULT_CONDITIONS = ["module", "browser", "node", DEV_PROD_CONDITION];
51
+ const DEFAULT_CLIENT_CONDITIONS = Object.freeze(
52
+ DEFAULT_CONDITIONS.filter((c) => c !== "node")
53
+ );
54
+ const DEFAULT_SERVER_CONDITIONS = Object.freeze(
55
+ DEFAULT_CONDITIONS.filter((c) => c !== "browser")
56
+ );
43
57
  const ESBUILD_MODULES_TARGET = [
44
58
  "es2020",
45
59
  // support import.meta.url
@@ -48,15 +62,6 @@ const ESBUILD_MODULES_TARGET = [
48
62
  "chrome87",
49
63
  "safari14"
50
64
  ];
51
- const DEFAULT_EXTENSIONS = [
52
- ".mjs",
53
- ".js",
54
- ".mts",
55
- ".ts",
56
- ".jsx",
57
- ".tsx",
58
- ".json"
59
- ];
60
65
  const DEFAULT_CONFIG_FILES = [
61
66
  "vite.config.js",
62
67
  "vite.config.mjs",
@@ -135,5 +140,8 @@ const DEFAULT_DEV_PORT = 5173;
135
140
  const DEFAULT_PREVIEW_PORT = 4173;
136
141
  const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
137
142
  const METADATA_FILENAME = "_metadata.json";
143
+ const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = "ERR_OPTIMIZE_DEPS_PROCESSING_ERROR";
144
+ const ERR_OUTDATED_OPTIMIZED_DEP = "ERR_OUTDATED_OPTIMIZED_DEP";
145
+ const ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR = "ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR";
138
146
 
139
- 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, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
147
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CLIENT_CONDITIONS, DEFAULT_CLIENT_MAIN_FIELDS, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_SERVER_CONDITIONS, DEFAULT_SERVER_MAIN_FIELDS, DEP_VERSION_RE, DEV_PROD_CONDITION, ENV_ENTRY, ENV_PUBLIC_PATH, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_OUTDATED_OPTIMIZED_DEP, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };