vite 6.0.0-beta.3 → 6.0.0-beta.5

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,17 +1,13 @@
1
- import { M as commonjsGlobal, L as getDefaultExportFromCjs } from './dep-ChZnDG_O.js';
2
- import require$$0__default from 'fs';
1
+ import { M as commonjsGlobal, L as getDefaultExportFromCjs } from './dep-BW_D9zgJ.js';
2
+ import require$$0$3 from 'fs';
3
3
  import require$$0$1 from 'postcss';
4
4
  import require$$0 from 'path';
5
5
  import require$$3 from 'crypto';
6
6
  import require$$0$2 from 'util';
7
- import { r as requireLib } from './dep-wWOLM6NS.js';
7
+ import { r as requireLib } from './dep-mtw2NpNs.js';
8
8
 
9
- import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
10
- import { dirname as __cjs_dirname } from 'node:path';
11
9
  import { createRequire as __cjs_createRequire } from 'node:module';
12
10
 
13
- const __filename = __cjs_fileURLToPath(import.meta.url);
14
- const __dirname = __cjs_dirname(__filename);
15
11
  const require = __cjs_createRequire(import.meta.url);
16
12
  const __require = require;
17
13
  function _mergeNamespaces(n, m) {
@@ -7192,7 +7188,7 @@ function requireBuild () {
7192
7188
  if (hasRequiredBuild) return build.exports;
7193
7189
  hasRequiredBuild = 1;
7194
7190
 
7195
- var _fs = require$$0__default;
7191
+ var _fs = require$$0$3;
7196
7192
 
7197
7193
  var _fs2 = requireFs();
7198
7194
 
@@ -1,14 +1,10 @@
1
- import { L as getDefaultExportFromCjs } from './dep-ChZnDG_O.js';
2
- import require$$0 from 'path';
3
- import require$$0__default from 'fs';
4
- import { r as requireLib } from './dep-wWOLM6NS.js';
1
+ import { L as getDefaultExportFromCjs } from './dep-BW_D9zgJ.js';
2
+ import require$$0$1 from 'path';
3
+ import require$$0 from 'fs';
4
+ import { r as requireLib } from './dep-mtw2NpNs.js';
5
5
 
6
- import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
7
- import { dirname as __cjs_dirname } from 'node:path';
8
6
  import { createRequire as __cjs_createRequire } from 'node:module';
9
7
 
10
- const __filename = __cjs_fileURLToPath(import.meta.url);
11
- const __dirname = __cjs_dirname(__filename);
12
8
  const require = __cjs_createRequire(import.meta.url);
13
9
  const __require = require;
14
10
  function _mergeNamespaces(n, m) {
@@ -319,8 +315,8 @@ var hasRequiredReadCache;
319
315
  function requireReadCache () {
320
316
  if (hasRequiredReadCache) return readCache.exports;
321
317
  hasRequiredReadCache = 1;
322
- var fs = require$$0__default;
323
- var path = require$$0;
318
+ var fs = require$$0;
319
+ var path = require$$0$1;
324
320
  var pify = requirePify();
325
321
 
326
322
  var stat = pify(fs.stat);
@@ -708,7 +704,7 @@ function requireProcessContent () {
708
704
  hasRequiredProcessContent = 1;
709
705
 
710
706
  // builtin tooling
711
- const path = require$$0;
707
+ const path = require$$0$1;
712
708
 
713
709
  // placeholder tooling
714
710
  let sugarss;
@@ -775,7 +771,7 @@ function requireParseStyles () {
775
771
  if (hasRequiredParseStyles) return parseStyles_1;
776
772
  hasRequiredParseStyles = 1;
777
773
 
778
- const path = require$$0;
774
+ const path = require$$0$1;
779
775
 
780
776
  const dataURL = requireDataUrl();
781
777
  const parseStatements = requireParseStatements();
@@ -1021,7 +1017,7 @@ function requirePostcssImport () {
1021
1017
  if (hasRequiredPostcssImport) return postcssImport;
1022
1018
  hasRequiredPostcssImport = 1;
1023
1019
  // builtin tooling
1024
- const path = require$$0;
1020
+ const path = require$$0$1;
1025
1021
 
1026
1022
  // internal tooling
1027
1023
  const applyConditions = requireApplyConditions();
@@ -1,9 +1,5 @@
1
- import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
2
- import { dirname as __cjs_dirname } from 'node:path';
3
1
  import { createRequire as __cjs_createRequire } from 'node:module';
4
2
 
5
- const __filename = __cjs_fileURLToPath(import.meta.url);
6
- const __dirname = __cjs_dirname(__filename);
7
3
  const require = __cjs_createRequire(import.meta.url);
8
4
  const __require = require;
9
5
  var parse;
package/dist/node/cli.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import path from 'node:path';
2
- import fs from 'node:fs';
2
+ import fs__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { K as colors, E as createLogger, r as resolveConfig } from './chunks/dep-ChZnDG_O.js';
5
+ import { K as colors, E as createLogger, r as resolveConfig } from './chunks/dep-BW_D9zgJ.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
14
  import 'node:child_process';
16
15
  import 'node:http';
17
16
  import 'node:https';
17
+ import 'tty';
18
18
  import 'util';
19
19
  import 'net';
20
20
  import 'url';
@@ -28,13 +28,14 @@ import 'node:dns';
28
28
  import 'vite/module-runner';
29
29
  import 'rollup/parseAst';
30
30
  import 'node:readline';
31
+ import 'node:process';
32
+ import 'node:buffer';
31
33
  import 'node:events';
32
34
  import 'crypto';
33
35
  import 'module';
34
36
  import 'node:assert';
35
37
  import 'node:v8';
36
38
  import 'node:worker_threads';
37
- import 'node:buffer';
38
39
  import 'zlib';
39
40
  import 'buffer';
40
41
  import 'https';
@@ -667,7 +668,7 @@ const stopProfiler = (log) => {
667
668
  const outPath = path.resolve(
668
669
  `./vite-profile-${profileCount++}.cpuprofile`
669
670
  );
670
- fs.writeFileSync(outPath, JSON.stringify(profile));
671
+ fs__default.writeFileSync(outPath, JSON.stringify(profile));
671
672
  log(
672
673
  colors.yellow(
673
674
  `CPU profile written to ${colors.white(colors.dim(outPath))}`
@@ -703,10 +704,15 @@ function cleanGlobalCLIOptions(options) {
703
704
  delete ret.filter;
704
705
  delete ret.m;
705
706
  delete ret.mode;
707
+ delete ret.w;
706
708
  if ("sourcemap" in ret) {
707
709
  const sourcemap = ret.sourcemap;
708
710
  ret.sourcemap = sourcemap === "true" ? true : sourcemap === "false" ? false : ret.sourcemap;
709
711
  }
712
+ if ("watch" in ret) {
713
+ const watch = ret.watch;
714
+ ret.watch = watch ? {} : void 0;
715
+ }
710
716
  return ret;
711
717
  }
712
718
  function cleanBuilderCLIOptions(options) {
@@ -734,7 +740,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
734
740
  `[boolean] force the optimizer to ignore the cache and re-bundle`
735
741
  ).action(async (root, options) => {
736
742
  filterDuplicateOptions(options);
737
- const { createServer } = await import('./chunks/dep-ChZnDG_O.js').then(function (n) { return n.O; });
743
+ const { createServer } = await import('./chunks/dep-BW_D9zgJ.js').then(function (n) { return n.O; });
738
744
  try {
739
745
  const server = await createServer({
740
746
  root,
@@ -824,10 +830,10 @@ cli.command("build [root]", "build for production").option("--target <target>",
824
830
  ).option("--manifest [name]", `[boolean | string] emit build manifest json`).option("--ssrManifest [name]", `[boolean | string] emit ssr manifest json`).option(
825
831
  "--emptyOutDir",
826
832
  `[boolean] force empty outDir when it's outside of root`
827
- ).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(
828
834
  async (root, options) => {
829
835
  filterDuplicateOptions(options);
830
- const build = await import('./chunks/dep-ChZnDG_O.js').then(function (n) { return n.P; });
836
+ const { createBuilder } = await import('./chunks/dep-BW_D9zgJ.js').then(function (n) { return n.P; });
831
837
  const buildOptions = cleanGlobalCLIOptions(
832
838
  cleanBuilderCLIOptions(options)
833
839
  );
@@ -840,30 +846,10 @@ cli.command("build [root]", "build for production").option("--target <target>",
840
846
  logLevel: options.logLevel,
841
847
  clearScreen: options.clearScreen,
842
848
  build: buildOptions,
843
- ...options.app ? { builder: { entireApp: true } } : {}
849
+ ...options.app ? { builder: {} } : {}
844
850
  };
845
- const patchConfig = (resolved) => {
846
- if (resolved.builder.entireApp) {
847
- return;
848
- }
849
- const environmentName = resolved.build.ssr ? "ssr" : "client";
850
- resolved.build = {
851
- ...resolved.environments[environmentName].build
852
- };
853
- };
854
- const config = await build.resolveConfigToBuild(
855
- inlineConfig,
856
- patchConfig
857
- );
858
- if (config.builder.entireApp) {
859
- const builder = await build.createBuilderWithResolvedConfig(
860
- inlineConfig,
861
- config
862
- );
863
- await builder.buildApp();
864
- } else {
865
- await build.buildWithResolvedConfig(config);
866
- }
851
+ const builder = await createBuilder(inlineConfig, null);
852
+ await builder.buildApp();
867
853
  } catch (e) {
868
854
  createLogger(options.logLevel).error(
869
855
  colors.red(`error during build:
@@ -882,7 +868,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
882
868
  ).action(
883
869
  async (root, options) => {
884
870
  filterDuplicateOptions(options);
885
- const { optimizeDeps } = await import('./chunks/dep-ChZnDG_O.js').then(function (n) { return n.N; });
871
+ const { optimizeDeps } = await import('./chunks/dep-BW_D9zgJ.js').then(function (n) { return n.N; });
886
872
  try {
887
873
  const config = await resolveConfig(
888
874
  {
@@ -908,7 +894,7 @@ ${e.stack}`),
908
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(
909
895
  async (root, options) => {
910
896
  filterDuplicateOptions(options);
911
- const { preview } = await import('./chunks/dep-ChZnDG_O.js').then(function (n) { return n.Q; });
897
+ const { preview } = await import('./chunks/dep-BW_D9zgJ.js').then(function (n) { return n.Q; });
912
898
  try {
913
899
  const server = await preview({
914
900
  root,
@@ -26,6 +26,7 @@ export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../.
26
26
  import { SecureContextOptions } from 'node:tls';
27
27
  import { ZlibOptions } from 'node:zlib';
28
28
  import * as PostCSS from 'postcss';
29
+ import { SassLegacyPreprocessBaseOptions, SassModernPreprocessBaseOptions, LessPreprocessorBaseOptions, StylusPreprocessorBaseOptions } from '../../types/cssPreprocessorOptions.js';
29
30
  export { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap } from '../../types/importGlob.js';
30
31
  export { ChunkMetadata } from '../../types/metadata.js';
31
32
 
@@ -754,8 +755,8 @@ interface PreviewServer {
754
755
  */
755
756
  httpServer: HttpServer;
756
757
  /**
757
- * The resolved urls Vite prints on the CLI.
758
- * null before server is listening.
758
+ * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
759
+ * if the server is not listening on any port.
759
760
  */
760
761
  resolvedUrls: ResolvedServerUrls | null;
761
762
  /**
@@ -921,8 +922,8 @@ type DepOptimizationOptions = DepOptimizationConfig & {
921
922
  * will crawl those entry points instead.
922
923
  *
923
924
  * If neither of these fit your needs, you can specify custom entries using
924
- * this option - the value should be a fast-glob pattern or array of patterns
925
- * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
925
+ * this option - the value should be a tinyglobby pattern or array of patterns
926
+ * (https://github.com/SuperchupuDev/tinyglobby) that are relative from
926
927
  * vite project root. This will overwrite default entries inference.
927
928
  */
928
929
  entries?: string | string[];
@@ -1278,7 +1279,20 @@ declare class DevEnvironment extends BaseEnvironment {
1278
1279
  constructor(name: string, config: ResolvedConfig, context: DevEnvironmentContext);
1279
1280
  init(options?: {
1280
1281
  watcher?: FSWatcher;
1282
+ /**
1283
+ * the previous instance used for the environment with the same name
1284
+ *
1285
+ * when using, the consumer should check if it's an instance generated from the same class or factory function
1286
+ */
1287
+ previousInstance?: DevEnvironment;
1281
1288
  }): Promise<void>;
1289
+ /**
1290
+ * When the dev server is restarted, the methods are called in the following order:
1291
+ * - new instance `init`
1292
+ * - previous instance `close`
1293
+ * - new instance `listen`
1294
+ */
1295
+ listen(server: ViteDevServer): Promise<void>;
1282
1296
  fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<FetchResult>;
1283
1297
  reloadModule(module: EnvironmentModuleNode): Promise<void>;
1284
1298
  transformRequest(url: string): Promise<TransformResult | null>;
@@ -1827,7 +1841,6 @@ interface ResolvePluginOptions {
1827
1841
  isRequire?: boolean;
1828
1842
  webCompatible?: boolean;
1829
1843
  isFromTsImporter?: boolean;
1830
- tryEsmOnly?: boolean;
1831
1844
  scan?: boolean;
1832
1845
  ssrOptimizeCheck?: boolean;
1833
1846
  /**
@@ -2135,14 +2148,14 @@ interface ViteBuilder {
2135
2148
  interface BuilderOptions {
2136
2149
  sharedConfigBuild?: boolean;
2137
2150
  sharedPlugins?: boolean;
2138
- entireApp?: boolean;
2139
2151
  buildApp?: (builder: ViteBuilder) => Promise<void>;
2140
2152
  }
2141
2153
  type ResolvedBuilderOptions = Required<BuilderOptions>;
2142
2154
  /**
2143
2155
  * Creates a ViteBuilder to orchestrate building multiple environments.
2156
+ * @experimental
2144
2157
  */
2145
- declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
2158
+ declare function createBuilder(inlineConfig?: InlineConfig, useLegacyBuilder?: null | boolean): Promise<ViteBuilder>;
2146
2159
 
2147
2160
  type Environment = DevEnvironment | BuildEnvironment | UnknownEnvironment;
2148
2161
 
@@ -2964,8 +2977,8 @@ interface ViteDevServer {
2964
2977
  */
2965
2978
  moduleGraph: ModuleGraph;
2966
2979
  /**
2967
- * The resolved urls Vite prints on the CLI. null in middleware mode or
2968
- * before `server.listen` is called.
2980
+ * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
2981
+ * in middleware mode or if the server is not listening on any port.
2969
2982
  */
2970
2983
  resolvedUrls: ResolvedServerUrls | null;
2971
2984
  /**
@@ -3145,7 +3158,13 @@ interface CSSOptions {
3145
3158
  * In addition to options specific to each processors, Vite supports `additionalData` option.
3146
3159
  * The `additionalData` option can be used to inject extra code for each style content.
3147
3160
  */
3148
- preprocessorOptions?: Record<string, any>;
3161
+ preprocessorOptions?: {
3162
+ scss?: SassPreprocessorOptions;
3163
+ sass?: SassPreprocessorOptions;
3164
+ less?: LessPreprocessorOptions;
3165
+ styl?: StylusPreprocessorOptions;
3166
+ stylus?: StylusPreprocessorOptions;
3167
+ };
3149
3168
  /**
3150
3169
  * If this option is set, preprocessors will run in workers when possible.
3151
3170
  * `true` means the number of CPUs minus 1.
@@ -3196,6 +3215,24 @@ interface PreprocessCSSResult {
3196
3215
  */
3197
3216
  declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
3198
3217
  declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
3218
+ type PreprocessorAdditionalDataResult = string | {
3219
+ content: string;
3220
+ map?: ExistingRawSourceMap;
3221
+ };
3222
+ type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>);
3223
+ type SassPreprocessorOptions = {
3224
+ additionalData?: PreprocessorAdditionalData;
3225
+ } & (({
3226
+ api?: 'legacy';
3227
+ } & SassLegacyPreprocessBaseOptions) | ({
3228
+ api: 'modern' | 'modern-compiler';
3229
+ } & SassModernPreprocessBaseOptions));
3230
+ type LessPreprocessorOptions = {
3231
+ additionalData?: PreprocessorAdditionalData;
3232
+ } & LessPreprocessorBaseOptions;
3233
+ type StylusPreprocessorOptions = {
3234
+ additionalData?: PreprocessorAdditionalData;
3235
+ } & StylusPreprocessorBaseOptions;
3199
3236
 
3200
3237
  interface HtmlTagDescriptor {
3201
3238
  tag: string;
@@ -3464,10 +3501,11 @@ interface JsonOptions {
3464
3501
  namedExports?: boolean;
3465
3502
  /**
3466
3503
  * Generate performant output as JSON.parse("stringified").
3467
- * Enabling this will disable namedExports.
3468
- * @default false
3504
+ *
3505
+ * When set to 'auto', the data will be stringified only if the data is bigger than 10kB.
3506
+ * @default 'auto'
3469
3507
  */
3470
- stringify?: boolean;
3508
+ stringify?: boolean | 'auto';
3471
3509
  }
3472
3510
 
3473
3511
  type SSRTarget = 'node' | 'webworker';
@@ -3709,6 +3747,7 @@ interface UserConfig extends DefaultEnvironmentOptions {
3709
3747
  assetsInclude?: string | RegExp | (string | RegExp)[];
3710
3748
  /**
3711
3749
  * Builder specific options
3750
+ * @experimental
3712
3751
  */
3713
3752
  builder?: BuilderOptions;
3714
3753
  /**
@@ -3897,7 +3936,8 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3897
3936
  esbuild: ESBuildOptions | false;
3898
3937
  server: ResolvedServerOptions;
3899
3938
  dev: ResolvedDevEnvironmentOptions;
3900
- builder: ResolvedBuilderOptions;
3939
+ /** @experimental */
3940
+ builder: ResolvedBuilderOptions | undefined;
3901
3941
  build: ResolvedBuildOptions;
3902
3942
  preview: ResolvedPreviewOptions;
3903
3943
  ssr: ResolvedSSROptions;
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-ChZnDG_O.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, z as createFilter, f as createIdResolver, E as createLogger, k as createRunnableDevEnvironment, c as createServer, u as createServerHotChannel, q as createServerModuleRunner, d as defineConfig, n as fetchModule, g as formatPostcssSourceMap, H as isFileLoadingAllowed, G as isFileServingAllowed, m as isRunnableDevEnvironment, l as loadConfigFromFile, I as loadEnv, y as mergeAlias, x as mergeConfig, v as moduleRunnerTransform, w as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, J as resolveEnvPrefix, A as rollupVersion, F as searchForWorkspaceRoot, C as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ChZnDG_O.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BW_D9zgJ.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, z as createFilter, f as createIdResolver, E as createLogger, k as createRunnableDevEnvironment, c as createServer, u as createServerHotChannel, q as createServerModuleRunner, d as defineConfig, n as fetchModule, g as formatPostcssSourceMap, H as isFileLoadingAllowed, G as isFileServingAllowed, m as isRunnableDevEnvironment, l as loadConfigFromFile, I as loadEnv, y as mergeAlias, x as mergeConfig, v as moduleRunnerTransform, w as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, J as resolveEnvPrefix, A as rollupVersion, F as searchForWorkspaceRoot, C as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BW_D9zgJ.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
@@ -10,12 +10,12 @@ import 'node:url';
10
10
  import 'node:util';
11
11
  import 'node:perf_hooks';
12
12
  import 'node:module';
13
- import 'tty';
14
13
  import 'path';
15
14
  import 'fs';
16
15
  import 'node:child_process';
17
16
  import 'node:http';
18
17
  import 'node:https';
18
+ import 'tty';
19
19
  import 'util';
20
20
  import 'net';
21
21
  import 'events';
@@ -29,13 +29,14 @@ import 'node:crypto';
29
29
  import 'node:dns';
30
30
  import 'vite/module-runner';
31
31
  import 'node:readline';
32
+ import 'node:process';
33
+ import 'node:buffer';
32
34
  import 'node:events';
33
35
  import 'crypto';
34
36
  import 'module';
35
37
  import 'node:assert';
36
38
  import 'node:v8';
37
39
  import 'node:worker_threads';
38
- import 'node:buffer';
39
40
  import 'zlib';
40
41
  import 'buffer';
41
42
  import 'https';
@@ -448,7 +448,7 @@ class HMRClient {
448
448
  }
449
449
  // After an HMR update, some modules are no longer imported on the page
450
450
  // but they may have left behind side effects that need to be cleaned up
451
- // (.e.g style injections)
451
+ // (e.g. style injections)
452
452
  async prunePaths(paths) {
453
453
  await Promise.all(
454
454
  paths.map((path) => {