vite 6.0.11 → 6.1.0-beta.1

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__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-M1IYMR16.js';
5
+ import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-ChTE610F.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -699,6 +699,7 @@ function cleanGlobalCLIOptions(options) {
699
699
  delete ret.l;
700
700
  delete ret.logLevel;
701
701
  delete ret.clearScreen;
702
+ delete ret.configLoader;
702
703
  delete ret.d;
703
704
  delete ret.debug;
704
705
  delete ret.f;
@@ -735,23 +736,27 @@ const convertBase = (v) => {
735
736
  };
736
737
  cli.option("-c, --config <file>", `[string] use specified config file`).option("--base <path>", `[string] public base path (default: /)`, {
737
738
  type: [convertBase]
738
- }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).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`);
739
+ }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option(
740
+ "--configLoader <loader>",
741
+ `[string] use 'bundle' to bundle the config with esbuild or 'runner' (experimental) to process it on the fly (default: bundle)`
742
+ ).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`);
739
743
  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(
740
744
  "--force",
741
745
  `[boolean] force the optimizer to ignore the cache and re-bundle`
742
746
  ).action(async (root, options) => {
743
747
  filterDuplicateOptions(options);
744
- const { createServer } = await import('./chunks/dep-M1IYMR16.js').then(function (n) { return n.Q; });
748
+ const { createServer } = await import('./chunks/dep-ChTE610F.js').then(function (n) { return n.S; });
745
749
  try {
746
750
  const server = await createServer({
747
751
  root,
748
752
  base: options.base,
749
753
  mode: options.mode,
750
754
  configFile: options.config,
755
+ configLoader: options.configLoader,
751
756
  logLevel: options.logLevel,
752
757
  clearScreen: options.clearScreen,
753
- optimizeDeps: { force: options.force },
754
- server: cleanGlobalCLIOptions(options)
758
+ server: cleanGlobalCLIOptions(options),
759
+ forceOptimizeDeps: options.force
755
760
  });
756
761
  if (!server.httpServer) {
757
762
  throw new Error("HTTP server not available");
@@ -834,7 +839,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
834
839
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
835
840
  async (root, options) => {
836
841
  filterDuplicateOptions(options);
837
- const { createBuilder } = await import('./chunks/dep-M1IYMR16.js').then(function (n) { return n.R; });
842
+ const { createBuilder } = await import('./chunks/dep-ChTE610F.js').then(function (n) { return n.T; });
838
843
  const buildOptions = cleanGlobalCLIOptions(
839
844
  cleanBuilderCLIOptions(options)
840
845
  );
@@ -844,6 +849,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
844
849
  base: options.base,
845
850
  mode: options.mode,
846
851
  configFile: options.config,
852
+ configLoader: options.configLoader,
847
853
  logLevel: options.logLevel,
848
854
  clearScreen: options.clearScreen,
849
855
  build: buildOptions,
@@ -869,13 +875,14 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
869
875
  ).action(
870
876
  async (root, options) => {
871
877
  filterDuplicateOptions(options);
872
- const { optimizeDeps } = await import('./chunks/dep-M1IYMR16.js').then(function (n) { return n.P; });
878
+ const { optimizeDeps } = await import('./chunks/dep-ChTE610F.js').then(function (n) { return n.R; });
873
879
  try {
874
880
  const config = await resolveConfig(
875
881
  {
876
882
  root,
877
883
  base: options.base,
878
884
  configFile: options.config,
885
+ configLoader: options.configLoader,
879
886
  logLevel: options.logLevel,
880
887
  mode: options.mode
881
888
  },
@@ -895,12 +902,13 @@ ${e.stack}`),
895
902
  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(
896
903
  async (root, options) => {
897
904
  filterDuplicateOptions(options);
898
- const { preview } = await import('./chunks/dep-M1IYMR16.js').then(function (n) { return n.S; });
905
+ const { preview } = await import('./chunks/dep-ChTE610F.js').then(function (n) { return n.U; });
899
906
  try {
900
907
  const server = await preview({
901
908
  root,
902
909
  base: options.base,
903
910
  configFile: options.config,
911
+ configLoader: options.configLoader,
904
912
  logLevel: options.logLevel,
905
913
  mode: options.mode,
906
914
  build: {
@@ -56,7 +56,6 @@ const DEFAULT_SERVER_CONDITIONS = Object.freeze(
56
56
  );
57
57
  const ESBUILD_MODULES_TARGET = [
58
58
  "es2020",
59
- // support import.meta.url
60
59
  "edge88",
61
60
  "firefox78",
62
61
  "chrome87",
@@ -100,6 +99,7 @@ const KNOWN_ASSET_TYPES = [
100
99
  "webp",
101
100
  "avif",
102
101
  "cur",
102
+ "jxl",
103
103
  // media
104
104
  "mp4",
105
105
  "webm",
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, MinimalPluginContext, InputOptions, CustomPluginOptions, LoadResult, SourceDescription, SourceMapInput, ExistingRawSourceMap, OutputBundle, OutputChunk, ObjectHook, ResolveIdResult, GetManualChunk } from 'rollup';
2
+ import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, InputOptions, CustomPluginOptions, LoadResult, SourceDescription, PluginContextMeta, RollupLog, OutputBundle, OutputChunk, ObjectHook, ResolveIdResult, SourceMapInput, ExistingRawSourceMap, GetManualChunk } from 'rollup';
3
3
  import * as rollup from 'rollup';
4
4
  export { rollup as Rollup };
5
5
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
@@ -29,6 +29,7 @@ import * as PostCSS from 'postcss';
29
29
  import { LightningCSSOptions } from '../../types/internal/lightningcssOptions.js';
30
30
  export { LightningCSSOptions } from '../../types/internal/lightningcssOptions.js';
31
31
  import { SassLegacyPreprocessBaseOptions, SassModernPreprocessBaseOptions, LessPreprocessorBaseOptions, StylusPreprocessorBaseOptions } from '../../types/internal/cssPreprocessorOptions.js';
32
+ import { M as ModuleRunnerTransport } from './moduleRunnerTransport.d-CXw_Ws6P.js';
32
33
  export { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap } from '../../types/importGlob.js';
33
34
  export { ChunkMetadata } from '../../types/metadata.js';
34
35
 
@@ -622,7 +623,7 @@ interface ProxyOptions extends HttpProxy.ServerOptions {
622
623
  */
623
624
  bypass?: (req: http.IncomingMessage,
624
625
  /** undefined for WebSocket upgrade requests */
625
- res: http.ServerResponse | undefined, options: ProxyOptions) => void | null | undefined | false | string;
626
+ res: http.ServerResponse | undefined, options: ProxyOptions) => void | null | undefined | false | string | Promise<void | null | undefined | boolean | string>;
626
627
  /**
627
628
  * rewrite the Origin header of a WebSocket request to match the target
628
629
  *
@@ -1290,6 +1291,7 @@ type ServerHotChannelApi = {
1290
1291
  outsideEmitter: EventEmitter;
1291
1292
  };
1292
1293
  type ServerHotChannel = HotChannel<ServerHotChannelApi>;
1294
+ type NormalizedServerHotChannel = NormalizedHotChannel<ServerHotChannelApi>;
1293
1295
  /** @deprecated use `ServerHotChannel` instead */
1294
1296
  type ServerHMRChannel = ServerHotChannel;
1295
1297
  declare function createServerHotChannel(): ServerHotChannel;
@@ -2432,6 +2434,10 @@ interface EnvironmentResolveOptions {
2432
2434
  * @experimental
2433
2435
  */
2434
2436
  external?: string[] | true;
2437
+ /**
2438
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
2439
+ */
2440
+ builtins?: (string | RegExp)[];
2435
2441
  }
2436
2442
  interface ResolveOptions extends EnvironmentResolveOptions {
2437
2443
  /**
@@ -2454,6 +2460,7 @@ interface ResolvePluginOptions {
2454
2460
  tryPrefix?: string;
2455
2461
  preferRelative?: boolean;
2456
2462
  isRequire?: boolean;
2463
+ /** @deprecated */
2457
2464
  isFromTsImporter?: boolean;
2458
2465
  scan?: boolean;
2459
2466
  /**
@@ -2461,7 +2468,7 @@ interface ResolvePluginOptions {
2461
2468
  */
2462
2469
  ssrConfig?: SSROptions;
2463
2470
  }
2464
- interface InternalResolveOptions extends Required<Omit<ResolveOptions, 'enableBuiltinNoExternalCheck'>>, ResolvePluginOptions {
2471
+ interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {
2465
2472
  }
2466
2473
 
2467
2474
  /** Cache for package.json resolution and package.json contents */
@@ -2611,7 +2618,7 @@ interface BuildEnvironmentOptions {
2611
2618
  */
2612
2619
  copyPublicDir?: boolean;
2613
2620
  /**
2614
- * Whether to emit a .vite/manifest.json under assets dir to map hash-less filenames
2621
+ * Whether to emit a .vite/manifest.json in the output dir to map hash-less filenames
2615
2622
  * to their hashed versions. Useful when you want to generate your own HTML
2616
2623
  * instead of using the one generated by Vite.
2617
2624
  *
@@ -2853,6 +2860,16 @@ declare class EnvironmentPluginContainer {
2853
2860
  }): Promise<void>;
2854
2861
  close(): Promise<void>;
2855
2862
  }
2863
+ declare class MinimalPluginContext implements rollup.MinimalPluginContext {
2864
+ meta: PluginContextMeta;
2865
+ environment: Environment;
2866
+ constructor(meta: PluginContextMeta, environment: Environment);
2867
+ debug(rawLog: string | RollupLog | (() => string | RollupLog)): void;
2868
+ info(rawLog: string | RollupLog | (() => string | RollupLog)): void;
2869
+ warn(rawLog: string | RollupLog | (() => string | RollupLog)): void;
2870
+ error(e: string | RollupError): never;
2871
+ private _normalizeRawLog;
2872
+ }
2856
2873
  declare class PluginContainer {
2857
2874
  private environments;
2858
2875
  constructor(environments: Record<string, Environment>);
@@ -3134,129 +3151,6 @@ interface ResolvedServerUrls {
3134
3151
  }
3135
3152
  declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
3136
3153
 
3137
- interface ESBuildOptions extends esbuild_TransformOptions {
3138
- include?: string | RegExp | ReadonlyArray<string | RegExp>;
3139
- exclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3140
- jsxInject?: string;
3141
- /**
3142
- * This option is not respected. Use `build.minify` instead.
3143
- */
3144
- minify?: never;
3145
- }
3146
- type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
3147
- map: SourceMap;
3148
- };
3149
- declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<ESBuildTransformResult>;
3150
-
3151
- interface JsonOptions {
3152
- /**
3153
- * Generate a named export for every property of the JSON object
3154
- * @default true
3155
- */
3156
- namedExports?: boolean;
3157
- /**
3158
- * Generate performant output as JSON.parse("stringified").
3159
- *
3160
- * When set to 'auto', the data will be stringified only if the data is bigger than 10kB.
3161
- * @default 'auto'
3162
- */
3163
- stringify?: boolean | 'auto';
3164
- }
3165
-
3166
- interface CSSOptions {
3167
- /**
3168
- * Using lightningcss is an experimental option to handle CSS modules,
3169
- * assets and imports via Lightning CSS. It requires to install it as a
3170
- * peer dependency. This is incompatible with the use of preprocessors.
3171
- *
3172
- * @default 'postcss'
3173
- * @experimental
3174
- */
3175
- transformer?: 'postcss' | 'lightningcss';
3176
- /**
3177
- * https://github.com/css-modules/postcss-modules
3178
- */
3179
- modules?: CSSModulesOptions | false;
3180
- /**
3181
- * Options for preprocessors.
3182
- *
3183
- * In addition to options specific to each processors, Vite supports `additionalData` option.
3184
- * The `additionalData` option can be used to inject extra code for each style content.
3185
- */
3186
- preprocessorOptions?: {
3187
- scss?: SassPreprocessorOptions;
3188
- sass?: SassPreprocessorOptions;
3189
- less?: LessPreprocessorOptions;
3190
- styl?: StylusPreprocessorOptions;
3191
- stylus?: StylusPreprocessorOptions;
3192
- };
3193
- /**
3194
- * If this option is set, preprocessors will run in workers when possible.
3195
- * `true` means the number of CPUs minus 1.
3196
- *
3197
- * @default 0
3198
- * @experimental
3199
- */
3200
- preprocessorMaxWorkers?: number | true;
3201
- postcss?: string | (PostCSS.ProcessOptions & {
3202
- plugins?: PostCSS.AcceptedPlugin[];
3203
- });
3204
- /**
3205
- * Enables css sourcemaps during dev
3206
- * @default false
3207
- * @experimental
3208
- */
3209
- devSourcemap?: boolean;
3210
- /**
3211
- * @experimental
3212
- */
3213
- lightningcss?: LightningCSSOptions;
3214
- }
3215
- interface CSSModulesOptions {
3216
- getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
3217
- scopeBehaviour?: 'global' | 'local';
3218
- globalModulePaths?: RegExp[];
3219
- exportGlobals?: boolean;
3220
- generateScopedName?: string | ((name: string, filename: string, css: string) => string);
3221
- hashPrefix?: string;
3222
- /**
3223
- * default: undefined
3224
- */
3225
- localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
3226
- }
3227
- type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & Required<Pick<CSSOptions, 'transformer'>> & {
3228
- lightningcss?: LightningCSSOptions;
3229
- };
3230
- interface PreprocessCSSResult {
3231
- code: string;
3232
- map?: SourceMapInput;
3233
- modules?: Record<string, string>;
3234
- deps?: Set<string>;
3235
- }
3236
- /**
3237
- * @experimental
3238
- */
3239
- declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
3240
- declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
3241
- type PreprocessorAdditionalDataResult = string | {
3242
- content: string;
3243
- map?: ExistingRawSourceMap;
3244
- };
3245
- type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>);
3246
- type SassPreprocessorOptions = {
3247
- additionalData?: PreprocessorAdditionalData;
3248
- } & (({
3249
- api: 'legacy';
3250
- } & SassLegacyPreprocessBaseOptions) | ({
3251
- api?: 'modern' | 'modern-compiler';
3252
- } & SassModernPreprocessBaseOptions));
3253
- type LessPreprocessorOptions = {
3254
- additionalData?: PreprocessorAdditionalData;
3255
- } & LessPreprocessorBaseOptions;
3256
- type StylusPreprocessorOptions = {
3257
- additionalData?: PreprocessorAdditionalData;
3258
- } & StylusPreprocessorBaseOptions;
3259
-
3260
3154
  interface HtmlTagDescriptor {
3261
3155
  tag: string;
3262
3156
  attrs?: Record<string, string | boolean | undefined>;
@@ -3527,6 +3421,129 @@ type PluginOption = Thenable<Plugin | FalsyPlugin | PluginOption[]>;
3527
3421
  */
3528
3422
  declare function perEnvironmentPlugin(name: string, applyToEnvironment: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption): Plugin;
3529
3423
 
3424
+ interface CSSOptions {
3425
+ /**
3426
+ * Using lightningcss is an experimental option to handle CSS modules,
3427
+ * assets and imports via Lightning CSS. It requires to install it as a
3428
+ * peer dependency. This is incompatible with the use of preprocessors.
3429
+ *
3430
+ * @default 'postcss'
3431
+ * @experimental
3432
+ */
3433
+ transformer?: 'postcss' | 'lightningcss';
3434
+ /**
3435
+ * https://github.com/css-modules/postcss-modules
3436
+ */
3437
+ modules?: CSSModulesOptions | false;
3438
+ /**
3439
+ * Options for preprocessors.
3440
+ *
3441
+ * In addition to options specific to each processors, Vite supports `additionalData` option.
3442
+ * The `additionalData` option can be used to inject extra code for each style content.
3443
+ */
3444
+ preprocessorOptions?: {
3445
+ scss?: SassPreprocessorOptions;
3446
+ sass?: SassPreprocessorOptions;
3447
+ less?: LessPreprocessorOptions;
3448
+ styl?: StylusPreprocessorOptions;
3449
+ stylus?: StylusPreprocessorOptions;
3450
+ };
3451
+ /**
3452
+ * If this option is set, preprocessors will run in workers when possible.
3453
+ * `true` means the number of CPUs minus 1.
3454
+ *
3455
+ * @default 0
3456
+ * @experimental
3457
+ */
3458
+ preprocessorMaxWorkers?: number | true;
3459
+ postcss?: string | (PostCSS.ProcessOptions & {
3460
+ plugins?: PostCSS.AcceptedPlugin[];
3461
+ });
3462
+ /**
3463
+ * Enables css sourcemaps during dev
3464
+ * @default false
3465
+ * @experimental
3466
+ */
3467
+ devSourcemap?: boolean;
3468
+ /**
3469
+ * @experimental
3470
+ */
3471
+ lightningcss?: LightningCSSOptions;
3472
+ }
3473
+ interface CSSModulesOptions {
3474
+ getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
3475
+ scopeBehaviour?: 'global' | 'local';
3476
+ globalModulePaths?: RegExp[];
3477
+ exportGlobals?: boolean;
3478
+ generateScopedName?: string | ((name: string, filename: string, css: string) => string);
3479
+ hashPrefix?: string;
3480
+ /**
3481
+ * default: undefined
3482
+ */
3483
+ localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
3484
+ }
3485
+ type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & Required<Pick<CSSOptions, 'transformer'>> & {
3486
+ lightningcss?: LightningCSSOptions;
3487
+ };
3488
+ interface PreprocessCSSResult {
3489
+ code: string;
3490
+ map?: SourceMapInput;
3491
+ modules?: Record<string, string>;
3492
+ deps?: Set<string>;
3493
+ }
3494
+ /**
3495
+ * @experimental
3496
+ */
3497
+ declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
3498
+ declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
3499
+ type PreprocessorAdditionalDataResult = string | {
3500
+ content: string;
3501
+ map?: ExistingRawSourceMap;
3502
+ };
3503
+ type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>);
3504
+ type SassPreprocessorOptions = {
3505
+ additionalData?: PreprocessorAdditionalData;
3506
+ } & (({
3507
+ api: 'legacy';
3508
+ } & SassLegacyPreprocessBaseOptions) | ({
3509
+ api?: 'modern' | 'modern-compiler';
3510
+ } & SassModernPreprocessBaseOptions));
3511
+ type LessPreprocessorOptions = {
3512
+ additionalData?: PreprocessorAdditionalData;
3513
+ } & LessPreprocessorBaseOptions;
3514
+ type StylusPreprocessorOptions = {
3515
+ additionalData?: PreprocessorAdditionalData;
3516
+ } & StylusPreprocessorBaseOptions;
3517
+
3518
+ interface ESBuildOptions extends esbuild_TransformOptions {
3519
+ include?: string | RegExp | ReadonlyArray<string | RegExp>;
3520
+ exclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3521
+ jsxInject?: string;
3522
+ /**
3523
+ * This option is not respected. Use `build.minify` instead.
3524
+ */
3525
+ minify?: never;
3526
+ }
3527
+ type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
3528
+ map: SourceMap;
3529
+ };
3530
+ declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<ESBuildTransformResult>;
3531
+
3532
+ interface JsonOptions {
3533
+ /**
3534
+ * Generate a named export for every property of the JSON object
3535
+ * @default true
3536
+ */
3537
+ namedExports?: boolean;
3538
+ /**
3539
+ * Generate performant output as JSON.parse("stringified").
3540
+ *
3541
+ * When set to 'auto', the data will be stringified only if the data is bigger than 10kB.
3542
+ * @default 'auto'
3543
+ */
3544
+ stringify?: boolean | 'auto';
3545
+ }
3546
+
3530
3547
  type SSRTarget = 'node' | 'webworker';
3531
3548
  type SsrDepOptimizationConfig = DepOptimizationConfig;
3532
3549
  interface SSROptions {
@@ -3944,9 +3961,12 @@ interface ResolvedWorkerOptions {
3944
3961
  }
3945
3962
  interface InlineConfig extends UserConfig {
3946
3963
  configFile?: string | false;
3964
+ /** @experimental */
3965
+ configLoader?: 'bundle' | 'runner';
3947
3966
  envFile?: false;
3967
+ forceOptimizeDeps?: boolean;
3948
3968
  }
3949
- type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'json' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments' | 'server' | 'preview'> & {
3969
+ interface ResolvedConfig extends Readonly<Omit<UserConfig, 'plugins' | 'css' | 'json' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments' | 'server' | 'preview'> & {
3950
3970
  configFile: string | undefined;
3951
3971
  configFileDependencies: string[];
3952
3972
  inlineConfig: InlineConfig;
@@ -3993,7 +4013,8 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'json' | 'as
3993
4013
  * @deprecated
3994
4014
  */
3995
4015
  webSocketToken: string;
3996
- } & PluginHookUtils>;
4016
+ } & PluginHookUtils> {
4017
+ }
3997
4018
  interface PluginHookUtils {
3998
4019
  getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
3999
4020
  getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
@@ -4003,7 +4024,7 @@ declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 's
4003
4024
 
4004
4025
  ): Promise<ResolvedConfig>;
4005
4026
  declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
4006
- declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger): Promise<{
4027
+ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger, configLoader?: 'bundle' | 'runner'): Promise<{
4007
4028
  path: string;
4008
4029
  config: UserConfig;
4009
4030
  dependencies: string[];
@@ -4033,6 +4054,9 @@ interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | '
4033
4054
  */
4034
4055
  evaluator?: ModuleEvaluator;
4035
4056
  }
4057
+ declare const createServerModuleRunnerTransport: (options: {
4058
+ channel: NormalizedServerHotChannel;
4059
+ }) => ModuleRunnerTransport;
4036
4060
  /**
4037
4061
  * Create an instance of the Vite SSR runtime that support HMR.
4038
4062
  * @experimental
@@ -4055,6 +4079,16 @@ declare class RunnableDevEnvironment extends DevEnvironment {
4055
4079
  close(): Promise<void>;
4056
4080
  }
4057
4081
 
4082
+ interface RunnerImportResult<T> {
4083
+ module: T;
4084
+ dependencies: string[];
4085
+ }
4086
+ /**
4087
+ * Import any file using the default Vite environment.
4088
+ * @experimental
4089
+ */
4090
+ declare function runnerImport<T>(moduleId: string, inlineConfig?: InlineConfig): Promise<RunnerImportResult<T>>;
4091
+
4058
4092
  interface FetchModuleOptions {
4059
4093
  cached?: boolean;
4060
4094
  inlineSourceMap?: boolean;
@@ -4080,6 +4114,7 @@ declare const DEFAULT_CLIENT_MAIN_FIELDS: readonly string[];
4080
4114
  declare const DEFAULT_SERVER_MAIN_FIELDS: readonly string[];
4081
4115
  declare const DEFAULT_CLIENT_CONDITIONS: readonly string[];
4082
4116
  declare const DEFAULT_SERVER_CONDITIONS: readonly string[];
4117
+ declare const defaultAllowedOrigins: RegExp;
4083
4118
 
4084
4119
  declare const isCSSRequest: (request: string) => boolean;
4085
4120
  /**
@@ -4154,4 +4189,4 @@ interface ManifestChunk {
4154
4189
  dynamicImports?: string[];
4155
4190
  }
4156
4191
 
4157
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHMRChannel, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, type SkipInformation, SplitVendorChunkCache, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
4192
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type NormalizedHotChannel, type NormalizedHotChannelClient, type NormalizedServerHotChannel, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHMRChannel, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, type SkipInformation, SplitVendorChunkCache, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, createServerModuleRunnerTransport, defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, runnerImport, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
@@ -1,11 +1,11 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-M1IYMR16.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-M1IYMR16.js';
4
- export { DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-ChTE610F.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ChTE610F.js';
4
+ export { defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
7
- import 'node:fs/promises';
8
7
  import 'node:path';
8
+ import 'node:fs/promises';
9
9
  import 'node:url';
10
10
  import 'node:util';
11
11
  import 'node:perf_hooks';
@@ -1,89 +1,8 @@
1
1
  import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
2
- import { HotPayload, Update } from '../../types/hmrPayload.js';
2
+ import { Update, HotPayload } from '../../types/hmrPayload.js';
3
3
  import { InferCustomEventPayload } from '../../types/customEvent.js';
4
-
5
- interface FetchFunctionOptions {
6
- cached?: boolean;
7
- startOffset?: number;
8
- }
9
- type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
10
- interface CachedFetchResult {
11
- /**
12
- * If module cached in the runner, we can just confirm
13
- * it wasn't invalidated on the server side.
14
- */
15
- cache: true;
16
- }
17
- interface ExternalFetchResult {
18
- /**
19
- * The path to the externalized module starting with file://,
20
- * by default this will be imported via a dynamic "import"
21
- * instead of being transformed by vite and loaded with vite runner
22
- */
23
- externalize: string;
24
- /**
25
- * Type of the module. Will be used to determine if import statement is correct.
26
- * For example, if Vite needs to throw an error if variable is not actually exported
27
- */
28
- type: 'module' | 'commonjs' | 'builtin' | 'network';
29
- }
30
- interface ViteFetchResult {
31
- /**
32
- * Code that will be evaluated by vite runner
33
- * by default this will be wrapped in an async function
34
- */
35
- code: string;
36
- /**
37
- * File path of the module on disk.
38
- * This will be resolved as import.meta.url/filename
39
- * Will be equal to `null` for virtual modules
40
- */
41
- file: string | null;
42
- /**
43
- * Module ID in the server module graph.
44
- */
45
- id: string;
46
- /**
47
- * Module URL used in the import.
48
- */
49
- url: string;
50
- /**
51
- * Invalidate module on the client side.
52
- */
53
- invalidate: boolean;
54
- }
55
- type InvokeMethods = {
56
- fetchModule: (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
57
- };
58
-
59
- type ModuleRunnerTransportHandlers = {
60
- onMessage: (data: HotPayload) => void;
61
- onDisconnection: () => void;
62
- };
63
- /**
64
- * "send and connect" or "invoke" must be implemented
65
- */
66
- interface ModuleRunnerTransport {
67
- connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void;
68
- disconnect?(): Promise<void> | void;
69
- send?(data: HotPayload): Promise<void> | void;
70
- invoke?(data: HotPayload): Promise<{
71
- result: any;
72
- } | {
73
- error: any;
74
- }>;
75
- timeout?: number;
76
- }
77
- interface NormalizedModuleRunnerTransport {
78
- connect?(onMessage?: (data: HotPayload) => void): Promise<void> | void;
79
- disconnect?(): Promise<void> | void;
80
- send(data: HotPayload): Promise<void>;
81
- invoke<T extends keyof InvokeMethods>(name: T, data: Parameters<InvokeMethods[T]>): Promise<ReturnType<Awaited<InvokeMethods[T]>>>;
82
- }
83
- declare const createWebSocketModuleRunnerTransport: (options: {
84
- createConnection: () => WebSocket;
85
- pingInterval?: number;
86
- }) => Required<Pick<ModuleRunnerTransport, "connect" | "disconnect" | "send">>;
4
+ import { N as NormalizedModuleRunnerTransport, E as ExternalFetchResult, V as ViteFetchResult, F as FetchFunctionOptions, a as FetchResult, M as ModuleRunnerTransport } from './moduleRunnerTransport.d-CXw_Ws6P.js';
5
+ export { b as ModuleRunnerTransportHandlers, c as createWebSocketModuleRunnerTransport } from './moduleRunnerTransport.d-CXw_Ws6P.js';
87
6
 
88
7
  interface SourceMapLike {
89
8
  version: number;
@@ -361,9 +280,9 @@ declare class EvaluatedModules {
361
280
  }
362
281
 
363
282
  declare class ESModulesEvaluator implements ModuleEvaluator {
364
- startOffset: number;
283
+ readonly startOffset: number;
365
284
  runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
366
285
  runExternalModule(filepath: string): Promise<any>;
367
286
  }
368
287
 
369
- export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRLogger, type InterceptorOptions, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, type ModuleRunnerTransport, type ModuleRunnerTransportHandlers, type ResolvedResult, type SSRImportMetadata, createWebSocketModuleRunnerTransport, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
288
+ export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, type FetchFunction, FetchFunctionOptions, FetchResult, type HMRLogger, type InterceptorOptions, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, ModuleRunnerTransport, type ResolvedResult, type SSRImportMetadata, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };