vite 6.0.0-alpha.8 → 6.0.0-beta.0
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/LICENSE.md +115 -206
- package/bin/vite.js +1 -1
- package/client.d.ts +12 -0
- package/dist/client/client.mjs +614 -612
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep-8PNdpITG.js → dep-Bv1xMYNy.js} +45999 -47654
- package/dist/node/chunks/{dep-m9gtlanK.js → dep-CSD_20z-.js} +1 -1
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-BJOLgJFH.js → dep-D9t7igss.js} +165 -968
- package/dist/node/cli.js +282 -257
- package/dist/node/constants.js +108 -84
- package/dist/node/index.d.ts +2084 -2035
- package/dist/node/index.js +237 -148
- package/dist/node/module-runner.d.ts +31 -12
- package/dist/node/module-runner.js +262 -204
- package/dist/node-cjs/publicUtils.cjs +679 -717
- package/index.cjs +27 -5
- package/package.json +34 -31
- package/types/customEvent.d.ts +1 -0
- package/types/hmrPayload.d.ts +3 -1
- package/dist/client/client.mjs.map +0 -1
- package/dist/client/env.mjs.map +0 -1
- package/dist/node/chunks/dep-C7zR1Rh8.js +0 -233
package/dist/node/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { PluginHooks, RollupError,
|
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';
|
3
3
|
import * as rollup from 'rollup';
|
4
4
|
export { rollup as Rollup };
|
5
5
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
@@ -15,16 +15,16 @@ import * as url from 'node:url';
|
|
15
15
|
import { URL } from 'node:url';
|
16
16
|
import * as stream from 'node:stream';
|
17
17
|
import { Duplex, DuplexOptions } from 'node:stream';
|
18
|
-
import {
|
19
|
-
import { ZlibOptions } from 'node:zlib';
|
20
|
-
import { HMRPayload, CustomPayload } from '../../types/hmrPayload.js';
|
21
|
-
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, PrunePayload, Update, UpdatePayload } from '../../types/hmrPayload.js';
|
22
|
-
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
23
|
-
export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../../types/customEvent.js';
|
24
|
-
import { FetchResult, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
|
18
|
+
import { FetchResult, FetchFunctionOptions, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
|
25
19
|
export { FetchFunction, FetchResult } from 'vite/module-runner';
|
26
20
|
import { BuildOptions as esbuild_BuildOptions, TransformOptions as esbuild_TransformOptions, TransformResult as esbuild_TransformResult } from 'esbuild';
|
27
21
|
export { TransformOptions as EsbuildTransformOptions, version as esbuildVersion } from 'esbuild';
|
22
|
+
import { HotPayload, CustomPayload } from '../../types/hmrPayload.js';
|
23
|
+
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hmrPayload.js';
|
24
|
+
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
25
|
+
export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../../types/customEvent.js';
|
26
|
+
import { SecureContextOptions } from 'node:tls';
|
27
|
+
import { ZlibOptions } from 'node:zlib';
|
28
28
|
import * as PostCSS from 'postcss';
|
29
29
|
export { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap } from '../../types/importGlob.js';
|
30
30
|
export { ChunkMetadata } from '../../types/metadata.js';
|
@@ -412,6 +412,7 @@ declare namespace HttpProxy {
|
|
412
412
|
* @param req - Client request.
|
413
413
|
* @param res - Client response.
|
414
414
|
* @param options - Additional options.
|
415
|
+
* @param callback - Error callback.
|
415
416
|
*/
|
416
417
|
web(
|
417
418
|
req: http.IncomingMessage,
|
@@ -426,6 +427,7 @@ declare namespace HttpProxy {
|
|
426
427
|
* @param socket - Client socket.
|
427
428
|
* @param head - Client head.
|
428
429
|
* @param options - Additional options.
|
430
|
+
* @param callback - Error callback.
|
429
431
|
*/
|
430
432
|
ws(
|
431
433
|
req: http.IncomingMessage,
|
@@ -616,6 +618,12 @@ interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
616
618
|
* webpack-dev-server style bypass function
|
617
619
|
*/
|
618
620
|
bypass?: (req: http.IncomingMessage, res: http.ServerResponse, options: ProxyOptions) => void | null | undefined | false | string;
|
621
|
+
/**
|
622
|
+
* rewrite the Origin header of a WebSocket request to match the the target
|
623
|
+
*
|
624
|
+
* **Exercise caution as rewriting the Origin can leave the proxying open to [CSRF attacks](https://owasp.org/www-community/attacks/csrf).**
|
625
|
+
*/
|
626
|
+
rewriteWsOrigin?: boolean | undefined;
|
619
627
|
}
|
620
628
|
|
621
629
|
type LogType = 'error' | 'warn' | 'info';
|
@@ -679,8 +687,8 @@ interface CommonServerOptions {
|
|
679
687
|
* ``` js
|
680
688
|
* module.exports = {
|
681
689
|
* proxy: {
|
682
|
-
* // string shorthand
|
683
|
-
* '/foo': 'http://localhost:4567
|
690
|
+
* // string shorthand: /foo -> http://localhost:4567/foo
|
691
|
+
* '/foo': 'http://localhost:4567',
|
684
692
|
* // with options
|
685
693
|
* '/api': {
|
686
694
|
* target: 'http://jsonplaceholder.typicode.com',
|
@@ -708,7 +716,7 @@ interface CommonServerOptions {
|
|
708
716
|
* https://github.com/expressjs/cors#configuration-options
|
709
717
|
*/
|
710
718
|
interface CorsOptions {
|
711
|
-
origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
719
|
+
origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
712
720
|
methods?: string | string[];
|
713
721
|
allowedHeaders?: string | string[];
|
714
722
|
exposedHeaders?: string | string[];
|
@@ -783,835 +791,220 @@ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
|
|
783
791
|
action?(server: Server): void | Promise<void>;
|
784
792
|
};
|
785
793
|
|
794
|
+
declare class PartialEnvironment {
|
795
|
+
name: string;
|
796
|
+
getTopLevelConfig(): ResolvedConfig;
|
797
|
+
config: ResolvedConfig & ResolvedEnvironmentOptions;
|
798
|
+
/**
|
799
|
+
* @deprecated use environment.config instead
|
800
|
+
**/
|
801
|
+
get options(): ResolvedEnvironmentOptions;
|
802
|
+
logger: Logger;
|
803
|
+
constructor(name: string, topLevelConfig: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
804
|
+
}
|
805
|
+
declare class BaseEnvironment extends PartialEnvironment {
|
806
|
+
get plugins(): Plugin[];
|
807
|
+
constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
808
|
+
}
|
786
809
|
/**
|
787
|
-
* This
|
788
|
-
*
|
810
|
+
* This class discourages users from inversely checking the `mode`
|
811
|
+
* to determine the type of environment, e.g.
|
812
|
+
*
|
813
|
+
* ```js
|
814
|
+
* const isDev = environment.mode !== 'build' // bad
|
815
|
+
* const isDev = environment.mode === 'dev' // good
|
816
|
+
* ```
|
817
|
+
*
|
818
|
+
* You should also not check against `"unknown"` specfically. It's
|
819
|
+
* a placeholder for more possible environment types.
|
789
820
|
*/
|
790
|
-
|
791
|
-
|
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>;
|
821
|
+
declare class UnknownEnvironment extends BaseEnvironment {
|
822
|
+
mode: "unknown";
|
813
823
|
}
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
custom?: CustomPluginOptions;
|
820
|
-
skip?: Set<Plugin>;
|
821
|
-
ssr?: boolean;
|
822
|
-
environment?: PluginEnvironment;
|
823
|
-
isEntry?: boolean;
|
824
|
-
}): Promise<PartialResolvedId | null>;
|
825
|
-
transform(code: string, id: string, options?: {
|
826
|
-
inMap?: SourceDescription['map'];
|
827
|
-
ssr?: boolean;
|
828
|
-
environment?: PluginEnvironment;
|
829
|
-
}): Promise<{
|
830
|
-
code: string;
|
831
|
-
map: SourceMap | {
|
832
|
-
mappings: '';
|
833
|
-
} | null;
|
834
|
-
}>;
|
835
|
-
load(id: string, options?: {
|
836
|
-
ssr?: boolean;
|
837
|
-
environment?: PluginEnvironment;
|
838
|
-
}): Promise<LoadResult | null>;
|
839
|
-
watchChange(id: string, change: {
|
840
|
-
event: 'create' | 'update' | 'delete';
|
841
|
-
}): Promise<void>;
|
842
|
-
close(): Promise<void>;
|
824
|
+
|
825
|
+
interface FetchModuleOptions {
|
826
|
+
cached?: boolean;
|
827
|
+
inlineSourceMap?: boolean;
|
828
|
+
processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
|
843
829
|
}
|
830
|
+
/**
|
831
|
+
* Fetch module information for Vite runner.
|
832
|
+
* @experimental
|
833
|
+
*/
|
834
|
+
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
844
835
|
|
845
|
-
|
846
|
-
|
836
|
+
declare class ScanEnvironment extends BaseEnvironment {
|
837
|
+
mode: "scan";
|
838
|
+
get pluginContainer(): EnvironmentPluginContainer;
|
839
|
+
init(): Promise<void>;
|
840
|
+
}
|
847
841
|
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
listener: (
|
1015
|
-
this: WebSocket,
|
1016
|
-
data: WebSocket.RawData,
|
1017
|
-
isBinary: boolean,
|
1018
|
-
) => void,
|
1019
|
-
): this
|
1020
|
-
once(event: 'open', listener: (this: WebSocket) => void): this
|
1021
|
-
once(
|
1022
|
-
event: 'ping' | 'pong',
|
1023
|
-
listener: (this: WebSocket, data: Buffer) => void,
|
1024
|
-
): this
|
1025
|
-
once(
|
1026
|
-
event: 'unexpected-response',
|
1027
|
-
listener: (
|
1028
|
-
this: WebSocket,
|
1029
|
-
request: ClientRequest,
|
1030
|
-
response: IncomingMessage,
|
1031
|
-
) => void,
|
1032
|
-
): this
|
1033
|
-
once(
|
1034
|
-
event: string | symbol,
|
1035
|
-
listener: (this: WebSocket, ...args: any[]) => void,
|
1036
|
-
): this
|
1037
|
-
|
1038
|
-
off(
|
1039
|
-
event: 'close',
|
1040
|
-
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
1041
|
-
): this
|
1042
|
-
off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
1043
|
-
off(
|
1044
|
-
event: 'upgrade',
|
1045
|
-
listener: (this: WebSocket, request: IncomingMessage) => void,
|
1046
|
-
): this
|
1047
|
-
off(
|
1048
|
-
event: 'message',
|
1049
|
-
listener: (
|
1050
|
-
this: WebSocket,
|
1051
|
-
data: WebSocket.RawData,
|
1052
|
-
isBinary: boolean,
|
1053
|
-
) => void,
|
1054
|
-
): this
|
1055
|
-
off(event: 'open', listener: (this: WebSocket) => void): this
|
1056
|
-
off(
|
1057
|
-
event: 'ping' | 'pong',
|
1058
|
-
listener: (this: WebSocket, data: Buffer) => void,
|
1059
|
-
): this
|
1060
|
-
off(
|
1061
|
-
event: 'unexpected-response',
|
1062
|
-
listener: (
|
1063
|
-
this: WebSocket,
|
1064
|
-
request: ClientRequest,
|
1065
|
-
response: IncomingMessage,
|
1066
|
-
) => void,
|
1067
|
-
): this
|
1068
|
-
off(
|
1069
|
-
event: string | symbol,
|
1070
|
-
listener: (this: WebSocket, ...args: any[]) => void,
|
1071
|
-
): this
|
1072
|
-
|
1073
|
-
addListener(
|
1074
|
-
event: 'close',
|
1075
|
-
listener: (code: number, reason: Buffer) => void,
|
1076
|
-
): this
|
1077
|
-
addListener(event: 'error', listener: (err: Error) => void): this
|
1078
|
-
addListener(
|
1079
|
-
event: 'upgrade',
|
1080
|
-
listener: (request: IncomingMessage) => void,
|
1081
|
-
): this
|
1082
|
-
addListener(
|
1083
|
-
event: 'message',
|
1084
|
-
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
1085
|
-
): this
|
1086
|
-
addListener(event: 'open', listener: () => void): this
|
1087
|
-
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
1088
|
-
addListener(
|
1089
|
-
event: 'unexpected-response',
|
1090
|
-
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
1091
|
-
): this
|
1092
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this
|
1093
|
-
|
1094
|
-
removeListener(
|
1095
|
-
event: 'close',
|
1096
|
-
listener: (code: number, reason: Buffer) => void,
|
1097
|
-
): this
|
1098
|
-
removeListener(event: 'error', listener: (err: Error) => void): this
|
1099
|
-
removeListener(
|
1100
|
-
event: 'upgrade',
|
1101
|
-
listener: (request: IncomingMessage) => void,
|
1102
|
-
): this
|
1103
|
-
removeListener(
|
1104
|
-
event: 'message',
|
1105
|
-
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
1106
|
-
): this
|
1107
|
-
removeListener(event: 'open', listener: () => void): this
|
1108
|
-
removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
1109
|
-
removeListener(
|
1110
|
-
event: 'unexpected-response',
|
1111
|
-
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
1112
|
-
): this
|
1113
|
-
removeListener(
|
1114
|
-
event: string | symbol,
|
1115
|
-
listener: (...args: any[]) => void,
|
1116
|
-
): this
|
1117
|
-
}
|
1118
|
-
// tslint:disable-line no-empty-interface
|
1119
|
-
|
1120
|
-
declare namespace WebSocket {
|
1121
|
-
/**
|
1122
|
-
* Data represents the raw message payload received over the WebSocket.
|
1123
|
-
*/
|
1124
|
-
type RawData = Buffer | ArrayBuffer | Buffer[]
|
1125
|
-
|
1126
|
-
/**
|
1127
|
-
* Data represents the message payload received over the WebSocket.
|
1128
|
-
*/
|
1129
|
-
type Data = string | Buffer | ArrayBuffer | Buffer[]
|
1130
|
-
|
1131
|
-
/**
|
1132
|
-
* CertMeta represents the accepted types for certificate & key data.
|
1133
|
-
*/
|
1134
|
-
type CertMeta = string | string[] | Buffer | Buffer[]
|
1135
|
-
|
1136
|
-
/**
|
1137
|
-
* VerifyClientCallbackSync is a synchronous callback used to inspect the
|
1138
|
-
* incoming message. The return value (boolean) of the function determines
|
1139
|
-
* whether or not to accept the handshake.
|
1140
|
-
*/
|
1141
|
-
type VerifyClientCallbackSync = (info: {
|
1142
|
-
origin: string
|
1143
|
-
secure: boolean
|
1144
|
-
req: IncomingMessage
|
1145
|
-
}) => boolean
|
1146
|
-
|
1147
|
-
/**
|
1148
|
-
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
|
1149
|
-
* incoming message. The return value (boolean) of the function determines
|
1150
|
-
* whether or not to accept the handshake.
|
1151
|
-
*/
|
1152
|
-
type VerifyClientCallbackAsync = (
|
1153
|
-
info: { origin: string; secure: boolean; req: IncomingMessage },
|
1154
|
-
callback: (
|
1155
|
-
res: boolean,
|
1156
|
-
code?: number,
|
1157
|
-
message?: string,
|
1158
|
-
headers?: OutgoingHttpHeaders,
|
1159
|
-
) => void,
|
1160
|
-
) => void
|
1161
|
-
|
1162
|
-
interface ClientOptions extends SecureContextOptions {
|
1163
|
-
protocol?: string | undefined
|
1164
|
-
followRedirects?: boolean | undefined
|
1165
|
-
generateMask?(mask: Buffer): void
|
1166
|
-
handshakeTimeout?: number | undefined
|
1167
|
-
maxRedirects?: number | undefined
|
1168
|
-
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
1169
|
-
localAddress?: string | undefined
|
1170
|
-
protocolVersion?: number | undefined
|
1171
|
-
headers?: { [key: string]: string } | undefined
|
1172
|
-
origin?: string | undefined
|
1173
|
-
agent?: Agent | undefined
|
1174
|
-
host?: string | undefined
|
1175
|
-
family?: number | undefined
|
1176
|
-
checkServerIdentity?(servername: string, cert: CertMeta): boolean
|
1177
|
-
rejectUnauthorized?: boolean | undefined
|
1178
|
-
maxPayload?: number | undefined
|
1179
|
-
skipUTF8Validation?: boolean | undefined
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
interface PerMessageDeflateOptions {
|
1183
|
-
serverNoContextTakeover?: boolean | undefined
|
1184
|
-
clientNoContextTakeover?: boolean | undefined
|
1185
|
-
serverMaxWindowBits?: number | undefined
|
1186
|
-
clientMaxWindowBits?: number | undefined
|
1187
|
-
zlibDeflateOptions?:
|
1188
|
-
| {
|
1189
|
-
flush?: number | undefined
|
1190
|
-
finishFlush?: number | undefined
|
1191
|
-
chunkSize?: number | undefined
|
1192
|
-
windowBits?: number | undefined
|
1193
|
-
level?: number | undefined
|
1194
|
-
memLevel?: number | undefined
|
1195
|
-
strategy?: number | undefined
|
1196
|
-
dictionary?: Buffer | Buffer[] | DataView | undefined
|
1197
|
-
info?: boolean | undefined
|
1198
|
-
}
|
1199
|
-
| undefined
|
1200
|
-
zlibInflateOptions?: ZlibOptions | undefined
|
1201
|
-
threshold?: number | undefined
|
1202
|
-
concurrencyLimit?: number | undefined
|
1203
|
-
}
|
1204
|
-
|
1205
|
-
interface Event {
|
1206
|
-
type: string
|
1207
|
-
target: WebSocket
|
1208
|
-
}
|
1209
|
-
|
1210
|
-
interface ErrorEvent {
|
1211
|
-
error: any
|
1212
|
-
message: string
|
1213
|
-
type: string
|
1214
|
-
target: WebSocket
|
1215
|
-
}
|
1216
|
-
|
1217
|
-
interface CloseEvent {
|
1218
|
-
wasClean: boolean
|
1219
|
-
code: number
|
1220
|
-
reason: string
|
1221
|
-
type: string
|
1222
|
-
target: WebSocket
|
1223
|
-
}
|
1224
|
-
|
1225
|
-
interface MessageEvent {
|
1226
|
-
data: Data
|
1227
|
-
type: string
|
1228
|
-
target: WebSocket
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
interface EventListenerOptions {
|
1232
|
-
once?: boolean | undefined
|
1233
|
-
}
|
1234
|
-
|
1235
|
-
interface ServerOptions {
|
1236
|
-
host?: string | undefined
|
1237
|
-
port?: number | undefined
|
1238
|
-
backlog?: number | undefined
|
1239
|
-
server?: Server | HttpsServer | undefined
|
1240
|
-
verifyClient?:
|
1241
|
-
| VerifyClientCallbackAsync
|
1242
|
-
| VerifyClientCallbackSync
|
1243
|
-
| undefined
|
1244
|
-
handleProtocols?: (
|
1245
|
-
protocols: Set<string>,
|
1246
|
-
request: IncomingMessage,
|
1247
|
-
) => string | false
|
1248
|
-
path?: string | undefined
|
1249
|
-
noServer?: boolean | undefined
|
1250
|
-
clientTracking?: boolean | undefined
|
1251
|
-
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
1252
|
-
maxPayload?: number | undefined
|
1253
|
-
skipUTF8Validation?: boolean | undefined
|
1254
|
-
WebSocket?: typeof WebSocket.WebSocket | undefined
|
1255
|
-
}
|
1256
|
-
|
1257
|
-
interface AddressInfo {
|
1258
|
-
address: string
|
1259
|
-
family: string
|
1260
|
-
port: number
|
1261
|
-
}
|
1262
|
-
|
1263
|
-
// WebSocket Server
|
1264
|
-
class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
1265
|
-
options: ServerOptions
|
1266
|
-
path: string
|
1267
|
-
clients: Set<T>
|
1268
|
-
|
1269
|
-
constructor(options?: ServerOptions, callback?: () => void)
|
1270
|
-
|
1271
|
-
address(): AddressInfo | string
|
1272
|
-
close(cb?: (err?: Error) => void): void
|
1273
|
-
handleUpgrade(
|
1274
|
-
request: IncomingMessage,
|
1275
|
-
socket: Duplex,
|
1276
|
-
upgradeHead: Buffer,
|
1277
|
-
callback: (client: T, request: IncomingMessage) => void,
|
1278
|
-
): void
|
1279
|
-
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
1280
|
-
|
1281
|
-
// Events
|
1282
|
-
on(
|
1283
|
-
event: 'connection',
|
1284
|
-
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
1285
|
-
): this
|
1286
|
-
on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
1287
|
-
on(
|
1288
|
-
event: 'headers',
|
1289
|
-
cb: (
|
1290
|
-
this: Server<T>,
|
1291
|
-
headers: string[],
|
1292
|
-
request: IncomingMessage,
|
1293
|
-
) => void,
|
1294
|
-
): this
|
1295
|
-
on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
1296
|
-
on(
|
1297
|
-
event: string | symbol,
|
1298
|
-
listener: (this: Server<T>, ...args: any[]) => void,
|
1299
|
-
): this
|
1300
|
-
|
1301
|
-
once(
|
1302
|
-
event: 'connection',
|
1303
|
-
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
1304
|
-
): this
|
1305
|
-
once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
1306
|
-
once(
|
1307
|
-
event: 'headers',
|
1308
|
-
cb: (
|
1309
|
-
this: Server<T>,
|
1310
|
-
headers: string[],
|
1311
|
-
request: IncomingMessage,
|
1312
|
-
) => void,
|
1313
|
-
): this
|
1314
|
-
once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
1315
|
-
once(
|
1316
|
-
event: string | symbol,
|
1317
|
-
listener: (this: Server<T>, ...args: any[]) => void,
|
1318
|
-
): this
|
1319
|
-
|
1320
|
-
off(
|
1321
|
-
event: 'connection',
|
1322
|
-
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
1323
|
-
): this
|
1324
|
-
off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
1325
|
-
off(
|
1326
|
-
event: 'headers',
|
1327
|
-
cb: (
|
1328
|
-
this: Server<T>,
|
1329
|
-
headers: string[],
|
1330
|
-
request: IncomingMessage,
|
1331
|
-
) => void,
|
1332
|
-
): this
|
1333
|
-
off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
1334
|
-
off(
|
1335
|
-
event: string | symbol,
|
1336
|
-
listener: (this: Server<T>, ...args: any[]) => void,
|
1337
|
-
): this
|
1338
|
-
|
1339
|
-
addListener(
|
1340
|
-
event: 'connection',
|
1341
|
-
cb: (client: T, request: IncomingMessage) => void,
|
1342
|
-
): this
|
1343
|
-
addListener(event: 'error', cb: (err: Error) => void): this
|
1344
|
-
addListener(
|
1345
|
-
event: 'headers',
|
1346
|
-
cb: (headers: string[], request: IncomingMessage) => void,
|
1347
|
-
): this
|
1348
|
-
addListener(event: 'close' | 'listening', cb: () => void): this
|
1349
|
-
addListener(
|
1350
|
-
event: string | symbol,
|
1351
|
-
listener: (...args: any[]) => void,
|
1352
|
-
): this
|
1353
|
-
|
1354
|
-
removeListener(event: 'connection', cb: (client: T) => void): this
|
1355
|
-
removeListener(event: 'error', cb: (err: Error) => void): this
|
1356
|
-
removeListener(
|
1357
|
-
event: 'headers',
|
1358
|
-
cb: (headers: string[], request: IncomingMessage) => void,
|
1359
|
-
): this
|
1360
|
-
removeListener(event: 'close' | 'listening', cb: () => void): this
|
1361
|
-
removeListener(
|
1362
|
-
event: string | symbol,
|
1363
|
-
listener: (...args: any[]) => void,
|
1364
|
-
): this
|
1365
|
-
}
|
1366
|
-
|
1367
|
-
const WebSocketServer: typeof Server
|
1368
|
-
interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
|
1369
|
-
const WebSocket: typeof WebSocketAlias
|
1370
|
-
interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
1371
|
-
|
1372
|
-
// WebSocket stream
|
1373
|
-
function createWebSocketStream(
|
1374
|
-
websocket: WebSocket,
|
1375
|
-
options?: DuplexOptions,
|
1376
|
-
): Duplex
|
1377
|
-
}
|
1378
|
-
|
1379
|
-
declare class Environment {
|
1380
|
-
#private;
|
1381
|
-
name: string;
|
1382
|
-
config: ResolvedConfig;
|
1383
|
-
options: ResolvedEnvironmentOptions;
|
1384
|
-
get plugins(): BoundedPlugin[];
|
1385
|
-
get logger(): Logger;
|
1386
|
-
constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
1387
|
-
}
|
1388
|
-
|
1389
|
-
interface FetchModuleOptions {
|
1390
|
-
inlineSourceMap?: boolean;
|
1391
|
-
processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
|
1392
|
-
}
|
1393
|
-
/**
|
1394
|
-
* Fetch module information for Vite runner.
|
1395
|
-
* @experimental
|
1396
|
-
*/
|
1397
|
-
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
1398
|
-
|
1399
|
-
declare class ScanEnvironment extends Environment {
|
1400
|
-
mode: "scan";
|
1401
|
-
get pluginContainer(): BoundedPluginContainer;
|
1402
|
-
init(): Promise<void>;
|
1403
|
-
}
|
1404
|
-
|
1405
|
-
type ExportsData = {
|
1406
|
-
hasModuleSyntax: boolean;
|
1407
|
-
exports: readonly string[];
|
1408
|
-
jsxLoader?: boolean;
|
1409
|
-
};
|
1410
|
-
interface DepsOptimizer {
|
1411
|
-
init: () => Promise<void>;
|
1412
|
-
metadata: DepOptimizationMetadata;
|
1413
|
-
scanProcessing?: Promise<void>;
|
1414
|
-
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
1415
|
-
run: () => void;
|
1416
|
-
isOptimizedDepFile: (id: string) => boolean;
|
1417
|
-
isOptimizedDepUrl: (url: string) => boolean;
|
1418
|
-
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
|
1419
|
-
close: () => Promise<void>;
|
1420
|
-
options: DepOptimizationOptions;
|
1421
|
-
}
|
1422
|
-
interface DepOptimizationConfig {
|
1423
|
-
/**
|
1424
|
-
* Force optimize listed dependencies (must be resolvable import paths,
|
1425
|
-
* cannot be globs).
|
1426
|
-
*/
|
1427
|
-
include?: string[];
|
1428
|
-
/**
|
1429
|
-
* Do not optimize these dependencies (must be resolvable import paths,
|
1430
|
-
* cannot be globs).
|
1431
|
-
*/
|
1432
|
-
exclude?: string[];
|
1433
|
-
/**
|
1434
|
-
* Forces ESM interop when importing these dependencies. Some legacy
|
1435
|
-
* packages advertise themselves as ESM but use `require` internally
|
1436
|
-
* @experimental
|
1437
|
-
*/
|
1438
|
-
needsInterop?: string[];
|
1439
|
-
/**
|
1440
|
-
* Options to pass to esbuild during the dep scanning and optimization
|
1441
|
-
*
|
1442
|
-
* Certain options are omitted since changing them would not be compatible
|
1443
|
-
* with Vite's dep optimization.
|
1444
|
-
*
|
1445
|
-
* - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
|
1446
|
-
* - `plugins` are merged with Vite's dep plugin
|
1447
|
-
*
|
1448
|
-
* https://esbuild.github.io/api
|
1449
|
-
*/
|
1450
|
-
esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
|
1451
|
-
/**
|
1452
|
-
* List of file extensions that can be optimized. A corresponding esbuild
|
1453
|
-
* plugin must exist to handle the specific extension.
|
1454
|
-
*
|
1455
|
-
* By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
|
1456
|
-
* allows specifying additional extensions.
|
1457
|
-
*
|
1458
|
-
* @experimental
|
1459
|
-
*/
|
1460
|
-
extensions?: string[];
|
1461
|
-
/**
|
1462
|
-
* Deps optimization during build was removed in Vite 5.1. This option is
|
1463
|
-
* now redundant and will be removed in a future version. Switch to using
|
1464
|
-
* `optimizeDeps.noDiscovery` and an empty or undefined `optimizeDeps.include`.
|
1465
|
-
* true or 'dev' disables the optimizer, false or 'build' leaves it enabled.
|
1466
|
-
* @default 'build'
|
1467
|
-
* @deprecated
|
1468
|
-
* @experimental
|
1469
|
-
*/
|
1470
|
-
disabled?: boolean | 'build' | 'dev';
|
1471
|
-
/**
|
1472
|
-
* Automatic dependency discovery. When `noDiscovery` is true, only dependencies
|
1473
|
-
* listed in `include` will be optimized. The scanner isn't run for cold start
|
1474
|
-
* in this case. CJS-only dependencies must be present in `include` during dev.
|
1475
|
-
* @default false
|
1476
|
-
* @experimental
|
1477
|
-
*/
|
1478
|
-
noDiscovery?: boolean;
|
1479
|
-
/**
|
1480
|
-
* When enabled, it will hold the first optimized deps results until all static
|
1481
|
-
* imports are crawled on cold start. This avoids the need for full-page reloads
|
1482
|
-
* when new dependencies are discovered and they trigger the generation of new
|
1483
|
-
* common chunks. If all dependencies are found by the scanner plus the explicitely
|
1484
|
-
* defined ones in `include`, it is better to disable this option to let the
|
1485
|
-
* browser process more requests in parallel.
|
1486
|
-
* @default true
|
1487
|
-
* @experimental
|
1488
|
-
*/
|
1489
|
-
holdUntilCrawlEnd?: boolean;
|
1490
|
-
}
|
1491
|
-
type DepOptimizationOptions = DepOptimizationConfig & {
|
1492
|
-
/**
|
1493
|
-
* By default, Vite will crawl your `index.html` to detect dependencies that
|
1494
|
-
* need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
|
1495
|
-
* will crawl those entry points instead.
|
1496
|
-
*
|
1497
|
-
* If neither of these fit your needs, you can specify custom entries using
|
1498
|
-
* this option - the value should be a fast-glob pattern or array of patterns
|
1499
|
-
* (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
|
1500
|
-
* vite project root. This will overwrite default entries inference.
|
1501
|
-
*/
|
1502
|
-
entries?: string | string[];
|
1503
|
-
/**
|
1504
|
-
* Force dep pre-optimization regardless of whether deps have changed.
|
1505
|
-
* @experimental
|
1506
|
-
*/
|
1507
|
-
force?: boolean;
|
1508
|
-
};
|
1509
|
-
interface OptimizedDepInfo {
|
1510
|
-
id: string;
|
1511
|
-
file: string;
|
1512
|
-
src?: string;
|
1513
|
-
needsInterop?: boolean;
|
1514
|
-
browserHash?: string;
|
1515
|
-
fileHash?: string;
|
1516
|
-
/**
|
1517
|
-
* During optimization, ids can still be resolved to their final location
|
1518
|
-
* but the bundles may not yet be saved to disk
|
1519
|
-
*/
|
1520
|
-
processing?: Promise<void>;
|
1521
|
-
/**
|
1522
|
-
* ExportData cache, discovered deps will parse the src entry to get exports
|
1523
|
-
* data used both to define if interop is needed and when pre-bundling
|
1524
|
-
*/
|
1525
|
-
exportsData?: Promise<ExportsData>;
|
1526
|
-
}
|
1527
|
-
interface DepOptimizationMetadata {
|
1528
|
-
/**
|
1529
|
-
* The main hash is determined by user config and dependency lockfiles.
|
1530
|
-
* This is checked on server startup to avoid unnecessary re-bundles.
|
1531
|
-
*/
|
1532
|
-
hash: string;
|
1533
|
-
/**
|
1534
|
-
* This hash is determined by dependency lockfiles.
|
1535
|
-
* This is checked on server startup to avoid unnecessary re-bundles.
|
1536
|
-
*/
|
1537
|
-
lockfileHash: string;
|
1538
|
-
/**
|
1539
|
-
* This hash is determined by user config.
|
1540
|
-
* This is checked on server startup to avoid unnecessary re-bundles.
|
1541
|
-
*/
|
1542
|
-
configHash: string;
|
1543
|
-
/**
|
1544
|
-
* The browser hash is determined by the main hash plus additional dependencies
|
1545
|
-
* discovered at runtime. This is used to invalidate browser requests to
|
1546
|
-
* optimized deps.
|
1547
|
-
*/
|
1548
|
-
browserHash: string;
|
1549
|
-
/**
|
1550
|
-
* Metadata for each already optimized dependency
|
1551
|
-
*/
|
1552
|
-
optimized: Record<string, OptimizedDepInfo>;
|
1553
|
-
/**
|
1554
|
-
* Metadata for non-entry optimized chunks and dynamic imports
|
1555
|
-
*/
|
1556
|
-
chunks: Record<string, OptimizedDepInfo>;
|
1557
|
-
/**
|
1558
|
-
* Metadata for each newly discovered dependency after processing
|
1559
|
-
*/
|
1560
|
-
discovered: Record<string, OptimizedDepInfo>;
|
1561
|
-
/**
|
1562
|
-
* OptimizedDepInfo list
|
1563
|
-
*/
|
1564
|
-
depInfoList: OptimizedDepInfo[];
|
1565
|
-
}
|
1566
|
-
|
1567
|
-
declare class RemoteEnvironmentTransport {
|
1568
|
-
private readonly options;
|
1569
|
-
constructor(options: {
|
1570
|
-
send: (data: any) => void;
|
1571
|
-
onMessage: (handler: (data: any) => void) => void;
|
1572
|
-
});
|
1573
|
-
register(environment: DevEnvironment): void;
|
1574
|
-
}
|
1575
|
-
|
1576
|
-
interface DevEnvironmentSetup {
|
1577
|
-
hot?: false | HMRChannel;
|
1578
|
-
watcher?: FSWatcher;
|
1579
|
-
options?: EnvironmentOptions;
|
1580
|
-
runner?: FetchModuleOptions & {
|
1581
|
-
transport?: RemoteEnvironmentTransport;
|
1582
|
-
};
|
1583
|
-
depsOptimizer?: DepsOptimizer;
|
1584
|
-
}
|
1585
|
-
declare class DevEnvironment extends Environment {
|
1586
|
-
mode: "dev";
|
1587
|
-
moduleGraph: EnvironmentModuleGraph;
|
1588
|
-
watcher?: FSWatcher;
|
1589
|
-
depsOptimizer?: DepsOptimizer;
|
1590
|
-
get pluginContainer(): BoundedPluginContainer;
|
1591
|
-
/**
|
1592
|
-
* HMR channel for this environment. If not provided or disabled,
|
1593
|
-
* it will be a noop channel that does nothing.
|
1594
|
-
*
|
1595
|
-
* @example
|
1596
|
-
* environment.hot.send({ type: 'full-reload' })
|
1597
|
-
*/
|
1598
|
-
hot: HMRChannel;
|
1599
|
-
constructor(name: string, config: ResolvedConfig, setup?: DevEnvironmentSetup);
|
1600
|
-
init(): Promise<void>;
|
1601
|
-
fetchModule(id: string, importer?: string): Promise<FetchResult>;
|
1602
|
-
transformRequest(url: string): Promise<TransformResult | null>;
|
1603
|
-
warmupRequest(url: string): Promise<void>;
|
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>;
|
1614
|
-
}
|
842
|
+
type ExportsData = {
|
843
|
+
hasModuleSyntax: boolean;
|
844
|
+
exports: readonly string[];
|
845
|
+
jsxLoader?: boolean;
|
846
|
+
};
|
847
|
+
interface DepsOptimizer {
|
848
|
+
init: () => Promise<void>;
|
849
|
+
metadata: DepOptimizationMetadata;
|
850
|
+
scanProcessing?: Promise<void>;
|
851
|
+
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
852
|
+
run: () => void;
|
853
|
+
isOptimizedDepFile: (id: string) => boolean;
|
854
|
+
isOptimizedDepUrl: (url: string) => boolean;
|
855
|
+
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
|
856
|
+
close: () => Promise<void>;
|
857
|
+
options: DepOptimizationOptions;
|
858
|
+
}
|
859
|
+
interface DepOptimizationConfig {
|
860
|
+
/**
|
861
|
+
* Force optimize listed dependencies (must be resolvable import paths,
|
862
|
+
* cannot be globs).
|
863
|
+
*/
|
864
|
+
include?: string[];
|
865
|
+
/**
|
866
|
+
* Do not optimize these dependencies (must be resolvable import paths,
|
867
|
+
* cannot be globs).
|
868
|
+
*/
|
869
|
+
exclude?: string[];
|
870
|
+
/**
|
871
|
+
* Forces ESM interop when importing these dependencies. Some legacy
|
872
|
+
* packages advertise themselves as ESM but use `require` internally
|
873
|
+
* @experimental
|
874
|
+
*/
|
875
|
+
needsInterop?: string[];
|
876
|
+
/**
|
877
|
+
* Options to pass to esbuild during the dep scanning and optimization
|
878
|
+
*
|
879
|
+
* Certain options are omitted since changing them would not be compatible
|
880
|
+
* with Vite's dep optimization.
|
881
|
+
*
|
882
|
+
* - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
|
883
|
+
* - `plugins` are merged with Vite's dep plugin
|
884
|
+
*
|
885
|
+
* https://esbuild.github.io/api
|
886
|
+
*/
|
887
|
+
esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
|
888
|
+
/**
|
889
|
+
* List of file extensions that can be optimized. A corresponding esbuild
|
890
|
+
* plugin must exist to handle the specific extension.
|
891
|
+
*
|
892
|
+
* By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
|
893
|
+
* allows specifying additional extensions.
|
894
|
+
*
|
895
|
+
* @experimental
|
896
|
+
*/
|
897
|
+
extensions?: string[];
|
898
|
+
/**
|
899
|
+
* Deps optimization during build was removed in Vite 5.1. This option is
|
900
|
+
* now redundant and will be removed in a future version. Switch to using
|
901
|
+
* `optimizeDeps.noDiscovery` and an empty or undefined `optimizeDeps.include`.
|
902
|
+
* true or 'dev' disables the optimizer, false or 'build' leaves it enabled.
|
903
|
+
* @default 'build'
|
904
|
+
* @deprecated
|
905
|
+
* @experimental
|
906
|
+
*/
|
907
|
+
disabled?: boolean | 'build' | 'dev';
|
908
|
+
/**
|
909
|
+
* Automatic dependency discovery. When `noDiscovery` is true, only dependencies
|
910
|
+
* listed in `include` will be optimized. The scanner isn't run for cold start
|
911
|
+
* in this case. CJS-only dependencies must be present in `include` during dev.
|
912
|
+
* @default false
|
913
|
+
* @experimental
|
914
|
+
*/
|
915
|
+
noDiscovery?: boolean;
|
916
|
+
/**
|
917
|
+
* When enabled, it will hold the first optimized deps results until all static
|
918
|
+
* imports are crawled on cold start. This avoids the need for full-page reloads
|
919
|
+
* when new dependencies are discovered and they trigger the generation of new
|
920
|
+
* common chunks. If all dependencies are found by the scanner plus the explicitly
|
921
|
+
* defined ones in `include`, it is better to disable this option to let the
|
922
|
+
* browser process more requests in parallel.
|
923
|
+
* @default true
|
924
|
+
* @experimental
|
925
|
+
*/
|
926
|
+
holdUntilCrawlEnd?: boolean;
|
927
|
+
}
|
928
|
+
type DepOptimizationOptions = DepOptimizationConfig & {
|
929
|
+
/**
|
930
|
+
* By default, Vite will crawl your `index.html` to detect dependencies that
|
931
|
+
* need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
|
932
|
+
* will crawl those entry points instead.
|
933
|
+
*
|
934
|
+
* If neither of these fit your needs, you can specify custom entries using
|
935
|
+
* this option - the value should be a fast-glob pattern or array of patterns
|
936
|
+
* (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
|
937
|
+
* vite project root. This will overwrite default entries inference.
|
938
|
+
*/
|
939
|
+
entries?: string | string[];
|
940
|
+
/**
|
941
|
+
* Force dep pre-optimization regardless of whether deps have changed.
|
942
|
+
* @experimental
|
943
|
+
*/
|
944
|
+
force?: boolean;
|
945
|
+
};
|
946
|
+
interface OptimizedDepInfo {
|
947
|
+
id: string;
|
948
|
+
file: string;
|
949
|
+
src?: string;
|
950
|
+
needsInterop?: boolean;
|
951
|
+
browserHash?: string;
|
952
|
+
fileHash?: string;
|
953
|
+
/**
|
954
|
+
* During optimization, ids can still be resolved to their final location
|
955
|
+
* but the bundles may not yet be saved to disk
|
956
|
+
*/
|
957
|
+
processing?: Promise<void>;
|
958
|
+
/**
|
959
|
+
* ExportData cache, discovered deps will parse the src entry to get exports
|
960
|
+
* data used both to define if interop is needed and when pre-bundling
|
961
|
+
*/
|
962
|
+
exportsData?: Promise<ExportsData>;
|
963
|
+
}
|
964
|
+
interface DepOptimizationMetadata {
|
965
|
+
/**
|
966
|
+
* The main hash is determined by user config and dependency lockfiles.
|
967
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
968
|
+
*/
|
969
|
+
hash: string;
|
970
|
+
/**
|
971
|
+
* This hash is determined by dependency lockfiles.
|
972
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
973
|
+
*/
|
974
|
+
lockfileHash: string;
|
975
|
+
/**
|
976
|
+
* This hash is determined by user config.
|
977
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
978
|
+
*/
|
979
|
+
configHash: string;
|
980
|
+
/**
|
981
|
+
* The browser hash is determined by the main hash plus additional dependencies
|
982
|
+
* discovered at runtime. This is used to invalidate browser requests to
|
983
|
+
* optimized deps.
|
984
|
+
*/
|
985
|
+
browserHash: string;
|
986
|
+
/**
|
987
|
+
* Metadata for each already optimized dependency
|
988
|
+
*/
|
989
|
+
optimized: Record<string, OptimizedDepInfo>;
|
990
|
+
/**
|
991
|
+
* Metadata for non-entry optimized chunks and dynamic imports
|
992
|
+
*/
|
993
|
+
chunks: Record<string, OptimizedDepInfo>;
|
994
|
+
/**
|
995
|
+
* Metadata for each newly discovered dependency after processing
|
996
|
+
*/
|
997
|
+
discovered: Record<string, OptimizedDepInfo>;
|
998
|
+
/**
|
999
|
+
* OptimizedDepInfo list
|
1000
|
+
*/
|
1001
|
+
depInfoList: OptimizedDepInfo[];
|
1002
|
+
}
|
1003
|
+
/**
|
1004
|
+
* Scan and optimize dependencies within a project.
|
1005
|
+
* Used by Vite CLI when running `vite optimize`.
|
1006
|
+
*/
|
1007
|
+
declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
1615
1008
|
|
1616
1009
|
interface TransformResult {
|
1617
1010
|
code: string;
|
@@ -1625,13 +1018,9 @@ interface TransformResult {
|
|
1625
1018
|
}
|
1626
1019
|
interface TransformOptions {
|
1627
1020
|
/**
|
1628
|
-
* @deprecated
|
1021
|
+
* @deprecated inferred from environment
|
1629
1022
|
*/
|
1630
1023
|
ssr?: boolean;
|
1631
|
-
/**
|
1632
|
-
* TODO: should this be internal?
|
1633
|
-
*/
|
1634
|
-
html?: boolean;
|
1635
1024
|
}
|
1636
1025
|
|
1637
1026
|
declare class EnvironmentModuleNode {
|
@@ -1660,1294 +1049,1946 @@ declare class EnvironmentModuleNode {
|
|
1660
1049
|
lastHMRTimestamp: number;
|
1661
1050
|
lastInvalidationTimestamp: number;
|
1662
1051
|
/**
|
1663
|
-
* @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
|
1052
|
+
* @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
|
1053
|
+
*/
|
1054
|
+
constructor(url: string, environment: string, setIsSelfAccepting?: boolean);
|
1055
|
+
}
|
1056
|
+
type ResolvedUrl = [
|
1057
|
+
url: string,
|
1058
|
+
resolvedId: string,
|
1059
|
+
meta: object | null | undefined
|
1060
|
+
];
|
1061
|
+
declare class EnvironmentModuleGraph {
|
1062
|
+
environment: string;
|
1063
|
+
urlToModuleMap: Map<string, EnvironmentModuleNode>;
|
1064
|
+
idToModuleMap: Map<string, EnvironmentModuleNode>;
|
1065
|
+
etagToModuleMap: Map<string, EnvironmentModuleNode>;
|
1066
|
+
fileToModulesMap: Map<string, Set<EnvironmentModuleNode>>;
|
1067
|
+
constructor(environment: string, resolveId: (url: string) => Promise<PartialResolvedId | null>);
|
1068
|
+
getModuleByUrl(rawUrl: string): Promise<EnvironmentModuleNode | undefined>;
|
1069
|
+
getModuleById(id: string): EnvironmentModuleNode | undefined;
|
1070
|
+
getModulesByFile(file: string): Set<EnvironmentModuleNode> | undefined;
|
1071
|
+
onFileChange(file: string): void;
|
1072
|
+
onFileDelete(file: string): void;
|
1073
|
+
invalidateModule(mod: EnvironmentModuleNode, seen?: Set<EnvironmentModuleNode>, timestamp?: number, isHmr?: boolean,
|
1074
|
+
): void;
|
1075
|
+
invalidateAll(): void;
|
1076
|
+
/**
|
1077
|
+
* Update the module graph based on a module's updated imports information
|
1078
|
+
* If there are dependencies that no longer have any importers, they are
|
1079
|
+
* returned as a Set.
|
1080
|
+
*
|
1081
|
+
* @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
|
1082
|
+
* This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
|
1083
|
+
*/
|
1084
|
+
updateModuleInfo(mod: EnvironmentModuleNode, importedModules: Set<string | EnvironmentModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | EnvironmentModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean,
|
1085
|
+
): Promise<Set<EnvironmentModuleNode> | undefined>;
|
1086
|
+
ensureEntryFromUrl(rawUrl: string, setIsSelfAccepting?: boolean): Promise<EnvironmentModuleNode>;
|
1087
|
+
createFileOnlyEntry(file: string): EnvironmentModuleNode;
|
1088
|
+
resolveUrl(url: string): Promise<ResolvedUrl>;
|
1089
|
+
updateModuleTransformResult(mod: EnvironmentModuleNode, result: TransformResult | null): void;
|
1090
|
+
getModuleByEtag(etag: string): EnvironmentModuleNode | undefined;
|
1091
|
+
}
|
1092
|
+
|
1093
|
+
/**
|
1094
|
+
* Backward compatible ModuleNode and ModuleGraph with mixed nodes from both the client and ssr environments
|
1095
|
+
* It would be good to take the types names for the new EnvironmentModuleNode and EnvironmentModuleGraph but we can't
|
1096
|
+
* do that at this point without breaking to much code in the ecosystem.
|
1097
|
+
* We are going to deprecate these types and we can try to use them back in the future.
|
1098
|
+
*/
|
1099
|
+
declare class ModuleNode {
|
1100
|
+
_moduleGraph: ModuleGraph;
|
1101
|
+
_clientModule: EnvironmentModuleNode | undefined;
|
1102
|
+
_ssrModule: EnvironmentModuleNode | undefined;
|
1103
|
+
constructor(moduleGraph: ModuleGraph, clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode);
|
1104
|
+
_get<T extends keyof EnvironmentModuleNode>(prop: T): EnvironmentModuleNode[T];
|
1105
|
+
_set<T extends keyof EnvironmentModuleNode>(prop: T, value: EnvironmentModuleNode[T]): void;
|
1106
|
+
_wrapModuleSet(prop: ModuleSetNames, module: EnvironmentModuleNode | undefined): Set<ModuleNode>;
|
1107
|
+
_getModuleSetUnion(prop: 'importedModules' | 'importers'): Set<ModuleNode>;
|
1108
|
+
get url(): string;
|
1109
|
+
set url(value: string);
|
1110
|
+
get id(): string | null;
|
1111
|
+
set id(value: string | null);
|
1112
|
+
get file(): string | null;
|
1113
|
+
set file(value: string | null);
|
1114
|
+
get type(): 'js' | 'css';
|
1115
|
+
get info(): ModuleInfo | undefined;
|
1116
|
+
get meta(): Record<string, any> | undefined;
|
1117
|
+
get importers(): Set<ModuleNode>;
|
1118
|
+
get clientImportedModules(): Set<ModuleNode>;
|
1119
|
+
get ssrImportedModules(): Set<ModuleNode>;
|
1120
|
+
get importedModules(): Set<ModuleNode>;
|
1121
|
+
get acceptedHmrDeps(): Set<ModuleNode>;
|
1122
|
+
get acceptedHmrExports(): Set<string> | null;
|
1123
|
+
get importedBindings(): Map<string, Set<string>> | null;
|
1124
|
+
get isSelfAccepting(): boolean | undefined;
|
1125
|
+
get transformResult(): TransformResult | null;
|
1126
|
+
set transformResult(value: TransformResult | null);
|
1127
|
+
get ssrTransformResult(): TransformResult | null;
|
1128
|
+
set ssrTransformResult(value: TransformResult | null);
|
1129
|
+
get ssrModule(): Record<string, any> | null;
|
1130
|
+
get ssrError(): Error | null;
|
1131
|
+
get lastHMRTimestamp(): number;
|
1132
|
+
set lastHMRTimestamp(value: number);
|
1133
|
+
get lastInvalidationTimestamp(): number;
|
1134
|
+
get invalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined;
|
1135
|
+
get ssrInvalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined;
|
1136
|
+
}
|
1137
|
+
declare class ModuleGraph {
|
1138
|
+
urlToModuleMap: Map<string, ModuleNode>;
|
1139
|
+
idToModuleMap: Map<string, ModuleNode>;
|
1140
|
+
etagToModuleMap: Map<string, ModuleNode>;
|
1141
|
+
fileToModulesMap: Map<string, Set<ModuleNode>>;
|
1142
|
+
constructor(moduleGraphs: {
|
1143
|
+
client: () => EnvironmentModuleGraph;
|
1144
|
+
ssr: () => EnvironmentModuleGraph;
|
1145
|
+
});
|
1146
|
+
getModuleById(id: string): ModuleNode | undefined;
|
1147
|
+
getModuleByUrl(url: string, _ssr?: boolean): Promise<ModuleNode | undefined>;
|
1148
|
+
getModulesByFile(file: string): Set<ModuleNode> | undefined;
|
1149
|
+
onFileChange(file: string): void;
|
1150
|
+
onFileDelete(file: string): void;
|
1151
|
+
invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean,
|
1152
|
+
): void;
|
1153
|
+
invalidateAll(): void;
|
1154
|
+
ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
|
1155
|
+
createFileOnlyEntry(file: string): ModuleNode;
|
1156
|
+
resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
|
1157
|
+
updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr?: boolean): void;
|
1158
|
+
getModuleByEtag(etag: string): ModuleNode | undefined;
|
1159
|
+
getBackwardCompatibleBrowserModuleNode(clientModule: EnvironmentModuleNode): ModuleNode;
|
1160
|
+
getBackwardCompatibleServerModuleNode(ssrModule: EnvironmentModuleNode): ModuleNode;
|
1161
|
+
getBackwardCompatibleModuleNode(mod: EnvironmentModuleNode): ModuleNode;
|
1162
|
+
getBackwardCompatibleModuleNodeDual(clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode): ModuleNode;
|
1163
|
+
}
|
1164
|
+
type ModuleSetNames = 'acceptedHmrDeps' | 'importedModules';
|
1165
|
+
|
1166
|
+
interface HmrOptions {
|
1167
|
+
protocol?: string;
|
1168
|
+
host?: string;
|
1169
|
+
port?: number;
|
1170
|
+
clientPort?: number;
|
1171
|
+
path?: string;
|
1172
|
+
timeout?: number;
|
1173
|
+
overlay?: boolean;
|
1174
|
+
server?: HttpServer;
|
1175
|
+
}
|
1176
|
+
interface HotUpdateOptions {
|
1177
|
+
type: 'create' | 'update' | 'delete';
|
1178
|
+
file: string;
|
1179
|
+
timestamp: number;
|
1180
|
+
modules: Array<EnvironmentModuleNode>;
|
1181
|
+
read: () => string | Promise<string>;
|
1182
|
+
server: ViteDevServer;
|
1183
|
+
/**
|
1184
|
+
* @deprecated use this.environment in the hotUpdate hook instead
|
1185
|
+
**/
|
1186
|
+
environment: DevEnvironment;
|
1187
|
+
}
|
1188
|
+
interface HmrContext {
|
1189
|
+
file: string;
|
1190
|
+
timestamp: number;
|
1191
|
+
modules: Array<ModuleNode>;
|
1192
|
+
read: () => string | Promise<string>;
|
1193
|
+
server: ViteDevServer;
|
1194
|
+
}
|
1195
|
+
interface HotChannelClient {
|
1196
|
+
/**
|
1197
|
+
* Send event to the client
|
1198
|
+
*/
|
1199
|
+
send(payload: HotPayload): void;
|
1200
|
+
/**
|
1201
|
+
* Send custom event
|
1202
|
+
*/
|
1203
|
+
send(event: string, payload?: CustomPayload['data']): void;
|
1204
|
+
}
|
1205
|
+
/** @deprecated use `HotChannelClient` instead */
|
1206
|
+
type HMRBroadcasterClient = HotChannelClient;
|
1207
|
+
interface HotChannel {
|
1208
|
+
/**
|
1209
|
+
* Broadcast events to all clients
|
1210
|
+
*/
|
1211
|
+
send(payload: HotPayload): void;
|
1212
|
+
/**
|
1213
|
+
* Send custom event
|
1214
|
+
*/
|
1215
|
+
send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
|
1216
|
+
/**
|
1217
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
1218
|
+
*/
|
1219
|
+
on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client: HotChannelClient, ...args: any[]) => void): void;
|
1220
|
+
on(event: 'connection', listener: () => void): void;
|
1221
|
+
/**
|
1222
|
+
* Unregister event listener
|
1223
|
+
*/
|
1224
|
+
off(event: string, listener: Function): void;
|
1225
|
+
/**
|
1226
|
+
* Start listening for messages
|
1227
|
+
*/
|
1228
|
+
listen(): void;
|
1229
|
+
/**
|
1230
|
+
* Disconnect all clients, called when server is closed or restarted.
|
1231
|
+
*/
|
1232
|
+
close(): void;
|
1233
|
+
}
|
1234
|
+
/** @deprecated use `HotChannel` instead */
|
1235
|
+
type HMRChannel = HotChannel;
|
1236
|
+
interface ServerHotChannel extends HotChannel {
|
1237
|
+
api: {
|
1238
|
+
innerEmitter: EventEmitter;
|
1239
|
+
outsideEmitter: EventEmitter;
|
1240
|
+
};
|
1241
|
+
}
|
1242
|
+
/** @deprecated use `ServerHotChannel` instead */
|
1243
|
+
type ServerHMRChannel = ServerHotChannel;
|
1244
|
+
declare function createServerHotChannel(): ServerHotChannel;
|
1245
|
+
/** @deprecated use `environment.hot` instead */
|
1246
|
+
interface HotBroadcaster extends HotChannel {
|
1247
|
+
readonly channels: HotChannel[];
|
1248
|
+
/**
|
1249
|
+
* A noop.
|
1250
|
+
* @deprecated
|
1664
1251
|
*/
|
1665
|
-
|
1252
|
+
addChannel(channel: HotChannel): HotBroadcaster;
|
1253
|
+
close(): Promise<unknown[]>;
|
1666
1254
|
}
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1255
|
+
/** @deprecated use `environment.hot` instead */
|
1256
|
+
type HMRBroadcaster = HotBroadcaster;
|
1257
|
+
|
1258
|
+
declare class RemoteEnvironmentTransport {
|
1259
|
+
private readonly options;
|
1260
|
+
constructor(options: {
|
1261
|
+
send: (data: any) => void;
|
1262
|
+
onMessage: (handler: (data: any) => void) => void;
|
1263
|
+
});
|
1264
|
+
register(environment: DevEnvironment): void;
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
interface DevEnvironmentContext {
|
1268
|
+
hot: false | HotChannel;
|
1269
|
+
options?: EnvironmentOptions;
|
1270
|
+
runner?: FetchModuleOptions & {
|
1271
|
+
transport?: RemoteEnvironmentTransport;
|
1272
|
+
};
|
1273
|
+
depsOptimizer?: DepsOptimizer;
|
1274
|
+
}
|
1275
|
+
declare class DevEnvironment extends BaseEnvironment {
|
1276
|
+
mode: "dev";
|
1277
|
+
moduleGraph: EnvironmentModuleGraph;
|
1278
|
+
depsOptimizer?: DepsOptimizer;
|
1279
|
+
get pluginContainer(): EnvironmentPluginContainer;
|
1687
1280
|
/**
|
1688
|
-
*
|
1689
|
-
*
|
1690
|
-
* returned as a Set.
|
1281
|
+
* Hot channel for this environment. If not provided or disabled,
|
1282
|
+
* it will be a noop channel that does nothing.
|
1691
1283
|
*
|
1692
|
-
* @
|
1693
|
-
*
|
1284
|
+
* @example
|
1285
|
+
* environment.hot.send({ type: 'full-reload' })
|
1694
1286
|
*/
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1287
|
+
hot: HotChannel;
|
1288
|
+
constructor(name: string, config: ResolvedConfig, context: DevEnvironmentContext);
|
1289
|
+
init(options?: {
|
1290
|
+
watcher?: FSWatcher;
|
1291
|
+
}): Promise<void>;
|
1292
|
+
fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<FetchResult>;
|
1293
|
+
reloadModule(module: EnvironmentModuleNode): Promise<void>;
|
1294
|
+
transformRequest(url: string): Promise<TransformResult | null>;
|
1295
|
+
warmupRequest(url: string): Promise<void>;
|
1296
|
+
close(): Promise<void>;
|
1297
|
+
/**
|
1298
|
+
* Calling `await environment.waitForRequestsIdle(id)` will wait until all static imports
|
1299
|
+
* are processed after the first transformRequest call. If called from a load or transform
|
1300
|
+
* plugin hook, the id needs to be passed as a parameter to avoid deadlocks.
|
1301
|
+
* Calling this function after the first static imports section of the module graph has been
|
1302
|
+
* processed will resolve immediately.
|
1303
|
+
* @experimental
|
1304
|
+
*/
|
1305
|
+
waitForRequestsIdle(ignoredId?: string): Promise<void>;
|
1702
1306
|
}
|
1703
1307
|
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1308
|
+
interface RollupCommonJSOptions {
|
1309
|
+
/**
|
1310
|
+
* A minimatch pattern, or array of patterns, which specifies the files in
|
1311
|
+
* the build the plugin should operate on. By default, all files with
|
1312
|
+
* extension `".cjs"` or those in `extensions` are included, but you can
|
1313
|
+
* narrow this list by only including specific files. These files will be
|
1314
|
+
* analyzed and transpiled if either the analysis does not find ES module
|
1315
|
+
* specific statements or `transformMixedEsModules` is `true`.
|
1316
|
+
* @default undefined
|
1317
|
+
*/
|
1318
|
+
include?: string | RegExp | readonly (string | RegExp)[]
|
1319
|
+
/**
|
1320
|
+
* A minimatch pattern, or array of patterns, which specifies the files in
|
1321
|
+
* the build the plugin should _ignore_. By default, all files with
|
1322
|
+
* extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
1323
|
+
* can exclude additional files. See also the `include` option.
|
1324
|
+
* @default undefined
|
1325
|
+
*/
|
1326
|
+
exclude?: string | RegExp | readonly (string | RegExp)[]
|
1327
|
+
/**
|
1328
|
+
* For extensionless imports, search for extensions other than .js in the
|
1329
|
+
* order specified. Note that you need to make sure that non-JavaScript files
|
1330
|
+
* are transpiled by another plugin first.
|
1331
|
+
* @default [ '.js' ]
|
1332
|
+
*/
|
1333
|
+
extensions?: ReadonlyArray<string>
|
1334
|
+
/**
|
1335
|
+
* If true then uses of `global` won't be dealt with by this plugin
|
1336
|
+
* @default false
|
1337
|
+
*/
|
1338
|
+
ignoreGlobal?: boolean
|
1339
|
+
/**
|
1340
|
+
* If false, skips source map generation for CommonJS modules. This will
|
1341
|
+
* improve performance.
|
1342
|
+
* @default true
|
1343
|
+
*/
|
1344
|
+
sourceMap?: boolean
|
1345
|
+
/**
|
1346
|
+
* Some `require` calls cannot be resolved statically to be translated to
|
1347
|
+
* imports.
|
1348
|
+
* When this option is set to `false`, the generated code will either
|
1349
|
+
* directly throw an error when such a call is encountered or, when
|
1350
|
+
* `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
1351
|
+
* configured dynamic require target.
|
1352
|
+
* Setting this option to `true` will instead leave the `require` call in the
|
1353
|
+
* code or use it as a fallback for `dynamicRequireTargets`.
|
1354
|
+
* @default false
|
1355
|
+
*/
|
1356
|
+
ignoreDynamicRequires?: boolean
|
1357
|
+
/**
|
1358
|
+
* Instructs the plugin whether to enable mixed module transformations. This
|
1359
|
+
* is useful in scenarios with modules that contain a mix of ES `import`
|
1360
|
+
* statements and CommonJS `require` expressions. Set to `true` if `require`
|
1361
|
+
* calls should be transformed to imports in mixed modules, or `false` if the
|
1362
|
+
* `require` expressions should survive the transformation. The latter can be
|
1363
|
+
* important if the code contains environment detection, or you are coding
|
1364
|
+
* for an environment with special treatment for `require` calls such as
|
1365
|
+
* ElectronJS. See also the `ignore` option.
|
1366
|
+
* @default false
|
1367
|
+
*/
|
1368
|
+
transformMixedEsModules?: boolean
|
1369
|
+
/**
|
1370
|
+
* By default, this plugin will try to hoist `require` statements as imports
|
1371
|
+
* to the top of each file. While this works well for many code bases and
|
1372
|
+
* allows for very efficient ESM output, it does not perfectly capture
|
1373
|
+
* CommonJS semantics as the order of side effects like log statements may
|
1374
|
+
* change. But it is especially problematic when there are circular `require`
|
1375
|
+
* calls between CommonJS modules as those often rely on the lazy execution of
|
1376
|
+
* nested `require` calls.
|
1377
|
+
*
|
1378
|
+
* Setting this option to `true` will wrap all CommonJS files in functions
|
1379
|
+
* which are executed when they are required for the first time, preserving
|
1380
|
+
* NodeJS semantics. Note that this can have an impact on the size and
|
1381
|
+
* performance of the generated code.
|
1382
|
+
*
|
1383
|
+
* The default value of `"auto"` will only wrap CommonJS files when they are
|
1384
|
+
* part of a CommonJS dependency cycle, e.g. an index file that is required by
|
1385
|
+
* many of its dependencies. All other CommonJS files are hoisted. This is the
|
1386
|
+
* recommended setting for most code bases.
|
1387
|
+
*
|
1388
|
+
* `false` will entirely prevent wrapping and hoist all files. This may still
|
1389
|
+
* work depending on the nature of cyclic dependencies but will often cause
|
1390
|
+
* problems.
|
1391
|
+
*
|
1392
|
+
* You can also provide a minimatch pattern, or array of patterns, to only
|
1393
|
+
* specify a subset of files which should be wrapped in functions for proper
|
1394
|
+
* `require` semantics.
|
1395
|
+
*
|
1396
|
+
* `"debug"` works like `"auto"` but after bundling, it will display a warning
|
1397
|
+
* containing a list of ids that have been wrapped which can be used as
|
1398
|
+
* minimatch pattern for fine-tuning.
|
1399
|
+
* @default "auto"
|
1400
|
+
*/
|
1401
|
+
strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[]
|
1402
|
+
/**
|
1403
|
+
* Sometimes you have to leave require statements unconverted. Pass an array
|
1404
|
+
* containing the IDs or a `id => boolean` function.
|
1405
|
+
* @default []
|
1406
|
+
*/
|
1407
|
+
ignore?: ReadonlyArray<string> | ((id: string) => boolean)
|
1408
|
+
/**
|
1409
|
+
* In most cases, where `require` calls are inside a `try-catch` clause,
|
1410
|
+
* they should be left unconverted as it requires an optional dependency
|
1411
|
+
* that may or may not be installed beside the rolled up package.
|
1412
|
+
* Due to the conversion of `require` to a static `import` - the call is
|
1413
|
+
* hoisted to the top of the file, outside the `try-catch` clause.
|
1414
|
+
*
|
1415
|
+
* - `true`: Default. All `require` calls inside a `try` will be left unconverted.
|
1416
|
+
* - `false`: All `require` calls inside a `try` will be converted as if the
|
1417
|
+
* `try-catch` clause is not there.
|
1418
|
+
* - `remove`: Remove all `require` calls from inside any `try` block.
|
1419
|
+
* - `string[]`: Pass an array containing the IDs to left unconverted.
|
1420
|
+
* - `((id: string) => boolean|'remove')`: Pass a function that controls
|
1421
|
+
* individual IDs.
|
1422
|
+
*
|
1423
|
+
* @default true
|
1424
|
+
*/
|
1425
|
+
ignoreTryCatch?:
|
1426
|
+
| boolean
|
1427
|
+
| 'remove'
|
1428
|
+
| ReadonlyArray<string>
|
1429
|
+
| ((id: string) => boolean | 'remove')
|
1430
|
+
/**
|
1431
|
+
* Controls how to render imports from external dependencies. By default,
|
1432
|
+
* this plugin assumes that all external dependencies are CommonJS. This
|
1433
|
+
* means they are rendered as default imports to be compatible with e.g.
|
1434
|
+
* NodeJS where ES modules can only import a default export from a CommonJS
|
1435
|
+
* dependency.
|
1436
|
+
*
|
1437
|
+
* If you set `esmExternals` to `true`, this plugin assumes that all
|
1438
|
+
* external dependencies are ES modules and respect the
|
1439
|
+
* `requireReturnsDefault` option. If that option is not set, they will be
|
1440
|
+
* rendered as namespace imports.
|
1441
|
+
*
|
1442
|
+
* You can also supply an array of ids to be treated as ES modules, or a
|
1443
|
+
* function that will be passed each external id to determine whether it is
|
1444
|
+
* an ES module.
|
1445
|
+
* @default false
|
1446
|
+
*/
|
1447
|
+
esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
|
1448
|
+
/**
|
1449
|
+
* Controls what is returned when requiring an ES module from a CommonJS file.
|
1450
|
+
* When using the `esmExternals` option, this will also apply to external
|
1451
|
+
* modules. By default, this plugin will render those imports as namespace
|
1452
|
+
* imports i.e.
|
1453
|
+
*
|
1454
|
+
* ```js
|
1455
|
+
* // input
|
1456
|
+
* const foo = require('foo');
|
1457
|
+
*
|
1458
|
+
* // output
|
1459
|
+
* import * as foo from 'foo';
|
1460
|
+
* ```
|
1461
|
+
*
|
1462
|
+
* However, there are some situations where this may not be desired.
|
1463
|
+
* For these situations, you can change Rollup's behaviour either globally or
|
1464
|
+
* per module. To change it globally, set the `requireReturnsDefault` option
|
1465
|
+
* to one of the following values:
|
1466
|
+
*
|
1467
|
+
* - `false`: This is the default, requiring an ES module returns its
|
1468
|
+
* namespace. This is the only option that will also add a marker
|
1469
|
+
* `__esModule: true` to the namespace to support interop patterns in
|
1470
|
+
* CommonJS modules that are transpiled ES modules.
|
1471
|
+
* - `"namespace"`: Like `false`, requiring an ES module returns its
|
1472
|
+
* namespace, but the plugin does not add the `__esModule` marker and thus
|
1473
|
+
* creates more efficient code. For external dependencies when using
|
1474
|
+
* `esmExternals: true`, no additional interop code is generated.
|
1475
|
+
* - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
1476
|
+
* Rollup: If a module has a default export and no named exports, requiring
|
1477
|
+
* that module returns the default export. In all other cases, the namespace
|
1478
|
+
* is returned. For external dependencies when using `esmExternals: true`, a
|
1479
|
+
* corresponding interop helper is added.
|
1480
|
+
* - `"preferred"`: If a module has a default export, requiring that module
|
1481
|
+
* always returns the default export, no matter whether additional named
|
1482
|
+
* exports exist. This is similar to how previous versions of this plugin
|
1483
|
+
* worked. Again for external dependencies when using `esmExternals: true`,
|
1484
|
+
* an interop helper is added.
|
1485
|
+
* - `true`: This will always try to return the default export on require
|
1486
|
+
* without checking if it actually exists. This can throw at build time if
|
1487
|
+
* there is no default export. This is how external dependencies are handled
|
1488
|
+
* when `esmExternals` is not used. The advantage over the other options is
|
1489
|
+
* that, like `false`, this does not add an interop helper for external
|
1490
|
+
* dependencies, keeping the code lean.
|
1491
|
+
*
|
1492
|
+
* To change this for individual modules, you can supply a function for
|
1493
|
+
* `requireReturnsDefault` instead. This function will then be called once for
|
1494
|
+
* each required ES module or external dependency with the corresponding id
|
1495
|
+
* and allows you to return different values for different modules.
|
1496
|
+
* @default false
|
1497
|
+
*/
|
1498
|
+
requireReturnsDefault?:
|
1499
|
+
| boolean
|
1500
|
+
| 'auto'
|
1501
|
+
| 'preferred'
|
1502
|
+
| 'namespace'
|
1503
|
+
| ((id: string) => boolean | 'auto' | 'preferred' | 'namespace')
|
1504
|
+
|
1505
|
+
/**
|
1506
|
+
* @default "auto"
|
1507
|
+
*/
|
1508
|
+
defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto')
|
1509
|
+
/**
|
1510
|
+
* Some modules contain dynamic `require` calls, or require modules that
|
1511
|
+
* contain circular dependencies, which are not handled well by static
|
1512
|
+
* imports. Including those modules as `dynamicRequireTargets` will simulate a
|
1513
|
+
* CommonJS (NodeJS-like) environment for them with support for dynamic
|
1514
|
+
* dependencies. It also enables `strictRequires` for those modules.
|
1515
|
+
*
|
1516
|
+
* Note: In extreme cases, this feature may result in some paths being
|
1517
|
+
* rendered as absolute in the final bundle. The plugin tries to avoid
|
1518
|
+
* exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
1519
|
+
* with paths that are far away from your project's folder, that may require
|
1520
|
+
* replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
|
1521
|
+
*/
|
1522
|
+
dynamicRequireTargets?: string | ReadonlyArray<string>
|
1523
|
+
/**
|
1524
|
+
* To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
|
1525
|
+
* that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
|
1526
|
+
* may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
|
1527
|
+
* home directory name. By default, it uses the current working directory.
|
1528
|
+
*/
|
1529
|
+
dynamicRequireRoot?: string
|
1782
1530
|
}
|
1783
|
-
type ModuleSetNames = 'acceptedHmrDeps' | 'importedModules';
|
1784
1531
|
|
1785
|
-
interface
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
server: ViteDevServer;
|
1802
|
-
environment: DevEnvironment;
|
1803
|
-
}
|
1804
|
-
/**
|
1805
|
-
* @deprecated
|
1806
|
-
* Used by handleHotUpdate for backward compatibility with mixed client and ssr moduleGraph
|
1807
|
-
**/
|
1808
|
-
interface HmrContext {
|
1809
|
-
file: string;
|
1810
|
-
timestamp: number;
|
1811
|
-
modules: Array<ModuleNode>;
|
1812
|
-
read: () => string | Promise<string>;
|
1813
|
-
server: ViteDevServer;
|
1814
|
-
}
|
1815
|
-
interface HMRBroadcasterClient {
|
1816
|
-
/**
|
1817
|
-
* Send event to the client
|
1818
|
-
*/
|
1819
|
-
send(payload: HMRPayload): void;
|
1820
|
-
/**
|
1821
|
-
* Send custom event
|
1822
|
-
*/
|
1823
|
-
send(event: string, payload?: CustomPayload['data']): void;
|
1532
|
+
interface RollupDynamicImportVarsOptions {
|
1533
|
+
/**
|
1534
|
+
* Files to include in this plugin (default all).
|
1535
|
+
* @default []
|
1536
|
+
*/
|
1537
|
+
include?: string | RegExp | (string | RegExp)[]
|
1538
|
+
/**
|
1539
|
+
* Files to exclude in this plugin (default none).
|
1540
|
+
* @default []
|
1541
|
+
*/
|
1542
|
+
exclude?: string | RegExp | (string | RegExp)[]
|
1543
|
+
/**
|
1544
|
+
* By default, the plugin quits the build process when it encounters an error. If you set this option to true, it will throw a warning instead and leave the code untouched.
|
1545
|
+
* @default false
|
1546
|
+
*/
|
1547
|
+
warnOnError?: boolean
|
1824
1548
|
}
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1549
|
+
|
1550
|
+
// Modified and inlined to avoid extra dependency
|
1551
|
+
// Source: https://github.com/terser/terser/blob/master/tools/terser.d.ts
|
1552
|
+
// BSD Licensed https://github.com/terser/terser/blob/master/LICENSE
|
1553
|
+
|
1554
|
+
declare namespace Terser {
|
1555
|
+
export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
|
1556
|
+
|
1557
|
+
export type ConsoleProperty = keyof typeof console
|
1558
|
+
type DropConsoleOption = boolean | ConsoleProperty[]
|
1559
|
+
|
1560
|
+
export interface ParseOptions {
|
1561
|
+
bare_returns?: boolean
|
1562
|
+
/** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
|
1563
|
+
ecma?: ECMA
|
1564
|
+
html5_comments?: boolean
|
1565
|
+
shebang?: boolean
|
1566
|
+
}
|
1567
|
+
|
1568
|
+
export interface CompressOptions {
|
1569
|
+
arguments?: boolean
|
1570
|
+
arrows?: boolean
|
1571
|
+
booleans_as_integers?: boolean
|
1572
|
+
booleans?: boolean
|
1573
|
+
collapse_vars?: boolean
|
1574
|
+
comparisons?: boolean
|
1575
|
+
computed_props?: boolean
|
1576
|
+
conditionals?: boolean
|
1577
|
+
dead_code?: boolean
|
1578
|
+
defaults?: boolean
|
1579
|
+
directives?: boolean
|
1580
|
+
drop_console?: DropConsoleOption
|
1581
|
+
drop_debugger?: boolean
|
1582
|
+
ecma?: ECMA
|
1583
|
+
evaluate?: boolean
|
1584
|
+
expression?: boolean
|
1585
|
+
global_defs?: object
|
1586
|
+
hoist_funs?: boolean
|
1587
|
+
hoist_props?: boolean
|
1588
|
+
hoist_vars?: boolean
|
1589
|
+
ie8?: boolean
|
1590
|
+
if_return?: boolean
|
1591
|
+
inline?: boolean | InlineFunctions
|
1592
|
+
join_vars?: boolean
|
1593
|
+
keep_classnames?: boolean | RegExp
|
1594
|
+
keep_fargs?: boolean
|
1595
|
+
keep_fnames?: boolean | RegExp
|
1596
|
+
keep_infinity?: boolean
|
1597
|
+
loops?: boolean
|
1598
|
+
module?: boolean
|
1599
|
+
negate_iife?: boolean
|
1600
|
+
passes?: number
|
1601
|
+
properties?: boolean
|
1602
|
+
pure_funcs?: string[]
|
1603
|
+
pure_new?: boolean
|
1604
|
+
pure_getters?: boolean | 'strict'
|
1605
|
+
reduce_funcs?: boolean
|
1606
|
+
reduce_vars?: boolean
|
1607
|
+
sequences?: boolean | number
|
1608
|
+
side_effects?: boolean
|
1609
|
+
switches?: boolean
|
1610
|
+
toplevel?: boolean
|
1611
|
+
top_retain?: null | string | string[] | RegExp
|
1612
|
+
typeofs?: boolean
|
1613
|
+
unsafe_arrows?: boolean
|
1614
|
+
unsafe?: boolean
|
1615
|
+
unsafe_comps?: boolean
|
1616
|
+
unsafe_Function?: boolean
|
1617
|
+
unsafe_math?: boolean
|
1618
|
+
unsafe_symbols?: boolean
|
1619
|
+
unsafe_methods?: boolean
|
1620
|
+
unsafe_proto?: boolean
|
1621
|
+
unsafe_regexp?: boolean
|
1622
|
+
unsafe_undefined?: boolean
|
1623
|
+
unused?: boolean
|
1624
|
+
}
|
1625
|
+
|
1626
|
+
export enum InlineFunctions {
|
1627
|
+
Disabled = 0,
|
1628
|
+
SimpleFunctions = 1,
|
1629
|
+
WithArguments = 2,
|
1630
|
+
WithArgumentsAndVariables = 3,
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
export interface MangleOptions {
|
1634
|
+
eval?: boolean
|
1635
|
+
keep_classnames?: boolean | RegExp
|
1636
|
+
keep_fnames?: boolean | RegExp
|
1637
|
+
module?: boolean
|
1638
|
+
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
1639
|
+
properties?: boolean | ManglePropertiesOptions
|
1640
|
+
reserved?: string[]
|
1641
|
+
safari10?: boolean
|
1642
|
+
toplevel?: boolean
|
1643
|
+
}
|
1644
|
+
|
1645
|
+
/**
|
1646
|
+
* An identifier mangler for which the output is invariant with respect to the source code.
|
1647
|
+
*/
|
1648
|
+
export interface SimpleIdentifierMangler {
|
1838
1649
|
/**
|
1839
|
-
*
|
1650
|
+
* Obtains the nth most favored (usually shortest) identifier to rename a variable to.
|
1651
|
+
* The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
|
1652
|
+
* This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
|
1653
|
+
* @param n The ordinal of the identifier.
|
1840
1654
|
*/
|
1841
|
-
|
1842
|
-
|
1655
|
+
get(n: number): string
|
1656
|
+
}
|
1657
|
+
|
1658
|
+
/**
|
1659
|
+
* An identifier mangler that leverages character frequency analysis to determine identifier precedence.
|
1660
|
+
*/
|
1661
|
+
export interface WeightedIdentifierMangler extends SimpleIdentifierMangler {
|
1843
1662
|
/**
|
1844
|
-
*
|
1663
|
+
* Modifies the internal weighting of the input characters by the specified delta.
|
1664
|
+
* Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
|
1665
|
+
* @param chars The characters to modify the weighting of.
|
1666
|
+
* @param delta The numeric weight to add to the characters.
|
1845
1667
|
*/
|
1846
|
-
|
1668
|
+
consider(chars: string, delta: number): number
|
1847
1669
|
/**
|
1848
|
-
*
|
1670
|
+
* Resets character weights.
|
1849
1671
|
*/
|
1850
|
-
|
1672
|
+
reset(): void
|
1851
1673
|
/**
|
1852
|
-
*
|
1674
|
+
* Sorts identifiers by character frequency, in preparation for calls to get(n).
|
1853
1675
|
*/
|
1854
|
-
|
1676
|
+
sort(): void
|
1677
|
+
}
|
1678
|
+
|
1679
|
+
export interface ManglePropertiesOptions {
|
1680
|
+
builtins?: boolean
|
1681
|
+
debug?: boolean
|
1682
|
+
keep_quoted?: boolean | 'strict'
|
1683
|
+
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
1684
|
+
regex?: RegExp | string
|
1685
|
+
reserved?: string[]
|
1686
|
+
}
|
1687
|
+
|
1688
|
+
export interface FormatOptions {
|
1689
|
+
ascii_only?: boolean
|
1690
|
+
/** @deprecated Not implemented anymore */
|
1691
|
+
beautify?: boolean
|
1692
|
+
braces?: boolean
|
1693
|
+
comments?:
|
1694
|
+
| boolean
|
1695
|
+
| 'all'
|
1696
|
+
| 'some'
|
1697
|
+
| RegExp
|
1698
|
+
| ((
|
1699
|
+
node: any,
|
1700
|
+
comment: {
|
1701
|
+
value: string
|
1702
|
+
type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
|
1703
|
+
pos: number
|
1704
|
+
line: number
|
1705
|
+
col: number
|
1706
|
+
},
|
1707
|
+
) => boolean)
|
1708
|
+
ecma?: ECMA
|
1709
|
+
ie8?: boolean
|
1710
|
+
keep_numbers?: boolean
|
1711
|
+
indent_level?: number
|
1712
|
+
indent_start?: number
|
1713
|
+
inline_script?: boolean
|
1714
|
+
keep_quoted_props?: boolean
|
1715
|
+
max_line_len?: number | false
|
1716
|
+
preamble?: string
|
1717
|
+
preserve_annotations?: boolean
|
1718
|
+
quote_keys?: boolean
|
1719
|
+
quote_style?: OutputQuoteStyle
|
1720
|
+
safari10?: boolean
|
1721
|
+
semicolons?: boolean
|
1722
|
+
shebang?: boolean
|
1723
|
+
shorthand?: boolean
|
1724
|
+
source_map?: SourceMapOptions
|
1725
|
+
webkit?: boolean
|
1726
|
+
width?: number
|
1727
|
+
wrap_iife?: boolean
|
1728
|
+
wrap_func_args?: boolean
|
1729
|
+
}
|
1730
|
+
|
1731
|
+
export enum OutputQuoteStyle {
|
1732
|
+
PreferDouble = 0,
|
1733
|
+
AlwaysSingle = 1,
|
1734
|
+
AlwaysDouble = 2,
|
1735
|
+
AlwaysOriginal = 3,
|
1736
|
+
}
|
1737
|
+
|
1738
|
+
export interface MinifyOptions {
|
1739
|
+
compress?: boolean | CompressOptions
|
1740
|
+
ecma?: ECMA
|
1741
|
+
enclose?: boolean | string
|
1742
|
+
ie8?: boolean
|
1743
|
+
keep_classnames?: boolean | RegExp
|
1744
|
+
keep_fnames?: boolean | RegExp
|
1745
|
+
mangle?: boolean | MangleOptions
|
1746
|
+
module?: boolean
|
1747
|
+
nameCache?: object
|
1748
|
+
format?: FormatOptions
|
1749
|
+
/** @deprecated */
|
1750
|
+
output?: FormatOptions
|
1751
|
+
parse?: ParseOptions
|
1752
|
+
safari10?: boolean
|
1753
|
+
sourceMap?: boolean | SourceMapOptions
|
1754
|
+
toplevel?: boolean
|
1755
|
+
}
|
1756
|
+
|
1757
|
+
export interface MinifyOutput {
|
1758
|
+
code?: string
|
1759
|
+
map?: object | string
|
1760
|
+
decoded_map?: object | null
|
1761
|
+
}
|
1762
|
+
|
1763
|
+
export interface SourceMapOptions {
|
1764
|
+
/** Source map object, 'inline' or source map file content */
|
1765
|
+
content?: object | string
|
1766
|
+
includeSources?: boolean
|
1767
|
+
filename?: string
|
1768
|
+
root?: string
|
1769
|
+
asObject?: boolean
|
1770
|
+
url?: string | 'inline'
|
1771
|
+
}
|
1855
1772
|
}
|
1856
|
-
|
1857
|
-
|
1858
|
-
* All registered channels. Always has websocket channel.
|
1859
|
-
*/
|
1860
|
-
readonly channels: HMRChannel[];
|
1773
|
+
|
1774
|
+
interface TerserOptions extends Terser.MinifyOptions {
|
1861
1775
|
/**
|
1862
|
-
*
|
1776
|
+
* Vite-specific option to specify the max number of workers to spawn
|
1777
|
+
* when minifying files with terser.
|
1778
|
+
*
|
1779
|
+
* @default number of CPUs minus 1
|
1863
1780
|
*/
|
1864
|
-
|
1865
|
-
close(): Promise<unknown[]>;
|
1866
|
-
}
|
1867
|
-
interface ServerHMRChannel extends HMRChannel {
|
1868
|
-
api: {
|
1869
|
-
innerEmitter: EventEmitter;
|
1870
|
-
outsideEmitter: EventEmitter;
|
1871
|
-
};
|
1781
|
+
maxWorkers?: number;
|
1872
1782
|
}
|
1873
1783
|
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
<
|
1893
|
-
|
1894
|
-
/**
|
1895
|
-
* Unregister event listener.
|
1896
|
-
*/
|
1897
|
-
off: WebSocket.Server['off'] & {
|
1898
|
-
(event: string, listener: Function): void;
|
1784
|
+
/** Cache for package.json resolution and package.json contents */
|
1785
|
+
type PackageCache = Map<string, PackageData>;
|
1786
|
+
interface PackageData {
|
1787
|
+
dir: string;
|
1788
|
+
hasSideEffects: (id: string) => boolean | 'no-treeshake' | null;
|
1789
|
+
webResolvedImports: Record<string, string | undefined>;
|
1790
|
+
nodeResolvedImports: Record<string, string | undefined>;
|
1791
|
+
setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
|
1792
|
+
getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
|
1793
|
+
data: {
|
1794
|
+
[field: string]: any;
|
1795
|
+
name: string;
|
1796
|
+
type: string;
|
1797
|
+
version: string;
|
1798
|
+
main: string;
|
1799
|
+
module: string;
|
1800
|
+
browser: string | Record<string, string | false>;
|
1801
|
+
exports: string | Record<string, any> | string[];
|
1802
|
+
imports: Record<string, any>;
|
1803
|
+
dependencies: Record<string, string>;
|
1899
1804
|
};
|
1900
1805
|
}
|
1901
|
-
interface WebSocketClient {
|
1902
|
-
/**
|
1903
|
-
* Send event to the client
|
1904
|
-
*/
|
1905
|
-
send(payload: HMRPayload): void;
|
1906
|
-
/**
|
1907
|
-
* Send custom event
|
1908
|
-
*/
|
1909
|
-
send(event: string, payload?: CustomPayload['data']): void;
|
1910
|
-
/**
|
1911
|
-
* The raw WebSocket instance
|
1912
|
-
* @advanced
|
1913
|
-
*/
|
1914
|
-
socket: WebSocket;
|
1915
|
-
}
|
1916
1806
|
|
1917
|
-
interface
|
1918
|
-
/**
|
1919
|
-
* Configure HMR-specific options (port, host, path & protocol)
|
1920
|
-
*/
|
1921
|
-
hmr?: HmrOptions | boolean;
|
1922
|
-
/**
|
1923
|
-
* Warm-up files to transform and cache the results in advance. This improves the
|
1924
|
-
* initial page load during server starts and prevents transform waterfalls.
|
1925
|
-
* @deprecated use dev.warmup / environment.ssr.dev.warmup
|
1926
|
-
*/
|
1927
|
-
warmup?: {
|
1928
|
-
/**
|
1929
|
-
* The files to be transformed and used on the client-side. Supports glob patterns.
|
1930
|
-
*/
|
1931
|
-
clientFiles?: string[];
|
1932
|
-
/**
|
1933
|
-
* The files to be transformed and used in SSR. Supports glob patterns.
|
1934
|
-
*/
|
1935
|
-
ssrFiles?: string[];
|
1936
|
-
};
|
1937
|
-
/**
|
1938
|
-
* chokidar watch options or null to disable FS watching
|
1939
|
-
* https://github.com/paulmillr/chokidar#api
|
1940
|
-
*/
|
1941
|
-
watch?: WatchOptions | null;
|
1942
|
-
/**
|
1943
|
-
* Create Vite dev server to be used as a middleware in an existing server
|
1944
|
-
* @default false
|
1945
|
-
*/
|
1946
|
-
middlewareMode?: boolean | {
|
1947
|
-
/**
|
1948
|
-
* Parent server instance to attach to
|
1949
|
-
*
|
1950
|
-
* This is needed to proxy WebSocket connections to the parent server.
|
1951
|
-
*/
|
1952
|
-
server: http.Server;
|
1953
|
-
};
|
1954
|
-
/**
|
1955
|
-
* Options for files served via '/\@fs/'.
|
1956
|
-
*/
|
1957
|
-
fs?: FileSystemServeOptions;
|
1807
|
+
interface BuildEnvironmentOptions {
|
1958
1808
|
/**
|
1959
|
-
*
|
1809
|
+
* Compatibility transform target. The transform is performed with esbuild
|
1810
|
+
* and the lowest supported target is es2015/es6. Note this only handles
|
1811
|
+
* syntax transformation and does not cover polyfills (except for dynamic
|
1812
|
+
* import)
|
1960
1813
|
*
|
1961
|
-
*
|
1814
|
+
* Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
|
1815
|
+
* transpile targeting browsers that natively support dynamic es module imports.
|
1816
|
+
* https://caniuse.com/es6-module-dynamic-import
|
1817
|
+
*
|
1818
|
+
* Another special value is 'esnext' - which only performs minimal transpiling
|
1819
|
+
* (for minification compat) and assumes native dynamic imports support.
|
1820
|
+
*
|
1821
|
+
* For custom targets, see https://esbuild.github.io/api/#target and
|
1822
|
+
* https://esbuild.github.io/content-types/#javascript for more details.
|
1823
|
+
* @default 'modules'
|
1962
1824
|
*/
|
1963
|
-
|
1825
|
+
target?: 'modules' | esbuild_TransformOptions['target'] | false;
|
1964
1826
|
/**
|
1965
|
-
*
|
1827
|
+
* whether to inject module preload polyfill.
|
1828
|
+
* Note: does not apply to library mode.
|
1966
1829
|
* @default true
|
1967
|
-
* @deprecated use
|
1830
|
+
* @deprecated use `modulePreload.polyfill` instead
|
1968
1831
|
*/
|
1969
|
-
|
1832
|
+
polyfillModulePreload?: boolean;
|
1970
1833
|
/**
|
1971
|
-
*
|
1972
|
-
*
|
1973
|
-
*
|
1974
|
-
* By default, it excludes all paths containing `node_modules`. You can pass `false` to
|
1975
|
-
* disable this behavior, or, for full control, a function that takes the source path and
|
1976
|
-
* sourcemap path and returns whether to ignore the source path.
|
1977
|
-
* @deprecated use dev.sourcemapIgnoreList
|
1834
|
+
* Configure module preload
|
1835
|
+
* Note: does not apply to library mode.
|
1836
|
+
* @default true
|
1978
1837
|
*/
|
1979
|
-
|
1838
|
+
modulePreload?: boolean | ModulePreloadOptions;
|
1980
1839
|
/**
|
1981
|
-
*
|
1982
|
-
*
|
1840
|
+
* Directory relative from `root` where build output will be placed. If the
|
1841
|
+
* directory exists, it will be removed before the build.
|
1842
|
+
* @default 'dist'
|
1983
1843
|
*/
|
1984
|
-
|
1985
|
-
}
|
1986
|
-
interface ResolvedServerOptions extends Omit<ServerOptions, 'fs' | 'middlewareMode' | 'sourcemapIgnoreList'> {
|
1987
|
-
fs: Required<FileSystemServeOptions>;
|
1988
|
-
middlewareMode: NonNullable<ServerOptions['middlewareMode']>;
|
1989
|
-
sourcemapIgnoreList: Exclude<ServerOptions['sourcemapIgnoreList'], false | undefined>;
|
1990
|
-
}
|
1991
|
-
interface FileSystemServeOptions {
|
1844
|
+
outDir?: string;
|
1992
1845
|
/**
|
1993
|
-
*
|
1994
|
-
*
|
1995
|
-
*
|
1996
|
-
*
|
1997
|
-
* @default true
|
1846
|
+
* Directory relative from `outDir` where the built js/css/image assets will
|
1847
|
+
* be placed.
|
1848
|
+
* @default 'assets'
|
1998
1849
|
*/
|
1999
|
-
|
1850
|
+
assetsDir?: string;
|
2000
1851
|
/**
|
2001
|
-
*
|
2002
|
-
*
|
2003
|
-
*
|
2004
|
-
* Will try to search up for workspace root by default.
|
1852
|
+
* Static asset files smaller than this number (in bytes) will be inlined as
|
1853
|
+
* base64 strings. Default limit is `4096` (4 KiB). Set to `0` to disable.
|
1854
|
+
* @default 4096
|
2005
1855
|
*/
|
2006
|
-
|
1856
|
+
assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
|
2007
1857
|
/**
|
2008
|
-
*
|
2009
|
-
*
|
2010
|
-
*
|
2011
|
-
*
|
2012
|
-
*
|
2013
|
-
* @default ['.env', '.env.*', '*.crt', '*.pem']
|
1858
|
+
* Whether to code-split CSS. When enabled, CSS in async chunks will be
|
1859
|
+
* inlined as strings in the chunk and inserted via dynamically created
|
1860
|
+
* style tags when the chunk is loaded.
|
1861
|
+
* @default true
|
2014
1862
|
*/
|
2015
|
-
|
1863
|
+
cssCodeSplit?: boolean;
|
2016
1864
|
/**
|
2017
|
-
*
|
2018
|
-
*
|
2019
|
-
*
|
2020
|
-
*
|
1865
|
+
* An optional separate target for CSS minification.
|
1866
|
+
* As esbuild only supports configuring targets to mainstream
|
1867
|
+
* browsers, users may need this option when they are targeting
|
1868
|
+
* a niche browser that comes with most modern JavaScript features
|
1869
|
+
* but has poor CSS support, e.g. Android WeChat WebView, which
|
1870
|
+
* doesn't support the #RGBA syntax.
|
1871
|
+
* @default target
|
2021
1872
|
*/
|
2022
|
-
|
2023
|
-
}
|
2024
|
-
type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
2025
|
-
type HttpServer = http.Server | Http2SecureServer;
|
2026
|
-
interface ViteDevServer {
|
1873
|
+
cssTarget?: esbuild_TransformOptions['target'] | false;
|
2027
1874
|
/**
|
2028
|
-
*
|
1875
|
+
* Override CSS minification specifically instead of defaulting to `build.minify`,
|
1876
|
+
* so you can configure minification for JS and CSS separately.
|
1877
|
+
* @default 'esbuild'
|
2029
1878
|
*/
|
2030
|
-
|
1879
|
+
cssMinify?: boolean | 'esbuild' | 'lightningcss';
|
2031
1880
|
/**
|
2032
|
-
*
|
2033
|
-
*
|
2034
|
-
*
|
2035
|
-
*
|
2036
|
-
*
|
2037
|
-
* https://github.com/senchalabs/connect#use-middleware
|
1881
|
+
* If `true`, a separate sourcemap file will be created. If 'inline', the
|
1882
|
+
* sourcemap will be appended to the resulting output file as data URI.
|
1883
|
+
* 'hidden' works like `true` except that the corresponding sourcemap
|
1884
|
+
* comments in the bundled files are suppressed.
|
1885
|
+
* @default false
|
2038
1886
|
*/
|
2039
|
-
|
1887
|
+
sourcemap?: boolean | 'inline' | 'hidden';
|
2040
1888
|
/**
|
2041
|
-
*
|
2042
|
-
*
|
1889
|
+
* Set to `false` to disable minification, or specify the minifier to use.
|
1890
|
+
* Available options are 'terser' or 'esbuild'.
|
1891
|
+
* @default 'esbuild'
|
2043
1892
|
*/
|
2044
|
-
|
1893
|
+
minify?: boolean | 'terser' | 'esbuild';
|
2045
1894
|
/**
|
2046
|
-
*
|
2047
|
-
* https://
|
1895
|
+
* Options for terser
|
1896
|
+
* https://terser.org/docs/api-reference#minify-options
|
1897
|
+
*
|
1898
|
+
* In addition, you can also pass a `maxWorkers: number` option to specify the
|
1899
|
+
* max number of workers to spawn. Defaults to the number of CPUs minus 1.
|
2048
1900
|
*/
|
2049
|
-
|
1901
|
+
terserOptions?: TerserOptions;
|
2050
1902
|
/**
|
2051
|
-
*
|
2052
|
-
*
|
1903
|
+
* Will be merged with internal rollup options.
|
1904
|
+
* https://rollupjs.org/configuration-options/
|
2053
1905
|
*/
|
2054
|
-
|
1906
|
+
rollupOptions?: RollupOptions;
|
2055
1907
|
/**
|
2056
|
-
*
|
2057
|
-
*
|
2058
|
-
* Always sends a message to at least a WebSocket client. Any third party can
|
2059
|
-
* add a channel to the broadcaster to process messages
|
2060
|
-
* @deprecated use `environment.hot` instead
|
1908
|
+
* Options to pass on to `@rollup/plugin-commonjs`
|
2061
1909
|
*/
|
2062
|
-
|
1910
|
+
commonjsOptions?: RollupCommonJSOptions;
|
2063
1911
|
/**
|
2064
|
-
*
|
2065
|
-
* @deprecated use `environment.pluginContainer` instead
|
1912
|
+
* Options to pass on to `@rollup/plugin-dynamic-import-vars`
|
2066
1913
|
*/
|
2067
|
-
|
1914
|
+
dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
|
2068
1915
|
/**
|
2069
|
-
*
|
1916
|
+
* Whether to write bundle to disk
|
1917
|
+
* @default true
|
2070
1918
|
*/
|
2071
|
-
|
1919
|
+
write?: boolean;
|
2072
1920
|
/**
|
2073
|
-
*
|
2074
|
-
*
|
2075
|
-
* @deprecated use `environment.moduleGraph` instead
|
1921
|
+
* Empty outDir on write.
|
1922
|
+
* @default true when outDir is a sub directory of project root
|
2076
1923
|
*/
|
2077
|
-
|
1924
|
+
emptyOutDir?: boolean | null;
|
2078
1925
|
/**
|
2079
|
-
*
|
2080
|
-
*
|
1926
|
+
* Copy the public directory to outDir on write.
|
1927
|
+
* @default true
|
2081
1928
|
*/
|
2082
|
-
|
1929
|
+
copyPublicDir?: boolean;
|
2083
1930
|
/**
|
2084
|
-
*
|
2085
|
-
*
|
2086
|
-
*
|
1931
|
+
* Whether to emit a .vite/manifest.json under assets dir to map hash-less filenames
|
1932
|
+
* to their hashed versions. Useful when you want to generate your own HTML
|
1933
|
+
* instead of using the one generated by Vite.
|
1934
|
+
*
|
1935
|
+
* Example:
|
1936
|
+
*
|
1937
|
+
* ```json
|
1938
|
+
* {
|
1939
|
+
* "main.js": {
|
1940
|
+
* "file": "main.68fe3fad.js",
|
1941
|
+
* "css": "main.e6b63442.css",
|
1942
|
+
* "imports": [...],
|
1943
|
+
* "dynamicImports": [...]
|
1944
|
+
* }
|
1945
|
+
* }
|
1946
|
+
* ```
|
1947
|
+
* @default false
|
2087
1948
|
*/
|
2088
|
-
|
1949
|
+
manifest?: boolean | string;
|
2089
1950
|
/**
|
2090
|
-
*
|
2091
|
-
*
|
2092
|
-
*
|
2093
|
-
* @
|
1951
|
+
* Build in library mode. The value should be the global name of the lib in
|
1952
|
+
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
1953
|
+
* configurations that are suitable for distributing libraries.
|
1954
|
+
* @default false
|
2094
1955
|
*/
|
2095
|
-
|
1956
|
+
lib?: LibraryOptions | false;
|
2096
1957
|
/**
|
2097
|
-
*
|
1958
|
+
* Produce SSR oriented build. Note this requires specifying SSR entry via
|
1959
|
+
* `rollupOptions.input`.
|
1960
|
+
* @default false
|
2098
1961
|
*/
|
2099
|
-
|
1962
|
+
ssr?: boolean | string;
|
2100
1963
|
/**
|
2101
|
-
*
|
2102
|
-
*
|
1964
|
+
* Generate SSR manifest for determining style links and asset preload
|
1965
|
+
* directives in production.
|
1966
|
+
* @default false
|
2103
1967
|
*/
|
2104
|
-
|
2105
|
-
mappings: '';
|
2106
|
-
} | null, url: string, originalCode?: string): Promise<TransformResult | null>;
|
1968
|
+
ssrManifest?: boolean | string;
|
2107
1969
|
/**
|
2108
|
-
*
|
1970
|
+
* Emit assets during SSR.
|
1971
|
+
* @default false
|
2109
1972
|
*/
|
2110
|
-
|
2111
|
-
fixStacktrace?: boolean;
|
2112
|
-
}): Promise<Record<string, any>>;
|
1973
|
+
ssrEmitAssets?: boolean;
|
2113
1974
|
/**
|
2114
|
-
*
|
1975
|
+
* Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
|
1976
|
+
* By default, it is true for the client and false for other environments.
|
2115
1977
|
*/
|
2116
|
-
|
1978
|
+
emitAssets?: boolean;
|
2117
1979
|
/**
|
2118
|
-
*
|
1980
|
+
* Set to false to disable reporting compressed chunk sizes.
|
1981
|
+
* Can slightly improve build speed.
|
1982
|
+
* @default true
|
2119
1983
|
*/
|
2120
|
-
|
1984
|
+
reportCompressedSize?: boolean;
|
2121
1985
|
/**
|
2122
|
-
*
|
2123
|
-
*
|
1986
|
+
* Adjust chunk size warning limit (in kB).
|
1987
|
+
* @default 500
|
2124
1988
|
*/
|
2125
|
-
|
1989
|
+
chunkSizeWarningLimit?: number;
|
2126
1990
|
/**
|
2127
|
-
*
|
2128
|
-
*
|
1991
|
+
* Rollup watch options
|
1992
|
+
* https://rollupjs.org/configuration-options/#watch
|
1993
|
+
* @default null
|
2129
1994
|
*/
|
2130
|
-
|
1995
|
+
watch?: WatcherOptions | null;
|
2131
1996
|
/**
|
2132
|
-
*
|
1997
|
+
* create the Build Environment instance
|
2133
1998
|
*/
|
2134
|
-
|
1999
|
+
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
|
2000
|
+
}
|
2001
|
+
type BuildOptions = BuildEnvironmentOptions;
|
2002
|
+
interface LibraryOptions {
|
2135
2003
|
/**
|
2136
|
-
*
|
2004
|
+
* Path of library entry
|
2137
2005
|
*/
|
2138
|
-
|
2006
|
+
entry: InputOption;
|
2139
2007
|
/**
|
2140
|
-
*
|
2008
|
+
* The name of the exposed global variable. Required when the `formats` option includes
|
2009
|
+
* `umd` or `iife`
|
2141
2010
|
*/
|
2142
|
-
|
2011
|
+
name?: string;
|
2143
2012
|
/**
|
2144
|
-
*
|
2013
|
+
* Output bundle formats
|
2014
|
+
* @default ['es', 'umd']
|
2145
2015
|
*/
|
2146
|
-
|
2016
|
+
formats?: LibraryFormats[];
|
2147
2017
|
/**
|
2148
|
-
*
|
2149
|
-
*
|
2150
|
-
*
|
2018
|
+
* The name of the package file output. The default file name is the name option
|
2019
|
+
* of the project package.json. It can also be defined as a function taking the
|
2020
|
+
* format as an argument.
|
2151
2021
|
*/
|
2152
|
-
|
2022
|
+
fileName?: string | ((format: ModuleFormat, entryName: string) => string);
|
2023
|
+
}
|
2024
|
+
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' | 'system';
|
2025
|
+
interface ModulePreloadOptions {
|
2153
2026
|
/**
|
2154
|
-
*
|
2027
|
+
* Whether to inject a module preload polyfill.
|
2028
|
+
* Note: does not apply to library mode.
|
2029
|
+
* @default true
|
2155
2030
|
*/
|
2156
|
-
|
2031
|
+
polyfill?: boolean;
|
2157
2032
|
/**
|
2158
|
-
*
|
2159
|
-
* are processed. If called from a load or transform plugin hook, the id needs to be
|
2160
|
-
* passed as a parameter to avoid deadlocks. Calling this function after the first
|
2161
|
-
* static imports section of the module graph has been processed will resolve immediately.
|
2033
|
+
* Resolve the list of dependencies to preload for a given dynamic import
|
2162
2034
|
* @experimental
|
2163
|
-
* @deprecated use environment.waitForRequestsIdle()
|
2164
2035
|
*/
|
2165
|
-
|
2036
|
+
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2166
2037
|
}
|
2167
|
-
interface
|
2168
|
-
|
2169
|
-
|
2038
|
+
interface ResolvedModulePreloadOptions {
|
2039
|
+
polyfill: boolean;
|
2040
|
+
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2170
2041
|
}
|
2171
|
-
|
2042
|
+
type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
|
2043
|
+
hostId: string;
|
2044
|
+
hostType: 'html' | 'js';
|
2045
|
+
}) => string[];
|
2046
|
+
interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> {
|
2047
|
+
modulePreload: false | ResolvedModulePreloadOptions;
|
2048
|
+
}
|
2049
|
+
interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
|
2050
|
+
modulePreload: false | ResolvedModulePreloadOptions;
|
2051
|
+
}
|
2052
|
+
/**
|
2053
|
+
* Bundles a single environment for production.
|
2054
|
+
* Returns a Promise containing the build result.
|
2055
|
+
*/
|
2056
|
+
declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2057
|
+
type RenderBuiltAssetUrl = (filename: string, type: {
|
2058
|
+
type: 'asset' | 'public';
|
2059
|
+
hostId: string;
|
2060
|
+
hostType: 'js' | 'css' | 'html';
|
2061
|
+
ssr: boolean;
|
2062
|
+
}) => string | {
|
2063
|
+
relative?: boolean;
|
2064
|
+
runtime?: string;
|
2065
|
+
} | undefined;
|
2066
|
+
declare class BuildEnvironment extends BaseEnvironment {
|
2067
|
+
mode: "build";
|
2068
|
+
constructor(name: string, config: ResolvedConfig, setup?: {
|
2069
|
+
options?: EnvironmentOptions;
|
2070
|
+
});
|
2071
|
+
init(): Promise<void>;
|
2072
|
+
}
|
2073
|
+
interface ViteBuilder {
|
2074
|
+
environments: Record<string, BuildEnvironment>;
|
2075
|
+
config: ResolvedConfig;
|
2076
|
+
buildApp(): Promise<void>;
|
2077
|
+
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2078
|
+
}
|
2079
|
+
interface BuilderOptions {
|
2080
|
+
sharedConfigBuild?: boolean;
|
2081
|
+
sharedPlugins?: boolean;
|
2082
|
+
entireApp?: boolean;
|
2083
|
+
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2084
|
+
}
|
2085
|
+
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2086
|
+
/**
|
2087
|
+
* Creates a ViteBuilder to orchestrate building multiple environments.
|
2088
|
+
*/
|
2089
|
+
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2172
2090
|
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2091
|
+
type Environment = DevEnvironment | BuildEnvironment | UnknownEnvironment;
|
2092
|
+
|
2093
|
+
declare class EnvironmentPluginContainer {
|
2094
|
+
environment: Environment;
|
2095
|
+
plugins: Plugin[];
|
2096
|
+
watcher?: FSWatcher | undefined;
|
2097
|
+
private _pluginContextMap;
|
2098
|
+
private _resolvedRollupOptions?;
|
2099
|
+
private _processesing;
|
2100
|
+
private _seenResolves;
|
2101
|
+
private _moduleNodeToLoadAddedImports;
|
2102
|
+
getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks'];
|
2103
|
+
getSortedPlugins: PluginHookUtils['getSortedPlugins'];
|
2104
|
+
moduleGraph: EnvironmentModuleGraph | undefined;
|
2105
|
+
watchFiles: Set<string>;
|
2106
|
+
minimalContext: MinimalPluginContext;
|
2107
|
+
private _started;
|
2108
|
+
private _buildStartPromise;
|
2109
|
+
private _closed;
|
2110
|
+
private _updateModuleLoadAddedImports;
|
2111
|
+
private _getAddedImports;
|
2112
|
+
getModuleInfo(id: string): ModuleInfo | null;
|
2113
|
+
private handleHookPromise;
|
2114
|
+
get options(): InputOptions;
|
2115
|
+
resolveRollupOptions(): Promise<InputOptions>;
|
2116
|
+
private _getPluginContext;
|
2117
|
+
private hookParallel;
|
2118
|
+
buildStart(_options?: InputOptions): Promise<void>;
|
2119
|
+
resolveId(rawId: string, importer?: string | undefined, options?: {
|
2120
|
+
attributes?: Record<string, string>;
|
2121
|
+
custom?: CustomPluginOptions;
|
2122
|
+
skip?: Set<Plugin>;
|
2123
|
+
isEntry?: boolean;
|
2124
|
+
}): Promise<PartialResolvedId | null>;
|
2125
|
+
load(id: string): Promise<LoadResult | null>;
|
2126
|
+
transform(code: string, id: string, options?: {
|
2127
|
+
inMap?: SourceDescription['map'];
|
2128
|
+
}): Promise<{
|
2129
|
+
code: string;
|
2130
|
+
map: SourceMap | {
|
2131
|
+
mappings: '';
|
2132
|
+
} | null;
|
2133
|
+
}>;
|
2134
|
+
watchChange(id: string, change: {
|
2135
|
+
event: 'create' | 'update' | 'delete';
|
2136
|
+
}): Promise<void>;
|
2137
|
+
close(): Promise<void>;
|
2138
|
+
}
|
2139
|
+
declare class PluginContainer {
|
2140
|
+
private environments;
|
2141
|
+
constructor(environments: Record<string, Environment>);
|
2142
|
+
private _getEnvironment;
|
2143
|
+
private _getPluginContainer;
|
2144
|
+
getModuleInfo(id: string): ModuleInfo | null;
|
2145
|
+
get options(): InputOptions;
|
2146
|
+
buildStart(_options?: InputOptions): Promise<void>;
|
2147
|
+
watchChange(id: string, change: {
|
2148
|
+
event: 'create' | 'update' | 'delete';
|
2149
|
+
}): Promise<void>;
|
2150
|
+
resolveId(rawId: string, importer?: string, options?: {
|
2151
|
+
attributes?: Record<string, string>;
|
2152
|
+
custom?: CustomPluginOptions;
|
2153
|
+
skip?: Set<Plugin>;
|
2154
|
+
ssr?: boolean;
|
2155
|
+
isEntry?: boolean;
|
2156
|
+
}): Promise<PartialResolvedId | null>;
|
2157
|
+
load(id: string, options?: {
|
2158
|
+
ssr?: boolean;
|
2159
|
+
}): Promise<LoadResult | null>;
|
2160
|
+
transform(code: string, id: string, options?: {
|
2161
|
+
ssr?: boolean;
|
2162
|
+
environment?: Environment;
|
2163
|
+
inMap?: SourceDescription['map'];
|
2164
|
+
}): Promise<{
|
2165
|
+
code: string;
|
2166
|
+
map: SourceMap | {
|
2167
|
+
mappings: '';
|
2168
|
+
} | null;
|
2169
|
+
}>;
|
2170
|
+
close(): Promise<void>;
|
2194
2171
|
}
|
2195
2172
|
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
/**
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
/**
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
* NodeJS semantics. Note that this can have an impact on the size and
|
2269
|
-
* performance of the generated code.
|
2270
|
-
*
|
2271
|
-
* The default value of `"auto"` will only wrap CommonJS files when they are
|
2272
|
-
* part of a CommonJS dependency cycle, e.g. an index file that is required by
|
2273
|
-
* many of its dependencies. All other CommonJS files are hoisted. This is the
|
2274
|
-
* recommended setting for most code bases.
|
2275
|
-
*
|
2276
|
-
* `false` will entirely prevent wrapping and hoist all files. This may still
|
2277
|
-
* work depending on the nature of cyclic dependencies but will often cause
|
2278
|
-
* problems.
|
2279
|
-
*
|
2280
|
-
* You can also provide a minimatch pattern, or array of patterns, to only
|
2281
|
-
* specify a subset of files which should be wrapped in functions for proper
|
2282
|
-
* `require` semantics.
|
2283
|
-
*
|
2284
|
-
* `"debug"` works like `"auto"` but after bundling, it will display a warning
|
2285
|
-
* containing a list of ids that have been wrapped which can be used as
|
2286
|
-
* minimatch pattern for fine-tuning.
|
2287
|
-
* @default "auto"
|
2288
|
-
*/
|
2289
|
-
strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[]
|
2290
|
-
/**
|
2291
|
-
* Sometimes you have to leave require statements unconverted. Pass an array
|
2292
|
-
* containing the IDs or a `id => boolean` function.
|
2293
|
-
* @default []
|
2294
|
-
*/
|
2295
|
-
ignore?: ReadonlyArray<string> | ((id: string) => boolean)
|
2296
|
-
/**
|
2297
|
-
* In most cases, where `require` calls are inside a `try-catch` clause,
|
2298
|
-
* they should be left unconverted as it requires an optional dependency
|
2299
|
-
* that may or may not be installed beside the rolled up package.
|
2300
|
-
* Due to the conversion of `require` to a static `import` - the call is
|
2301
|
-
* hoisted to the top of the file, outside the `try-catch` clause.
|
2302
|
-
*
|
2303
|
-
* - `true`: Default. All `require` calls inside a `try` will be left unconverted.
|
2304
|
-
* - `false`: All `require` calls inside a `try` will be converted as if the
|
2305
|
-
* `try-catch` clause is not there.
|
2306
|
-
* - `remove`: Remove all `require` calls from inside any `try` block.
|
2307
|
-
* - `string[]`: Pass an array containing the IDs to left unconverted.
|
2308
|
-
* - `((id: string) => boolean|'remove')`: Pass a function that controls
|
2309
|
-
* individual IDs.
|
2310
|
-
*
|
2311
|
-
* @default true
|
2312
|
-
*/
|
2313
|
-
ignoreTryCatch?:
|
2314
|
-
| boolean
|
2315
|
-
| 'remove'
|
2316
|
-
| ReadonlyArray<string>
|
2317
|
-
| ((id: string) => boolean | 'remove')
|
2173
|
+
// Modified and inlined to avoid extra dependency
|
2174
|
+
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts
|
2175
|
+
|
2176
|
+
declare const WebSocketAlias: typeof WebSocket
|
2177
|
+
interface WebSocketAlias extends WebSocket {}
|
2178
|
+
|
2179
|
+
// WebSocket socket.
|
2180
|
+
declare class WebSocket extends EventEmitter {
|
2181
|
+
/** The connection is not yet open. */
|
2182
|
+
static readonly CONNECTING: 0
|
2183
|
+
/** The connection is open and ready to communicate. */
|
2184
|
+
static readonly OPEN: 1
|
2185
|
+
/** The connection is in the process of closing. */
|
2186
|
+
static readonly CLOSING: 2
|
2187
|
+
/** The connection is closed. */
|
2188
|
+
static readonly CLOSED: 3
|
2189
|
+
|
2190
|
+
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
|
2191
|
+
readonly bufferedAmount: number
|
2192
|
+
readonly extensions: string
|
2193
|
+
/** Indicates whether the websocket is paused */
|
2194
|
+
readonly isPaused: boolean
|
2195
|
+
readonly protocol: string
|
2196
|
+
/** The current state of the connection */
|
2197
|
+
readonly readyState:
|
2198
|
+
| typeof WebSocket.CONNECTING
|
2199
|
+
| typeof WebSocket.OPEN
|
2200
|
+
| typeof WebSocket.CLOSING
|
2201
|
+
| typeof WebSocket.CLOSED
|
2202
|
+
readonly url: string
|
2203
|
+
|
2204
|
+
/** The connection is not yet open. */
|
2205
|
+
readonly CONNECTING: 0
|
2206
|
+
/** The connection is open and ready to communicate. */
|
2207
|
+
readonly OPEN: 1
|
2208
|
+
/** The connection is in the process of closing. */
|
2209
|
+
readonly CLOSING: 2
|
2210
|
+
/** The connection is closed. */
|
2211
|
+
readonly CLOSED: 3
|
2212
|
+
|
2213
|
+
onopen: ((event: WebSocket.Event) => void) | null
|
2214
|
+
onerror: ((event: WebSocket.ErrorEvent) => void) | null
|
2215
|
+
onclose: ((event: WebSocket.CloseEvent) => void) | null
|
2216
|
+
onmessage: ((event: WebSocket.MessageEvent) => void) | null
|
2217
|
+
|
2218
|
+
constructor(address: null)
|
2219
|
+
constructor(
|
2220
|
+
address: string | URL,
|
2221
|
+
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
2222
|
+
)
|
2223
|
+
constructor(
|
2224
|
+
address: string | URL,
|
2225
|
+
protocols?: string | string[],
|
2226
|
+
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
2227
|
+
)
|
2228
|
+
|
2229
|
+
close(code?: number, data?: string | Buffer): void
|
2230
|
+
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
2231
|
+
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
2232
|
+
send(data: any, cb?: (err?: Error) => void): void
|
2233
|
+
send(
|
2234
|
+
data: any,
|
2235
|
+
options: {
|
2236
|
+
mask?: boolean | undefined
|
2237
|
+
binary?: boolean | undefined
|
2238
|
+
compress?: boolean | undefined
|
2239
|
+
fin?: boolean | undefined
|
2240
|
+
},
|
2241
|
+
cb?: (err?: Error) => void,
|
2242
|
+
): void
|
2243
|
+
terminate(): void
|
2244
|
+
|
2318
2245
|
/**
|
2319
|
-
*
|
2320
|
-
* this
|
2321
|
-
*
|
2322
|
-
* NodeJS where ES modules can only import a default export from a CommonJS
|
2323
|
-
* dependency.
|
2324
|
-
*
|
2325
|
-
* If you set `esmExternals` to `true`, this plugin assumes that all
|
2326
|
-
* external dependencies are ES modules and respect the
|
2327
|
-
* `requireReturnsDefault` option. If that option is not set, they will be
|
2328
|
-
* rendered as namespace imports.
|
2329
|
-
*
|
2330
|
-
* You can also supply an array of ids to be treated as ES modules, or a
|
2331
|
-
* function that will be passed each external id to determine whether it is
|
2332
|
-
* an ES module.
|
2333
|
-
* @default false
|
2246
|
+
* Pause the websocket causing it to stop emitting events. Some events can still be
|
2247
|
+
* emitted after this is called, until all buffered data is consumed. This method
|
2248
|
+
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
2334
2249
|
*/
|
2335
|
-
|
2250
|
+
pause(): void
|
2336
2251
|
/**
|
2337
|
-
*
|
2338
|
-
*
|
2339
|
-
* modules. By default, this plugin will render those imports as namespace
|
2340
|
-
* imports i.e.
|
2341
|
-
*
|
2342
|
-
* ```js
|
2343
|
-
* // input
|
2344
|
-
* const foo = require('foo');
|
2345
|
-
*
|
2346
|
-
* // output
|
2347
|
-
* import * as foo from 'foo';
|
2348
|
-
* ```
|
2349
|
-
*
|
2350
|
-
* However, there are some situations where this may not be desired.
|
2351
|
-
* For these situations, you can change Rollup's behaviour either globally or
|
2352
|
-
* per module. To change it globally, set the `requireReturnsDefault` option
|
2353
|
-
* to one of the following values:
|
2354
|
-
*
|
2355
|
-
* - `false`: This is the default, requiring an ES module returns its
|
2356
|
-
* namespace. This is the only option that will also add a marker
|
2357
|
-
* `__esModule: true` to the namespace to support interop patterns in
|
2358
|
-
* CommonJS modules that are transpiled ES modules.
|
2359
|
-
* - `"namespace"`: Like `false`, requiring an ES module returns its
|
2360
|
-
* namespace, but the plugin does not add the `__esModule` marker and thus
|
2361
|
-
* creates more efficient code. For external dependencies when using
|
2362
|
-
* `esmExternals: true`, no additional interop code is generated.
|
2363
|
-
* - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
2364
|
-
* Rollup: If a module has a default export and no named exports, requiring
|
2365
|
-
* that module returns the default export. In all other cases, the namespace
|
2366
|
-
* is returned. For external dependencies when using `esmExternals: true`, a
|
2367
|
-
* corresponding interop helper is added.
|
2368
|
-
* - `"preferred"`: If a module has a default export, requiring that module
|
2369
|
-
* always returns the default export, no matter whether additional named
|
2370
|
-
* exports exist. This is similar to how previous versions of this plugin
|
2371
|
-
* worked. Again for external dependencies when using `esmExternals: true`,
|
2372
|
-
* an interop helper is added.
|
2373
|
-
* - `true`: This will always try to return the default export on require
|
2374
|
-
* without checking if it actually exists. This can throw at build time if
|
2375
|
-
* there is no default export. This is how external dependencies are handled
|
2376
|
-
* when `esmExternals` is not used. The advantage over the other options is
|
2377
|
-
* that, like `false`, this does not add an interop helper for external
|
2378
|
-
* dependencies, keeping the code lean.
|
2379
|
-
*
|
2380
|
-
* To change this for individual modules, you can supply a function for
|
2381
|
-
* `requireReturnsDefault` instead. This function will then be called once for
|
2382
|
-
* each required ES module or external dependency with the corresponding id
|
2383
|
-
* and allows you to return different values for different modules.
|
2384
|
-
* @default false
|
2252
|
+
* Make a paused socket resume emitting events. This method is a noop if the ready
|
2253
|
+
* state is `CONNECTING` or `CLOSED`.
|
2385
2254
|
*/
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2255
|
+
resume(): void
|
2256
|
+
|
2257
|
+
// HTML5 WebSocket events
|
2258
|
+
addEventListener(
|
2259
|
+
method: 'message',
|
2260
|
+
cb: (event: WebSocket.MessageEvent) => void,
|
2261
|
+
options?: WebSocket.EventListenerOptions,
|
2262
|
+
): void
|
2263
|
+
addEventListener(
|
2264
|
+
method: 'close',
|
2265
|
+
cb: (event: WebSocket.CloseEvent) => void,
|
2266
|
+
options?: WebSocket.EventListenerOptions,
|
2267
|
+
): void
|
2268
|
+
addEventListener(
|
2269
|
+
method: 'error',
|
2270
|
+
cb: (event: WebSocket.ErrorEvent) => void,
|
2271
|
+
options?: WebSocket.EventListenerOptions,
|
2272
|
+
): void
|
2273
|
+
addEventListener(
|
2274
|
+
method: 'open',
|
2275
|
+
cb: (event: WebSocket.Event) => void,
|
2276
|
+
options?: WebSocket.EventListenerOptions,
|
2277
|
+
): void
|
2278
|
+
|
2279
|
+
removeEventListener(
|
2280
|
+
method: 'message',
|
2281
|
+
cb: (event: WebSocket.MessageEvent) => void,
|
2282
|
+
): void
|
2283
|
+
removeEventListener(
|
2284
|
+
method: 'close',
|
2285
|
+
cb: (event: WebSocket.CloseEvent) => void,
|
2286
|
+
): void
|
2287
|
+
removeEventListener(
|
2288
|
+
method: 'error',
|
2289
|
+
cb: (event: WebSocket.ErrorEvent) => void,
|
2290
|
+
): void
|
2291
|
+
removeEventListener(
|
2292
|
+
method: 'open',
|
2293
|
+
cb: (event: WebSocket.Event) => void,
|
2294
|
+
): void
|
2295
|
+
|
2296
|
+
// Events
|
2297
|
+
on(
|
2298
|
+
event: 'close',
|
2299
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2300
|
+
): this
|
2301
|
+
on(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2302
|
+
on(
|
2303
|
+
event: 'upgrade',
|
2304
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2305
|
+
): this
|
2306
|
+
on(
|
2307
|
+
event: 'message',
|
2308
|
+
listener: (
|
2309
|
+
this: WebSocket,
|
2310
|
+
data: WebSocket.RawData,
|
2311
|
+
isBinary: boolean,
|
2312
|
+
) => void,
|
2313
|
+
): this
|
2314
|
+
on(event: 'open', listener: (this: WebSocket) => void): this
|
2315
|
+
on(
|
2316
|
+
event: 'ping' | 'pong',
|
2317
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
2318
|
+
): this
|
2319
|
+
on(
|
2320
|
+
event: 'unexpected-response',
|
2321
|
+
listener: (
|
2322
|
+
this: WebSocket,
|
2323
|
+
request: ClientRequest,
|
2324
|
+
response: IncomingMessage,
|
2325
|
+
) => void,
|
2326
|
+
): this
|
2327
|
+
on(
|
2328
|
+
event: string | symbol,
|
2329
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
2330
|
+
): this
|
2331
|
+
|
2332
|
+
once(
|
2333
|
+
event: 'close',
|
2334
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2335
|
+
): this
|
2336
|
+
once(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2337
|
+
once(
|
2338
|
+
event: 'upgrade',
|
2339
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2340
|
+
): this
|
2341
|
+
once(
|
2342
|
+
event: 'message',
|
2343
|
+
listener: (
|
2344
|
+
this: WebSocket,
|
2345
|
+
data: WebSocket.RawData,
|
2346
|
+
isBinary: boolean,
|
2347
|
+
) => void,
|
2348
|
+
): this
|
2349
|
+
once(event: 'open', listener: (this: WebSocket) => void): this
|
2350
|
+
once(
|
2351
|
+
event: 'ping' | 'pong',
|
2352
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
2353
|
+
): this
|
2354
|
+
once(
|
2355
|
+
event: 'unexpected-response',
|
2356
|
+
listener: (
|
2357
|
+
this: WebSocket,
|
2358
|
+
request: ClientRequest,
|
2359
|
+
response: IncomingMessage,
|
2360
|
+
) => void,
|
2361
|
+
): this
|
2362
|
+
once(
|
2363
|
+
event: string | symbol,
|
2364
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
2365
|
+
): this
|
2392
2366
|
|
2367
|
+
off(
|
2368
|
+
event: 'close',
|
2369
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2370
|
+
): this
|
2371
|
+
off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2372
|
+
off(
|
2373
|
+
event: 'upgrade',
|
2374
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2375
|
+
): this
|
2376
|
+
off(
|
2377
|
+
event: 'message',
|
2378
|
+
listener: (
|
2379
|
+
this: WebSocket,
|
2380
|
+
data: WebSocket.RawData,
|
2381
|
+
isBinary: boolean,
|
2382
|
+
) => void,
|
2383
|
+
): this
|
2384
|
+
off(event: 'open', listener: (this: WebSocket) => void): this
|
2385
|
+
off(
|
2386
|
+
event: 'ping' | 'pong',
|
2387
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
2388
|
+
): this
|
2389
|
+
off(
|
2390
|
+
event: 'unexpected-response',
|
2391
|
+
listener: (
|
2392
|
+
this: WebSocket,
|
2393
|
+
request: ClientRequest,
|
2394
|
+
response: IncomingMessage,
|
2395
|
+
) => void,
|
2396
|
+
): this
|
2397
|
+
off(
|
2398
|
+
event: string | symbol,
|
2399
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
2400
|
+
): this
|
2401
|
+
|
2402
|
+
addListener(
|
2403
|
+
event: 'close',
|
2404
|
+
listener: (code: number, reason: Buffer) => void,
|
2405
|
+
): this
|
2406
|
+
addListener(event: 'error', listener: (err: Error) => void): this
|
2407
|
+
addListener(
|
2408
|
+
event: 'upgrade',
|
2409
|
+
listener: (request: IncomingMessage) => void,
|
2410
|
+
): this
|
2411
|
+
addListener(
|
2412
|
+
event: 'message',
|
2413
|
+
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
2414
|
+
): this
|
2415
|
+
addListener(event: 'open', listener: () => void): this
|
2416
|
+
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
2417
|
+
addListener(
|
2418
|
+
event: 'unexpected-response',
|
2419
|
+
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
2420
|
+
): this
|
2421
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this
|
2422
|
+
|
2423
|
+
removeListener(
|
2424
|
+
event: 'close',
|
2425
|
+
listener: (code: number, reason: Buffer) => void,
|
2426
|
+
): this
|
2427
|
+
removeListener(event: 'error', listener: (err: Error) => void): this
|
2428
|
+
removeListener(
|
2429
|
+
event: 'upgrade',
|
2430
|
+
listener: (request: IncomingMessage) => void,
|
2431
|
+
): this
|
2432
|
+
removeListener(
|
2433
|
+
event: 'message',
|
2434
|
+
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
2435
|
+
): this
|
2436
|
+
removeListener(event: 'open', listener: () => void): this
|
2437
|
+
removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
2438
|
+
removeListener(
|
2439
|
+
event: 'unexpected-response',
|
2440
|
+
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
2441
|
+
): this
|
2442
|
+
removeListener(
|
2443
|
+
event: string | symbol,
|
2444
|
+
listener: (...args: any[]) => void,
|
2445
|
+
): this
|
2446
|
+
}
|
2447
|
+
|
2448
|
+
declare namespace WebSocket {
|
2393
2449
|
/**
|
2394
|
-
*
|
2395
|
-
*/
|
2396
|
-
defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto')
|
2397
|
-
/**
|
2398
|
-
* Some modules contain dynamic `require` calls, or require modules that
|
2399
|
-
* contain circular dependencies, which are not handled well by static
|
2400
|
-
* imports. Including those modules as `dynamicRequireTargets` will simulate a
|
2401
|
-
* CommonJS (NodeJS-like) environment for them with support for dynamic
|
2402
|
-
* dependencies. It also enables `strictRequires` for those modules.
|
2403
|
-
*
|
2404
|
-
* Note: In extreme cases, this feature may result in some paths being
|
2405
|
-
* rendered as absolute in the final bundle. The plugin tries to avoid
|
2406
|
-
* exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
2407
|
-
* with paths that are far away from your project's folder, that may require
|
2408
|
-
* replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
|
2450
|
+
* Data represents the raw message payload received over the WebSocket.
|
2409
2451
|
*/
|
2410
|
-
|
2452
|
+
type RawData = Buffer | ArrayBuffer | Buffer[]
|
2453
|
+
|
2411
2454
|
/**
|
2412
|
-
*
|
2413
|
-
* that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
|
2414
|
-
* may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
|
2415
|
-
* home directory name. By default, it uses the current working directory.
|
2455
|
+
* Data represents the message payload received over the WebSocket.
|
2416
2456
|
*/
|
2417
|
-
|
2418
|
-
}
|
2457
|
+
type Data = string | Buffer | ArrayBuffer | Buffer[]
|
2419
2458
|
|
2420
|
-
interface RollupDynamicImportVarsOptions {
|
2421
2459
|
/**
|
2422
|
-
*
|
2423
|
-
* @default []
|
2460
|
+
* CertMeta represents the accepted types for certificate & key data.
|
2424
2461
|
*/
|
2425
|
-
|
2462
|
+
type CertMeta = string | string[] | Buffer | Buffer[]
|
2463
|
+
|
2426
2464
|
/**
|
2427
|
-
*
|
2428
|
-
*
|
2465
|
+
* VerifyClientCallbackSync is a synchronous callback used to inspect the
|
2466
|
+
* incoming message. The return value (boolean) of the function determines
|
2467
|
+
* whether or not to accept the handshake.
|
2429
2468
|
*/
|
2430
|
-
|
2469
|
+
type VerifyClientCallbackSync = (info: {
|
2470
|
+
origin: string
|
2471
|
+
secure: boolean
|
2472
|
+
req: IncomingMessage
|
2473
|
+
}) => boolean
|
2474
|
+
|
2431
2475
|
/**
|
2432
|
-
*
|
2433
|
-
*
|
2476
|
+
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
|
2477
|
+
* incoming message. The return value (boolean) of the function determines
|
2478
|
+
* whether or not to accept the handshake.
|
2434
2479
|
*/
|
2435
|
-
|
2436
|
-
}
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
export interface ParseOptions {
|
2446
|
-
bare_returns?: boolean
|
2447
|
-
/** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
|
2448
|
-
ecma?: ECMA
|
2449
|
-
html5_comments?: boolean
|
2450
|
-
shebang?: boolean
|
2451
|
-
}
|
2480
|
+
type VerifyClientCallbackAsync = (
|
2481
|
+
info: { origin: string; secure: boolean; req: IncomingMessage },
|
2482
|
+
callback: (
|
2483
|
+
res: boolean,
|
2484
|
+
code?: number,
|
2485
|
+
message?: string,
|
2486
|
+
headers?: OutgoingHttpHeaders,
|
2487
|
+
) => void,
|
2488
|
+
) => void
|
2452
2489
|
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
|
2467
|
-
|
2468
|
-
|
2469
|
-
|
2470
|
-
|
2471
|
-
hoist_funs?: boolean
|
2472
|
-
hoist_props?: boolean
|
2473
|
-
hoist_vars?: boolean
|
2474
|
-
ie8?: boolean
|
2475
|
-
if_return?: boolean
|
2476
|
-
inline?: boolean | InlineFunctions
|
2477
|
-
join_vars?: boolean
|
2478
|
-
keep_classnames?: boolean | RegExp
|
2479
|
-
keep_fargs?: boolean
|
2480
|
-
keep_fnames?: boolean | RegExp
|
2481
|
-
keep_infinity?: boolean
|
2482
|
-
loops?: boolean
|
2483
|
-
module?: boolean
|
2484
|
-
negate_iife?: boolean
|
2485
|
-
passes?: number
|
2486
|
-
properties?: boolean
|
2487
|
-
pure_funcs?: string[]
|
2488
|
-
pure_getters?: boolean | 'strict'
|
2489
|
-
reduce_funcs?: boolean
|
2490
|
-
reduce_vars?: boolean
|
2491
|
-
sequences?: boolean | number
|
2492
|
-
side_effects?: boolean
|
2493
|
-
switches?: boolean
|
2494
|
-
toplevel?: boolean
|
2495
|
-
top_retain?: null | string | string[] | RegExp
|
2496
|
-
typeofs?: boolean
|
2497
|
-
unsafe_arrows?: boolean
|
2498
|
-
unsafe?: boolean
|
2499
|
-
unsafe_comps?: boolean
|
2500
|
-
unsafe_Function?: boolean
|
2501
|
-
unsafe_math?: boolean
|
2502
|
-
unsafe_symbols?: boolean
|
2503
|
-
unsafe_methods?: boolean
|
2504
|
-
unsafe_proto?: boolean
|
2505
|
-
unsafe_regexp?: boolean
|
2506
|
-
unsafe_undefined?: boolean
|
2507
|
-
unused?: boolean
|
2490
|
+
interface ClientOptions extends SecureContextOptions {
|
2491
|
+
protocol?: string | undefined
|
2492
|
+
followRedirects?: boolean | undefined
|
2493
|
+
generateMask?(mask: Buffer): void
|
2494
|
+
handshakeTimeout?: number | undefined
|
2495
|
+
maxRedirects?: number | undefined
|
2496
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
2497
|
+
localAddress?: string | undefined
|
2498
|
+
protocolVersion?: number | undefined
|
2499
|
+
headers?: { [key: string]: string } | undefined
|
2500
|
+
origin?: string | undefined
|
2501
|
+
agent?: Agent | undefined
|
2502
|
+
host?: string | undefined
|
2503
|
+
family?: number | undefined
|
2504
|
+
checkServerIdentity?(servername: string, cert: CertMeta): boolean
|
2505
|
+
rejectUnauthorized?: boolean | undefined
|
2506
|
+
maxPayload?: number | undefined
|
2507
|
+
skipUTF8Validation?: boolean | undefined
|
2508
2508
|
}
|
2509
2509
|
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2510
|
+
interface PerMessageDeflateOptions {
|
2511
|
+
serverNoContextTakeover?: boolean | undefined
|
2512
|
+
clientNoContextTakeover?: boolean | undefined
|
2513
|
+
serverMaxWindowBits?: number | undefined
|
2514
|
+
clientMaxWindowBits?: number | undefined
|
2515
|
+
zlibDeflateOptions?:
|
2516
|
+
| {
|
2517
|
+
flush?: number | undefined
|
2518
|
+
finishFlush?: number | undefined
|
2519
|
+
chunkSize?: number | undefined
|
2520
|
+
windowBits?: number | undefined
|
2521
|
+
level?: number | undefined
|
2522
|
+
memLevel?: number | undefined
|
2523
|
+
strategy?: number | undefined
|
2524
|
+
dictionary?: Buffer | Buffer[] | DataView | undefined
|
2525
|
+
info?: boolean | undefined
|
2526
|
+
}
|
2527
|
+
| undefined
|
2528
|
+
zlibInflateOptions?: ZlibOptions | undefined
|
2529
|
+
threshold?: number | undefined
|
2530
|
+
concurrencyLimit?: number | undefined
|
2515
2531
|
}
|
2516
2532
|
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
keep_fnames?: boolean | RegExp
|
2521
|
-
module?: boolean
|
2522
|
-
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
2523
|
-
properties?: boolean | ManglePropertiesOptions
|
2524
|
-
reserved?: string[]
|
2525
|
-
safari10?: boolean
|
2526
|
-
toplevel?: boolean
|
2533
|
+
interface Event {
|
2534
|
+
type: string
|
2535
|
+
target: WebSocket
|
2527
2536
|
}
|
2528
2537
|
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
* Obtains the nth most favored (usually shortest) identifier to rename a variable to.
|
2535
|
-
* The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
|
2536
|
-
* This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
|
2537
|
-
* @param n - The ordinal of the identifier.
|
2538
|
-
*/
|
2539
|
-
get(n: number): string
|
2538
|
+
interface ErrorEvent {
|
2539
|
+
error: any
|
2540
|
+
message: string
|
2541
|
+
type: string
|
2542
|
+
target: WebSocket
|
2540
2543
|
}
|
2541
2544
|
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
* Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
|
2549
|
-
* @param chars - The characters to modify the weighting of.
|
2550
|
-
* @param delta - The numeric weight to add to the characters.
|
2551
|
-
*/
|
2552
|
-
consider(chars: string, delta: number): number
|
2553
|
-
/**
|
2554
|
-
* Resets character weights.
|
2555
|
-
*/
|
2556
|
-
reset(): void
|
2557
|
-
/**
|
2558
|
-
* Sorts identifiers by character frequency, in preparation for calls to get(n).
|
2559
|
-
*/
|
2560
|
-
sort(): void
|
2545
|
+
interface CloseEvent {
|
2546
|
+
wasClean: boolean
|
2547
|
+
code: number
|
2548
|
+
reason: string
|
2549
|
+
type: string
|
2550
|
+
target: WebSocket
|
2561
2551
|
}
|
2562
2552
|
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
2568
|
-
regex?: RegExp | string
|
2569
|
-
reserved?: string[]
|
2553
|
+
interface MessageEvent {
|
2554
|
+
data: Data
|
2555
|
+
type: string
|
2556
|
+
target: WebSocket
|
2570
2557
|
}
|
2571
2558
|
|
2572
|
-
|
2573
|
-
|
2574
|
-
/** @deprecated Not implemented anymore */
|
2575
|
-
beautify?: boolean
|
2576
|
-
braces?: boolean
|
2577
|
-
comments?:
|
2578
|
-
| boolean
|
2579
|
-
| 'all'
|
2580
|
-
| 'some'
|
2581
|
-
| RegExp
|
2582
|
-
| ((
|
2583
|
-
node: any,
|
2584
|
-
comment: {
|
2585
|
-
value: string
|
2586
|
-
type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
|
2587
|
-
pos: number
|
2588
|
-
line: number
|
2589
|
-
col: number
|
2590
|
-
},
|
2591
|
-
) => boolean)
|
2592
|
-
ecma?: ECMA
|
2593
|
-
ie8?: boolean
|
2594
|
-
keep_numbers?: boolean
|
2595
|
-
indent_level?: number
|
2596
|
-
indent_start?: number
|
2597
|
-
inline_script?: boolean
|
2598
|
-
keep_quoted_props?: boolean
|
2599
|
-
max_line_len?: number | false
|
2600
|
-
preamble?: string
|
2601
|
-
preserve_annotations?: boolean
|
2602
|
-
quote_keys?: boolean
|
2603
|
-
quote_style?: OutputQuoteStyle
|
2604
|
-
safari10?: boolean
|
2605
|
-
semicolons?: boolean
|
2606
|
-
shebang?: boolean
|
2607
|
-
shorthand?: boolean
|
2608
|
-
source_map?: SourceMapOptions
|
2609
|
-
webkit?: boolean
|
2610
|
-
width?: number
|
2611
|
-
wrap_iife?: boolean
|
2612
|
-
wrap_func_args?: boolean
|
2559
|
+
interface EventListenerOptions {
|
2560
|
+
once?: boolean | undefined
|
2613
2561
|
}
|
2614
2562
|
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2563
|
+
interface ServerOptions {
|
2564
|
+
host?: string | undefined
|
2565
|
+
port?: number | undefined
|
2566
|
+
backlog?: number | undefined
|
2567
|
+
server?: Server | HttpsServer | undefined
|
2568
|
+
verifyClient?:
|
2569
|
+
| VerifyClientCallbackAsync
|
2570
|
+
| VerifyClientCallbackSync
|
2571
|
+
| undefined
|
2572
|
+
handleProtocols?: (
|
2573
|
+
protocols: Set<string>,
|
2574
|
+
request: IncomingMessage,
|
2575
|
+
) => string | false
|
2576
|
+
path?: string | undefined
|
2577
|
+
noServer?: boolean | undefined
|
2578
|
+
clientTracking?: boolean | undefined
|
2579
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
2580
|
+
maxPayload?: number | undefined
|
2581
|
+
skipUTF8Validation?: boolean | undefined
|
2582
|
+
WebSocket?: typeof WebSocket.WebSocket | undefined
|
2620
2583
|
}
|
2621
2584
|
|
2622
|
-
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
ie8?: boolean
|
2627
|
-
keep_classnames?: boolean | RegExp
|
2628
|
-
keep_fnames?: boolean | RegExp
|
2629
|
-
mangle?: boolean | MangleOptions
|
2630
|
-
module?: boolean
|
2631
|
-
nameCache?: object
|
2632
|
-
format?: FormatOptions
|
2633
|
-
/** @deprecated deprecated */
|
2634
|
-
output?: FormatOptions
|
2635
|
-
parse?: ParseOptions
|
2636
|
-
safari10?: boolean
|
2637
|
-
sourceMap?: boolean | SourceMapOptions
|
2638
|
-
toplevel?: boolean
|
2585
|
+
interface AddressInfo {
|
2586
|
+
address: string
|
2587
|
+
family: string
|
2588
|
+
port: number
|
2639
2589
|
}
|
2640
2590
|
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2591
|
+
// WebSocket Server
|
2592
|
+
class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
2593
|
+
options: ServerOptions
|
2594
|
+
path: string
|
2595
|
+
clients: Set<T>
|
2596
|
+
|
2597
|
+
constructor(options?: ServerOptions, callback?: () => void)
|
2598
|
+
|
2599
|
+
address(): AddressInfo | string
|
2600
|
+
close(cb?: (err?: Error) => void): void
|
2601
|
+
handleUpgrade(
|
2602
|
+
request: IncomingMessage,
|
2603
|
+
socket: Duplex,
|
2604
|
+
upgradeHead: Buffer,
|
2605
|
+
callback: (client: T, request: IncomingMessage) => void,
|
2606
|
+
): void
|
2607
|
+
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
2608
|
+
|
2609
|
+
// Events
|
2610
|
+
on(
|
2611
|
+
event: 'connection',
|
2612
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
2613
|
+
): this
|
2614
|
+
on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
2615
|
+
on(
|
2616
|
+
event: 'headers',
|
2617
|
+
cb: (
|
2618
|
+
this: Server<T>,
|
2619
|
+
headers: string[],
|
2620
|
+
request: IncomingMessage,
|
2621
|
+
) => void,
|
2622
|
+
): this
|
2623
|
+
on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
2624
|
+
on(
|
2625
|
+
event: string | symbol,
|
2626
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
2627
|
+
): this
|
2628
|
+
|
2629
|
+
once(
|
2630
|
+
event: 'connection',
|
2631
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
2632
|
+
): this
|
2633
|
+
once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
2634
|
+
once(
|
2635
|
+
event: 'headers',
|
2636
|
+
cb: (
|
2637
|
+
this: Server<T>,
|
2638
|
+
headers: string[],
|
2639
|
+
request: IncomingMessage,
|
2640
|
+
) => void,
|
2641
|
+
): this
|
2642
|
+
once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
2643
|
+
once(
|
2644
|
+
event: string | symbol,
|
2645
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
2646
|
+
): this
|
2647
|
+
|
2648
|
+
off(
|
2649
|
+
event: 'connection',
|
2650
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
2651
|
+
): this
|
2652
|
+
off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
2653
|
+
off(
|
2654
|
+
event: 'headers',
|
2655
|
+
cb: (
|
2656
|
+
this: Server<T>,
|
2657
|
+
headers: string[],
|
2658
|
+
request: IncomingMessage,
|
2659
|
+
) => void,
|
2660
|
+
): this
|
2661
|
+
off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
2662
|
+
off(
|
2663
|
+
event: string | symbol,
|
2664
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
2665
|
+
): this
|
2666
|
+
|
2667
|
+
addListener(
|
2668
|
+
event: 'connection',
|
2669
|
+
cb: (client: T, request: IncomingMessage) => void,
|
2670
|
+
): this
|
2671
|
+
addListener(event: 'error', cb: (err: Error) => void): this
|
2672
|
+
addListener(
|
2673
|
+
event: 'headers',
|
2674
|
+
cb: (headers: string[], request: IncomingMessage) => void,
|
2675
|
+
): this
|
2676
|
+
addListener(event: 'close' | 'listening', cb: () => void): this
|
2677
|
+
addListener(
|
2678
|
+
event: string | symbol,
|
2679
|
+
listener: (...args: any[]) => void,
|
2680
|
+
): this
|
2681
|
+
|
2682
|
+
removeListener(event: 'connection', cb: (client: T) => void): this
|
2683
|
+
removeListener(event: 'error', cb: (err: Error) => void): this
|
2684
|
+
removeListener(
|
2685
|
+
event: 'headers',
|
2686
|
+
cb: (headers: string[], request: IncomingMessage) => void,
|
2687
|
+
): this
|
2688
|
+
removeListener(event: 'close' | 'listening', cb: () => void): this
|
2689
|
+
removeListener(
|
2690
|
+
event: string | symbol,
|
2691
|
+
listener: (...args: any[]) => void,
|
2692
|
+
): this
|
2645
2693
|
}
|
2646
2694
|
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2695
|
+
const WebSocketServer: typeof Server
|
2696
|
+
interface WebSocketServer extends Server {}
|
2697
|
+
const WebSocket: typeof WebSocketAlias
|
2698
|
+
interface WebSocket extends WebSocketAlias {}
|
2699
|
+
|
2700
|
+
// WebSocket stream
|
2701
|
+
function createWebSocketStream(
|
2702
|
+
websocket: WebSocket,
|
2703
|
+
options?: DuplexOptions,
|
2704
|
+
): Duplex
|
2655
2705
|
}
|
2656
2706
|
|
2657
|
-
|
2707
|
+
type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
|
2708
|
+
interface WebSocketServer extends HotChannel {
|
2658
2709
|
/**
|
2659
|
-
*
|
2660
|
-
* when minifying files with terser.
|
2661
|
-
*
|
2662
|
-
* @default number of CPUs minus 1
|
2710
|
+
* Listen on port and host
|
2663
2711
|
*/
|
2664
|
-
|
2712
|
+
listen(): void;
|
2713
|
+
/**
|
2714
|
+
* Get all connected clients.
|
2715
|
+
*/
|
2716
|
+
clients: Set<WebSocketClient>;
|
2717
|
+
/**
|
2718
|
+
* Disconnect all clients and terminate the server.
|
2719
|
+
*/
|
2720
|
+
close(): Promise<void>;
|
2721
|
+
/**
|
2722
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
2723
|
+
*/
|
2724
|
+
on: WebSocket.Server['on'] & {
|
2725
|
+
<T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
|
2726
|
+
};
|
2727
|
+
/**
|
2728
|
+
* Unregister event listener.
|
2729
|
+
*/
|
2730
|
+
off: WebSocket.Server['off'] & {
|
2731
|
+
(event: string, listener: Function): void;
|
2732
|
+
};
|
2733
|
+
}
|
2734
|
+
interface WebSocketClient extends HotChannelClient {
|
2735
|
+
/**
|
2736
|
+
* The raw WebSocket instance
|
2737
|
+
* @advanced
|
2738
|
+
*/
|
2739
|
+
socket: WebSocket;
|
2665
2740
|
}
|
2666
2741
|
|
2667
|
-
interface
|
2742
|
+
interface ServerOptions extends CommonServerOptions {
|
2668
2743
|
/**
|
2669
|
-
*
|
2670
|
-
* and the lowest supported target is es2015/es6. Note this only handles
|
2671
|
-
* syntax transformation and does not cover polyfills (except for dynamic
|
2672
|
-
* import)
|
2673
|
-
*
|
2674
|
-
* Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
|
2675
|
-
* transpile targeting browsers that natively support dynamic es module imports.
|
2676
|
-
* https://caniuse.com/es6-module-dynamic-import
|
2677
|
-
*
|
2678
|
-
* Another special value is 'esnext' - which only performs minimal transpiling
|
2679
|
-
* (for minification compat) and assumes native dynamic imports support.
|
2680
|
-
*
|
2681
|
-
* For custom targets, see https://esbuild.github.io/api/#target and
|
2682
|
-
* https://esbuild.github.io/content-types/#javascript for more details.
|
2683
|
-
* @default 'modules'
|
2744
|
+
* Configure HMR-specific options (port, host, path & protocol)
|
2684
2745
|
*/
|
2685
|
-
|
2746
|
+
hmr?: HmrOptions | boolean;
|
2686
2747
|
/**
|
2687
|
-
*
|
2688
|
-
*
|
2689
|
-
* @default true
|
2690
|
-
* @deprecated use `modulePreload.polyfill` instead
|
2748
|
+
* Do not start the websocket connection.
|
2749
|
+
* @experimental
|
2691
2750
|
*/
|
2692
|
-
|
2751
|
+
ws?: false;
|
2693
2752
|
/**
|
2694
|
-
*
|
2695
|
-
*
|
2753
|
+
* Warm-up files to transform and cache the results in advance. This improves the
|
2754
|
+
* initial page load during server starts and prevents transform waterfalls.
|
2755
|
+
*/
|
2756
|
+
warmup?: {
|
2757
|
+
/**
|
2758
|
+
* The files to be transformed and used on the client-side. Supports glob patterns.
|
2759
|
+
*/
|
2760
|
+
clientFiles?: string[];
|
2761
|
+
/**
|
2762
|
+
* The files to be transformed and used in SSR. Supports glob patterns.
|
2763
|
+
*/
|
2764
|
+
ssrFiles?: string[];
|
2765
|
+
};
|
2766
|
+
/**
|
2767
|
+
* chokidar watch options or null to disable FS watching
|
2768
|
+
* https://github.com/paulmillr/chokidar#api
|
2769
|
+
*/
|
2770
|
+
watch?: WatchOptions | null;
|
2771
|
+
/**
|
2772
|
+
* Create Vite dev server to be used as a middleware in an existing server
|
2773
|
+
* @default false
|
2774
|
+
*/
|
2775
|
+
middlewareMode?: boolean | {
|
2776
|
+
/**
|
2777
|
+
* Parent server instance to attach to
|
2778
|
+
*
|
2779
|
+
* This is needed to proxy WebSocket connections to the parent server.
|
2780
|
+
*/
|
2781
|
+
server: HttpServer;
|
2782
|
+
};
|
2783
|
+
/**
|
2784
|
+
* Options for files served via '/\@fs/'.
|
2785
|
+
*/
|
2786
|
+
fs?: FileSystemServeOptions;
|
2787
|
+
/**
|
2788
|
+
* Origin for the generated asset URLs.
|
2789
|
+
*
|
2790
|
+
* @example `http://127.0.0.1:8080`
|
2791
|
+
*/
|
2792
|
+
origin?: string;
|
2793
|
+
/**
|
2794
|
+
* Pre-transform known direct imports
|
2696
2795
|
* @default true
|
2697
2796
|
*/
|
2698
|
-
|
2797
|
+
preTransformRequests?: boolean;
|
2699
2798
|
/**
|
2700
|
-
*
|
2701
|
-
*
|
2702
|
-
*
|
2799
|
+
* Whether or not to ignore-list source files in the dev server sourcemap, used to populate
|
2800
|
+
* the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
|
2801
|
+
*
|
2802
|
+
* By default, it excludes all paths containing `node_modules`. You can pass `false` to
|
2803
|
+
* disable this behavior, or, for full control, a function that takes the source path and
|
2804
|
+
* sourcemap path and returns whether to ignore the source path.
|
2703
2805
|
*/
|
2704
|
-
|
2806
|
+
sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
|
2705
2807
|
/**
|
2706
|
-
*
|
2707
|
-
*
|
2708
|
-
* @default
|
2808
|
+
* Backward compatibility. The buildStart and buildEnd hooks were called only once for all
|
2809
|
+
* environments. This option enables per-environment buildStart and buildEnd hooks.
|
2810
|
+
* @default false
|
2811
|
+
* @experimental
|
2709
2812
|
*/
|
2710
|
-
|
2813
|
+
perEnvironmentBuildStartEnd?: boolean;
|
2711
2814
|
/**
|
2712
|
-
*
|
2713
|
-
*
|
2714
|
-
* @default 4096
|
2815
|
+
* Run HMR tasks, by default the HMR propagation is done in parallel for all environments
|
2816
|
+
* @experimental
|
2715
2817
|
*/
|
2716
|
-
|
2818
|
+
hotUpdateEnvironments?: (server: ViteDevServer, hmr: (environment: DevEnvironment) => Promise<void>) => Promise<void>;
|
2819
|
+
}
|
2820
|
+
interface ResolvedServerOptions extends Omit<ServerOptions, 'fs' | 'middlewareMode' | 'sourcemapIgnoreList'> {
|
2821
|
+
fs: Required<FileSystemServeOptions>;
|
2822
|
+
middlewareMode: NonNullable<ServerOptions['middlewareMode']>;
|
2823
|
+
sourcemapIgnoreList: Exclude<ServerOptions['sourcemapIgnoreList'], false | undefined>;
|
2824
|
+
}
|
2825
|
+
interface FileSystemServeOptions {
|
2717
2826
|
/**
|
2718
|
-
*
|
2719
|
-
*
|
2720
|
-
*
|
2827
|
+
* Strictly restrict file accessing outside of allowing paths.
|
2828
|
+
*
|
2829
|
+
* Set to `false` to disable the warning
|
2830
|
+
*
|
2721
2831
|
* @default true
|
2722
2832
|
*/
|
2723
|
-
|
2833
|
+
strict?: boolean;
|
2724
2834
|
/**
|
2725
|
-
*
|
2726
|
-
*
|
2727
|
-
*
|
2728
|
-
*
|
2729
|
-
* but has poor CSS support, e.g. Android WeChat WebView, which
|
2730
|
-
* doesn't support the #RGBA syntax.
|
2731
|
-
* @default target
|
2835
|
+
* Restrict accessing files outside the allowed directories.
|
2836
|
+
*
|
2837
|
+
* Accepts absolute path or a path relative to project root.
|
2838
|
+
* Will try to search up for workspace root by default.
|
2732
2839
|
*/
|
2733
|
-
|
2840
|
+
allow?: string[];
|
2734
2841
|
/**
|
2735
|
-
*
|
2736
|
-
*
|
2737
|
-
*
|
2842
|
+
* Restrict accessing files that matches the patterns.
|
2843
|
+
*
|
2844
|
+
* This will have higher priority than `allow`.
|
2845
|
+
* picomatch patterns are supported.
|
2846
|
+
*
|
2847
|
+
* @default ['.env', '.env.*', '*.crt', '*.pem']
|
2738
2848
|
*/
|
2739
|
-
|
2849
|
+
deny?: string[];
|
2740
2850
|
/**
|
2741
|
-
*
|
2742
|
-
*
|
2743
|
-
*
|
2744
|
-
*
|
2745
|
-
* @default false
|
2851
|
+
* Enable caching of fs calls. It is enabled by default if no custom watch ignored patterns are provided.
|
2852
|
+
*
|
2853
|
+
* @experimental
|
2854
|
+
* @default undefined
|
2746
2855
|
*/
|
2747
|
-
|
2856
|
+
cachedChecks?: boolean;
|
2857
|
+
}
|
2858
|
+
type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
2859
|
+
type HttpServer = http.Server | Http2SecureServer;
|
2860
|
+
interface ViteDevServer {
|
2748
2861
|
/**
|
2749
|
-
*
|
2750
|
-
* Available options are 'terser' or 'esbuild'.
|
2751
|
-
* @default 'esbuild'
|
2862
|
+
* The resolved vite config object
|
2752
2863
|
*/
|
2753
|
-
|
2864
|
+
config: ResolvedConfig;
|
2754
2865
|
/**
|
2755
|
-
*
|
2756
|
-
*
|
2866
|
+
* A connect app instance.
|
2867
|
+
* - Can be used to attach custom middlewares to the dev server.
|
2868
|
+
* - Can also be used as the handler function of a custom http server
|
2869
|
+
* or as a middleware in any connect-style Node.js frameworks
|
2757
2870
|
*
|
2758
|
-
*
|
2759
|
-
* max number of workers to spawn. Defaults to the number of CPUs minus 1.
|
2871
|
+
* https://github.com/senchalabs/connect#use-middleware
|
2760
2872
|
*/
|
2761
|
-
|
2873
|
+
middlewares: Connect.Server;
|
2762
2874
|
/**
|
2763
|
-
*
|
2764
|
-
*
|
2875
|
+
* native Node http server instance
|
2876
|
+
* will be null in middleware mode
|
2765
2877
|
*/
|
2766
|
-
|
2878
|
+
httpServer: HttpServer | null;
|
2767
2879
|
/**
|
2768
|
-
*
|
2880
|
+
* chokidar watcher instance
|
2881
|
+
* https://github.com/paulmillr/chokidar#api
|
2769
2882
|
*/
|
2770
|
-
|
2883
|
+
watcher: FSWatcher;
|
2771
2884
|
/**
|
2772
|
-
*
|
2885
|
+
* web socket server with `send(payload)` method
|
2773
2886
|
*/
|
2774
|
-
|
2887
|
+
ws: WebSocketServer;
|
2775
2888
|
/**
|
2776
|
-
*
|
2777
|
-
*
|
2889
|
+
* HMR broadcaster that can be used to send custom HMR messages to the client
|
2890
|
+
*
|
2891
|
+
* Always sends a message to at least a WebSocket client. Any third party can
|
2892
|
+
* add a channel to the broadcaster to process messages
|
2778
2893
|
*/
|
2779
|
-
|
2894
|
+
hot: HotBroadcaster;
|
2780
2895
|
/**
|
2781
|
-
*
|
2782
|
-
* @default true when outDir is a sub directory of project root
|
2896
|
+
* Rollup plugin container that can run plugin hooks on a given file
|
2783
2897
|
*/
|
2784
|
-
|
2898
|
+
pluginContainer: PluginContainer;
|
2785
2899
|
/**
|
2786
|
-
*
|
2787
|
-
* @default true
|
2900
|
+
* Module execution environments attached to the Vite server.
|
2788
2901
|
*/
|
2789
|
-
|
2902
|
+
environments: Record<'client' | 'ssr' | (string & {}), DevEnvironment>;
|
2903
|
+
/**
|
2904
|
+
* Module graph that tracks the import relationships, url to file mapping
|
2905
|
+
* and hmr state.
|
2906
|
+
*/
|
2907
|
+
moduleGraph: ModuleGraph;
|
2790
2908
|
/**
|
2791
|
-
*
|
2792
|
-
*
|
2793
|
-
* instead of using the one generated by Vite.
|
2794
|
-
*
|
2795
|
-
* Example:
|
2796
|
-
*
|
2797
|
-
* ```json
|
2798
|
-
* {
|
2799
|
-
* "main.js": {
|
2800
|
-
* "file": "main.68fe3fad.js",
|
2801
|
-
* "css": "main.e6b63442.css",
|
2802
|
-
* "imports": [...],
|
2803
|
-
* "dynamicImports": [...]
|
2804
|
-
* }
|
2805
|
-
* }
|
2806
|
-
* ```
|
2807
|
-
* @default false
|
2909
|
+
* The resolved urls Vite prints on the CLI. null in middleware mode or
|
2910
|
+
* before `server.listen` is called.
|
2808
2911
|
*/
|
2809
|
-
|
2912
|
+
resolvedUrls: ResolvedServerUrls | null;
|
2810
2913
|
/**
|
2811
|
-
*
|
2812
|
-
*
|
2813
|
-
* @default false
|
2914
|
+
* Programmatically resolve, load and transform a URL and get the result
|
2915
|
+
* without going through the http request pipeline.
|
2814
2916
|
*/
|
2815
|
-
|
2917
|
+
transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
|
2816
2918
|
/**
|
2817
|
-
*
|
2818
|
-
*
|
2819
|
-
*
|
2919
|
+
* Same as `transformRequest` but only warm up the URLs so the next request
|
2920
|
+
* will already be cached. The function will never throw as it handles and
|
2921
|
+
* reports errors internally.
|
2820
2922
|
*/
|
2821
|
-
|
2923
|
+
warmupRequest(url: string, options?: TransformOptions): Promise<void>;
|
2822
2924
|
/**
|
2823
|
-
*
|
2824
|
-
* @default false
|
2825
|
-
* @deprecated use emitAssets
|
2925
|
+
* Apply vite built-in HTML transforms and any plugin HTML transforms.
|
2826
2926
|
*/
|
2827
|
-
|
2927
|
+
transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
|
2828
2928
|
/**
|
2829
|
-
*
|
2830
|
-
* By default, it is true for the client and false for other environments.
|
2831
|
-
* TODO: Should this be true for all environments by default? Or should this be
|
2832
|
-
* controlled by the builder so so we can avoid emitting duplicated assets.
|
2929
|
+
* Transform module code into SSR format.
|
2833
2930
|
*/
|
2834
|
-
|
2931
|
+
ssrTransform(code: string, inMap: SourceMap | {
|
2932
|
+
mappings: '';
|
2933
|
+
} | null, url: string, originalCode?: string): Promise<TransformResult | null>;
|
2835
2934
|
/**
|
2836
|
-
*
|
2837
|
-
* Can slightly improve build speed.
|
2838
|
-
* @default true
|
2935
|
+
* Load a given URL as an instantiated module for SSR.
|
2839
2936
|
*/
|
2840
|
-
|
2937
|
+
ssrLoadModule(url: string, opts?: {
|
2938
|
+
fixStacktrace?: boolean;
|
2939
|
+
}): Promise<Record<string, any>>;
|
2841
2940
|
/**
|
2842
|
-
*
|
2843
|
-
* @default 500
|
2941
|
+
* Returns a fixed version of the given stack
|
2844
2942
|
*/
|
2845
|
-
|
2943
|
+
ssrRewriteStacktrace(stack: string): string;
|
2846
2944
|
/**
|
2847
|
-
*
|
2848
|
-
* https://rollupjs.org/configuration-options/#watch
|
2849
|
-
* @default null
|
2945
|
+
* Mutates the given SSR error by rewriting the stacktrace
|
2850
2946
|
*/
|
2851
|
-
|
2947
|
+
ssrFixStacktrace(e: Error): void;
|
2852
2948
|
/**
|
2853
|
-
*
|
2949
|
+
* Triggers HMR for a module in the module graph. You can use the `server.moduleGraph`
|
2950
|
+
* API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
|
2854
2951
|
*/
|
2855
|
-
|
2856
|
-
}
|
2857
|
-
interface BuildOptions extends BuildEnvironmentOptions {
|
2952
|
+
reloadModule(module: ModuleNode): Promise<void>;
|
2858
2953
|
/**
|
2859
|
-
*
|
2860
|
-
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
2861
|
-
* configurations that are suitable for distributing libraries.
|
2862
|
-
* @default false
|
2954
|
+
* Start the server.
|
2863
2955
|
*/
|
2864
|
-
|
2865
|
-
}
|
2866
|
-
interface LibraryOptions {
|
2956
|
+
listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
|
2867
2957
|
/**
|
2868
|
-
*
|
2958
|
+
* Stop the server.
|
2869
2959
|
*/
|
2870
|
-
|
2960
|
+
close(): Promise<void>;
|
2871
2961
|
/**
|
2872
|
-
*
|
2873
|
-
* `umd` or `iife`
|
2962
|
+
* Print server urls
|
2874
2963
|
*/
|
2875
|
-
|
2964
|
+
printUrls(): void;
|
2876
2965
|
/**
|
2877
|
-
*
|
2878
|
-
* @default ['es', 'umd']
|
2966
|
+
* Bind CLI shortcuts
|
2879
2967
|
*/
|
2880
|
-
|
2968
|
+
bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void;
|
2881
2969
|
/**
|
2882
|
-
*
|
2883
|
-
*
|
2884
|
-
*
|
2970
|
+
* Restart the server.
|
2971
|
+
*
|
2972
|
+
* @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
|
2885
2973
|
*/
|
2886
|
-
|
2887
|
-
}
|
2888
|
-
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
|
2889
|
-
interface ModulePreloadOptions {
|
2974
|
+
restart(forceOptimize?: boolean): Promise<void>;
|
2890
2975
|
/**
|
2891
|
-
*
|
2892
|
-
* Note: does not apply to library mode.
|
2893
|
-
* @default true
|
2976
|
+
* Open browser
|
2894
2977
|
*/
|
2895
|
-
|
2978
|
+
openBrowser(): void;
|
2896
2979
|
/**
|
2897
|
-
*
|
2898
|
-
*
|
2980
|
+
* Calling `await server.waitForRequestsIdle(id)` will wait until all static imports
|
2981
|
+
* are processed. If called from a load or transform plugin hook, the id needs to be
|
2982
|
+
* passed as a parameter to avoid deadlocks. Calling this function after the first
|
2983
|
+
* static imports section of the module graph has been processed will resolve immediately.
|
2899
2984
|
*/
|
2900
|
-
|
2901
|
-
}
|
2902
|
-
interface ResolvedModulePreloadOptions {
|
2903
|
-
polyfill: boolean;
|
2904
|
-
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2905
|
-
}
|
2906
|
-
type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
|
2907
|
-
hostId: string;
|
2908
|
-
hostType: 'html' | 'js';
|
2909
|
-
}) => string[];
|
2910
|
-
interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> {
|
2911
|
-
modulePreload: false | ResolvedModulePreloadOptions;
|
2912
|
-
}
|
2913
|
-
interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
|
2914
|
-
modulePreload: false | ResolvedModulePreloadOptions;
|
2915
|
-
}
|
2916
|
-
/**
|
2917
|
-
* Bundles the app for production.
|
2918
|
-
* Returns a Promise containing the build result.
|
2919
|
-
*/
|
2920
|
-
declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2921
|
-
type RenderBuiltAssetUrl = (filename: string, type: {
|
2922
|
-
type: 'asset' | 'public';
|
2923
|
-
hostId: string;
|
2924
|
-
hostType: 'js' | 'css' | 'html';
|
2925
|
-
ssr: boolean;
|
2926
|
-
}) => string | {
|
2927
|
-
relative?: boolean;
|
2928
|
-
runtime?: string;
|
2929
|
-
} | undefined;
|
2930
|
-
declare class BuildEnvironment extends Environment {
|
2931
|
-
mode: "build";
|
2932
|
-
constructor(name: string, config: ResolvedConfig, setup?: {
|
2933
|
-
options?: EnvironmentOptions;
|
2934
|
-
});
|
2935
|
-
init(): Promise<void>;
|
2936
|
-
}
|
2937
|
-
interface ViteBuilder {
|
2938
|
-
environments: Record<string, BuildEnvironment>;
|
2939
|
-
config: ResolvedConfig;
|
2940
|
-
buildApp(): Promise<void>;
|
2941
|
-
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2985
|
+
waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
|
2942
2986
|
}
|
2943
|
-
interface
|
2944
|
-
|
2945
|
-
|
2946
|
-
entireApp?: boolean;
|
2947
|
-
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2987
|
+
interface ResolvedServerUrls {
|
2988
|
+
local: string[];
|
2989
|
+
network: string[];
|
2948
2990
|
}
|
2949
|
-
|
2950
|
-
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2991
|
+
declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
|
2951
2992
|
|
2952
2993
|
interface ESBuildOptions extends esbuild_TransformOptions {
|
2953
2994
|
include?: string | RegExp | string[] | RegExp[];
|
@@ -2975,7 +3016,7 @@ interface FsUtils {
|
|
2975
3016
|
initWatcher?: (watcher: FSWatcher) => void;
|
2976
3017
|
}
|
2977
3018
|
|
2978
|
-
interface
|
3019
|
+
interface EnvironmentResolveOptions {
|
2979
3020
|
/**
|
2980
3021
|
* @default ['browser', 'module', 'jsnext:main', 'jsnext']
|
2981
3022
|
*/
|
@@ -2987,10 +3028,6 @@ interface ResolveOptions {
|
|
2987
3028
|
*/
|
2988
3029
|
extensions?: string[];
|
2989
3030
|
dedupe?: string[];
|
2990
|
-
/**
|
2991
|
-
* @default false
|
2992
|
-
*/
|
2993
|
-
preserveSymlinks?: boolean;
|
2994
3031
|
/**
|
2995
3032
|
* external/noExternal logic, this only works for certain environments
|
2996
3033
|
* Previously this was ssr.external/ssr.noExternal
|
@@ -2999,6 +3036,12 @@ interface ResolveOptions {
|
|
2999
3036
|
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
3000
3037
|
external?: string[] | true;
|
3001
3038
|
}
|
3039
|
+
interface ResolveOptions extends EnvironmentResolveOptions {
|
3040
|
+
/**
|
3041
|
+
* @default false
|
3042
|
+
*/
|
3043
|
+
preserveSymlinks?: boolean;
|
3044
|
+
}
|
3002
3045
|
interface ResolvePluginOptions {
|
3003
3046
|
root: string;
|
3004
3047
|
isBuild: boolean;
|
@@ -3015,14 +3058,13 @@ interface ResolvePluginOptions {
|
|
3015
3058
|
tryPrefix?: string;
|
3016
3059
|
preferRelative?: boolean;
|
3017
3060
|
isRequire?: boolean;
|
3018
|
-
nodeCompatible?: boolean;
|
3019
3061
|
webCompatible?: boolean;
|
3020
3062
|
isFromTsImporter?: boolean;
|
3021
3063
|
tryEsmOnly?: boolean;
|
3022
3064
|
scan?: boolean;
|
3023
3065
|
ssrOptimizeCheck?: boolean;
|
3024
3066
|
/**
|
3025
|
-
* @deprecated environment.
|
3067
|
+
* @deprecated environment.config are used instead
|
3026
3068
|
*/
|
3027
3069
|
ssrConfig?: SSROptions;
|
3028
3070
|
}
|
@@ -3081,6 +3123,7 @@ type LightningCSSOptions = {
|
|
3081
3123
|
pseudoClasses?: PseudoClasses
|
3082
3124
|
unusedSymbols?: string[]
|
3083
3125
|
cssModules?: CSSModulesConfig
|
3126
|
+
errorRecovery?: boolean
|
3084
3127
|
}
|
3085
3128
|
|
3086
3129
|
interface CSSOptions {
|
@@ -3119,7 +3162,6 @@ interface CSSOptions {
|
|
3119
3162
|
* Enables css sourcemaps during dev
|
3120
3163
|
* @default false
|
3121
3164
|
* @experimental
|
3122
|
-
* @deprecated use dev.sourcemap instead
|
3123
3165
|
*/
|
3124
3166
|
devSourcemap?: boolean;
|
3125
3167
|
/**
|
@@ -3153,7 +3195,7 @@ interface PreprocessCSSResult {
|
|
3153
3195
|
/**
|
3154
3196
|
* @experimental
|
3155
3197
|
*/
|
3156
|
-
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig
|
3198
|
+
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
|
3157
3199
|
declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
|
3158
3200
|
|
3159
3201
|
interface HtmlTagDescriptor {
|
@@ -3224,23 +3266,29 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3224
3266
|
* If a plugin should be applied only for server or build, a function format
|
3225
3267
|
* config file can be used to conditional determine the plugins to use.
|
3226
3268
|
*
|
3227
|
-
* The current
|
3228
|
-
*
|
3229
|
-
*
|
3230
|
-
*
|
3231
|
-
* buildStart, resolveId, transform, load, and buildEnd, hooks. It can be a dev
|
3232
|
-
* or a build environment. Plugins can use this.environment.mode === 'dev' to
|
3233
|
-
* check if they have access to dev specific APIs.
|
3269
|
+
* The current environment can be accessed from the context for the all non-global
|
3270
|
+
* hooks (it is not available in config, configResolved, configureServer, etc).
|
3271
|
+
* It can be a dev, build, or scan environment.
|
3272
|
+
* Plugins can use this.environment.mode === 'dev' to guard for dev specific APIs.
|
3234
3273
|
*/
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3274
|
+
interface PluginContextExtension {
|
3275
|
+
/**
|
3276
|
+
* Vite-specific environment instance
|
3277
|
+
*/
|
3278
|
+
environment: Environment;
|
3279
|
+
}
|
3280
|
+
interface HotUpdatePluginContext {
|
3281
|
+
environment: DevEnvironment;
|
3238
3282
|
}
|
3239
|
-
interface
|
3240
|
-
environment?: PluginEnvironment;
|
3283
|
+
interface PluginContext extends rollup.PluginContext, PluginContextExtension {
|
3241
3284
|
}
|
3242
|
-
interface
|
3243
|
-
|
3285
|
+
interface ResolveIdPluginContext extends rollup.PluginContext, PluginContextExtension {
|
3286
|
+
}
|
3287
|
+
interface TransformPluginContext extends rollup.TransformPluginContext, PluginContextExtension {
|
3288
|
+
}
|
3289
|
+
declare module 'rollup' {
|
3290
|
+
interface PluginContext extends PluginContextExtension {
|
3291
|
+
}
|
3244
3292
|
}
|
3245
3293
|
/**
|
3246
3294
|
* There are two types of plugins in Vite. App plugins and environment plugins.
|
@@ -3248,23 +3296,14 @@ interface TransformPluginContext extends rollup.TransformPluginContext {
|
|
3248
3296
|
* once per each environment allowing users to have completely different plugins
|
3249
3297
|
* for each of them. The constructor gets the resolved environment after the server
|
3250
3298
|
* and builder has already been created simplifying config access and cache
|
3251
|
-
*
|
3299
|
+
* management for for environment specific plugins.
|
3252
3300
|
* Environment Plugins are closer to regular rollup plugins. They can't define
|
3253
3301
|
* app level hooks (like config, configResolved, configureServer, etc).
|
3254
3302
|
*/
|
3255
|
-
|
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> {
|
3303
|
+
interface Plugin<A = any> extends rollup.Plugin<A> {
|
3265
3304
|
/**
|
3266
3305
|
* Perform custom handling of HMR updates.
|
3267
|
-
* The handler receives
|
3306
|
+
* The handler receives an options containing changed filename, timestamp, a
|
3268
3307
|
* list of modules affected by the file change, and the dev server instance.
|
3269
3308
|
*
|
3270
3309
|
* - The hook can return a filtered list of modules to narrow down the update.
|
@@ -3272,42 +3311,27 @@ interface BasePlugin<A = any> extends rollup.Plugin<A> {
|
|
3272
3311
|
* the descriptors.
|
3273
3312
|
*
|
3274
3313
|
* - The hook can also return an empty array and then perform custom updates
|
3275
|
-
* by sending a custom hmr payload via
|
3314
|
+
* by sending a custom hmr payload via environment.hot.send().
|
3276
3315
|
*
|
3277
3316
|
* - If the hook doesn't return a value, the hmr update will be performed as
|
3278
3317
|
* normal.
|
3279
3318
|
*/
|
3280
|
-
hotUpdate?: ObjectHook<(this:
|
3319
|
+
hotUpdate?: ObjectHook<(this: HotUpdatePluginContext, options: HotUpdateOptions) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
|
3281
3320
|
/**
|
3282
3321
|
* extend hooks with ssr flag
|
3283
3322
|
*/
|
3284
3323
|
resolveId?: ObjectHook<(this: ResolveIdPluginContext, source: string, importer: string | undefined, options: {
|
3285
3324
|
attributes: Record<string, string>;
|
3286
3325
|
custom?: CustomPluginOptions;
|
3287
|
-
/**
|
3288
|
-
* @deprecated use this.environment
|
3289
|
-
*/
|
3290
3326
|
ssr?: boolean;
|
3291
3327
|
isEntry: boolean;
|
3292
3328
|
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
3293
3329
|
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
3294
|
-
/**
|
3295
|
-
* @deprecated use this.environment
|
3296
|
-
*/
|
3297
3330
|
ssr?: boolean;
|
3298
3331
|
}) => Promise<LoadResult> | LoadResult>;
|
3299
3332
|
transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
|
3300
|
-
/**
|
3301
|
-
* @deprecated use this.environment
|
3302
|
-
*/
|
3303
3333
|
ssr?: boolean;
|
3304
3334
|
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
3305
|
-
buildStart?: ModifyHookContext<rollup.Plugin<A>['buildStart'], PluginContext>;
|
3306
|
-
generateBundle?: ModifyHookContext<rollup.Plugin<A>['generateBundle'], PluginContext>;
|
3307
|
-
renderChunk?: ModifyHookContext<rollup.Plugin<A>['renderChunk'], PluginContext>;
|
3308
|
-
}
|
3309
|
-
type BoundedPlugin<A = any> = BasePlugin<A>;
|
3310
|
-
interface Plugin<A = any> extends BasePlugin<A> {
|
3311
3335
|
/**
|
3312
3336
|
* Opt-in this plugin into the shared plugins pipeline.
|
3313
3337
|
* For backward-compatibility, plugins are re-recreated for each environment
|
@@ -3318,12 +3342,13 @@ interface Plugin<A = any> extends BasePlugin<A> {
|
|
3318
3342
|
*/
|
3319
3343
|
sharedDuringBuild?: boolean;
|
3320
3344
|
/**
|
3321
|
-
*
|
3322
|
-
*
|
3323
|
-
*
|
3324
|
-
*
|
3345
|
+
* Opt-in this plugin into per-environment buildStart and buildEnd during dev.
|
3346
|
+
* For backward-compatibility, the buildStart hook is called only once during
|
3347
|
+
* dev, for the client environment. Plugins can opt-in to be called
|
3348
|
+
* per-environment, aligning with the build hook behavior.
|
3349
|
+
* @experimental
|
3325
3350
|
*/
|
3326
|
-
|
3351
|
+
perEnvironmentStartEndDuringDev?: boolean;
|
3327
3352
|
/**
|
3328
3353
|
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
|
3329
3354
|
* is still subject to the `order` property in the hook object.
|
@@ -3342,6 +3367,11 @@ interface Plugin<A = any> extends BasePlugin<A> {
|
|
3342
3367
|
* Apply the plugin only for serve or build, or on certain conditions.
|
3343
3368
|
*/
|
3344
3369
|
apply?: 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
|
3370
|
+
/**
|
3371
|
+
* Define environments where this plugin should be active
|
3372
|
+
* By default, the plugin is active in all environments
|
3373
|
+
*/
|
3374
|
+
applyToEnvironment?: (environment: Environment) => boolean;
|
3345
3375
|
/**
|
3346
3376
|
* Modify vite config before it's resolved. The hook can either mutate the
|
3347
3377
|
* passed-in config directly, or return a partial config object that will be
|
@@ -3403,9 +3433,19 @@ interface Plugin<A = any> extends BasePlugin<A> {
|
|
3403
3433
|
*/
|
3404
3434
|
transformIndexHtml?: IndexHtmlTransform;
|
3405
3435
|
/**
|
3406
|
-
*
|
3407
|
-
*
|
3408
|
-
*
|
3436
|
+
* Perform custom handling of HMR updates.
|
3437
|
+
* The handler receives a context containing changed filename, timestamp, a
|
3438
|
+
* list of modules affected by the file change, and the dev server instance.
|
3439
|
+
*
|
3440
|
+
* - The hook can return a filtered list of modules to narrow down the update.
|
3441
|
+
* e.g. for a Vue SFC, we can narrow down the part to update by comparing
|
3442
|
+
* the descriptors.
|
3443
|
+
*
|
3444
|
+
* - The hook can also return an empty array and then perform custom updates
|
3445
|
+
* by sending a custom hmr payload via server.ws.send().
|
3446
|
+
*
|
3447
|
+
* - If the hook doesn't return a value, the hmr update will be performed as
|
3448
|
+
* normal.
|
3409
3449
|
*/
|
3410
3450
|
handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
|
3411
3451
|
}
|
@@ -3413,10 +3453,9 @@ type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
|
|
3413
3453
|
type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
|
3414
3454
|
[P in K]: NonNullable<Plugin[P]>;
|
3415
3455
|
};
|
3416
|
-
type
|
3417
|
-
type
|
3418
|
-
type
|
3419
|
-
type PluginOption = MaybePlugin | PluginOption[] | Promise<MaybePlugin | PluginOption[]>;
|
3456
|
+
type Thenable<T> = T | Promise<T>;
|
3457
|
+
type FalsyPlugin = false | null | undefined;
|
3458
|
+
type PluginOption = Thenable<Plugin | FalsyPlugin | PluginOption[]>;
|
3420
3459
|
|
3421
3460
|
interface JsonOptions {
|
3422
3461
|
/**
|
@@ -3433,31 +3472,15 @@ interface JsonOptions {
|
|
3433
3472
|
}
|
3434
3473
|
|
3435
3474
|
type SSRTarget = 'node' | 'webworker';
|
3436
|
-
type
|
3437
|
-
/**
|
3438
|
-
* @deprecated use environments.ssr
|
3439
|
-
*/
|
3475
|
+
type SsrDepOptimizationConfig = DepOptimizationConfig;
|
3440
3476
|
interface SSROptions {
|
3441
|
-
/**
|
3442
|
-
* @deprecated use environment.resolve.noExternal
|
3443
|
-
*/
|
3444
3477
|
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
3445
|
-
/**
|
3446
|
-
* @deprecated use environment.resolve.external
|
3447
|
-
*/
|
3448
3478
|
external?: string[] | true;
|
3449
3479
|
/**
|
3450
3480
|
* Define the target for the ssr build. The browser field in package.json
|
3451
3481
|
* is ignored for node but used if webworker is the target
|
3452
|
-
*
|
3453
|
-
* if (ssr.target === 'webworker') {
|
3454
|
-
* build.rollupOptions.entryFileNames = '[name].js'
|
3455
|
-
* build.rollupOptions.inlineDynamicImports = (typeof input === 'string' || Object.keys(input).length === 1))
|
3456
|
-
* webCompatible = true
|
3457
|
-
* }
|
3458
|
-
*
|
3482
|
+
* This option may be replaced by the experimental `environmentOptions.webCompatible`
|
3459
3483
|
* @default 'node'
|
3460
|
-
* @deprecated use environment.webCompatible
|
3461
3484
|
*/
|
3462
3485
|
target?: SSRTarget;
|
3463
3486
|
/**
|
@@ -3467,12 +3490,8 @@ interface SSROptions {
|
|
3467
3490
|
* During dev:
|
3468
3491
|
* explicit no external CJS dependencies are optimized by default
|
3469
3492
|
* @experimental
|
3470
|
-
* @deprecated
|
3471
|
-
*/
|
3472
|
-
optimizeDeps?: SsrDepOptimizationOptions;
|
3473
|
-
/**
|
3474
|
-
* @deprecated
|
3475
3493
|
*/
|
3494
|
+
optimizeDeps?: SsrDepOptimizationConfig;
|
3476
3495
|
resolve?: {
|
3477
3496
|
/**
|
3478
3497
|
* Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
|
@@ -3480,21 +3499,19 @@ interface SSROptions {
|
|
3480
3499
|
* Use this to override the default ssr conditions for the ssr build.
|
3481
3500
|
*
|
3482
3501
|
* @default rootConfig.resolve.conditions
|
3483
|
-
* @deprecated
|
3484
3502
|
*/
|
3485
3503
|
conditions?: string[];
|
3486
3504
|
/**
|
3487
3505
|
* Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
|
3488
3506
|
*
|
3489
3507
|
* @default []
|
3490
|
-
* @deprecated
|
3491
3508
|
*/
|
3492
3509
|
externalConditions?: string[];
|
3493
3510
|
};
|
3494
3511
|
}
|
3495
3512
|
interface ResolvedSSROptions extends SSROptions {
|
3496
3513
|
target: SSRTarget;
|
3497
|
-
optimizeDeps:
|
3514
|
+
optimizeDeps: SsrDepOptimizationConfig;
|
3498
3515
|
}
|
3499
3516
|
|
3500
3517
|
interface ConfigEnv {
|
@@ -3528,9 +3545,12 @@ declare function defineConfig(config: UserConfig): UserConfig;
|
|
3528
3545
|
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
3529
3546
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
3530
3547
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3548
|
+
interface CreateDevEnvironmentContext {
|
3549
|
+
ws: WebSocketServer;
|
3550
|
+
}
|
3531
3551
|
interface DevEnvironmentOptions {
|
3532
3552
|
/**
|
3533
|
-
* Files
|
3553
|
+
* Files to be pre-transformed. Supports glob patterns.
|
3534
3554
|
*/
|
3535
3555
|
warmup?: string[];
|
3536
3556
|
/**
|
@@ -3559,11 +3579,11 @@ interface DevEnvironmentOptions {
|
|
3559
3579
|
/**
|
3560
3580
|
* Optimize deps config
|
3561
3581
|
*/
|
3562
|
-
optimizeDeps?:
|
3582
|
+
optimizeDeps?: DepOptimizationOptions;
|
3563
3583
|
/**
|
3564
3584
|
* create the Dev Environment instance
|
3565
3585
|
*/
|
3566
|
-
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<DevEnvironment> | DevEnvironment;
|
3586
|
+
createEnvironment?: (name: string, config: ResolvedConfig, context: CreateDevEnvironmentContext) => Promise<DevEnvironment> | DevEnvironment;
|
3567
3587
|
/**
|
3568
3588
|
* For environments that support a full-reload, like the client, we can short-circuit when
|
3569
3589
|
* restarting the server throwing early to stop processing current files. We avoided this for
|
@@ -3578,30 +3598,30 @@ interface DevEnvironmentOptions {
|
|
3578
3598
|
*/
|
3579
3599
|
moduleRunnerTransform?: boolean;
|
3580
3600
|
}
|
3581
|
-
type ResolvedDevEnvironmentOptions = Required<
|
3582
|
-
|
3583
|
-
};
|
3584
|
-
type EnvironmentResolveOptions = ResolveOptions & {
|
3601
|
+
type ResolvedDevEnvironmentOptions = Required<DevEnvironmentOptions>;
|
3602
|
+
type AllResolveOptions = ResolveOptions & {
|
3585
3603
|
alias?: AliasOptions;
|
3586
3604
|
};
|
3587
3605
|
interface SharedEnvironmentOptions {
|
3606
|
+
/**
|
3607
|
+
* Define global variable replacements.
|
3608
|
+
* Entries will be defined on `window` during dev and replaced during build.
|
3609
|
+
*/
|
3610
|
+
define?: Record<string, any>;
|
3588
3611
|
/**
|
3589
3612
|
* Configure resolver
|
3590
3613
|
*/
|
3591
3614
|
resolve?: EnvironmentResolveOptions;
|
3615
|
+
/**
|
3616
|
+
* Define if this environment is used for Server Side Rendering
|
3617
|
+
* @default 'server' if it isn't the client environment
|
3618
|
+
*/
|
3619
|
+
consumer?: 'client' | 'server';
|
3592
3620
|
/**
|
3593
3621
|
* Runtime Compatibility
|
3594
3622
|
* Temporal options, we should remove these in favor of fine-grained control
|
3595
3623
|
*/
|
3596
|
-
nodeCompatible?: boolean;
|
3597
3624
|
webCompatible?: boolean;
|
3598
|
-
/**
|
3599
|
-
* Should Vite inject timestamp if module is invalidated
|
3600
|
-
* Disabling this will break built-in HMR support
|
3601
|
-
* @experimental
|
3602
|
-
* @default true
|
3603
|
-
*/
|
3604
|
-
injectInvalidationTimestamp?: boolean;
|
3605
3625
|
}
|
3606
3626
|
interface EnvironmentOptions extends SharedEnvironmentOptions {
|
3607
3627
|
/**
|
@@ -3613,17 +3633,17 @@ interface EnvironmentOptions extends SharedEnvironmentOptions {
|
|
3613
3633
|
*/
|
3614
3634
|
build?: BuildEnvironmentOptions;
|
3615
3635
|
}
|
3616
|
-
type
|
3636
|
+
type ResolvedResolveOptions = Required<ResolveOptions>;
|
3617
3637
|
type ResolvedEnvironmentOptions = {
|
3618
|
-
|
3619
|
-
|
3638
|
+
define?: Record<string, any>;
|
3639
|
+
resolve: ResolvedResolveOptions;
|
3640
|
+
consumer: 'client' | 'server';
|
3620
3641
|
webCompatible: boolean;
|
3621
|
-
injectInvalidationTimestamp: boolean;
|
3622
3642
|
dev: ResolvedDevEnvironmentOptions;
|
3623
3643
|
build: ResolvedBuildEnvironmentOptions;
|
3624
3644
|
};
|
3625
|
-
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, '
|
3626
|
-
|
3645
|
+
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'consumer' | 'webCompatible' | 'resolve'> & {
|
3646
|
+
resolve?: AllResolveOptions;
|
3627
3647
|
};
|
3628
3648
|
interface UserConfig extends DefaultEnvironmentOptions {
|
3629
3649
|
/**
|
@@ -3661,11 +3681,6 @@ interface UserConfig extends DefaultEnvironmentOptions {
|
|
3661
3681
|
* each command, and can be overridden by the command line --mode option.
|
3662
3682
|
*/
|
3663
3683
|
mode?: string;
|
3664
|
-
/**
|
3665
|
-
* Define global variable replacements.
|
3666
|
-
* Entries will be defined on `window` during dev and replaced during build.
|
3667
|
-
*/
|
3668
|
-
define?: Record<string, any>;
|
3669
3684
|
/**
|
3670
3685
|
* Array of vite plugins to use.
|
3671
3686
|
*/
|
@@ -3711,6 +3726,10 @@ interface UserConfig extends DefaultEnvironmentOptions {
|
|
3711
3726
|
* @experimental
|
3712
3727
|
*/
|
3713
3728
|
experimental?: ExperimentalOptions;
|
3729
|
+
/**
|
3730
|
+
* Options to opt-in to future behavior
|
3731
|
+
*/
|
3732
|
+
future?: FutureOptions;
|
3714
3733
|
/**
|
3715
3734
|
* Legacy options
|
3716
3735
|
*
|
@@ -3792,6 +3811,14 @@ interface HTMLOptions {
|
|
3792
3811
|
*/
|
3793
3812
|
cspNonce?: string;
|
3794
3813
|
}
|
3814
|
+
interface FutureOptions {
|
3815
|
+
removePluginHookHandleHotUpdate?: 'warn';
|
3816
|
+
removePluginHookSsrArgument?: 'warn';
|
3817
|
+
removeServerModuleGraph?: 'warn';
|
3818
|
+
removeServerHot?: 'warn';
|
3819
|
+
removeServerTransformRequest?: 'warn';
|
3820
|
+
removeSsrLoadModule?: 'warn';
|
3821
|
+
}
|
3795
3822
|
interface ExperimentalOptions {
|
3796
3823
|
/**
|
3797
3824
|
* Append fake `&lang.(ext)` when queries are specified, to preserve the file extension for following plugins to process.
|
@@ -3887,7 +3914,9 @@ interface PluginHookUtils {
|
|
3887
3914
|
getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
|
3888
3915
|
}
|
3889
3916
|
type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
|
3890
|
-
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean,
|
3917
|
+
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean,
|
3918
|
+
|
3919
|
+
): Promise<ResolvedConfig>;
|
3891
3920
|
declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
|
3892
3921
|
declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger): Promise<{
|
3893
3922
|
path: string;
|
@@ -3895,9 +3924,16 @@ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, c
|
|
3895
3924
|
dependencies: string[];
|
3896
3925
|
} | null>;
|
3897
3926
|
|
3927
|
+
type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: string, aliasOnly?: boolean) => Promise<string | undefined>;
|
3928
|
+
/**
|
3929
|
+
* Create an internal resolver to be used in special scenarios, e.g.
|
3930
|
+
* optimizer and handling css @imports
|
3931
|
+
*/
|
3932
|
+
declare function createIdResolver(config: ResolvedConfig, options?: Partial<InternalResolveOptions>): ResolveIdFn;
|
3933
|
+
|
3898
3934
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3899
3935
|
|
3900
|
-
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig,
|
3936
|
+
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, context: DevEnvironmentContext): DevEnvironment;
|
3901
3937
|
|
3902
3938
|
/**
|
3903
3939
|
* @experimental
|
@@ -3926,21 +3962,30 @@ declare function createServerModuleRunner(environment: DevEnvironment, options?:
|
|
3926
3962
|
* @experimental
|
3927
3963
|
*/
|
3928
3964
|
declare class ServerHMRConnector implements ModuleRunnerHMRConnection {
|
3929
|
-
private
|
3965
|
+
private hotChannel;
|
3930
3966
|
private handlers;
|
3931
3967
|
private hmrClient;
|
3932
3968
|
private connected;
|
3933
|
-
constructor(
|
3969
|
+
constructor(hotChannel: ServerHotChannel);
|
3934
3970
|
isReady(): boolean;
|
3935
3971
|
send(message: string): void;
|
3936
|
-
onUpdate(handler: (payload:
|
3972
|
+
onUpdate(handler: (payload: HotPayload) => void): void;
|
3973
|
+
}
|
3974
|
+
|
3975
|
+
interface ModuleRunnerTransformOptions {
|
3976
|
+
json?: {
|
3977
|
+
stringify?: boolean;
|
3978
|
+
};
|
3937
3979
|
}
|
3980
|
+
declare function ssrTransform(code: string, inMap: SourceMap | {
|
3981
|
+
mappings: '';
|
3982
|
+
} | null, url: string, originalCode: string, options?: ModuleRunnerTransformOptions): Promise<TransformResult | null>;
|
3938
3983
|
|
3939
3984
|
declare const VERSION: string;
|
3940
3985
|
|
3941
3986
|
declare const isCSSRequest: (request: string) => boolean;
|
3942
3987
|
/**
|
3943
|
-
* @deprecated use build.
|
3988
|
+
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3944
3989
|
*/
|
3945
3990
|
declare class SplitVendorChunkCache {
|
3946
3991
|
cache: Map<string, boolean>;
|
@@ -3948,13 +3993,13 @@ declare class SplitVendorChunkCache {
|
|
3948
3993
|
reset(): void;
|
3949
3994
|
}
|
3950
3995
|
/**
|
3951
|
-
* @deprecated use build.
|
3996
|
+
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3952
3997
|
*/
|
3953
3998
|
declare function splitVendorChunk(options?: {
|
3954
3999
|
cache?: SplitVendorChunkCache;
|
3955
4000
|
}): GetManualChunk;
|
3956
4001
|
/**
|
3957
|
-
* @deprecated use build.
|
4002
|
+
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3958
4003
|
*/
|
3959
4004
|
declare function splitVendorChunkPlugin(): Plugin;
|
3960
4005
|
|
@@ -3987,9 +4032,13 @@ declare function searchForWorkspaceRoot(current: string, root?: string): string;
|
|
3987
4032
|
|
3988
4033
|
/**
|
3989
4034
|
* Check if the url is allowed to be served, via the `server.fs` config.
|
3990
|
-
|
4035
|
+
*/
|
4036
|
+
declare function isFileServingAllowed(config: ResolvedConfig, url: string): boolean;
|
4037
|
+
/**
|
4038
|
+
* @deprecated Use the `isFileServingAllowed(config, url)` signature instead.
|
3991
4039
|
*/
|
3992
4040
|
declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
|
4041
|
+
declare function isFileLoadingAllowed(config: ResolvedConfig, filePath: string): boolean;
|
3993
4042
|
|
3994
4043
|
declare function loadEnv(mode: string, envDir: string, prefixes?: string | string[]): Record<string, string>;
|
3995
4044
|
declare function resolveEnvPrefix({ envPrefix, }: UserConfig): string[];
|
@@ -4007,4 +4056,4 @@ interface ManifestChunk {
|
|
4007
4056
|
dynamicImports?: string[];
|
4008
4057
|
}
|
4009
4058
|
|
4010
|
-
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, 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
|
4059
|
+
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, 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 HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, 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 ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, 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 ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, 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, createNodeDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
|