vite 6.0.0-alpha.1 → 6.0.0-alpha.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/client/client.mjs +9 -8
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-BD8Vf02W.js → dep-BJOLgJFH.js} +1 -1
- package/dist/node/chunks/dep-C7zR1Rh8.js +233 -0
- package/dist/node/chunks/{dep-gq9_cnPm.js → dep-DhoCcTbV.js} +27173 -27153
- package/dist/node/chunks/{dep-DPzWXNBe.js → dep-m9gtlanK.js} +1 -1
- package/dist/node/cli.js +43 -73
- package/dist/node/index.d.ts +183 -85
- package/dist/node/index.js +9 -120
- package/dist/node/module-runner.d.ts +11 -10
- package/dist/node/module-runner.js +55 -44
- package/dist/node-cjs/publicUtils.cjs +72 -33
- package/package.json +6 -6
package/dist/node/index.d.ts
CHANGED
@@ -632,6 +632,7 @@ interface Logger {
|
|
632
632
|
interface LogOptions {
|
633
633
|
clear?: boolean;
|
634
634
|
timestamp?: boolean;
|
635
|
+
environment?: string;
|
635
636
|
}
|
636
637
|
interface LogErrorOptions extends LogOptions {
|
637
638
|
error?: Error | RollupError | null;
|
@@ -787,6 +788,29 @@ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
|
|
787
788
|
* https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
|
788
789
|
*/
|
789
790
|
|
791
|
+
interface BoundedPluginContainer {
|
792
|
+
options: InputOptions;
|
793
|
+
buildStart(options: InputOptions): Promise<void>;
|
794
|
+
resolveId(id: string, importer: string | undefined, options?: {
|
795
|
+
attributes?: Record<string, string>;
|
796
|
+
custom?: CustomPluginOptions;
|
797
|
+
skip?: Set<Plugin>;
|
798
|
+
isEntry?: boolean;
|
799
|
+
}): Promise<PartialResolvedId | null>;
|
800
|
+
transform(code: string, id: string, options?: {
|
801
|
+
inMap?: SourceDescription['map'];
|
802
|
+
}): Promise<{
|
803
|
+
code: string;
|
804
|
+
map: SourceMap | {
|
805
|
+
mappings: '';
|
806
|
+
} | null;
|
807
|
+
}>;
|
808
|
+
load(id: string, options?: {}): Promise<LoadResult | null>;
|
809
|
+
watchChange(id: string, change: {
|
810
|
+
event: 'create' | 'update' | 'delete';
|
811
|
+
}): Promise<void>;
|
812
|
+
close(): Promise<void>;
|
813
|
+
}
|
790
814
|
interface PluginContainer {
|
791
815
|
options: InputOptions;
|
792
816
|
buildStart(options: InputOptions): Promise<void>;
|
@@ -1353,9 +1377,11 @@ declare namespace WebSocket {
|
|
1353
1377
|
}
|
1354
1378
|
|
1355
1379
|
declare class Environment {
|
1380
|
+
#private;
|
1356
1381
|
name: string;
|
1357
1382
|
config: ResolvedConfig;
|
1358
1383
|
options: ResolvedEnvironmentOptions;
|
1384
|
+
get plugins(): BoundedPlugin[];
|
1359
1385
|
get logger(): Logger;
|
1360
1386
|
constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
1361
1387
|
}
|
@@ -1370,8 +1396,14 @@ interface FetchModuleOptions {
|
|
1370
1396
|
*/
|
1371
1397
|
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
1372
1398
|
|
1399
|
+
declare class ScanEnvironment extends Environment {
|
1400
|
+
mode: "scan";
|
1401
|
+
get pluginContainer(): BoundedPluginContainer;
|
1402
|
+
init(): Promise<void>;
|
1403
|
+
}
|
1404
|
+
|
1373
1405
|
type ExportsData = {
|
1374
|
-
|
1406
|
+
hasModuleSyntax: boolean;
|
1375
1407
|
exports: readonly string[];
|
1376
1408
|
jsxLoader?: boolean;
|
1377
1409
|
};
|
@@ -1531,11 +1563,6 @@ interface DepOptimizationMetadata {
|
|
1531
1563
|
*/
|
1532
1564
|
depInfoList: OptimizedDepInfo[];
|
1533
1565
|
}
|
1534
|
-
/**
|
1535
|
-
* Scan and optimize dependencies within a project.
|
1536
|
-
* Used by Vite CLI when running `vite optimize`.
|
1537
|
-
*/
|
1538
|
-
declare function optimizeDeps(environment: Environment, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
1539
1566
|
|
1540
1567
|
declare class RemoteEnvironmentTransport {
|
1541
1568
|
private readonly options;
|
@@ -1548,16 +1575,19 @@ declare class RemoteEnvironmentTransport {
|
|
1548
1575
|
|
1549
1576
|
interface DevEnvironmentSetup {
|
1550
1577
|
hot?: false | HMRChannel;
|
1578
|
+
watcher?: FSWatcher;
|
1551
1579
|
options?: EnvironmentOptions;
|
1552
1580
|
runner?: FetchModuleOptions & {
|
1553
1581
|
transport?: RemoteEnvironmentTransport;
|
1554
1582
|
};
|
1583
|
+
depsOptimizer?: DepsOptimizer;
|
1555
1584
|
}
|
1556
1585
|
declare class DevEnvironment extends Environment {
|
1557
1586
|
mode: "dev";
|
1558
1587
|
moduleGraph: EnvironmentModuleGraph;
|
1559
|
-
|
1588
|
+
watcher?: FSWatcher;
|
1560
1589
|
depsOptimizer?: DepsOptimizer;
|
1590
|
+
get pluginContainer(): BoundedPluginContainer;
|
1561
1591
|
/**
|
1562
1592
|
* HMR channel for this environment. If not provided or disabled,
|
1563
1593
|
* it will be a noop channel that does nothing.
|
@@ -1566,18 +1596,21 @@ declare class DevEnvironment extends Environment {
|
|
1566
1596
|
* environment.hot.send({ type: 'full-reload' })
|
1567
1597
|
*/
|
1568
1598
|
hot: HMRChannel;
|
1569
|
-
constructor(
|
1570
|
-
|
1571
|
-
options?: EnvironmentOptions;
|
1572
|
-
runner?: FetchModuleOptions & {
|
1573
|
-
transport?: RemoteEnvironmentTransport;
|
1574
|
-
};
|
1575
|
-
depsOptimizer?: DepsOptimizer;
|
1576
|
-
});
|
1599
|
+
constructor(name: string, config: ResolvedConfig, setup?: DevEnvironmentSetup);
|
1600
|
+
init(): Promise<void>;
|
1577
1601
|
fetchModule(id: string, importer?: string): Promise<FetchResult>;
|
1578
1602
|
transformRequest(url: string): Promise<TransformResult | null>;
|
1579
1603
|
warmupRequest(url: string): Promise<void>;
|
1580
1604
|
close(): Promise<void>;
|
1605
|
+
/**
|
1606
|
+
* Calling `await environment.waitForRequestsIdle(id)` will wait until all static imports
|
1607
|
+
* are processed after the first transformRequest call. If called from a load or transform
|
1608
|
+
* plugin hook, the id needs to be passed as a parameter to avoid deadlocks.
|
1609
|
+
* Calling this function after the first static imports section of the module graph has been
|
1610
|
+
* processed will resolve immediately.
|
1611
|
+
* @experimental
|
1612
|
+
*/
|
1613
|
+
waitForRequestsIdle(ignoredId?: string): Promise<void>;
|
1581
1614
|
}
|
1582
1615
|
|
1583
1616
|
interface TransformResult {
|
@@ -1585,6 +1618,7 @@ interface TransformResult {
|
|
1585
1618
|
map: SourceMap | {
|
1586
1619
|
mappings: '';
|
1587
1620
|
} | null;
|
1621
|
+
ssr?: boolean;
|
1588
1622
|
etag?: string;
|
1589
1623
|
deps?: string[];
|
1590
1624
|
dynamicDeps?: string[];
|
@@ -2023,11 +2057,12 @@ interface ViteDevServer {
|
|
2023
2057
|
*
|
2024
2058
|
* Always sends a message to at least a WebSocket client. Any third party can
|
2025
2059
|
* add a channel to the broadcaster to process messages
|
2026
|
-
* @deprecated use `
|
2060
|
+
* @deprecated use `environment.hot` instead
|
2027
2061
|
*/
|
2028
2062
|
hot: HMRBroadcaster;
|
2029
2063
|
/**
|
2030
2064
|
* Rollup plugin container that can run plugin hooks on a given file
|
2065
|
+
* @deprecated use `environment.pluginContainer` instead
|
2031
2066
|
*/
|
2032
2067
|
pluginContainer: PluginContainer;
|
2033
2068
|
/**
|
@@ -2037,7 +2072,7 @@ interface ViteDevServer {
|
|
2037
2072
|
/**
|
2038
2073
|
* Module graph that tracks the import relationships, url to file mapping
|
2039
2074
|
* and hmr state.
|
2040
|
-
* @deprecated use environment
|
2075
|
+
* @deprecated use `environment.moduleGraph` instead
|
2041
2076
|
*/
|
2042
2077
|
moduleGraph: ModuleGraph;
|
2043
2078
|
/**
|
@@ -2064,6 +2099,7 @@ interface ViteDevServer {
|
|
2064
2099
|
transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
|
2065
2100
|
/**
|
2066
2101
|
* Transform module code into SSR format.
|
2102
|
+
* TODO: expose this to any environment?
|
2067
2103
|
*/
|
2068
2104
|
ssrTransform(code: string, inMap: SourceMap | {
|
2069
2105
|
mappings: '';
|
@@ -2124,6 +2160,7 @@ interface ViteDevServer {
|
|
2124
2160
|
* passed as a parameter to avoid deadlocks. Calling this function after the first
|
2125
2161
|
* static imports section of the module graph has been processed will resolve immediately.
|
2126
2162
|
* @experimental
|
2163
|
+
* @deprecated use environment.waitForRequestsIdle()
|
2127
2164
|
*/
|
2128
2165
|
waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
|
2129
2166
|
}
|
@@ -2815,7 +2852,7 @@ interface BuildEnvironmentOptions {
|
|
2815
2852
|
/**
|
2816
2853
|
* create the Build Environment instance
|
2817
2854
|
*/
|
2818
|
-
createEnvironment?: (
|
2855
|
+
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
|
2819
2856
|
}
|
2820
2857
|
interface BuildOptions extends BuildEnvironmentOptions {
|
2821
2858
|
/**
|
@@ -2892,25 +2929,25 @@ type RenderBuiltAssetUrl = (filename: string, type: {
|
|
2892
2929
|
} | undefined;
|
2893
2930
|
declare class BuildEnvironment extends Environment {
|
2894
2931
|
mode: "build";
|
2895
|
-
|
2896
|
-
constructor(builder: ViteBuilder, name: string, setup?: {
|
2932
|
+
constructor(name: string, config: ResolvedConfig, setup?: {
|
2897
2933
|
options?: EnvironmentOptions;
|
2898
2934
|
});
|
2935
|
+
init(): Promise<void>;
|
2899
2936
|
}
|
2900
2937
|
interface ViteBuilder {
|
2901
2938
|
environments: Record<string, BuildEnvironment>;
|
2902
2939
|
config: ResolvedConfig;
|
2903
|
-
|
2940
|
+
buildApp(): Promise<void>;
|
2904
2941
|
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2905
2942
|
}
|
2906
2943
|
interface BuilderOptions {
|
2907
|
-
|
2944
|
+
sharedConfigBuild?: boolean;
|
2945
|
+
sharedPlugins?: boolean;
|
2946
|
+
entireApp?: boolean;
|
2947
|
+
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2908
2948
|
}
|
2909
2949
|
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2910
|
-
|
2911
|
-
plugins?: () => PluginOption[];
|
2912
|
-
}
|
2913
|
-
declare function createViteBuilder(builderOptions?: BuilderOptions, defaultBuilderInlineConfig?: BuilderInlineConfig): Promise<ViteBuilder>;
|
2950
|
+
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2914
2951
|
|
2915
2952
|
interface ESBuildOptions extends esbuild_TransformOptions {
|
2916
2953
|
include?: string | RegExp | string[] | RegExp[];
|
@@ -2924,7 +2961,7 @@ interface ESBuildOptions extends esbuild_TransformOptions {
|
|
2924
2961
|
type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
|
2925
2962
|
map: SourceMap;
|
2926
2963
|
};
|
2927
|
-
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
2964
|
+
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object, root?: string, watcher?: any): Promise<ESBuildTransformResult>;
|
2928
2965
|
|
2929
2966
|
interface FsUtils {
|
2930
2967
|
existsSync: (path: string) => boolean;
|
@@ -3195,14 +3232,36 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3195
3232
|
* or a build environment. Plugins can use this.environment.mode === 'dev' to
|
3196
3233
|
* check if they have access to dev specific APIs.
|
3197
3234
|
*/
|
3198
|
-
type PluginEnvironment = DevEnvironment | BuildEnvironment;
|
3235
|
+
type PluginEnvironment = DevEnvironment | BuildEnvironment | ScanEnvironment;
|
3199
3236
|
interface PluginContext extends rollup.PluginContext {
|
3200
3237
|
environment?: PluginEnvironment;
|
3201
3238
|
}
|
3239
|
+
interface ResolveIdPluginContext extends rollup.PluginContext {
|
3240
|
+
environment?: PluginEnvironment;
|
3241
|
+
}
|
3202
3242
|
interface TransformPluginContext extends rollup.TransformPluginContext {
|
3203
3243
|
environment?: PluginEnvironment;
|
3204
3244
|
}
|
3205
|
-
|
3245
|
+
/**
|
3246
|
+
* There are two types of plugins in Vite. App plugins and environment plugins.
|
3247
|
+
* Environment Plugins are defined by a constructor function that will be called
|
3248
|
+
* once per each environment allowing users to have completely different plugins
|
3249
|
+
* for each of them. The constructor gets the resolved environment after the server
|
3250
|
+
* and builder has already been created simplifying config access and cache
|
3251
|
+
* managementfor for environment specific plugins.
|
3252
|
+
* Environment Plugins are closer to regular rollup plugins. They can't define
|
3253
|
+
* app level hooks (like config, configResolved, configureServer, etc).
|
3254
|
+
*/
|
3255
|
+
type ModifyFunctionContext<Function_, NewContext> = Function_ extends (this: infer This, ...parameters: infer Arguments) => infer Return ? (this: NewContext, ...parameters: Arguments) => Return : never;
|
3256
|
+
type ModifyObjectHookContext<Handler, Object_ extends {
|
3257
|
+
handler: Handler;
|
3258
|
+
}, NewContext> = Object_ & {
|
3259
|
+
handler: ModifyFunctionContext<Handler, NewContext>;
|
3260
|
+
};
|
3261
|
+
type ModifyHookContext<Hook, NewContext> = Hook extends {
|
3262
|
+
handler: infer Handler;
|
3263
|
+
} ? ModifyObjectHookContext<Handler, Hook, NewContext> : ModifyFunctionContext<Hook, NewContext>;
|
3264
|
+
interface BasePlugin<A = any> extends rollup.Plugin<A> {
|
3206
3265
|
/**
|
3207
3266
|
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
|
3208
3267
|
* is still subject to the `order` property in the hook object.
|
@@ -3217,6 +3276,61 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3217
3276
|
* - vite build post plugins
|
3218
3277
|
*/
|
3219
3278
|
enforce?: 'pre' | 'post';
|
3279
|
+
/**
|
3280
|
+
* Perform custom handling of HMR updates.
|
3281
|
+
* The handler receives a context containing changed filename, timestamp, a
|
3282
|
+
* list of modules affected by the file change, and the dev server instance.
|
3283
|
+
*
|
3284
|
+
* - The hook can return a filtered list of modules to narrow down the update.
|
3285
|
+
* e.g. for a Vue SFC, we can narrow down the part to update by comparing
|
3286
|
+
* the descriptors.
|
3287
|
+
*
|
3288
|
+
* - The hook can also return an empty array and then perform custom updates
|
3289
|
+
* by sending a custom hmr payload via server.hot.send().
|
3290
|
+
*
|
3291
|
+
* - If the hook doesn't return a value, the hmr update will be performed as
|
3292
|
+
* normal.
|
3293
|
+
*/
|
3294
|
+
hotUpdate?: ObjectHook<(this: void, ctx: HotUpdateContext) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
|
3295
|
+
/**
|
3296
|
+
* extend hooks with ssr flag
|
3297
|
+
*/
|
3298
|
+
resolveId?: ObjectHook<(this: ResolveIdPluginContext, source: string, importer: string | undefined, options: {
|
3299
|
+
attributes: Record<string, string>;
|
3300
|
+
custom?: CustomPluginOptions;
|
3301
|
+
/**
|
3302
|
+
* @deprecated use this.environment
|
3303
|
+
*/
|
3304
|
+
ssr?: boolean;
|
3305
|
+
isEntry: boolean;
|
3306
|
+
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
3307
|
+
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
3308
|
+
/**
|
3309
|
+
* @deprecated use this.environment
|
3310
|
+
*/
|
3311
|
+
ssr?: boolean;
|
3312
|
+
}) => Promise<LoadResult> | LoadResult>;
|
3313
|
+
transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
|
3314
|
+
/**
|
3315
|
+
* @deprecated use this.environment
|
3316
|
+
*/
|
3317
|
+
ssr?: boolean;
|
3318
|
+
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
3319
|
+
buildStart?: ModifyHookContext<rollup.Plugin<A>['buildStart'], PluginContext>;
|
3320
|
+
generateBundle?: ModifyHookContext<rollup.Plugin<A>['generateBundle'], PluginContext>;
|
3321
|
+
renderChunk?: ModifyHookContext<rollup.Plugin<A>['renderChunk'], PluginContext>;
|
3322
|
+
}
|
3323
|
+
type BoundedPlugin<A = any> = BasePlugin<A>;
|
3324
|
+
interface Plugin<A = any> extends BasePlugin<A> {
|
3325
|
+
/**
|
3326
|
+
* Opt-in this plugin into the shared plugins pipeline.
|
3327
|
+
* For backward-compatibility, plugins are re-recreated for each environment
|
3328
|
+
* during `vite build --app`
|
3329
|
+
* We have an opt-in per plugin, and a general `builder.sharedPlugins`
|
3330
|
+
* In a future major, we'll flip the default to be shared by default
|
3331
|
+
* @experimental
|
3332
|
+
*/
|
3333
|
+
sharedDuringBuild?: boolean;
|
3220
3334
|
/**
|
3221
3335
|
* Apply the plugin only for serve or build, or on certain conditions.
|
3222
3336
|
*/
|
@@ -3287,51 +3401,19 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3287
3401
|
* with the mixed client and ssr moduleGraph. Use hotUpdate instead
|
3288
3402
|
*/
|
3289
3403
|
handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
|
3290
|
-
/**
|
3291
|
-
* Perform custom handling of HMR updates.
|
3292
|
-
* The handler receives a context containing changed filename, timestamp, a
|
3293
|
-
* list of modules affected by the file change, and the dev server instance.
|
3294
|
-
*
|
3295
|
-
* - The hook can return a filtered list of modules to narrow down the update.
|
3296
|
-
* e.g. for a Vue SFC, we can narrow down the part to update by comparing
|
3297
|
-
* the descriptors.
|
3298
|
-
*
|
3299
|
-
* - The hook can also return an empty array and then perform custom updates
|
3300
|
-
* by sending a custom hmr payload via server.hot.send().
|
3301
|
-
*
|
3302
|
-
* - If the hook doesn't return a value, the hmr update will be performed as
|
3303
|
-
* normal.
|
3304
|
-
*/
|
3305
|
-
hotUpdate?: ObjectHook<(this: void, ctx: HotUpdateContext) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
|
3306
|
-
/**
|
3307
|
-
* extend hooks with ssr flag
|
3308
|
-
*/
|
3309
|
-
resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
|
3310
|
-
attributes: Record<string, string>;
|
3311
|
-
custom?: CustomPluginOptions;
|
3312
|
-
/**
|
3313
|
-
* @deprecated use this.environment
|
3314
|
-
*/
|
3315
|
-
ssr?: boolean;
|
3316
|
-
isEntry: boolean;
|
3317
|
-
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
3318
|
-
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
3319
|
-
/**
|
3320
|
-
* @deprecated use this.environment
|
3321
|
-
*/
|
3322
|
-
ssr?: boolean;
|
3323
|
-
}) => Promise<LoadResult> | LoadResult>;
|
3324
|
-
transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
|
3325
|
-
/**
|
3326
|
-
* @deprecated use this.environment
|
3327
|
-
*/
|
3328
|
-
ssr?: boolean;
|
3329
|
-
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
3330
3404
|
}
|
3331
3405
|
type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
|
3332
3406
|
type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
|
3333
3407
|
[P in K]: NonNullable<Plugin[P]>;
|
3334
3408
|
};
|
3409
|
+
type BoundedPluginConstructor = {
|
3410
|
+
(environment: PluginEnvironment): BoundedPluginOption;
|
3411
|
+
sharedDuringBuild?: boolean;
|
3412
|
+
};
|
3413
|
+
type MaybeBoundedPlugin = BoundedPlugin | false | null | undefined;
|
3414
|
+
type BoundedPluginOption = MaybeBoundedPlugin | BoundedPluginOption[] | Promise<MaybeBoundedPlugin | BoundedPluginOption[]>;
|
3415
|
+
type MaybePlugin = Plugin | BoundedPluginConstructor | false | null | undefined;
|
3416
|
+
type PluginOption = MaybePlugin | PluginOption[] | Promise<MaybePlugin | PluginOption[]>;
|
3335
3417
|
|
3336
3418
|
interface JsonOptions {
|
3337
3419
|
/**
|
@@ -3443,17 +3525,14 @@ declare function defineConfig(config: UserConfig): UserConfig;
|
|
3443
3525
|
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
3444
3526
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
3445
3527
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3446
|
-
type PluginOption = Plugin | false | null | undefined | PluginOption[] | Promise<Plugin | false | null | undefined | PluginOption[]>;
|
3447
3528
|
interface DevEnvironmentOptions {
|
3448
3529
|
/**
|
3449
|
-
*
|
3530
|
+
* Files tßo be pre-transformed. Supports glob patterns.
|
3450
3531
|
*/
|
3451
|
-
warmup?:
|
3452
|
-
files: string[];
|
3453
|
-
};
|
3532
|
+
warmup?: string[];
|
3454
3533
|
/**
|
3455
3534
|
* Pre-transform known direct imports
|
3456
|
-
*
|
3535
|
+
* defaults to true for the client environment, false for the rest
|
3457
3536
|
*/
|
3458
3537
|
preTransformRequests?: boolean;
|
3459
3538
|
/**
|
@@ -3481,7 +3560,7 @@ interface DevEnvironmentOptions {
|
|
3481
3560
|
/**
|
3482
3561
|
* create the Dev Environment instance
|
3483
3562
|
*/
|
3484
|
-
createEnvironment?: (
|
3563
|
+
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<DevEnvironment> | DevEnvironment;
|
3485
3564
|
/**
|
3486
3565
|
* For environments that support a full-reload, like the client, we can short-circuit when
|
3487
3566
|
* restarting the server throwing early to stop processing current files. We avoided this for
|
@@ -3489,9 +3568,15 @@ interface DevEnvironmentOptions {
|
|
3489
3568
|
* @experimental
|
3490
3569
|
*/
|
3491
3570
|
recoverable?: boolean;
|
3571
|
+
/**
|
3572
|
+
* For environments associated with a module runner.
|
3573
|
+
* By default it is true for the client environment and false for non-client environments.
|
3574
|
+
* This option can also be used instead of the removed config.experimental.skipSsrTransform.
|
3575
|
+
*/
|
3576
|
+
moduleRunnerTransform?: boolean;
|
3492
3577
|
}
|
3493
3578
|
type ResolvedDevEnvironmentOptions = Required<Omit<DevEnvironmentOptions, 'createEnvironment'>> & {
|
3494
|
-
createEnvironment: ((
|
3579
|
+
createEnvironment: ((name: string, config: ResolvedConfig) => Promise<DevEnvironment> | DevEnvironment) | undefined;
|
3495
3580
|
};
|
3496
3581
|
type EnvironmentResolveOptions = ResolveOptions & {
|
3497
3582
|
alias?: AliasOptions;
|
@@ -3507,6 +3592,13 @@ interface SharedEnvironmentOptions {
|
|
3507
3592
|
*/
|
3508
3593
|
nodeCompatible?: boolean;
|
3509
3594
|
webCompatible?: boolean;
|
3595
|
+
/**
|
3596
|
+
* Should Vite inject timestamp if module is invalidated
|
3597
|
+
* Disabling this will break built-in HMR support
|
3598
|
+
* @experimental
|
3599
|
+
* @default true
|
3600
|
+
*/
|
3601
|
+
injectInvalidationTimestamp?: boolean;
|
3510
3602
|
}
|
3511
3603
|
interface EnvironmentOptions extends SharedEnvironmentOptions {
|
3512
3604
|
/**
|
@@ -3523,6 +3615,7 @@ type ResolvedEnvironmentOptions = {
|
|
3523
3615
|
resolve: ResolvedEnvironmentResolveOptions;
|
3524
3616
|
nodeCompatible: boolean;
|
3525
3617
|
webCompatible: boolean;
|
3618
|
+
injectInvalidationTimestamp: boolean;
|
3526
3619
|
dev: ResolvedDevEnvironmentOptions;
|
3527
3620
|
build: ResolvedBuildEnvironmentOptions;
|
3528
3621
|
};
|
@@ -3741,7 +3834,10 @@ interface LegacyOptions {
|
|
3741
3834
|
}
|
3742
3835
|
interface ResolvedWorkerOptions {
|
3743
3836
|
format: 'es' | 'iife';
|
3744
|
-
plugins: (bundleChain: string[]) => Promise<
|
3837
|
+
plugins: (bundleChain: string[]) => Promise<{
|
3838
|
+
plugins: Plugin[];
|
3839
|
+
config: ResolvedConfig;
|
3840
|
+
}>;
|
3745
3841
|
rollupOptions: RollupOptions;
|
3746
3842
|
}
|
3747
3843
|
interface InlineConfig extends UserConfig {
|
@@ -3766,6 +3862,7 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
|
|
3766
3862
|
alias: Alias[];
|
3767
3863
|
};
|
3768
3864
|
plugins: readonly Plugin[];
|
3865
|
+
rawPlugins: readonly (Plugin | BoundedPluginConstructor)[];
|
3769
3866
|
css: ResolvedCSSOptions;
|
3770
3867
|
esbuild: ESBuildOptions | false;
|
3771
3868
|
server: ResolvedServerOptions;
|
@@ -3788,7 +3885,7 @@ interface PluginHookUtils {
|
|
3788
3885
|
getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
|
3789
3886
|
}
|
3790
3887
|
type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
|
3791
|
-
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean): Promise<ResolvedConfig>;
|
3888
|
+
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean, patchConfig?: ((config: ResolvedConfig) => void) | undefined, patchPlugins?: ((plugins: (Plugin | BoundedPluginConstructor)[]) => void) | undefined): Promise<ResolvedConfig>;
|
3792
3889
|
declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
|
3793
3890
|
declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger): Promise<{
|
3794
3891
|
path: string;
|
@@ -3798,7 +3895,7 @@ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, c
|
|
3798
3895
|
|
3799
3896
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3800
3897
|
|
3801
|
-
declare function createNodeDevEnvironment(
|
3898
|
+
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, options?: DevEnvironmentSetup): DevEnvironment;
|
3802
3899
|
|
3803
3900
|
/**
|
3804
3901
|
* @experimental
|
@@ -3812,9 +3909,9 @@ interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | '
|
|
3812
3909
|
logger?: ModuleRunnerHmr['logger'];
|
3813
3910
|
};
|
3814
3911
|
/**
|
3815
|
-
* Provide a custom module
|
3912
|
+
* Provide a custom module evaluator. This controls how the code is executed.
|
3816
3913
|
*/
|
3817
|
-
|
3914
|
+
evaluator?: ModuleEvaluator;
|
3818
3915
|
}
|
3819
3916
|
/**
|
3820
3917
|
* Create an instance of the Vite SSR runtime that support HMR.
|
@@ -3827,11 +3924,11 @@ declare function createServerModuleRunner(environment: DevEnvironment, options?:
|
|
3827
3924
|
* @experimental
|
3828
3925
|
*/
|
3829
3926
|
declare class ServerHMRConnector implements ModuleRunnerHMRConnection {
|
3830
|
-
private handlers;
|
3831
3927
|
private hmrChannel;
|
3928
|
+
private handlers;
|
3832
3929
|
private hmrClient;
|
3833
3930
|
private connected;
|
3834
|
-
constructor(
|
3931
|
+
constructor(hmrChannel: ServerHMRChannel);
|
3835
3932
|
isReady(): boolean;
|
3836
3933
|
send(message: string): void;
|
3837
3934
|
onUpdate(handler: (payload: HMRPayload) => void): void;
|
@@ -3888,6 +3985,7 @@ declare function searchForWorkspaceRoot(current: string, root?: string): string;
|
|
3888
3985
|
|
3889
3986
|
/**
|
3890
3987
|
* Check if the url is allowed to be served, via the `server.fs` config.
|
3988
|
+
* @deprecate use isFileLoadingAllowed
|
3891
3989
|
*/
|
3892
3990
|
declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
|
3893
3991
|
|
@@ -3907,4 +4005,4 @@ interface ManifestChunk {
|
|
3907
4005
|
dynamicImports?: string[];
|
3908
4006
|
}
|
3909
4007
|
|
3910
|
-
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, EnvironmentModuleGraph, EnvironmentModuleNode, 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 HotUpdateContext, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, 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 OptimizedDepInfo, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, RemoteEnvironmentTransport, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createFilter, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner,
|
4008
|
+
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, type BoundedPlugin, type BoundedPluginConstructor, 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 DevEnvironmentOptions, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, EnvironmentModuleGraph, EnvironmentModuleNode, 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 HotUpdateContext, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, 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 OptimizedDepInfo, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, RemoteEnvironmentTransport, 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, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, 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, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
|