vite 6.0.0-alpha.15 → 6.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-BH5K5NVS.js → dep-CNsiFGD3.js} +1 -1
- package/dist/node/chunks/{dep-cpG-cLQR.js → dep-DJVII9WQ.js} +1 -1
- package/dist/node/chunks/{dep-C8uvdLOV.js → dep-DVlS5vGL.js} +37167 -30752
- package/dist/node/cli.js +53 -35
- package/dist/node/constants.js +28 -1
- package/dist/node/index.d.ts +1938 -1945
- package/dist/node/index.js +6 -7
- package/dist/node/module-runner.d.ts +2 -2
- package/dist/node/module-runner.js +2 -2
- package/dist/node-cjs/publicUtils.cjs +17 -0
- package/package.json +2 -2
- package/types/customEvent.d.ts +1 -1
- package/types/{hmrPayload.d.ts → hotPayload.d.ts} +3 -1
- package/dist/node/chunks/dep-B2yOf3Tu.js +0 -6385
package/dist/node/index.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { PluginHooks, RollupError,
|
2
|
+
import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, InputOptions, CustomPluginOptions, SourceDescription, LoadResult, 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';
|
6
6
|
import * as http from 'node:http';
|
7
|
-
import { OutgoingHttpHeaders, ClientRequestArgs, IncomingMessage, ClientRequest, Agent,
|
7
|
+
import { OutgoingHttpHeaders, Server, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, ServerResponse } from 'node:http';
|
8
8
|
import { Http2SecureServer } from 'node:http2';
|
9
9
|
import * as fs from 'node:fs';
|
10
10
|
import * as events from 'node:events';
|
@@ -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 { SecureContextOptions } from 'node:tls';
|
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
18
|
import { FetchResult, 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/hotPayload.js';
|
23
|
+
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hotPayload.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';
|
@@ -783,835 +783,207 @@ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
|
|
783
783
|
action?(server: Server): void | Promise<void>;
|
784
784
|
};
|
785
785
|
|
786
|
+
declare class PartialEnvironment {
|
787
|
+
name: string;
|
788
|
+
config: ResolvedConfig;
|
789
|
+
options: ResolvedEnvironmentOptions;
|
790
|
+
logger: Logger;
|
791
|
+
constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
792
|
+
}
|
793
|
+
declare class BaseEnvironment extends PartialEnvironment {
|
794
|
+
get plugins(): Plugin[];
|
795
|
+
constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
796
|
+
}
|
786
797
|
/**
|
787
|
-
* This
|
788
|
-
*
|
798
|
+
* This is used both to avoid users to hardcode conditions like
|
799
|
+
* !scan && !build => dev
|
789
800
|
*/
|
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>;
|
801
|
+
declare class FutureCompatEnvironment extends BaseEnvironment {
|
802
|
+
mode: "futureCompat";
|
813
803
|
}
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
attributes?: Record<string, string>;
|
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>;
|
804
|
+
|
805
|
+
interface FetchModuleOptions {
|
806
|
+
inlineSourceMap?: boolean;
|
807
|
+
processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
|
843
808
|
}
|
809
|
+
/**
|
810
|
+
* Fetch module information for Vite runner.
|
811
|
+
* @experimental
|
812
|
+
*/
|
813
|
+
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
844
814
|
|
845
|
-
|
846
|
-
|
815
|
+
declare class ScanEnvironment extends BaseEnvironment {
|
816
|
+
mode: "scan";
|
817
|
+
get pluginContainer(): EnvironmentPluginContainer;
|
818
|
+
init(): Promise<void>;
|
819
|
+
}
|
847
820
|
|
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(): EnvironmentPlugin[];
|
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(): EnvironmentPluginContainer;
|
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(): EnvironmentPluginContainer;
|
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
|
-
}
|
821
|
+
type ExportsData = {
|
822
|
+
hasModuleSyntax: boolean;
|
823
|
+
exports: readonly string[];
|
824
|
+
jsxLoader?: boolean;
|
825
|
+
};
|
826
|
+
interface DepsOptimizer {
|
827
|
+
init: () => Promise<void>;
|
828
|
+
metadata: DepOptimizationMetadata;
|
829
|
+
scanProcessing?: Promise<void>;
|
830
|
+
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
831
|
+
run: () => void;
|
832
|
+
isOptimizedDepFile: (id: string) => boolean;
|
833
|
+
isOptimizedDepUrl: (url: string) => boolean;
|
834
|
+
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
|
835
|
+
close: () => Promise<void>;
|
836
|
+
options: DepOptimizationOptions;
|
837
|
+
}
|
838
|
+
interface DepOptimizationConfig {
|
839
|
+
/**
|
840
|
+
* Force optimize listed dependencies (must be resolvable import paths,
|
841
|
+
* cannot be globs).
|
842
|
+
*/
|
843
|
+
include?: string[];
|
844
|
+
/**
|
845
|
+
* Do not optimize these dependencies (must be resolvable import paths,
|
846
|
+
* cannot be globs).
|
847
|
+
*/
|
848
|
+
exclude?: string[];
|
849
|
+
/**
|
850
|
+
* Forces ESM interop when importing these dependencies. Some legacy
|
851
|
+
* packages advertise themselves as ESM but use `require` internally
|
852
|
+
* @experimental
|
853
|
+
*/
|
854
|
+
needsInterop?: string[];
|
855
|
+
/**
|
856
|
+
* Options to pass to esbuild during the dep scanning and optimization
|
857
|
+
*
|
858
|
+
* Certain options are omitted since changing them would not be compatible
|
859
|
+
* with Vite's dep optimization.
|
860
|
+
*
|
861
|
+
* - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
|
862
|
+
* - `plugins` are merged with Vite's dep plugin
|
863
|
+
*
|
864
|
+
* https://esbuild.github.io/api
|
865
|
+
*/
|
866
|
+
esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
|
867
|
+
/**
|
868
|
+
* List of file extensions that can be optimized. A corresponding esbuild
|
869
|
+
* plugin must exist to handle the specific extension.
|
870
|
+
*
|
871
|
+
* By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
|
872
|
+
* allows specifying additional extensions.
|
873
|
+
*
|
874
|
+
* @experimental
|
875
|
+
*/
|
876
|
+
extensions?: string[];
|
877
|
+
/**
|
878
|
+
* Deps optimization during build was removed in Vite 5.1. This option is
|
879
|
+
* now redundant and will be removed in a future version. Switch to using
|
880
|
+
* `optimizeDeps.noDiscovery` and an empty or undefined `optimizeDeps.include`.
|
881
|
+
* true or 'dev' disables the optimizer, false or 'build' leaves it enabled.
|
882
|
+
* @default 'build'
|
883
|
+
* @deprecated
|
884
|
+
* @experimental
|
885
|
+
*/
|
886
|
+
disabled?: boolean | 'build' | 'dev';
|
887
|
+
/**
|
888
|
+
* Automatic dependency discovery. When `noDiscovery` is true, only dependencies
|
889
|
+
* listed in `include` will be optimized. The scanner isn't run for cold start
|
890
|
+
* in this case. CJS-only dependencies must be present in `include` during dev.
|
891
|
+
* @default false
|
892
|
+
* @experimental
|
893
|
+
*/
|
894
|
+
noDiscovery?: boolean;
|
895
|
+
/**
|
896
|
+
* When enabled, it will hold the first optimized deps results until all static
|
897
|
+
* imports are crawled on cold start. This avoids the need for full-page reloads
|
898
|
+
* when new dependencies are discovered and they trigger the generation of new
|
899
|
+
* common chunks. If all dependencies are found by the scanner plus the explicitly
|
900
|
+
* defined ones in `include`, it is better to disable this option to let the
|
901
|
+
* browser process more requests in parallel.
|
902
|
+
* @default true
|
903
|
+
* @experimental
|
904
|
+
*/
|
905
|
+
holdUntilCrawlEnd?: boolean;
|
906
|
+
}
|
907
|
+
type DepOptimizationOptions = DepOptimizationConfig & {
|
908
|
+
/**
|
909
|
+
* By default, Vite will crawl your `index.html` to detect dependencies that
|
910
|
+
* need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
|
911
|
+
* will crawl those entry points instead.
|
912
|
+
*
|
913
|
+
* If neither of these fit your needs, you can specify custom entries using
|
914
|
+
* this option - the value should be a fast-glob pattern or array of patterns
|
915
|
+
* (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
|
916
|
+
* vite project root. This will overwrite default entries inference.
|
917
|
+
*/
|
918
|
+
entries?: string | string[];
|
919
|
+
/**
|
920
|
+
* Force dep pre-optimization regardless of whether deps have changed.
|
921
|
+
* @experimental
|
922
|
+
*/
|
923
|
+
force?: boolean;
|
924
|
+
};
|
925
|
+
interface OptimizedDepInfo {
|
926
|
+
id: string;
|
927
|
+
file: string;
|
928
|
+
src?: string;
|
929
|
+
needsInterop?: boolean;
|
930
|
+
browserHash?: string;
|
931
|
+
fileHash?: string;
|
932
|
+
/**
|
933
|
+
* During optimization, ids can still be resolved to their final location
|
934
|
+
* but the bundles may not yet be saved to disk
|
935
|
+
*/
|
936
|
+
processing?: Promise<void>;
|
937
|
+
/**
|
938
|
+
* ExportData cache, discovered deps will parse the src entry to get exports
|
939
|
+
* data used both to define if interop is needed and when pre-bundling
|
940
|
+
*/
|
941
|
+
exportsData?: Promise<ExportsData>;
|
942
|
+
}
|
943
|
+
interface DepOptimizationMetadata {
|
944
|
+
/**
|
945
|
+
* The main hash is determined by user config and dependency lockfiles.
|
946
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
947
|
+
*/
|
948
|
+
hash: string;
|
949
|
+
/**
|
950
|
+
* This hash is determined by dependency lockfiles.
|
951
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
952
|
+
*/
|
953
|
+
lockfileHash: string;
|
954
|
+
/**
|
955
|
+
* This hash is determined by user config.
|
956
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
957
|
+
*/
|
958
|
+
configHash: string;
|
959
|
+
/**
|
960
|
+
* The browser hash is determined by the main hash plus additional dependencies
|
961
|
+
* discovered at runtime. This is used to invalidate browser requests to
|
962
|
+
* optimized deps.
|
963
|
+
*/
|
964
|
+
browserHash: string;
|
965
|
+
/**
|
966
|
+
* Metadata for each already optimized dependency
|
967
|
+
*/
|
968
|
+
optimized: Record<string, OptimizedDepInfo>;
|
969
|
+
/**
|
970
|
+
* Metadata for non-entry optimized chunks and dynamic imports
|
971
|
+
*/
|
972
|
+
chunks: Record<string, OptimizedDepInfo>;
|
973
|
+
/**
|
974
|
+
* Metadata for each newly discovered dependency after processing
|
975
|
+
*/
|
976
|
+
discovered: Record<string, OptimizedDepInfo>;
|
977
|
+
/**
|
978
|
+
* OptimizedDepInfo list
|
979
|
+
*/
|
980
|
+
depInfoList: OptimizedDepInfo[];
|
981
|
+
}
|
982
|
+
/**
|
983
|
+
* Scan and optimize dependencies within a project.
|
984
|
+
* Used by Vite CLI when running `vite optimize`.
|
985
|
+
*/
|
986
|
+
declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
1615
987
|
|
1616
988
|
interface TransformResult {
|
1617
989
|
code: string;
|
@@ -1664,1290 +1036,1903 @@ declare class EnvironmentModuleNode {
|
|
1664
1036
|
*/
|
1665
1037
|
constructor(url: string, environment: string, setIsSelfAccepting?: boolean);
|
1666
1038
|
}
|
1667
|
-
type ResolvedUrl = [
|
1668
|
-
url: string,
|
1669
|
-
resolvedId: string,
|
1670
|
-
meta: object | null | undefined
|
1671
|
-
];
|
1672
|
-
declare class EnvironmentModuleGraph {
|
1673
|
-
environment: string;
|
1674
|
-
urlToModuleMap: Map<string, EnvironmentModuleNode>;
|
1675
|
-
idToModuleMap: Map<string, EnvironmentModuleNode>;
|
1676
|
-
etagToModuleMap: Map<string, EnvironmentModuleNode>;
|
1677
|
-
fileToModulesMap: Map<string, Set<EnvironmentModuleNode>>;
|
1678
|
-
constructor(environment: string, resolveId: (url: string) => Promise<PartialResolvedId | null>);
|
1679
|
-
getModuleByUrl(rawUrl: string): Promise<EnvironmentModuleNode | undefined>;
|
1680
|
-
getModuleById(id: string): EnvironmentModuleNode | undefined;
|
1681
|
-
getModulesByFile(file: string): Set<EnvironmentModuleNode> | undefined;
|
1682
|
-
onFileChange(file: string): void;
|
1683
|
-
onFileDelete(file: string): void;
|
1684
|
-
invalidateModule(mod: EnvironmentModuleNode, seen?: Set<EnvironmentModuleNode>, timestamp?: number, isHmr?: boolean,
|
1685
|
-
): void;
|
1686
|
-
invalidateAll(): void;
|
1039
|
+
type ResolvedUrl = [
|
1040
|
+
url: string,
|
1041
|
+
resolvedId: string,
|
1042
|
+
meta: object | null | undefined
|
1043
|
+
];
|
1044
|
+
declare class EnvironmentModuleGraph {
|
1045
|
+
environment: string;
|
1046
|
+
urlToModuleMap: Map<string, EnvironmentModuleNode>;
|
1047
|
+
idToModuleMap: Map<string, EnvironmentModuleNode>;
|
1048
|
+
etagToModuleMap: Map<string, EnvironmentModuleNode>;
|
1049
|
+
fileToModulesMap: Map<string, Set<EnvironmentModuleNode>>;
|
1050
|
+
constructor(environment: string, resolveId: (url: string) => Promise<PartialResolvedId | null>);
|
1051
|
+
getModuleByUrl(rawUrl: string): Promise<EnvironmentModuleNode | undefined>;
|
1052
|
+
getModuleById(id: string): EnvironmentModuleNode | undefined;
|
1053
|
+
getModulesByFile(file: string): Set<EnvironmentModuleNode> | undefined;
|
1054
|
+
onFileChange(file: string): void;
|
1055
|
+
onFileDelete(file: string): void;
|
1056
|
+
invalidateModule(mod: EnvironmentModuleNode, seen?: Set<EnvironmentModuleNode>, timestamp?: number, isHmr?: boolean,
|
1057
|
+
): void;
|
1058
|
+
invalidateAll(): void;
|
1059
|
+
/**
|
1060
|
+
* Update the module graph based on a module's updated imports information
|
1061
|
+
* If there are dependencies that no longer have any importers, they are
|
1062
|
+
* returned as a Set.
|
1063
|
+
*
|
1064
|
+
* @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
|
1065
|
+
* This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
|
1066
|
+
*/
|
1067
|
+
updateModuleInfo(mod: EnvironmentModuleNode, importedModules: Set<string | EnvironmentModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | EnvironmentModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean,
|
1068
|
+
): Promise<Set<EnvironmentModuleNode> | undefined>;
|
1069
|
+
ensureEntryFromUrl(rawUrl: string, setIsSelfAccepting?: boolean): Promise<EnvironmentModuleNode>;
|
1070
|
+
createFileOnlyEntry(file: string): EnvironmentModuleNode;
|
1071
|
+
resolveUrl(url: string): Promise<ResolvedUrl>;
|
1072
|
+
updateModuleTransformResult(mod: EnvironmentModuleNode, result: TransformResult | null): void;
|
1073
|
+
getModuleByEtag(etag: string): EnvironmentModuleNode | undefined;
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
/**
|
1077
|
+
* Backward compatible ModuleNode and ModuleGraph with mixed nodes from both the client and ssr enviornments
|
1078
|
+
* It would be good to take the types names for the new EnvironmentModuleNode and EnvironmentModuleGraph but we can't
|
1079
|
+
* do that at this point without breaking to much code in the ecosystem.
|
1080
|
+
* We are going to deprecate these types and we can try to use them back in the future.
|
1081
|
+
*/
|
1082
|
+
declare class ModuleNode {
|
1083
|
+
_moduleGraph: ModuleGraph;
|
1084
|
+
_clientModule: EnvironmentModuleNode | undefined;
|
1085
|
+
_ssrModule: EnvironmentModuleNode | undefined;
|
1086
|
+
constructor(moduleGraph: ModuleGraph, clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode);
|
1087
|
+
_get<T extends keyof EnvironmentModuleNode>(prop: T): EnvironmentModuleNode[T];
|
1088
|
+
_wrapModuleSet(prop: ModuleSetNames, module: EnvironmentModuleNode | undefined): Set<ModuleNode>;
|
1089
|
+
_getModuleSetUnion(prop: 'importedModules' | 'importers'): Set<ModuleNode>;
|
1090
|
+
get url(): string;
|
1091
|
+
get id(): string | null;
|
1092
|
+
get file(): string | null;
|
1093
|
+
get type(): 'js' | 'css';
|
1094
|
+
get info(): ModuleInfo | undefined;
|
1095
|
+
get meta(): Record<string, any> | undefined;
|
1096
|
+
get importers(): Set<ModuleNode>;
|
1097
|
+
get clientImportedModules(): Set<ModuleNode>;
|
1098
|
+
get ssrImportedModules(): Set<ModuleNode>;
|
1099
|
+
get importedModules(): Set<ModuleNode>;
|
1100
|
+
get acceptedHmrDeps(): Set<ModuleNode>;
|
1101
|
+
get acceptedHmrExports(): Set<string> | null;
|
1102
|
+
get importedBindings(): Map<string, Set<string>> | null;
|
1103
|
+
get isSelfAccepting(): boolean | undefined;
|
1104
|
+
get transformResult(): TransformResult | null;
|
1105
|
+
set transformResult(value: TransformResult | null);
|
1106
|
+
get ssrTransformResult(): TransformResult | null;
|
1107
|
+
set ssrTransformResult(value: TransformResult | null);
|
1108
|
+
get ssrModule(): Record<string, any> | null;
|
1109
|
+
get ssrError(): Error | null;
|
1110
|
+
get lastHMRTimestamp(): number;
|
1111
|
+
set lastHMRTimestamp(value: number);
|
1112
|
+
get lastInvalidationTimestamp(): number;
|
1113
|
+
get invalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined;
|
1114
|
+
get ssrInvalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined;
|
1115
|
+
}
|
1116
|
+
declare class ModuleGraph {
|
1117
|
+
urlToModuleMap: Map<string, ModuleNode>;
|
1118
|
+
idToModuleMap: Map<string, ModuleNode>;
|
1119
|
+
etagToModuleMap: Map<string, ModuleNode>;
|
1120
|
+
fileToModulesMap: Map<string, Set<ModuleNode>>;
|
1121
|
+
constructor(moduleGraphs: {
|
1122
|
+
client: () => EnvironmentModuleGraph;
|
1123
|
+
ssr: () => EnvironmentModuleGraph;
|
1124
|
+
});
|
1125
|
+
/** @deprecated */
|
1126
|
+
getModuleById(id: string): ModuleNode | undefined;
|
1127
|
+
/** @deprecated */
|
1128
|
+
getModuleByUrl(url: string, ssr?: boolean): Promise<ModuleNode | undefined>;
|
1129
|
+
/** @deprecated */
|
1130
|
+
getModulesByFile(file: string): Set<ModuleNode> | undefined;
|
1131
|
+
/** @deprecated */
|
1132
|
+
onFileChange(file: string): void;
|
1133
|
+
/** @deprecated */
|
1134
|
+
onFileDelete(file: string): void;
|
1135
|
+
/** @deprecated */
|
1136
|
+
invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean,
|
1137
|
+
): void;
|
1138
|
+
/** @deprecated */
|
1139
|
+
invalidateAll(): void;
|
1140
|
+
/** @deprecated */
|
1141
|
+
ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
|
1142
|
+
/** @deprecated */
|
1143
|
+
createFileOnlyEntry(file: string): ModuleNode;
|
1144
|
+
/** @deprecated */
|
1145
|
+
resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
|
1146
|
+
/** @deprecated */
|
1147
|
+
updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr?: boolean): void;
|
1148
|
+
/** @deprecated */
|
1149
|
+
getModuleByEtag(etag: string): ModuleNode | undefined;
|
1150
|
+
getBackwardCompatibleBrowserModuleNode(clientModule: EnvironmentModuleNode): ModuleNode;
|
1151
|
+
getBackwardCompatibleServerModuleNode(ssrModule: EnvironmentModuleNode): ModuleNode;
|
1152
|
+
getBackwardCompatibleModuleNode(mod: EnvironmentModuleNode): ModuleNode;
|
1153
|
+
getBackwardCompatibleModuleNodeDual(clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode): ModuleNode;
|
1154
|
+
}
|
1155
|
+
type ModuleSetNames = 'acceptedHmrDeps' | 'importedModules';
|
1156
|
+
|
1157
|
+
interface HmrOptions {
|
1158
|
+
protocol?: string;
|
1159
|
+
host?: string;
|
1160
|
+
port?: number;
|
1161
|
+
clientPort?: number;
|
1162
|
+
path?: string;
|
1163
|
+
timeout?: number;
|
1164
|
+
overlay?: boolean;
|
1165
|
+
server?: Server;
|
1166
|
+
}
|
1167
|
+
interface HotUpdateContext {
|
1168
|
+
type: 'create' | 'update' | 'delete';
|
1169
|
+
file: string;
|
1170
|
+
timestamp: number;
|
1171
|
+
modules: Array<EnvironmentModuleNode>;
|
1172
|
+
read: () => string | Promise<string>;
|
1173
|
+
server: ViteDevServer;
|
1174
|
+
environment: DevEnvironment;
|
1175
|
+
}
|
1176
|
+
/**
|
1177
|
+
* @deprecated
|
1178
|
+
* Used by handleHotUpdate for backward compatibility with mixed client and ssr moduleGraph
|
1179
|
+
**/
|
1180
|
+
interface HmrContext {
|
1181
|
+
file: string;
|
1182
|
+
timestamp: number;
|
1183
|
+
modules: Array<ModuleNode>;
|
1184
|
+
read: () => string | Promise<string>;
|
1185
|
+
server: ViteDevServer;
|
1186
|
+
}
|
1187
|
+
interface HotChannelClient {
|
1188
|
+
/**
|
1189
|
+
* Send event to the client
|
1190
|
+
*/
|
1191
|
+
send(payload: HotPayload): void;
|
1192
|
+
/**
|
1193
|
+
* Send custom event
|
1194
|
+
*/
|
1195
|
+
send(event: string, payload?: CustomPayload['data']): void;
|
1196
|
+
}
|
1197
|
+
interface HotChannel {
|
1198
|
+
/**
|
1199
|
+
* Broadcast events to all clients
|
1200
|
+
*/
|
1201
|
+
send(payload: HotPayload): void;
|
1202
|
+
/**
|
1203
|
+
* Send custom event
|
1204
|
+
*/
|
1205
|
+
send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
|
1206
|
+
/**
|
1207
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
1208
|
+
*/
|
1209
|
+
on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client: HotChannelClient, ...args: any[]) => void): void;
|
1210
|
+
on(event: 'connection', listener: () => void): void;
|
1211
|
+
/**
|
1212
|
+
* Unregister event listener
|
1213
|
+
*/
|
1214
|
+
off(event: string, listener: Function): void;
|
1215
|
+
/**
|
1216
|
+
* Start listening for messages
|
1217
|
+
*/
|
1218
|
+
listen(): void;
|
1219
|
+
/**
|
1220
|
+
* Disconnect all clients, called when server is closed or restarted.
|
1221
|
+
*/
|
1222
|
+
close(): void;
|
1223
|
+
}
|
1224
|
+
interface ServerHotChannel extends HotChannel {
|
1225
|
+
api: {
|
1226
|
+
innerEmitter: EventEmitter;
|
1227
|
+
outsideEmitter: EventEmitter;
|
1228
|
+
};
|
1229
|
+
}
|
1230
|
+
|
1231
|
+
declare class RemoteEnvironmentTransport {
|
1232
|
+
private readonly options;
|
1233
|
+
constructor(options: {
|
1234
|
+
send: (data: any) => void;
|
1235
|
+
onMessage: (handler: (data: any) => void) => void;
|
1236
|
+
});
|
1237
|
+
register(environment: DevEnvironment): void;
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
interface DevEnvironmentSetup {
|
1241
|
+
hot: false | HotChannel;
|
1242
|
+
watcher?: FSWatcher;
|
1243
|
+
options?: EnvironmentOptions;
|
1244
|
+
runner?: FetchModuleOptions & {
|
1245
|
+
transport?: RemoteEnvironmentTransport;
|
1246
|
+
};
|
1247
|
+
depsOptimizer?: DepsOptimizer;
|
1248
|
+
}
|
1249
|
+
declare class DevEnvironment extends BaseEnvironment {
|
1250
|
+
mode: "dev";
|
1251
|
+
moduleGraph: EnvironmentModuleGraph;
|
1252
|
+
watcher?: FSWatcher;
|
1253
|
+
depsOptimizer?: DepsOptimizer;
|
1254
|
+
get pluginContainer(): EnvironmentPluginContainer;
|
1687
1255
|
/**
|
1688
|
-
*
|
1689
|
-
*
|
1690
|
-
* returned as a Set.
|
1256
|
+
* Hot channel for this environment. If not provided or disabled,
|
1257
|
+
* it will be a noop channel that does nothing.
|
1691
1258
|
*
|
1692
|
-
* @
|
1693
|
-
*
|
1259
|
+
* @example
|
1260
|
+
* environment.hot.send({ type: 'full-reload' })
|
1694
1261
|
*/
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1262
|
+
hot: HotChannel;
|
1263
|
+
constructor(name: string, config: ResolvedConfig, setup: DevEnvironmentSetup);
|
1264
|
+
init(): Promise<void>;
|
1265
|
+
fetchModule(id: string, importer?: string): Promise<FetchResult>;
|
1266
|
+
transformRequest(url: string): Promise<TransformResult | null>;
|
1267
|
+
warmupRequest(url: string): Promise<void>;
|
1268
|
+
close(): Promise<void>;
|
1269
|
+
/**
|
1270
|
+
* Calling `await environment.waitForRequestsIdle(id)` will wait until all static imports
|
1271
|
+
* are processed after the first transformRequest call. If called from a load or transform
|
1272
|
+
* plugin hook, the id needs to be passed as a parameter to avoid deadlocks.
|
1273
|
+
* Calling this function after the first static imports section of the module graph has been
|
1274
|
+
* processed will resolve immediately.
|
1275
|
+
* @experimental
|
1276
|
+
*/
|
1277
|
+
waitForRequestsIdle(ignoredId?: string): Promise<void>;
|
1702
1278
|
}
|
1703
1279
|
|
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
|
-
|
1280
|
+
interface RollupCommonJSOptions {
|
1281
|
+
/**
|
1282
|
+
* A minimatch pattern, or array of patterns, which specifies the files in
|
1283
|
+
* the build the plugin should operate on. By default, all files with
|
1284
|
+
* extension `".cjs"` or those in `extensions` are included, but you can
|
1285
|
+
* narrow this list by only including specific files. These files will be
|
1286
|
+
* analyzed and transpiled if either the analysis does not find ES module
|
1287
|
+
* specific statements or `transformMixedEsModules` is `true`.
|
1288
|
+
* @default undefined
|
1289
|
+
*/
|
1290
|
+
include?: string | RegExp | readonly (string | RegExp)[]
|
1291
|
+
/**
|
1292
|
+
* A minimatch pattern, or array of patterns, which specifies the files in
|
1293
|
+
* the build the plugin should _ignore_. By default, all files with
|
1294
|
+
* extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
1295
|
+
* can exclude additional files. See also the `include` option.
|
1296
|
+
* @default undefined
|
1297
|
+
*/
|
1298
|
+
exclude?: string | RegExp | readonly (string | RegExp)[]
|
1299
|
+
/**
|
1300
|
+
* For extensionless imports, search for extensions other than .js in the
|
1301
|
+
* order specified. Note that you need to make sure that non-JavaScript files
|
1302
|
+
* are transpiled by another plugin first.
|
1303
|
+
* @default [ '.js' ]
|
1304
|
+
*/
|
1305
|
+
extensions?: ReadonlyArray<string>
|
1306
|
+
/**
|
1307
|
+
* If true then uses of `global` won't be dealt with by this plugin
|
1308
|
+
* @default false
|
1309
|
+
*/
|
1310
|
+
ignoreGlobal?: boolean
|
1311
|
+
/**
|
1312
|
+
* If false, skips source map generation for CommonJS modules. This will
|
1313
|
+
* improve performance.
|
1314
|
+
* @default true
|
1315
|
+
*/
|
1316
|
+
sourceMap?: boolean
|
1317
|
+
/**
|
1318
|
+
* Some `require` calls cannot be resolved statically to be translated to
|
1319
|
+
* imports.
|
1320
|
+
* When this option is set to `false`, the generated code will either
|
1321
|
+
* directly throw an error when such a call is encountered or, when
|
1322
|
+
* `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
1323
|
+
* configured dynamic require target.
|
1324
|
+
* Setting this option to `true` will instead leave the `require` call in the
|
1325
|
+
* code or use it as a fallback for `dynamicRequireTargets`.
|
1326
|
+
* @default false
|
1327
|
+
*/
|
1328
|
+
ignoreDynamicRequires?: boolean
|
1329
|
+
/**
|
1330
|
+
* Instructs the plugin whether to enable mixed module transformations. This
|
1331
|
+
* is useful in scenarios with modules that contain a mix of ES `import`
|
1332
|
+
* statements and CommonJS `require` expressions. Set to `true` if `require`
|
1333
|
+
* calls should be transformed to imports in mixed modules, or `false` if the
|
1334
|
+
* `require` expressions should survive the transformation. The latter can be
|
1335
|
+
* important if the code contains environment detection, or you are coding
|
1336
|
+
* for an environment with special treatment for `require` calls such as
|
1337
|
+
* ElectronJS. See also the `ignore` option.
|
1338
|
+
* @default false
|
1339
|
+
*/
|
1340
|
+
transformMixedEsModules?: boolean
|
1341
|
+
/**
|
1342
|
+
* By default, this plugin will try to hoist `require` statements as imports
|
1343
|
+
* to the top of each file. While this works well for many code bases and
|
1344
|
+
* allows for very efficient ESM output, it does not perfectly capture
|
1345
|
+
* CommonJS semantics as the order of side effects like log statements may
|
1346
|
+
* change. But it is especially problematic when there are circular `require`
|
1347
|
+
* calls between CommonJS modules as those often rely on the lazy execution of
|
1348
|
+
* nested `require` calls.
|
1349
|
+
*
|
1350
|
+
* Setting this option to `true` will wrap all CommonJS files in functions
|
1351
|
+
* which are executed when they are required for the first time, preserving
|
1352
|
+
* NodeJS semantics. Note that this can have an impact on the size and
|
1353
|
+
* performance of the generated code.
|
1354
|
+
*
|
1355
|
+
* The default value of `"auto"` will only wrap CommonJS files when they are
|
1356
|
+
* part of a CommonJS dependency cycle, e.g. an index file that is required by
|
1357
|
+
* many of its dependencies. All other CommonJS files are hoisted. This is the
|
1358
|
+
* recommended setting for most code bases.
|
1359
|
+
*
|
1360
|
+
* `false` will entirely prevent wrapping and hoist all files. This may still
|
1361
|
+
* work depending on the nature of cyclic dependencies but will often cause
|
1362
|
+
* problems.
|
1363
|
+
*
|
1364
|
+
* You can also provide a minimatch pattern, or array of patterns, to only
|
1365
|
+
* specify a subset of files which should be wrapped in functions for proper
|
1366
|
+
* `require` semantics.
|
1367
|
+
*
|
1368
|
+
* `"debug"` works like `"auto"` but after bundling, it will display a warning
|
1369
|
+
* containing a list of ids that have been wrapped which can be used as
|
1370
|
+
* minimatch pattern for fine-tuning.
|
1371
|
+
* @default "auto"
|
1372
|
+
*/
|
1373
|
+
strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[]
|
1374
|
+
/**
|
1375
|
+
* Sometimes you have to leave require statements unconverted. Pass an array
|
1376
|
+
* containing the IDs or a `id => boolean` function.
|
1377
|
+
* @default []
|
1378
|
+
*/
|
1379
|
+
ignore?: ReadonlyArray<string> | ((id: string) => boolean)
|
1380
|
+
/**
|
1381
|
+
* In most cases, where `require` calls are inside a `try-catch` clause,
|
1382
|
+
* they should be left unconverted as it requires an optional dependency
|
1383
|
+
* that may or may not be installed beside the rolled up package.
|
1384
|
+
* Due to the conversion of `require` to a static `import` - the call is
|
1385
|
+
* hoisted to the top of the file, outside the `try-catch` clause.
|
1386
|
+
*
|
1387
|
+
* - `true`: Default. All `require` calls inside a `try` will be left unconverted.
|
1388
|
+
* - `false`: All `require` calls inside a `try` will be converted as if the
|
1389
|
+
* `try-catch` clause is not there.
|
1390
|
+
* - `remove`: Remove all `require` calls from inside any `try` block.
|
1391
|
+
* - `string[]`: Pass an array containing the IDs to left unconverted.
|
1392
|
+
* - `((id: string) => boolean|'remove')`: Pass a function that controls
|
1393
|
+
* individual IDs.
|
1394
|
+
*
|
1395
|
+
* @default true
|
1396
|
+
*/
|
1397
|
+
ignoreTryCatch?:
|
1398
|
+
| boolean
|
1399
|
+
| 'remove'
|
1400
|
+
| ReadonlyArray<string>
|
1401
|
+
| ((id: string) => boolean | 'remove')
|
1402
|
+
/**
|
1403
|
+
* Controls how to render imports from external dependencies. By default,
|
1404
|
+
* this plugin assumes that all external dependencies are CommonJS. This
|
1405
|
+
* means they are rendered as default imports to be compatible with e.g.
|
1406
|
+
* NodeJS where ES modules can only import a default export from a CommonJS
|
1407
|
+
* dependency.
|
1408
|
+
*
|
1409
|
+
* If you set `esmExternals` to `true`, this plugin assumes that all
|
1410
|
+
* external dependencies are ES modules and respect the
|
1411
|
+
* `requireReturnsDefault` option. If that option is not set, they will be
|
1412
|
+
* rendered as namespace imports.
|
1413
|
+
*
|
1414
|
+
* You can also supply an array of ids to be treated as ES modules, or a
|
1415
|
+
* function that will be passed each external id to determine whether it is
|
1416
|
+
* an ES module.
|
1417
|
+
* @default false
|
1418
|
+
*/
|
1419
|
+
esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
|
1420
|
+
/**
|
1421
|
+
* Controls what is returned when requiring an ES module from a CommonJS file.
|
1422
|
+
* When using the `esmExternals` option, this will also apply to external
|
1423
|
+
* modules. By default, this plugin will render those imports as namespace
|
1424
|
+
* imports i.e.
|
1425
|
+
*
|
1426
|
+
* ```js
|
1427
|
+
* // input
|
1428
|
+
* const foo = require('foo');
|
1429
|
+
*
|
1430
|
+
* // output
|
1431
|
+
* import * as foo from 'foo';
|
1432
|
+
* ```
|
1433
|
+
*
|
1434
|
+
* However, there are some situations where this may not be desired.
|
1435
|
+
* For these situations, you can change Rollup's behaviour either globally or
|
1436
|
+
* per module. To change it globally, set the `requireReturnsDefault` option
|
1437
|
+
* to one of the following values:
|
1438
|
+
*
|
1439
|
+
* - `false`: This is the default, requiring an ES module returns its
|
1440
|
+
* namespace. This is the only option that will also add a marker
|
1441
|
+
* `__esModule: true` to the namespace to support interop patterns in
|
1442
|
+
* CommonJS modules that are transpiled ES modules.
|
1443
|
+
* - `"namespace"`: Like `false`, requiring an ES module returns its
|
1444
|
+
* namespace, but the plugin does not add the `__esModule` marker and thus
|
1445
|
+
* creates more efficient code. For external dependencies when using
|
1446
|
+
* `esmExternals: true`, no additional interop code is generated.
|
1447
|
+
* - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
1448
|
+
* Rollup: If a module has a default export and no named exports, requiring
|
1449
|
+
* that module returns the default export. In all other cases, the namespace
|
1450
|
+
* is returned. For external dependencies when using `esmExternals: true`, a
|
1451
|
+
* corresponding interop helper is added.
|
1452
|
+
* - `"preferred"`: If a module has a default export, requiring that module
|
1453
|
+
* always returns the default export, no matter whether additional named
|
1454
|
+
* exports exist. This is similar to how previous versions of this plugin
|
1455
|
+
* worked. Again for external dependencies when using `esmExternals: true`,
|
1456
|
+
* an interop helper is added.
|
1457
|
+
* - `true`: This will always try to return the default export on require
|
1458
|
+
* without checking if it actually exists. This can throw at build time if
|
1459
|
+
* there is no default export. This is how external dependencies are handled
|
1460
|
+
* when `esmExternals` is not used. The advantage over the other options is
|
1461
|
+
* that, like `false`, this does not add an interop helper for external
|
1462
|
+
* dependencies, keeping the code lean.
|
1463
|
+
*
|
1464
|
+
* To change this for individual modules, you can supply a function for
|
1465
|
+
* `requireReturnsDefault` instead. This function will then be called once for
|
1466
|
+
* each required ES module or external dependency with the corresponding id
|
1467
|
+
* and allows you to return different values for different modules.
|
1468
|
+
* @default false
|
1469
|
+
*/
|
1470
|
+
requireReturnsDefault?:
|
1471
|
+
| boolean
|
1472
|
+
| 'auto'
|
1473
|
+
| 'preferred'
|
1474
|
+
| 'namespace'
|
1475
|
+
| ((id: string) => boolean | 'auto' | 'preferred' | 'namespace')
|
1476
|
+
|
1477
|
+
/**
|
1478
|
+
* @default "auto"
|
1479
|
+
*/
|
1480
|
+
defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto')
|
1481
|
+
/**
|
1482
|
+
* Some modules contain dynamic `require` calls, or require modules that
|
1483
|
+
* contain circular dependencies, which are not handled well by static
|
1484
|
+
* imports. Including those modules as `dynamicRequireTargets` will simulate a
|
1485
|
+
* CommonJS (NodeJS-like) environment for them with support for dynamic
|
1486
|
+
* dependencies. It also enables `strictRequires` for those modules.
|
1487
|
+
*
|
1488
|
+
* Note: In extreme cases, this feature may result in some paths being
|
1489
|
+
* rendered as absolute in the final bundle. The plugin tries to avoid
|
1490
|
+
* exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
1491
|
+
* with paths that are far away from your project's folder, that may require
|
1492
|
+
* replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
|
1493
|
+
*/
|
1494
|
+
dynamicRequireTargets?: string | ReadonlyArray<string>
|
1495
|
+
/**
|
1496
|
+
* To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
|
1497
|
+
* that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
|
1498
|
+
* may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
|
1499
|
+
* home directory name. By default, it uses the current working directory.
|
1500
|
+
*/
|
1501
|
+
dynamicRequireRoot?: string
|
1782
1502
|
}
|
1783
|
-
type ModuleSetNames = 'acceptedHmrDeps' | 'importedModules';
|
1784
1503
|
|
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;
|
1824
|
-
}
|
1825
|
-
interface HMRChannel {
|
1826
|
-
/**
|
1827
|
-
* Unique channel name
|
1828
|
-
*/
|
1829
|
-
name: string;
|
1830
|
-
/**
|
1831
|
-
* Broadcast events to all clients
|
1832
|
-
*/
|
1833
|
-
send(payload: HMRPayload): void;
|
1834
|
-
/**
|
1835
|
-
* Send custom event
|
1836
|
-
*/
|
1837
|
-
send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
|
1838
|
-
/**
|
1839
|
-
* Handle custom event emitted by `import.meta.hot.send`
|
1840
|
-
*/
|
1841
|
-
on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client: HMRBroadcasterClient, ...args: any[]) => void): void;
|
1842
|
-
on(event: 'connection', listener: () => void): void;
|
1843
|
-
/**
|
1844
|
-
* Unregister event listener
|
1845
|
-
*/
|
1846
|
-
off(event: string, listener: Function): void;
|
1847
|
-
/**
|
1848
|
-
* Start listening for messages
|
1849
|
-
*/
|
1850
|
-
listen(): void;
|
1851
|
-
/**
|
1852
|
-
* Disconnect all clients, called when server is closed or restarted.
|
1853
|
-
*/
|
1854
|
-
close(): void;
|
1855
|
-
}
|
1856
|
-
interface HMRBroadcaster extends Omit<HMRChannel, 'close' | 'name'> {
|
1857
|
-
/**
|
1858
|
-
* All registered channels. Always has websocket channel.
|
1859
|
-
*/
|
1860
|
-
readonly channels: HMRChannel[];
|
1861
|
-
/**
|
1862
|
-
* Add a new third-party channel.
|
1863
|
-
*/
|
1864
|
-
addChannel(connection: HMRChannel): HMRBroadcaster;
|
1865
|
-
close(): Promise<unknown[]>;
|
1866
|
-
}
|
1867
|
-
interface ServerHMRChannel extends HMRChannel {
|
1868
|
-
api: {
|
1869
|
-
innerEmitter: EventEmitter;
|
1870
|
-
outsideEmitter: EventEmitter;
|
1871
|
-
};
|
1504
|
+
interface RollupDynamicImportVarsOptions {
|
1505
|
+
/**
|
1506
|
+
* Files to include in this plugin (default all).
|
1507
|
+
* @default []
|
1508
|
+
*/
|
1509
|
+
include?: string | RegExp | (string | RegExp)[]
|
1510
|
+
/**
|
1511
|
+
* Files to exclude in this plugin (default none).
|
1512
|
+
* @default []
|
1513
|
+
*/
|
1514
|
+
exclude?: string | RegExp | (string | RegExp)[]
|
1515
|
+
/**
|
1516
|
+
* 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.
|
1517
|
+
* @default false
|
1518
|
+
*/
|
1519
|
+
warnOnError?: boolean
|
1872
1520
|
}
|
1873
1521
|
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1522
|
+
// Modified and inlined to avoid extra dependency
|
1523
|
+
// Source: https://github.com/terser/terser/blob/master/tools/terser.d.ts
|
1524
|
+
// BSD Licensed https://github.com/terser/terser/blob/master/LICENSE
|
1525
|
+
|
1526
|
+
declare namespace Terser {
|
1527
|
+
export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
|
1528
|
+
|
1529
|
+
export interface ParseOptions {
|
1530
|
+
bare_returns?: boolean
|
1531
|
+
/** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
|
1532
|
+
ecma?: ECMA
|
1533
|
+
html5_comments?: boolean
|
1534
|
+
shebang?: boolean
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
export interface CompressOptions {
|
1538
|
+
arguments?: boolean
|
1539
|
+
arrows?: boolean
|
1540
|
+
booleans_as_integers?: boolean
|
1541
|
+
booleans?: boolean
|
1542
|
+
collapse_vars?: boolean
|
1543
|
+
comparisons?: boolean
|
1544
|
+
computed_props?: boolean
|
1545
|
+
conditionals?: boolean
|
1546
|
+
dead_code?: boolean
|
1547
|
+
defaults?: boolean
|
1548
|
+
directives?: boolean
|
1549
|
+
drop_console?: boolean
|
1550
|
+
drop_debugger?: boolean
|
1551
|
+
ecma?: ECMA
|
1552
|
+
evaluate?: boolean
|
1553
|
+
expression?: boolean
|
1554
|
+
global_defs?: object
|
1555
|
+
hoist_funs?: boolean
|
1556
|
+
hoist_props?: boolean
|
1557
|
+
hoist_vars?: boolean
|
1558
|
+
ie8?: boolean
|
1559
|
+
if_return?: boolean
|
1560
|
+
inline?: boolean | InlineFunctions
|
1561
|
+
join_vars?: boolean
|
1562
|
+
keep_classnames?: boolean | RegExp
|
1563
|
+
keep_fargs?: boolean
|
1564
|
+
keep_fnames?: boolean | RegExp
|
1565
|
+
keep_infinity?: boolean
|
1566
|
+
loops?: boolean
|
1567
|
+
module?: boolean
|
1568
|
+
negate_iife?: boolean
|
1569
|
+
passes?: number
|
1570
|
+
properties?: boolean
|
1571
|
+
pure_funcs?: string[]
|
1572
|
+
pure_getters?: boolean | 'strict'
|
1573
|
+
reduce_funcs?: boolean
|
1574
|
+
reduce_vars?: boolean
|
1575
|
+
sequences?: boolean | number
|
1576
|
+
side_effects?: boolean
|
1577
|
+
switches?: boolean
|
1578
|
+
toplevel?: boolean
|
1579
|
+
top_retain?: null | string | string[] | RegExp
|
1580
|
+
typeofs?: boolean
|
1581
|
+
unsafe_arrows?: boolean
|
1582
|
+
unsafe?: boolean
|
1583
|
+
unsafe_comps?: boolean
|
1584
|
+
unsafe_Function?: boolean
|
1585
|
+
unsafe_math?: boolean
|
1586
|
+
unsafe_symbols?: boolean
|
1587
|
+
unsafe_methods?: boolean
|
1588
|
+
unsafe_proto?: boolean
|
1589
|
+
unsafe_regexp?: boolean
|
1590
|
+
unsafe_undefined?: boolean
|
1591
|
+
unused?: boolean
|
1592
|
+
}
|
1593
|
+
|
1594
|
+
export enum InlineFunctions {
|
1595
|
+
Disabled = 0,
|
1596
|
+
SimpleFunctions = 1,
|
1597
|
+
WithArguments = 2,
|
1598
|
+
WithArgumentsAndVariables = 3,
|
1599
|
+
}
|
1600
|
+
|
1601
|
+
export interface MangleOptions {
|
1602
|
+
eval?: boolean
|
1603
|
+
keep_classnames?: boolean | RegExp
|
1604
|
+
keep_fnames?: boolean | RegExp
|
1605
|
+
module?: boolean
|
1606
|
+
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
1607
|
+
properties?: boolean | ManglePropertiesOptions
|
1608
|
+
reserved?: string[]
|
1609
|
+
safari10?: boolean
|
1610
|
+
toplevel?: boolean
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
/**
|
1614
|
+
* An identifier mangler for which the output is invariant with respect to the source code.
|
1615
|
+
*/
|
1616
|
+
export interface SimpleIdentifierMangler {
|
1880
1617
|
/**
|
1881
|
-
*
|
1618
|
+
* Obtains the nth most favored (usually shortest) identifier to rename a variable to.
|
1619
|
+
* The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
|
1620
|
+
* This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
|
1621
|
+
* @param n - The ordinal of the identifier.
|
1882
1622
|
*/
|
1883
|
-
|
1623
|
+
get(n: number): string
|
1624
|
+
}
|
1625
|
+
|
1626
|
+
/**
|
1627
|
+
* An identifier mangler that leverages character frequency analysis to determine identifier precedence.
|
1628
|
+
*/
|
1629
|
+
export interface WeightedIdentifierMangler extends SimpleIdentifierMangler {
|
1884
1630
|
/**
|
1885
|
-
*
|
1631
|
+
* Modifies the internal weighting of the input characters by the specified delta.
|
1632
|
+
* Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
|
1633
|
+
* @param chars - The characters to modify the weighting of.
|
1634
|
+
* @param delta - The numeric weight to add to the characters.
|
1886
1635
|
*/
|
1887
|
-
|
1636
|
+
consider(chars: string, delta: number): number
|
1888
1637
|
/**
|
1889
|
-
*
|
1638
|
+
* Resets character weights.
|
1890
1639
|
*/
|
1891
|
-
|
1892
|
-
<T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
|
1893
|
-
};
|
1640
|
+
reset(): void
|
1894
1641
|
/**
|
1895
|
-
*
|
1642
|
+
* Sorts identifiers by character frequency, in preparation for calls to get(n).
|
1896
1643
|
*/
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1644
|
+
sort(): void
|
1645
|
+
}
|
1646
|
+
|
1647
|
+
export interface ManglePropertiesOptions {
|
1648
|
+
builtins?: boolean
|
1649
|
+
debug?: boolean
|
1650
|
+
keep_quoted?: boolean | 'strict'
|
1651
|
+
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
1652
|
+
regex?: RegExp | string
|
1653
|
+
reserved?: string[]
|
1654
|
+
}
|
1655
|
+
|
1656
|
+
export interface FormatOptions {
|
1657
|
+
ascii_only?: boolean
|
1658
|
+
/** @deprecated Not implemented anymore */
|
1659
|
+
beautify?: boolean
|
1660
|
+
braces?: boolean
|
1661
|
+
comments?:
|
1662
|
+
| boolean
|
1663
|
+
| 'all'
|
1664
|
+
| 'some'
|
1665
|
+
| RegExp
|
1666
|
+
| ((
|
1667
|
+
node: any,
|
1668
|
+
comment: {
|
1669
|
+
value: string
|
1670
|
+
type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
|
1671
|
+
pos: number
|
1672
|
+
line: number
|
1673
|
+
col: number
|
1674
|
+
},
|
1675
|
+
) => boolean)
|
1676
|
+
ecma?: ECMA
|
1677
|
+
ie8?: boolean
|
1678
|
+
keep_numbers?: boolean
|
1679
|
+
indent_level?: number
|
1680
|
+
indent_start?: number
|
1681
|
+
inline_script?: boolean
|
1682
|
+
keep_quoted_props?: boolean
|
1683
|
+
max_line_len?: number | false
|
1684
|
+
preamble?: string
|
1685
|
+
preserve_annotations?: boolean
|
1686
|
+
quote_keys?: boolean
|
1687
|
+
quote_style?: OutputQuoteStyle
|
1688
|
+
safari10?: boolean
|
1689
|
+
semicolons?: boolean
|
1690
|
+
shebang?: boolean
|
1691
|
+
shorthand?: boolean
|
1692
|
+
source_map?: SourceMapOptions
|
1693
|
+
webkit?: boolean
|
1694
|
+
width?: number
|
1695
|
+
wrap_iife?: boolean
|
1696
|
+
wrap_func_args?: boolean
|
1697
|
+
}
|
1698
|
+
|
1699
|
+
export enum OutputQuoteStyle {
|
1700
|
+
PreferDouble = 0,
|
1701
|
+
AlwaysSingle = 1,
|
1702
|
+
AlwaysDouble = 2,
|
1703
|
+
AlwaysOriginal = 3,
|
1704
|
+
}
|
1705
|
+
|
1706
|
+
export interface MinifyOptions {
|
1707
|
+
compress?: boolean | CompressOptions
|
1708
|
+
ecma?: ECMA
|
1709
|
+
enclose?: boolean | string
|
1710
|
+
ie8?: boolean
|
1711
|
+
keep_classnames?: boolean | RegExp
|
1712
|
+
keep_fnames?: boolean | RegExp
|
1713
|
+
mangle?: boolean | MangleOptions
|
1714
|
+
module?: boolean
|
1715
|
+
nameCache?: object
|
1716
|
+
format?: FormatOptions
|
1717
|
+
/** @deprecated deprecated */
|
1718
|
+
output?: FormatOptions
|
1719
|
+
parse?: ParseOptions
|
1720
|
+
safari10?: boolean
|
1721
|
+
sourceMap?: boolean | SourceMapOptions
|
1722
|
+
toplevel?: boolean
|
1723
|
+
}
|
1724
|
+
|
1725
|
+
export interface MinifyOutput {
|
1726
|
+
code?: string
|
1727
|
+
map?: object | string
|
1728
|
+
decoded_map?: object | null
|
1729
|
+
}
|
1730
|
+
|
1731
|
+
export interface SourceMapOptions {
|
1732
|
+
/** Source map object, 'inline' or source map file content */
|
1733
|
+
content?: object | string
|
1734
|
+
includeSources?: boolean
|
1735
|
+
filename?: string
|
1736
|
+
root?: string
|
1737
|
+
url?: string | 'inline'
|
1738
|
+
}
|
1900
1739
|
}
|
1901
|
-
|
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;
|
1740
|
+
|
1741
|
+
interface TerserOptions extends Terser.MinifyOptions {
|
1910
1742
|
/**
|
1911
|
-
*
|
1912
|
-
*
|
1743
|
+
* Vite-specific option to specify the max number of workers to spawn
|
1744
|
+
* when minifying files with terser.
|
1745
|
+
*
|
1746
|
+
* @default number of CPUs minus 1
|
1913
1747
|
*/
|
1914
|
-
|
1748
|
+
maxWorkers?: number;
|
1915
1749
|
}
|
1916
1750
|
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
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;
|
1751
|
+
/** Cache for package.json resolution and package.json contents */
|
1752
|
+
type PackageCache = Map<string, PackageData>;
|
1753
|
+
interface PackageData {
|
1754
|
+
dir: string;
|
1755
|
+
hasSideEffects: (id: string) => boolean | 'no-treeshake' | null;
|
1756
|
+
webResolvedImports: Record<string, string | undefined>;
|
1757
|
+
nodeResolvedImports: Record<string, string | undefined>;
|
1758
|
+
setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
|
1759
|
+
getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
|
1760
|
+
data: {
|
1761
|
+
[field: string]: any;
|
1762
|
+
name: string;
|
1763
|
+
type: string;
|
1764
|
+
version: string;
|
1765
|
+
main: string;
|
1766
|
+
module: string;
|
1767
|
+
browser: string | Record<string, string | false>;
|
1768
|
+
exports: string | Record<string, any> | string[];
|
1769
|
+
imports: Record<string, any>;
|
1770
|
+
dependencies: Record<string, string>;
|
1771
|
+
};
|
1772
|
+
}
|
1773
|
+
|
1774
|
+
interface BuildEnvironmentOptions {
|
1958
1775
|
/**
|
1959
|
-
*
|
1776
|
+
* Compatibility transform target. The transform is performed with esbuild
|
1777
|
+
* and the lowest supported target is es2015/es6. Note this only handles
|
1778
|
+
* syntax transformation and does not cover polyfills (except for dynamic
|
1779
|
+
* import)
|
1960
1780
|
*
|
1961
|
-
*
|
1781
|
+
* Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
|
1782
|
+
* transpile targeting browsers that natively support dynamic es module imports.
|
1783
|
+
* https://caniuse.com/es6-module-dynamic-import
|
1784
|
+
*
|
1785
|
+
* Another special value is 'esnext' - which only performs minimal transpiling
|
1786
|
+
* (for minification compat) and assumes native dynamic imports support.
|
1787
|
+
*
|
1788
|
+
* For custom targets, see https://esbuild.github.io/api/#target and
|
1789
|
+
* https://esbuild.github.io/content-types/#javascript for more details.
|
1790
|
+
* @default 'modules'
|
1962
1791
|
*/
|
1963
|
-
|
1792
|
+
target?: 'modules' | esbuild_TransformOptions['target'] | false;
|
1964
1793
|
/**
|
1965
|
-
*
|
1794
|
+
* whether to inject module preload polyfill.
|
1795
|
+
* Note: does not apply to library mode.
|
1966
1796
|
* @default true
|
1967
|
-
* @deprecated use
|
1797
|
+
* @deprecated use `modulePreload.polyfill` instead
|
1968
1798
|
*/
|
1969
|
-
|
1799
|
+
polyfillModulePreload?: boolean;
|
1970
1800
|
/**
|
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
|
1801
|
+
* Configure module preload
|
1802
|
+
* Note: does not apply to library mode.
|
1803
|
+
* @default true
|
1978
1804
|
*/
|
1979
|
-
|
1805
|
+
modulePreload?: boolean | ModulePreloadOptions;
|
1980
1806
|
/**
|
1981
|
-
*
|
1982
|
-
*
|
1807
|
+
* Directory relative from `root` where build output will be placed. If the
|
1808
|
+
* directory exists, it will be removed before the build.
|
1809
|
+
* @default 'dist'
|
1983
1810
|
*/
|
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 {
|
1811
|
+
outDir?: string;
|
1992
1812
|
/**
|
1993
|
-
*
|
1994
|
-
*
|
1995
|
-
*
|
1996
|
-
*
|
1997
|
-
* @default true
|
1813
|
+
* Directory relative from `outDir` where the built js/css/image assets will
|
1814
|
+
* be placed.
|
1815
|
+
* @default 'assets'
|
1998
1816
|
*/
|
1999
|
-
|
1817
|
+
assetsDir?: string;
|
2000
1818
|
/**
|
2001
|
-
*
|
2002
|
-
*
|
2003
|
-
*
|
2004
|
-
* Will try to search up for workspace root by default.
|
1819
|
+
* Static asset files smaller than this number (in bytes) will be inlined as
|
1820
|
+
* base64 strings. Default limit is `4096` (4 KiB). Set to `0` to disable.
|
1821
|
+
* @default 4096
|
2005
1822
|
*/
|
2006
|
-
|
1823
|
+
assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
|
2007
1824
|
/**
|
2008
|
-
*
|
2009
|
-
*
|
2010
|
-
*
|
2011
|
-
*
|
2012
|
-
*
|
2013
|
-
* @default ['.env', '.env.*', '*.crt', '*.pem']
|
1825
|
+
* Whether to code-split CSS. When enabled, CSS in async chunks will be
|
1826
|
+
* inlined as strings in the chunk and inserted via dynamically created
|
1827
|
+
* style tags when the chunk is loaded.
|
1828
|
+
* @default true
|
2014
1829
|
*/
|
2015
|
-
|
1830
|
+
cssCodeSplit?: boolean;
|
2016
1831
|
/**
|
2017
|
-
*
|
2018
|
-
*
|
2019
|
-
*
|
2020
|
-
*
|
1832
|
+
* An optional separate target for CSS minification.
|
1833
|
+
* As esbuild only supports configuring targets to mainstream
|
1834
|
+
* browsers, users may need this option when they are targeting
|
1835
|
+
* a niche browser that comes with most modern JavaScript features
|
1836
|
+
* but has poor CSS support, e.g. Android WeChat WebView, which
|
1837
|
+
* doesn't support the #RGBA syntax.
|
1838
|
+
* @default target
|
2021
1839
|
*/
|
2022
|
-
|
2023
|
-
}
|
2024
|
-
type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
2025
|
-
type HttpServer = http.Server | Http2SecureServer;
|
2026
|
-
interface ViteDevServer {
|
1840
|
+
cssTarget?: esbuild_TransformOptions['target'] | false;
|
2027
1841
|
/**
|
2028
|
-
*
|
1842
|
+
* Override CSS minification specifically instead of defaulting to `build.minify`,
|
1843
|
+
* so you can configure minification for JS and CSS separately.
|
1844
|
+
* @default 'esbuild'
|
2029
1845
|
*/
|
2030
|
-
|
1846
|
+
cssMinify?: boolean | 'esbuild' | 'lightningcss';
|
2031
1847
|
/**
|
2032
|
-
*
|
2033
|
-
*
|
2034
|
-
*
|
2035
|
-
*
|
2036
|
-
*
|
2037
|
-
* https://github.com/senchalabs/connect#use-middleware
|
1848
|
+
* If `true`, a separate sourcemap file will be created. If 'inline', the
|
1849
|
+
* sourcemap will be appended to the resulting output file as data URI.
|
1850
|
+
* 'hidden' works like `true` except that the corresponding sourcemap
|
1851
|
+
* comments in the bundled files are suppressed.
|
1852
|
+
* @default false
|
2038
1853
|
*/
|
2039
|
-
|
1854
|
+
sourcemap?: boolean | 'inline' | 'hidden';
|
2040
1855
|
/**
|
2041
|
-
*
|
2042
|
-
*
|
1856
|
+
* Set to `false` to disable minification, or specify the minifier to use.
|
1857
|
+
* Available options are 'terser' or 'esbuild'.
|
1858
|
+
* @default 'esbuild'
|
2043
1859
|
*/
|
2044
|
-
|
1860
|
+
minify?: boolean | 'terser' | 'esbuild';
|
2045
1861
|
/**
|
2046
|
-
*
|
2047
|
-
* https://
|
1862
|
+
* Options for terser
|
1863
|
+
* https://terser.org/docs/api-reference#minify-options
|
1864
|
+
*
|
1865
|
+
* In addition, you can also pass a `maxWorkers: number` option to specify the
|
1866
|
+
* max number of workers to spawn. Defaults to the number of CPUs minus 1.
|
2048
1867
|
*/
|
2049
|
-
|
1868
|
+
terserOptions?: TerserOptions;
|
2050
1869
|
/**
|
2051
|
-
*
|
2052
|
-
*
|
1870
|
+
* Will be merged with internal rollup options.
|
1871
|
+
* https://rollupjs.org/configuration-options/
|
2053
1872
|
*/
|
2054
|
-
|
1873
|
+
rollupOptions?: RollupOptions;
|
2055
1874
|
/**
|
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
|
1875
|
+
* Options to pass on to `@rollup/plugin-commonjs`
|
2061
1876
|
*/
|
2062
|
-
|
1877
|
+
commonjsOptions?: RollupCommonJSOptions;
|
2063
1878
|
/**
|
2064
|
-
*
|
2065
|
-
* @deprecated use `environment.pluginContainer` instead
|
1879
|
+
* Options to pass on to `@rollup/plugin-dynamic-import-vars`
|
2066
1880
|
*/
|
2067
|
-
|
1881
|
+
dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
|
2068
1882
|
/**
|
2069
|
-
*
|
1883
|
+
* Whether to write bundle to disk
|
1884
|
+
* @default true
|
2070
1885
|
*/
|
2071
|
-
|
1886
|
+
write?: boolean;
|
2072
1887
|
/**
|
2073
|
-
*
|
2074
|
-
*
|
2075
|
-
* @deprecated use `environment.moduleGraph` instead
|
1888
|
+
* Empty outDir on write.
|
1889
|
+
* @default true when outDir is a sub directory of project root
|
2076
1890
|
*/
|
2077
|
-
|
1891
|
+
emptyOutDir?: boolean | null;
|
2078
1892
|
/**
|
2079
|
-
*
|
2080
|
-
*
|
1893
|
+
* Copy the public directory to outDir on write.
|
1894
|
+
* @default true
|
2081
1895
|
*/
|
2082
|
-
|
1896
|
+
copyPublicDir?: boolean;
|
2083
1897
|
/**
|
2084
|
-
*
|
2085
|
-
*
|
2086
|
-
*
|
1898
|
+
* Whether to emit a .vite/manifest.json under assets dir to map hash-less filenames
|
1899
|
+
* to their hashed versions. Useful when you want to generate your own HTML
|
1900
|
+
* instead of using the one generated by Vite.
|
1901
|
+
*
|
1902
|
+
* Example:
|
1903
|
+
*
|
1904
|
+
* ```json
|
1905
|
+
* {
|
1906
|
+
* "main.js": {
|
1907
|
+
* "file": "main.68fe3fad.js",
|
1908
|
+
* "css": "main.e6b63442.css",
|
1909
|
+
* "imports": [...],
|
1910
|
+
* "dynamicImports": [...]
|
1911
|
+
* }
|
1912
|
+
* }
|
1913
|
+
* ```
|
1914
|
+
* @default false
|
2087
1915
|
*/
|
2088
|
-
|
1916
|
+
manifest?: boolean | string;
|
2089
1917
|
/**
|
2090
|
-
*
|
2091
|
-
*
|
2092
|
-
*
|
2093
|
-
* @deprecated use environment.warmupRequest
|
1918
|
+
* Produce SSR oriented build. Note this requires specifying SSR entry via
|
1919
|
+
* `rollupOptions.input`.
|
1920
|
+
* @default false
|
2094
1921
|
*/
|
2095
|
-
|
1922
|
+
ssr?: boolean | string;
|
2096
1923
|
/**
|
2097
|
-
*
|
1924
|
+
* Generate SSR manifest for determining style links and asset preload
|
1925
|
+
* directives in production.
|
1926
|
+
* @default false
|
2098
1927
|
*/
|
2099
|
-
|
1928
|
+
ssrManifest?: boolean | string;
|
2100
1929
|
/**
|
2101
|
-
*
|
2102
|
-
*
|
1930
|
+
* Emit assets during SSR.
|
1931
|
+
* @default false
|
1932
|
+
* @deprecated use emitAssets
|
2103
1933
|
*/
|
2104
|
-
|
2105
|
-
mappings: '';
|
2106
|
-
} | null, url: string, originalCode?: string): Promise<TransformResult | null>;
|
1934
|
+
ssrEmitAssets?: boolean;
|
2107
1935
|
/**
|
2108
|
-
*
|
1936
|
+
* Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
|
1937
|
+
* By default, it is true for the client and false for other environments.
|
1938
|
+
* TODO: Should this be true for all environments by default? Or should this be
|
1939
|
+
* controlled by the builder so so we can avoid emitting duplicated assets.
|
2109
1940
|
*/
|
2110
|
-
|
2111
|
-
fixStacktrace?: boolean;
|
2112
|
-
}): Promise<Record<string, any>>;
|
1941
|
+
emitAssets?: boolean;
|
2113
1942
|
/**
|
2114
|
-
*
|
1943
|
+
* Set to false to disable reporting compressed chunk sizes.
|
1944
|
+
* Can slightly improve build speed.
|
1945
|
+
* @default true
|
2115
1946
|
*/
|
2116
|
-
|
1947
|
+
reportCompressedSize?: boolean;
|
2117
1948
|
/**
|
2118
|
-
*
|
1949
|
+
* Adjust chunk size warning limit (in kB).
|
1950
|
+
* @default 500
|
2119
1951
|
*/
|
2120
|
-
|
1952
|
+
chunkSizeWarningLimit?: number;
|
2121
1953
|
/**
|
2122
|
-
*
|
2123
|
-
*
|
1954
|
+
* Rollup watch options
|
1955
|
+
* https://rollupjs.org/configuration-options/#watch
|
1956
|
+
* @default null
|
2124
1957
|
*/
|
2125
|
-
|
1958
|
+
watch?: WatcherOptions | null;
|
2126
1959
|
/**
|
2127
|
-
*
|
2128
|
-
* If `hmr` is false, this is a no-op.
|
1960
|
+
* create the Build Environment instance
|
2129
1961
|
*/
|
2130
|
-
|
1962
|
+
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
|
1963
|
+
}
|
1964
|
+
interface BuildOptions extends BuildEnvironmentOptions {
|
2131
1965
|
/**
|
2132
|
-
*
|
1966
|
+
* Build in library mode. The value should be the global name of the lib in
|
1967
|
+
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
1968
|
+
* configurations that are suitable for distributing libraries.
|
1969
|
+
* @default false
|
2133
1970
|
*/
|
2134
|
-
|
1971
|
+
lib?: LibraryOptions | false;
|
1972
|
+
}
|
1973
|
+
interface LibraryOptions {
|
2135
1974
|
/**
|
2136
|
-
*
|
1975
|
+
* Path of library entry
|
2137
1976
|
*/
|
2138
|
-
|
1977
|
+
entry: InputOption;
|
2139
1978
|
/**
|
2140
|
-
*
|
1979
|
+
* The name of the exposed global variable. Required when the `formats` option includes
|
1980
|
+
* `umd` or `iife`
|
2141
1981
|
*/
|
2142
|
-
|
1982
|
+
name?: string;
|
2143
1983
|
/**
|
2144
|
-
*
|
1984
|
+
* Output bundle formats
|
1985
|
+
* @default ['es', 'umd']
|
2145
1986
|
*/
|
2146
|
-
|
1987
|
+
formats?: LibraryFormats[];
|
2147
1988
|
/**
|
2148
|
-
*
|
2149
|
-
*
|
2150
|
-
*
|
1989
|
+
* The name of the package file output. The default file name is the name option
|
1990
|
+
* of the project package.json. It can also be defined as a function taking the
|
1991
|
+
* format as an argument.
|
2151
1992
|
*/
|
2152
|
-
|
1993
|
+
fileName?: string | ((format: ModuleFormat, entryName: string) => string);
|
1994
|
+
}
|
1995
|
+
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
|
1996
|
+
interface ModulePreloadOptions {
|
2153
1997
|
/**
|
2154
|
-
*
|
1998
|
+
* Whether to inject a module preload polyfill.
|
1999
|
+
* Note: does not apply to library mode.
|
2000
|
+
* @default true
|
2155
2001
|
*/
|
2156
|
-
|
2002
|
+
polyfill?: boolean;
|
2157
2003
|
/**
|
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.
|
2004
|
+
* Resolve the list of dependencies to preload for a given dynamic import
|
2162
2005
|
* @experimental
|
2163
|
-
* @deprecated use environment.waitForRequestsIdle()
|
2164
2006
|
*/
|
2165
|
-
|
2007
|
+
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2166
2008
|
}
|
2167
|
-
interface
|
2168
|
-
|
2169
|
-
|
2009
|
+
interface ResolvedModulePreloadOptions {
|
2010
|
+
polyfill: boolean;
|
2011
|
+
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2170
2012
|
}
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
interface
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2013
|
+
type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
|
2014
|
+
hostId: string;
|
2015
|
+
hostType: 'html' | 'js';
|
2016
|
+
}) => string[];
|
2017
|
+
interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> {
|
2018
|
+
modulePreload: false | ResolvedModulePreloadOptions;
|
2019
|
+
}
|
2020
|
+
interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
|
2021
|
+
modulePreload: false | ResolvedModulePreloadOptions;
|
2022
|
+
}
|
2023
|
+
/**
|
2024
|
+
* Bundles the app for production.
|
2025
|
+
* Returns a Promise containing the build result.
|
2026
|
+
*/
|
2027
|
+
declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2028
|
+
type RenderBuiltAssetUrl = (filename: string, type: {
|
2029
|
+
type: 'asset' | 'public';
|
2030
|
+
hostId: string;
|
2031
|
+
hostType: 'js' | 'css' | 'html';
|
2032
|
+
ssr: boolean;
|
2033
|
+
}) => string | {
|
2034
|
+
relative?: boolean;
|
2035
|
+
runtime?: string;
|
2036
|
+
} | undefined;
|
2037
|
+
declare class BuildEnvironment extends BaseEnvironment {
|
2038
|
+
mode: "build";
|
2039
|
+
constructor(name: string, config: ResolvedConfig, setup?: {
|
2040
|
+
options?: EnvironmentOptions;
|
2041
|
+
});
|
2042
|
+
init(): Promise<void>;
|
2043
|
+
}
|
2044
|
+
interface ViteBuilder {
|
2045
|
+
environments: Record<string, BuildEnvironment>;
|
2046
|
+
config: ResolvedConfig;
|
2047
|
+
buildApp(): Promise<void>;
|
2048
|
+
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2049
|
+
}
|
2050
|
+
interface BuilderOptions {
|
2051
|
+
sharedConfigBuild?: boolean;
|
2052
|
+
sharedPlugins?: boolean;
|
2053
|
+
entireApp?: boolean;
|
2054
|
+
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2194
2055
|
}
|
2056
|
+
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2057
|
+
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2058
|
+
|
2059
|
+
type Environment = DevEnvironment | BuildEnvironment | ScanEnvironment | FutureCompatEnvironment;
|
2060
|
+
|
2061
|
+
/**
|
2062
|
+
* This file is refactored into TypeScript based on
|
2063
|
+
* https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
|
2064
|
+
*/
|
2065
|
+
|
2066
|
+
interface EnvironmentPluginContainer {
|
2067
|
+
options: InputOptions;
|
2068
|
+
buildStart(options: InputOptions): Promise<void>;
|
2069
|
+
resolveId(id: string, importer: string | undefined, options?: {
|
2070
|
+
attributes?: Record<string, string>;
|
2071
|
+
custom?: CustomPluginOptions;
|
2072
|
+
skip?: Set<Plugin>;
|
2073
|
+
isEntry?: boolean;
|
2074
|
+
}): Promise<PartialResolvedId | null>;
|
2075
|
+
transform(code: string, id: string, options?: {
|
2076
|
+
inMap?: SourceDescription['map'];
|
2077
|
+
}): Promise<{
|
2078
|
+
code: string;
|
2079
|
+
map: SourceMap | {
|
2080
|
+
mappings: '';
|
2081
|
+
} | null;
|
2082
|
+
}>;
|
2083
|
+
load(id: string, options?: {}): Promise<LoadResult | null>;
|
2084
|
+
watchChange(id: string, change: {
|
2085
|
+
event: 'create' | 'update' | 'delete';
|
2086
|
+
}): Promise<void>;
|
2087
|
+
close(): Promise<void>;
|
2088
|
+
}
|
2089
|
+
interface PluginContainer {
|
2090
|
+
options: InputOptions;
|
2091
|
+
buildStart(options: InputOptions): Promise<void>;
|
2092
|
+
resolveId(id: string, importer?: string, options?: {
|
2093
|
+
attributes?: Record<string, string>;
|
2094
|
+
custom?: CustomPluginOptions;
|
2095
|
+
skip?: Set<Plugin>;
|
2096
|
+
ssr?: boolean;
|
2097
|
+
environment?: Environment;
|
2098
|
+
isEntry?: boolean;
|
2099
|
+
}): Promise<PartialResolvedId | null>;
|
2100
|
+
transform(code: string, id: string, options?: {
|
2101
|
+
inMap?: SourceDescription['map'];
|
2102
|
+
ssr?: boolean;
|
2103
|
+
environment?: Environment;
|
2104
|
+
}): Promise<{
|
2105
|
+
code: string;
|
2106
|
+
map: SourceMap | {
|
2107
|
+
mappings: '';
|
2108
|
+
} | null;
|
2109
|
+
}>;
|
2110
|
+
load(id: string, options?: {
|
2111
|
+
ssr?: boolean;
|
2112
|
+
environment?: Environment;
|
2113
|
+
}): Promise<LoadResult | null>;
|
2114
|
+
watchChange(id: string, change: {
|
2115
|
+
event: 'create' | 'update' | 'delete';
|
2116
|
+
}): Promise<void>;
|
2117
|
+
close(): Promise<void>;
|
2118
|
+
}
|
2119
|
+
|
2120
|
+
// Modified and inlined to avoid extra dependency
|
2121
|
+
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts
|
2122
|
+
|
2123
|
+
declare const WebSocketAlias: typeof WebSocket
|
2124
|
+
interface WebSocketAlias extends WebSocket {}
|
2125
|
+
// WebSocket socket.
|
2126
|
+
declare class WebSocket extends EventEmitter {
|
2127
|
+
/** The connection is not yet open. */
|
2128
|
+
static readonly CONNECTING: 0
|
2129
|
+
/** The connection is open and ready to communicate. */
|
2130
|
+
static readonly OPEN: 1
|
2131
|
+
/** The connection is in the process of closing. */
|
2132
|
+
static readonly CLOSING: 2
|
2133
|
+
/** The connection is closed. */
|
2134
|
+
static readonly CLOSED: 3
|
2135
|
+
|
2136
|
+
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
|
2137
|
+
readonly bufferedAmount: number
|
2138
|
+
readonly extensions: string
|
2139
|
+
/** Indicates whether the websocket is paused */
|
2140
|
+
readonly isPaused: boolean
|
2141
|
+
readonly protocol: string
|
2142
|
+
/** The current state of the connection */
|
2143
|
+
readonly readyState:
|
2144
|
+
| typeof WebSocket.CONNECTING
|
2145
|
+
| typeof WebSocket.OPEN
|
2146
|
+
| typeof WebSocket.CLOSING
|
2147
|
+
| typeof WebSocket.CLOSED
|
2148
|
+
readonly url: string
|
2149
|
+
|
2150
|
+
/** The connection is not yet open. */
|
2151
|
+
readonly CONNECTING: 0
|
2152
|
+
/** The connection is open and ready to communicate. */
|
2153
|
+
readonly OPEN: 1
|
2154
|
+
/** The connection is in the process of closing. */
|
2155
|
+
readonly CLOSING: 2
|
2156
|
+
/** The connection is closed. */
|
2157
|
+
readonly CLOSED: 3
|
2158
|
+
|
2159
|
+
onopen: ((event: WebSocket.Event) => void) | null
|
2160
|
+
onerror: ((event: WebSocket.ErrorEvent) => void) | null
|
2161
|
+
onclose: ((event: WebSocket.CloseEvent) => void) | null
|
2162
|
+
onmessage: ((event: WebSocket.MessageEvent) => void) | null
|
2163
|
+
|
2164
|
+
constructor(address: null)
|
2165
|
+
constructor(
|
2166
|
+
address: string | URL,
|
2167
|
+
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
2168
|
+
)
|
2169
|
+
constructor(
|
2170
|
+
address: string | URL,
|
2171
|
+
protocols?: string | string[],
|
2172
|
+
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
2173
|
+
)
|
2174
|
+
|
2175
|
+
close(code?: number, data?: string | Buffer): void
|
2176
|
+
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
2177
|
+
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
2178
|
+
send(data: any, cb?: (err?: Error) => void): void
|
2179
|
+
send(
|
2180
|
+
data: any,
|
2181
|
+
options: {
|
2182
|
+
mask?: boolean | undefined
|
2183
|
+
binary?: boolean | undefined
|
2184
|
+
compress?: boolean | undefined
|
2185
|
+
fin?: boolean | undefined
|
2186
|
+
},
|
2187
|
+
cb?: (err?: Error) => void,
|
2188
|
+
): void
|
2189
|
+
terminate(): void
|
2195
2190
|
|
2196
|
-
interface RollupCommonJSOptions {
|
2197
|
-
/**
|
2198
|
-
* A minimatch pattern, or array of patterns, which specifies the files in
|
2199
|
-
* the build the plugin should operate on. By default, all files with
|
2200
|
-
* extension `".cjs"` or those in `extensions` are included, but you can
|
2201
|
-
* narrow this list by only including specific files. These files will be
|
2202
|
-
* analyzed and transpiled if either the analysis does not find ES module
|
2203
|
-
* specific statements or `transformMixedEsModules` is `true`.
|
2204
|
-
* @default undefined
|
2205
|
-
*/
|
2206
|
-
include?: string | RegExp | readonly (string | RegExp)[]
|
2207
|
-
/**
|
2208
|
-
* A minimatch pattern, or array of patterns, which specifies the files in
|
2209
|
-
* the build the plugin should _ignore_. By default, all files with
|
2210
|
-
* extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
2211
|
-
* can exclude additional files. See also the `include` option.
|
2212
|
-
* @default undefined
|
2213
|
-
*/
|
2214
|
-
exclude?: string | RegExp | readonly (string | RegExp)[]
|
2215
|
-
/**
|
2216
|
-
* For extensionless imports, search for extensions other than .js in the
|
2217
|
-
* order specified. Note that you need to make sure that non-JavaScript files
|
2218
|
-
* are transpiled by another plugin first.
|
2219
|
-
* @default [ '.js' ]
|
2220
|
-
*/
|
2221
|
-
extensions?: ReadonlyArray<string>
|
2222
|
-
/**
|
2223
|
-
* If true then uses of `global` won't be dealt with by this plugin
|
2224
|
-
* @default false
|
2225
|
-
*/
|
2226
|
-
ignoreGlobal?: boolean
|
2227
|
-
/**
|
2228
|
-
* If false, skips source map generation for CommonJS modules. This will
|
2229
|
-
* improve performance.
|
2230
|
-
* @default true
|
2231
|
-
*/
|
2232
|
-
sourceMap?: boolean
|
2233
|
-
/**
|
2234
|
-
* Some `require` calls cannot be resolved statically to be translated to
|
2235
|
-
* imports.
|
2236
|
-
* When this option is set to `false`, the generated code will either
|
2237
|
-
* directly throw an error when such a call is encountered or, when
|
2238
|
-
* `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
2239
|
-
* configured dynamic require target.
|
2240
|
-
* Setting this option to `true` will instead leave the `require` call in the
|
2241
|
-
* code or use it as a fallback for `dynamicRequireTargets`.
|
2242
|
-
* @default false
|
2243
|
-
*/
|
2244
|
-
ignoreDynamicRequires?: boolean
|
2245
|
-
/**
|
2246
|
-
* Instructs the plugin whether to enable mixed module transformations. This
|
2247
|
-
* is useful in scenarios with modules that contain a mix of ES `import`
|
2248
|
-
* statements and CommonJS `require` expressions. Set to `true` if `require`
|
2249
|
-
* calls should be transformed to imports in mixed modules, or `false` if the
|
2250
|
-
* `require` expressions should survive the transformation. The latter can be
|
2251
|
-
* important if the code contains environment detection, or you are coding
|
2252
|
-
* for an environment with special treatment for `require` calls such as
|
2253
|
-
* ElectronJS. See also the `ignore` option.
|
2254
|
-
* @default false
|
2255
|
-
*/
|
2256
|
-
transformMixedEsModules?: boolean
|
2257
|
-
/**
|
2258
|
-
* By default, this plugin will try to hoist `require` statements as imports
|
2259
|
-
* to the top of each file. While this works well for many code bases and
|
2260
|
-
* allows for very efficient ESM output, it does not perfectly capture
|
2261
|
-
* CommonJS semantics as the order of side effects like log statements may
|
2262
|
-
* change. But it is especially problematic when there are circular `require`
|
2263
|
-
* calls between CommonJS modules as those often rely on the lazy execution of
|
2264
|
-
* nested `require` calls.
|
2265
|
-
*
|
2266
|
-
* Setting this option to `true` will wrap all CommonJS files in functions
|
2267
|
-
* which are executed when they are required for the first time, preserving
|
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')
|
2318
2191
|
/**
|
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
|
2192
|
+
* Pause the websocket causing it to stop emitting events. Some events can still be
|
2193
|
+
* emitted after this is called, until all buffered data is consumed. This method
|
2194
|
+
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
2334
2195
|
*/
|
2335
|
-
|
2196
|
+
pause(): void
|
2336
2197
|
/**
|
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
|
2198
|
+
* Make a paused socket resume emitting events. This method is a noop if the ready
|
2199
|
+
* state is `CONNECTING` or `CLOSED`.
|
2385
2200
|
*/
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2201
|
+
resume(): void
|
2202
|
+
|
2203
|
+
// HTML5 WebSocket events
|
2204
|
+
addEventListener(
|
2205
|
+
method: 'message',
|
2206
|
+
cb: (event: WebSocket.MessageEvent) => void,
|
2207
|
+
options?: WebSocket.EventListenerOptions,
|
2208
|
+
): void
|
2209
|
+
addEventListener(
|
2210
|
+
method: 'close',
|
2211
|
+
cb: (event: WebSocket.CloseEvent) => void,
|
2212
|
+
options?: WebSocket.EventListenerOptions,
|
2213
|
+
): void
|
2214
|
+
addEventListener(
|
2215
|
+
method: 'error',
|
2216
|
+
cb: (event: WebSocket.ErrorEvent) => void,
|
2217
|
+
options?: WebSocket.EventListenerOptions,
|
2218
|
+
): void
|
2219
|
+
addEventListener(
|
2220
|
+
method: 'open',
|
2221
|
+
cb: (event: WebSocket.Event) => void,
|
2222
|
+
options?: WebSocket.EventListenerOptions,
|
2223
|
+
): void
|
2224
|
+
|
2225
|
+
removeEventListener(
|
2226
|
+
method: 'message',
|
2227
|
+
cb: (event: WebSocket.MessageEvent) => void,
|
2228
|
+
): void
|
2229
|
+
removeEventListener(
|
2230
|
+
method: 'close',
|
2231
|
+
cb: (event: WebSocket.CloseEvent) => void,
|
2232
|
+
): void
|
2233
|
+
removeEventListener(
|
2234
|
+
method: 'error',
|
2235
|
+
cb: (event: WebSocket.ErrorEvent) => void,
|
2236
|
+
): void
|
2237
|
+
removeEventListener(
|
2238
|
+
method: 'open',
|
2239
|
+
cb: (event: WebSocket.Event) => void,
|
2240
|
+
): void
|
2241
|
+
|
2242
|
+
// Events
|
2243
|
+
on(
|
2244
|
+
event: 'close',
|
2245
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2246
|
+
): this
|
2247
|
+
on(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2248
|
+
on(
|
2249
|
+
event: 'upgrade',
|
2250
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2251
|
+
): this
|
2252
|
+
on(
|
2253
|
+
event: 'message',
|
2254
|
+
listener: (
|
2255
|
+
this: WebSocket,
|
2256
|
+
data: WebSocket.RawData,
|
2257
|
+
isBinary: boolean,
|
2258
|
+
) => void,
|
2259
|
+
): this
|
2260
|
+
on(event: 'open', listener: (this: WebSocket) => void): this
|
2261
|
+
on(
|
2262
|
+
event: 'ping' | 'pong',
|
2263
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
2264
|
+
): this
|
2265
|
+
on(
|
2266
|
+
event: 'unexpected-response',
|
2267
|
+
listener: (
|
2268
|
+
this: WebSocket,
|
2269
|
+
request: ClientRequest,
|
2270
|
+
response: IncomingMessage,
|
2271
|
+
) => void,
|
2272
|
+
): this
|
2273
|
+
on(
|
2274
|
+
event: string | symbol,
|
2275
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
2276
|
+
): this
|
2392
2277
|
|
2278
|
+
once(
|
2279
|
+
event: 'close',
|
2280
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2281
|
+
): this
|
2282
|
+
once(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2283
|
+
once(
|
2284
|
+
event: 'upgrade',
|
2285
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2286
|
+
): this
|
2287
|
+
once(
|
2288
|
+
event: 'message',
|
2289
|
+
listener: (
|
2290
|
+
this: WebSocket,
|
2291
|
+
data: WebSocket.RawData,
|
2292
|
+
isBinary: boolean,
|
2293
|
+
) => void,
|
2294
|
+
): this
|
2295
|
+
once(event: 'open', listener: (this: WebSocket) => void): this
|
2296
|
+
once(
|
2297
|
+
event: 'ping' | 'pong',
|
2298
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
2299
|
+
): this
|
2300
|
+
once(
|
2301
|
+
event: 'unexpected-response',
|
2302
|
+
listener: (
|
2303
|
+
this: WebSocket,
|
2304
|
+
request: ClientRequest,
|
2305
|
+
response: IncomingMessage,
|
2306
|
+
) => void,
|
2307
|
+
): this
|
2308
|
+
once(
|
2309
|
+
event: string | symbol,
|
2310
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
2311
|
+
): this
|
2312
|
+
|
2313
|
+
off(
|
2314
|
+
event: 'close',
|
2315
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2316
|
+
): this
|
2317
|
+
off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2318
|
+
off(
|
2319
|
+
event: 'upgrade',
|
2320
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2321
|
+
): this
|
2322
|
+
off(
|
2323
|
+
event: 'message',
|
2324
|
+
listener: (
|
2325
|
+
this: WebSocket,
|
2326
|
+
data: WebSocket.RawData,
|
2327
|
+
isBinary: boolean,
|
2328
|
+
) => void,
|
2329
|
+
): this
|
2330
|
+
off(event: 'open', listener: (this: WebSocket) => void): this
|
2331
|
+
off(
|
2332
|
+
event: 'ping' | 'pong',
|
2333
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
2334
|
+
): this
|
2335
|
+
off(
|
2336
|
+
event: 'unexpected-response',
|
2337
|
+
listener: (
|
2338
|
+
this: WebSocket,
|
2339
|
+
request: ClientRequest,
|
2340
|
+
response: IncomingMessage,
|
2341
|
+
) => void,
|
2342
|
+
): this
|
2343
|
+
off(
|
2344
|
+
event: string | symbol,
|
2345
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
2346
|
+
): this
|
2347
|
+
|
2348
|
+
addListener(
|
2349
|
+
event: 'close',
|
2350
|
+
listener: (code: number, reason: Buffer) => void,
|
2351
|
+
): this
|
2352
|
+
addListener(event: 'error', listener: (err: Error) => void): this
|
2353
|
+
addListener(
|
2354
|
+
event: 'upgrade',
|
2355
|
+
listener: (request: IncomingMessage) => void,
|
2356
|
+
): this
|
2357
|
+
addListener(
|
2358
|
+
event: 'message',
|
2359
|
+
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
2360
|
+
): this
|
2361
|
+
addListener(event: 'open', listener: () => void): this
|
2362
|
+
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
2363
|
+
addListener(
|
2364
|
+
event: 'unexpected-response',
|
2365
|
+
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
2366
|
+
): this
|
2367
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this
|
2368
|
+
|
2369
|
+
removeListener(
|
2370
|
+
event: 'close',
|
2371
|
+
listener: (code: number, reason: Buffer) => void,
|
2372
|
+
): this
|
2373
|
+
removeListener(event: 'error', listener: (err: Error) => void): this
|
2374
|
+
removeListener(
|
2375
|
+
event: 'upgrade',
|
2376
|
+
listener: (request: IncomingMessage) => void,
|
2377
|
+
): this
|
2378
|
+
removeListener(
|
2379
|
+
event: 'message',
|
2380
|
+
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
2381
|
+
): this
|
2382
|
+
removeListener(event: 'open', listener: () => void): this
|
2383
|
+
removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
2384
|
+
removeListener(
|
2385
|
+
event: 'unexpected-response',
|
2386
|
+
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
2387
|
+
): this
|
2388
|
+
removeListener(
|
2389
|
+
event: string | symbol,
|
2390
|
+
listener: (...args: any[]) => void,
|
2391
|
+
): this
|
2392
|
+
}
|
2393
|
+
// tslint:disable-line no-empty-interface
|
2394
|
+
|
2395
|
+
declare namespace WebSocket {
|
2393
2396
|
/**
|
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/"` -\> `"/"`.
|
2397
|
+
* Data represents the raw message payload received over the WebSocket.
|
2409
2398
|
*/
|
2410
|
-
|
2399
|
+
type RawData = Buffer | ArrayBuffer | Buffer[]
|
2400
|
+
|
2411
2401
|
/**
|
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.
|
2402
|
+
* Data represents the message payload received over the WebSocket.
|
2416
2403
|
*/
|
2417
|
-
|
2418
|
-
}
|
2404
|
+
type Data = string | Buffer | ArrayBuffer | Buffer[]
|
2419
2405
|
|
2420
|
-
interface RollupDynamicImportVarsOptions {
|
2421
2406
|
/**
|
2422
|
-
*
|
2423
|
-
* @default []
|
2407
|
+
* CertMeta represents the accepted types for certificate & key data.
|
2424
2408
|
*/
|
2425
|
-
|
2409
|
+
type CertMeta = string | string[] | Buffer | Buffer[]
|
2410
|
+
|
2426
2411
|
/**
|
2427
|
-
*
|
2428
|
-
*
|
2412
|
+
* VerifyClientCallbackSync is a synchronous callback used to inspect the
|
2413
|
+
* incoming message. The return value (boolean) of the function determines
|
2414
|
+
* whether or not to accept the handshake.
|
2429
2415
|
*/
|
2430
|
-
|
2416
|
+
type VerifyClientCallbackSync = (info: {
|
2417
|
+
origin: string
|
2418
|
+
secure: boolean
|
2419
|
+
req: IncomingMessage
|
2420
|
+
}) => boolean
|
2421
|
+
|
2431
2422
|
/**
|
2432
|
-
*
|
2433
|
-
*
|
2423
|
+
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
|
2424
|
+
* incoming message. The return value (boolean) of the function determines
|
2425
|
+
* whether or not to accept the handshake.
|
2434
2426
|
*/
|
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
|
-
}
|
2427
|
+
type VerifyClientCallbackAsync = (
|
2428
|
+
info: { origin: string; secure: boolean; req: IncomingMessage },
|
2429
|
+
callback: (
|
2430
|
+
res: boolean,
|
2431
|
+
code?: number,
|
2432
|
+
message?: string,
|
2433
|
+
headers?: OutgoingHttpHeaders,
|
2434
|
+
) => void,
|
2435
|
+
) => void
|
2452
2436
|
|
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
|
2437
|
+
interface ClientOptions extends SecureContextOptions {
|
2438
|
+
protocol?: string | undefined
|
2439
|
+
followRedirects?: boolean | undefined
|
2440
|
+
generateMask?(mask: Buffer): void
|
2441
|
+
handshakeTimeout?: number | undefined
|
2442
|
+
maxRedirects?: number | undefined
|
2443
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
2444
|
+
localAddress?: string | undefined
|
2445
|
+
protocolVersion?: number | undefined
|
2446
|
+
headers?: { [key: string]: string } | undefined
|
2447
|
+
origin?: string | undefined
|
2448
|
+
agent?: Agent | undefined
|
2449
|
+
host?: string | undefined
|
2450
|
+
family?: number | undefined
|
2451
|
+
checkServerIdentity?(servername: string, cert: CertMeta): boolean
|
2452
|
+
rejectUnauthorized?: boolean | undefined
|
2453
|
+
maxPayload?: number | undefined
|
2454
|
+
skipUTF8Validation?: boolean | undefined
|
2508
2455
|
}
|
2509
2456
|
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2457
|
+
interface PerMessageDeflateOptions {
|
2458
|
+
serverNoContextTakeover?: boolean | undefined
|
2459
|
+
clientNoContextTakeover?: boolean | undefined
|
2460
|
+
serverMaxWindowBits?: number | undefined
|
2461
|
+
clientMaxWindowBits?: number | undefined
|
2462
|
+
zlibDeflateOptions?:
|
2463
|
+
| {
|
2464
|
+
flush?: number | undefined
|
2465
|
+
finishFlush?: number | undefined
|
2466
|
+
chunkSize?: number | undefined
|
2467
|
+
windowBits?: number | undefined
|
2468
|
+
level?: number | undefined
|
2469
|
+
memLevel?: number | undefined
|
2470
|
+
strategy?: number | undefined
|
2471
|
+
dictionary?: Buffer | Buffer[] | DataView | undefined
|
2472
|
+
info?: boolean | undefined
|
2473
|
+
}
|
2474
|
+
| undefined
|
2475
|
+
zlibInflateOptions?: ZlibOptions | undefined
|
2476
|
+
threshold?: number | undefined
|
2477
|
+
concurrencyLimit?: number | undefined
|
2515
2478
|
}
|
2516
2479
|
|
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
|
2480
|
+
interface Event {
|
2481
|
+
type: string
|
2482
|
+
target: WebSocket
|
2527
2483
|
}
|
2528
2484
|
|
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
|
2485
|
+
interface ErrorEvent {
|
2486
|
+
error: any
|
2487
|
+
message: string
|
2488
|
+
type: string
|
2489
|
+
target: WebSocket
|
2540
2490
|
}
|
2541
2491
|
|
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
|
2492
|
+
interface CloseEvent {
|
2493
|
+
wasClean: boolean
|
2494
|
+
code: number
|
2495
|
+
reason: string
|
2496
|
+
type: string
|
2497
|
+
target: WebSocket
|
2561
2498
|
}
|
2562
2499
|
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
2568
|
-
regex?: RegExp | string
|
2569
|
-
reserved?: string[]
|
2500
|
+
interface MessageEvent {
|
2501
|
+
data: Data
|
2502
|
+
type: string
|
2503
|
+
target: WebSocket
|
2570
2504
|
}
|
2571
2505
|
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2579
|
-
|
2580
|
-
|
2581
|
-
|
2582
|
-
|
|
2583
|
-
|
2584
|
-
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
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
|
2506
|
+
interface EventListenerOptions {
|
2507
|
+
once?: boolean | undefined
|
2508
|
+
}
|
2509
|
+
|
2510
|
+
interface ServerOptions {
|
2511
|
+
host?: string | undefined
|
2512
|
+
port?: number | undefined
|
2513
|
+
backlog?: number | undefined
|
2514
|
+
server?: Server | HttpsServer | undefined
|
2515
|
+
verifyClient?:
|
2516
|
+
| VerifyClientCallbackAsync
|
2517
|
+
| VerifyClientCallbackSync
|
2518
|
+
| undefined
|
2519
|
+
handleProtocols?: (
|
2520
|
+
protocols: Set<string>,
|
2521
|
+
request: IncomingMessage,
|
2522
|
+
) => string | false
|
2523
|
+
path?: string | undefined
|
2524
|
+
noServer?: boolean | undefined
|
2525
|
+
clientTracking?: boolean | undefined
|
2526
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
2527
|
+
maxPayload?: number | undefined
|
2528
|
+
skipUTF8Validation?: boolean | undefined
|
2529
|
+
WebSocket?: typeof WebSocket.WebSocket | undefined
|
2530
|
+
}
|
2531
|
+
|
2532
|
+
interface AddressInfo {
|
2533
|
+
address: string
|
2534
|
+
family: string
|
2535
|
+
port: number
|
2613
2536
|
}
|
2614
2537
|
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
|
2538
|
+
// WebSocket Server
|
2539
|
+
class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
2540
|
+
options: ServerOptions
|
2541
|
+
path: string
|
2542
|
+
clients: Set<T>
|
2543
|
+
|
2544
|
+
constructor(options?: ServerOptions, callback?: () => void)
|
2545
|
+
|
2546
|
+
address(): AddressInfo | string
|
2547
|
+
close(cb?: (err?: Error) => void): void
|
2548
|
+
handleUpgrade(
|
2549
|
+
request: IncomingMessage,
|
2550
|
+
socket: Duplex,
|
2551
|
+
upgradeHead: Buffer,
|
2552
|
+
callback: (client: T, request: IncomingMessage) => void,
|
2553
|
+
): void
|
2554
|
+
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
2555
|
+
|
2556
|
+
// Events
|
2557
|
+
on(
|
2558
|
+
event: 'connection',
|
2559
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
2560
|
+
): this
|
2561
|
+
on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
2562
|
+
on(
|
2563
|
+
event: 'headers',
|
2564
|
+
cb: (
|
2565
|
+
this: Server<T>,
|
2566
|
+
headers: string[],
|
2567
|
+
request: IncomingMessage,
|
2568
|
+
) => void,
|
2569
|
+
): this
|
2570
|
+
on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
2571
|
+
on(
|
2572
|
+
event: string | symbol,
|
2573
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
2574
|
+
): this
|
2575
|
+
|
2576
|
+
once(
|
2577
|
+
event: 'connection',
|
2578
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
2579
|
+
): this
|
2580
|
+
once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
2581
|
+
once(
|
2582
|
+
event: 'headers',
|
2583
|
+
cb: (
|
2584
|
+
this: Server<T>,
|
2585
|
+
headers: string[],
|
2586
|
+
request: IncomingMessage,
|
2587
|
+
) => void,
|
2588
|
+
): this
|
2589
|
+
once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
2590
|
+
once(
|
2591
|
+
event: string | symbol,
|
2592
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
2593
|
+
): this
|
2594
|
+
|
2595
|
+
off(
|
2596
|
+
event: 'connection',
|
2597
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
2598
|
+
): this
|
2599
|
+
off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
2600
|
+
off(
|
2601
|
+
event: 'headers',
|
2602
|
+
cb: (
|
2603
|
+
this: Server<T>,
|
2604
|
+
headers: string[],
|
2605
|
+
request: IncomingMessage,
|
2606
|
+
) => void,
|
2607
|
+
): this
|
2608
|
+
off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
2609
|
+
off(
|
2610
|
+
event: string | symbol,
|
2611
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
2612
|
+
): this
|
2613
|
+
|
2614
|
+
addListener(
|
2615
|
+
event: 'connection',
|
2616
|
+
cb: (client: T, request: IncomingMessage) => void,
|
2617
|
+
): this
|
2618
|
+
addListener(event: 'error', cb: (err: Error) => void): this
|
2619
|
+
addListener(
|
2620
|
+
event: 'headers',
|
2621
|
+
cb: (headers: string[], request: IncomingMessage) => void,
|
2622
|
+
): this
|
2623
|
+
addListener(event: 'close' | 'listening', cb: () => void): this
|
2624
|
+
addListener(
|
2625
|
+
event: string | symbol,
|
2626
|
+
listener: (...args: any[]) => void,
|
2627
|
+
): this
|
2621
2628
|
|
2622
|
-
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2630
|
-
|
2631
|
-
|
2632
|
-
|
2633
|
-
/** @deprecated deprecated */
|
2634
|
-
output?: FormatOptions
|
2635
|
-
parse?: ParseOptions
|
2636
|
-
safari10?: boolean
|
2637
|
-
sourceMap?: boolean | SourceMapOptions
|
2638
|
-
toplevel?: boolean
|
2629
|
+
removeListener(event: 'connection', cb: (client: T) => void): this
|
2630
|
+
removeListener(event: 'error', cb: (err: Error) => void): this
|
2631
|
+
removeListener(
|
2632
|
+
event: 'headers',
|
2633
|
+
cb: (headers: string[], request: IncomingMessage) => void,
|
2634
|
+
): this
|
2635
|
+
removeListener(event: 'close' | 'listening', cb: () => void): this
|
2636
|
+
removeListener(
|
2637
|
+
event: string | symbol,
|
2638
|
+
listener: (...args: any[]) => void,
|
2639
|
+
): this
|
2639
2640
|
}
|
2640
2641
|
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
}
|
2642
|
+
const WebSocketServer: typeof Server
|
2643
|
+
interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
|
2644
|
+
const WebSocket: typeof WebSocketAlias
|
2645
|
+
interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
2646
2646
|
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
root?: string
|
2653
|
-
url?: string | 'inline'
|
2654
|
-
}
|
2647
|
+
// WebSocket stream
|
2648
|
+
function createWebSocketStream(
|
2649
|
+
websocket: WebSocket,
|
2650
|
+
options?: DuplexOptions,
|
2651
|
+
): Duplex
|
2655
2652
|
}
|
2656
2653
|
|
2657
|
-
|
2654
|
+
type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
|
2655
|
+
interface WebSocketServer extends HotChannel {
|
2658
2656
|
/**
|
2659
|
-
*
|
2660
|
-
* when minifying files with terser.
|
2661
|
-
*
|
2662
|
-
* @default number of CPUs minus 1
|
2657
|
+
* Listen on port and host
|
2663
2658
|
*/
|
2664
|
-
|
2659
|
+
listen(): void;
|
2660
|
+
/**
|
2661
|
+
* Get all connected clients.
|
2662
|
+
*/
|
2663
|
+
clients: Set<WebSocketClient>;
|
2664
|
+
/**
|
2665
|
+
* Disconnect all clients and terminate the server.
|
2666
|
+
*/
|
2667
|
+
close(): Promise<void>;
|
2668
|
+
/**
|
2669
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
2670
|
+
*/
|
2671
|
+
on: WebSocket.Server['on'] & {
|
2672
|
+
<T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
|
2673
|
+
};
|
2674
|
+
/**
|
2675
|
+
* Unregister event listener.
|
2676
|
+
*/
|
2677
|
+
off: WebSocket.Server['off'] & {
|
2678
|
+
(event: string, listener: Function): void;
|
2679
|
+
};
|
2680
|
+
}
|
2681
|
+
interface WebSocketClient extends HotChannelClient {
|
2682
|
+
/**
|
2683
|
+
* The raw WebSocket instance
|
2684
|
+
* @advanced
|
2685
|
+
*/
|
2686
|
+
socket: WebSocket;
|
2665
2687
|
}
|
2666
2688
|
|
2667
|
-
interface
|
2689
|
+
interface ServerOptions extends CommonServerOptions {
|
2668
2690
|
/**
|
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'
|
2691
|
+
* Configure HMR-specific options (port, host, path & protocol)
|
2684
2692
|
*/
|
2685
|
-
|
2693
|
+
hmr?: HmrOptions | boolean;
|
2686
2694
|
/**
|
2687
|
-
*
|
2688
|
-
*
|
2689
|
-
* @
|
2690
|
-
* @deprecated use `modulePreload.polyfill` instead
|
2695
|
+
* Warm-up files to transform and cache the results in advance. This improves the
|
2696
|
+
* initial page load during server starts and prevents transform waterfalls.
|
2697
|
+
* @deprecated use dev.warmup / environment.ssr.dev.warmup
|
2691
2698
|
*/
|
2692
|
-
|
2699
|
+
warmup?: {
|
2700
|
+
/**
|
2701
|
+
* The files to be transformed and used on the client-side. Supports glob patterns.
|
2702
|
+
*/
|
2703
|
+
clientFiles?: string[];
|
2704
|
+
/**
|
2705
|
+
* The files to be transformed and used in SSR. Supports glob patterns.
|
2706
|
+
*/
|
2707
|
+
ssrFiles?: string[];
|
2708
|
+
};
|
2693
2709
|
/**
|
2694
|
-
*
|
2695
|
-
*
|
2696
|
-
* @default true
|
2710
|
+
* chokidar watch options or null to disable FS watching
|
2711
|
+
* https://github.com/paulmillr/chokidar#api
|
2697
2712
|
*/
|
2698
|
-
|
2713
|
+
watch?: WatchOptions | null;
|
2699
2714
|
/**
|
2700
|
-
*
|
2701
|
-
*
|
2702
|
-
* @default 'dist'
|
2715
|
+
* Create Vite dev server to be used as a middleware in an existing server
|
2716
|
+
* @default false
|
2703
2717
|
*/
|
2704
|
-
|
2718
|
+
middlewareMode?: boolean | {
|
2719
|
+
/**
|
2720
|
+
* Parent server instance to attach to
|
2721
|
+
*
|
2722
|
+
* This is needed to proxy WebSocket connections to the parent server.
|
2723
|
+
*/
|
2724
|
+
server: http.Server;
|
2725
|
+
};
|
2705
2726
|
/**
|
2706
|
-
*
|
2707
|
-
* be placed.
|
2708
|
-
* @default 'assets'
|
2727
|
+
* Options for files served via '/\@fs/'.
|
2709
2728
|
*/
|
2710
|
-
|
2729
|
+
fs?: FileSystemServeOptions;
|
2711
2730
|
/**
|
2712
|
-
*
|
2713
|
-
*
|
2714
|
-
* @
|
2731
|
+
* Origin for the generated asset URLs.
|
2732
|
+
*
|
2733
|
+
* @example `http://127.0.0.1:8080`
|
2715
2734
|
*/
|
2716
|
-
|
2735
|
+
origin?: string;
|
2717
2736
|
/**
|
2718
|
-
*
|
2719
|
-
* inlined as strings in the chunk and inserted via dynamically created
|
2720
|
-
* style tags when the chunk is loaded.
|
2737
|
+
* Pre-transform known direct imports
|
2721
2738
|
* @default true
|
2739
|
+
* @deprecated use dev.preTransformRequests
|
2722
2740
|
*/
|
2723
|
-
|
2741
|
+
preTransformRequests?: boolean;
|
2724
2742
|
/**
|
2725
|
-
*
|
2726
|
-
*
|
2727
|
-
*
|
2728
|
-
*
|
2729
|
-
*
|
2730
|
-
*
|
2731
|
-
* @
|
2743
|
+
* Whether or not to ignore-list source files in the dev server sourcemap, used to populate
|
2744
|
+
* the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
|
2745
|
+
*
|
2746
|
+
* By default, it excludes all paths containing `node_modules`. You can pass `false` to
|
2747
|
+
* disable this behavior, or, for full control, a function that takes the source path and
|
2748
|
+
* sourcemap path and returns whether to ignore the source path.
|
2749
|
+
* @deprecated use dev.sourcemapIgnoreList
|
2732
2750
|
*/
|
2733
|
-
|
2751
|
+
sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
|
2734
2752
|
/**
|
2735
|
-
*
|
2736
|
-
*
|
2737
|
-
* @default 'esbuild'
|
2753
|
+
* Run HMR tasks, by default the HMR propagation is done in parallel for all environments
|
2754
|
+
* @experimental
|
2738
2755
|
*/
|
2739
|
-
|
2756
|
+
hotUpdateEnvironments?: (server: ViteDevServer, hmr: (environment: DevEnvironment) => Promise<void>) => Promise<void>;
|
2757
|
+
}
|
2758
|
+
interface ResolvedServerOptions extends Omit<ServerOptions, 'fs' | 'middlewareMode' | 'sourcemapIgnoreList'> {
|
2759
|
+
fs: Required<FileSystemServeOptions>;
|
2760
|
+
middlewareMode: NonNullable<ServerOptions['middlewareMode']>;
|
2761
|
+
sourcemapIgnoreList: Exclude<ServerOptions['sourcemapIgnoreList'], false | undefined>;
|
2762
|
+
}
|
2763
|
+
interface FileSystemServeOptions {
|
2740
2764
|
/**
|
2741
|
-
*
|
2742
|
-
*
|
2743
|
-
*
|
2744
|
-
*
|
2745
|
-
* @default
|
2765
|
+
* Strictly restrict file accessing outside of allowing paths.
|
2766
|
+
*
|
2767
|
+
* Set to `false` to disable the warning
|
2768
|
+
*
|
2769
|
+
* @default true
|
2746
2770
|
*/
|
2747
|
-
|
2771
|
+
strict?: boolean;
|
2748
2772
|
/**
|
2749
|
-
*
|
2750
|
-
*
|
2751
|
-
*
|
2773
|
+
* Restrict accessing files outside the allowed directories.
|
2774
|
+
*
|
2775
|
+
* Accepts absolute path or a path relative to project root.
|
2776
|
+
* Will try to search up for workspace root by default.
|
2777
|
+
*/
|
2778
|
+
allow?: string[];
|
2779
|
+
/**
|
2780
|
+
* Restrict accessing files that matches the patterns.
|
2781
|
+
*
|
2782
|
+
* This will have higher priority than `allow`.
|
2783
|
+
* picomatch patterns are supported.
|
2784
|
+
*
|
2785
|
+
* @default ['.env', '.env.*', '*.crt', '*.pem']
|
2786
|
+
*/
|
2787
|
+
deny?: string[];
|
2788
|
+
/**
|
2789
|
+
* Enable caching of fs calls. It is enabled by default if no custom watch ignored patterns are provided.
|
2790
|
+
*
|
2791
|
+
* @experimental
|
2792
|
+
* @default undefined
|
2793
|
+
*/
|
2794
|
+
cachedChecks?: boolean;
|
2795
|
+
}
|
2796
|
+
type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
2797
|
+
type HttpServer = http.Server | Http2SecureServer;
|
2798
|
+
interface ViteDevServer {
|
2799
|
+
/**
|
2800
|
+
* The resolved vite config object
|
2752
2801
|
*/
|
2753
|
-
|
2802
|
+
config: ResolvedConfig;
|
2754
2803
|
/**
|
2755
|
-
*
|
2756
|
-
*
|
2804
|
+
* A connect app instance.
|
2805
|
+
* - Can be used to attach custom middlewares to the dev server.
|
2806
|
+
* - Can also be used as the handler function of a custom http server
|
2807
|
+
* or as a middleware in any connect-style Node.js frameworks
|
2757
2808
|
*
|
2758
|
-
*
|
2759
|
-
* max number of workers to spawn. Defaults to the number of CPUs minus 1.
|
2809
|
+
* https://github.com/senchalabs/connect#use-middleware
|
2760
2810
|
*/
|
2761
|
-
|
2811
|
+
middlewares: Connect.Server;
|
2762
2812
|
/**
|
2763
|
-
*
|
2764
|
-
*
|
2813
|
+
* native Node http server instance
|
2814
|
+
* will be null in middleware mode
|
2765
2815
|
*/
|
2766
|
-
|
2816
|
+
httpServer: HttpServer | null;
|
2767
2817
|
/**
|
2768
|
-
*
|
2818
|
+
* chokidar watcher instance
|
2819
|
+
* https://github.com/paulmillr/chokidar#api
|
2769
2820
|
*/
|
2770
|
-
|
2821
|
+
watcher: FSWatcher;
|
2771
2822
|
/**
|
2772
|
-
*
|
2823
|
+
* web socket server with `send(payload)` method
|
2824
|
+
* @deprecated use `environment.hot` instead
|
2773
2825
|
*/
|
2774
|
-
|
2826
|
+
ws: WebSocketServer;
|
2775
2827
|
/**
|
2776
|
-
*
|
2777
|
-
* @
|
2828
|
+
* Rollup plugin container that can run plugin hooks on a given file
|
2829
|
+
* @deprecated use `environment.pluginContainer` instead
|
2778
2830
|
*/
|
2779
|
-
|
2831
|
+
pluginContainer: PluginContainer;
|
2780
2832
|
/**
|
2781
|
-
*
|
2782
|
-
* @default true when outDir is a sub directory of project root
|
2833
|
+
* Module execution environments attached to the Vite server.
|
2783
2834
|
*/
|
2784
|
-
|
2835
|
+
environments: Record<'client' | 'ssr' | (string & {}), DevEnvironment>;
|
2785
2836
|
/**
|
2786
|
-
*
|
2787
|
-
*
|
2837
|
+
* Module graph that tracks the import relationships, url to file mapping
|
2838
|
+
* and hmr state.
|
2839
|
+
* @deprecated use `environment.moduleGraph` instead
|
2788
2840
|
*/
|
2789
|
-
|
2841
|
+
moduleGraph: ModuleGraph;
|
2790
2842
|
/**
|
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
|
2843
|
+
* The resolved urls Vite prints on the CLI. null in middleware mode or
|
2844
|
+
* before `server.listen` is called.
|
2808
2845
|
*/
|
2809
|
-
|
2846
|
+
resolvedUrls: ResolvedServerUrls | null;
|
2810
2847
|
/**
|
2811
|
-
*
|
2812
|
-
*
|
2813
|
-
* @
|
2848
|
+
* Programmatically resolve, load and transform a URL and get the result
|
2849
|
+
* without going through the http request pipeline.
|
2850
|
+
* @deprecated use environment.transformRequest
|
2814
2851
|
*/
|
2815
|
-
|
2852
|
+
transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
|
2816
2853
|
/**
|
2817
|
-
*
|
2818
|
-
*
|
2819
|
-
*
|
2854
|
+
* Same as `transformRequest` but only warm up the URLs so the next request
|
2855
|
+
* will already be cached. The function will never throw as it handles and
|
2856
|
+
* reports errors internally.
|
2857
|
+
* @deprecated use environment.warmupRequest
|
2820
2858
|
*/
|
2821
|
-
|
2859
|
+
warmupRequest(url: string, options?: TransformOptions): Promise<void>;
|
2822
2860
|
/**
|
2823
|
-
*
|
2824
|
-
* @default false
|
2825
|
-
* @deprecated use emitAssets
|
2861
|
+
* Apply vite built-in HTML transforms and any plugin HTML transforms.
|
2826
2862
|
*/
|
2827
|
-
|
2863
|
+
transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
|
2828
2864
|
/**
|
2829
|
-
*
|
2830
|
-
*
|
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.
|
2865
|
+
* Transform module code into SSR format.
|
2866
|
+
* TODO: expose this to any environment?
|
2833
2867
|
*/
|
2834
|
-
|
2868
|
+
ssrTransform(code: string, inMap: SourceMap | {
|
2869
|
+
mappings: '';
|
2870
|
+
} | null, url: string, originalCode?: string): Promise<TransformResult | null>;
|
2835
2871
|
/**
|
2836
|
-
*
|
2837
|
-
* Can slightly improve build speed.
|
2838
|
-
* @default true
|
2872
|
+
* Load a given URL as an instantiated module for SSR.
|
2839
2873
|
*/
|
2840
|
-
|
2874
|
+
ssrLoadModule(url: string, opts?: {
|
2875
|
+
fixStacktrace?: boolean;
|
2876
|
+
}): Promise<Record<string, any>>;
|
2841
2877
|
/**
|
2842
|
-
*
|
2843
|
-
* @default 500
|
2878
|
+
* Returns a fixed version of the given stack
|
2844
2879
|
*/
|
2845
|
-
|
2880
|
+
ssrRewriteStacktrace(stack: string): string;
|
2846
2881
|
/**
|
2847
|
-
*
|
2848
|
-
* https://rollupjs.org/configuration-options/#watch
|
2849
|
-
* @default null
|
2882
|
+
* Mutates the given SSR error by rewriting the stacktrace
|
2850
2883
|
*/
|
2851
|
-
|
2884
|
+
ssrFixStacktrace(e: Error): void;
|
2852
2885
|
/**
|
2853
|
-
*
|
2886
|
+
* Triggers HMR for a module in the module graph. You can use the `server.moduleGraph`
|
2887
|
+
* API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
|
2854
2888
|
*/
|
2855
|
-
|
2856
|
-
}
|
2857
|
-
interface BuildOptions extends BuildEnvironmentOptions {
|
2889
|
+
reloadModule(module: ModuleNode): Promise<void>;
|
2858
2890
|
/**
|
2859
|
-
*
|
2860
|
-
*
|
2861
|
-
* configurations that are suitable for distributing libraries.
|
2862
|
-
* @default false
|
2891
|
+
* Triggers HMR for an environment module in the module graph.
|
2892
|
+
* If `hmr` is false, this is a no-op.
|
2863
2893
|
*/
|
2864
|
-
|
2865
|
-
}
|
2866
|
-
interface LibraryOptions {
|
2894
|
+
reloadEnvironmentModule(module: EnvironmentModuleNode): Promise<void>;
|
2867
2895
|
/**
|
2868
|
-
*
|
2896
|
+
* Start the server.
|
2869
2897
|
*/
|
2870
|
-
|
2898
|
+
listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
|
2871
2899
|
/**
|
2872
|
-
*
|
2873
|
-
* `umd` or `iife`
|
2900
|
+
* Stop the server.
|
2874
2901
|
*/
|
2875
|
-
|
2902
|
+
close(): Promise<void>;
|
2876
2903
|
/**
|
2877
|
-
*
|
2878
|
-
* @default ['es', 'umd']
|
2904
|
+
* Print server urls
|
2879
2905
|
*/
|
2880
|
-
|
2906
|
+
printUrls(): void;
|
2881
2907
|
/**
|
2882
|
-
*
|
2883
|
-
* of the project package.json. It can also be defined as a function taking the
|
2884
|
-
* format as an argument.
|
2908
|
+
* Bind CLI shortcuts
|
2885
2909
|
*/
|
2886
|
-
|
2887
|
-
}
|
2888
|
-
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
|
2889
|
-
interface ModulePreloadOptions {
|
2910
|
+
bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void;
|
2890
2911
|
/**
|
2891
|
-
*
|
2892
|
-
*
|
2893
|
-
* @
|
2912
|
+
* Restart the server.
|
2913
|
+
*
|
2914
|
+
* @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
|
2894
2915
|
*/
|
2895
|
-
|
2916
|
+
restart(forceOptimize?: boolean): Promise<void>;
|
2896
2917
|
/**
|
2897
|
-
*
|
2918
|
+
* Open browser
|
2919
|
+
*/
|
2920
|
+
openBrowser(): void;
|
2921
|
+
/**
|
2922
|
+
* Calling `await server.waitForRequestsIdle(id)` will wait until all static imports
|
2923
|
+
* are processed. If called from a load or transform plugin hook, the id needs to be
|
2924
|
+
* passed as a parameter to avoid deadlocks. Calling this function after the first
|
2925
|
+
* static imports section of the module graph has been processed will resolve immediately.
|
2898
2926
|
* @experimental
|
2927
|
+
* @deprecated use environment.waitForRequestsIdle()
|
2899
2928
|
*/
|
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>;
|
2929
|
+
waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
|
2942
2930
|
}
|
2943
|
-
interface
|
2944
|
-
|
2945
|
-
|
2946
|
-
entireApp?: boolean;
|
2947
|
-
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2931
|
+
interface ResolvedServerUrls {
|
2932
|
+
local: string[];
|
2933
|
+
network: string[];
|
2948
2934
|
}
|
2949
|
-
|
2950
|
-
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2935
|
+
declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
|
2951
2936
|
|
2952
2937
|
interface ESBuildOptions extends esbuild_TransformOptions {
|
2953
2938
|
include?: string | RegExp | string[] | RegExp[];
|
@@ -3153,7 +3138,7 @@ interface PreprocessCSSResult {
|
|
3153
3138
|
/**
|
3154
3139
|
* @experimental
|
3155
3140
|
*/
|
3156
|
-
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig, environment?:
|
3141
|
+
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig, environment?: PartialEnvironment): Promise<PreprocessCSSResult>;
|
3157
3142
|
declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
|
3158
3143
|
|
3159
3144
|
interface HtmlTagDescriptor {
|
@@ -3232,15 +3217,18 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3232
3217
|
* or a build environment. Plugins can use this.environment.mode === 'dev' to
|
3233
3218
|
* check if they have access to dev specific APIs.
|
3234
3219
|
*/
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3220
|
+
interface PluginContextExtension {
|
3221
|
+
environment?: Environment;
|
3222
|
+
}
|
3223
|
+
interface PluginContext extends rollup.PluginContext, PluginContextExtension {
|
3238
3224
|
}
|
3239
|
-
interface ResolveIdPluginContext extends rollup.PluginContext {
|
3240
|
-
environment?: PluginEnvironment;
|
3225
|
+
interface ResolveIdPluginContext extends rollup.PluginContext, PluginContextExtension {
|
3241
3226
|
}
|
3242
|
-
interface TransformPluginContext extends rollup.TransformPluginContext {
|
3243
|
-
|
3227
|
+
interface TransformPluginContext extends rollup.TransformPluginContext, PluginContextExtension {
|
3228
|
+
}
|
3229
|
+
declare module 'rollup' {
|
3230
|
+
interface PluginContext extends PluginContextExtension {
|
3231
|
+
}
|
3244
3232
|
}
|
3245
3233
|
/**
|
3246
3234
|
* There are two types of plugins in Vite. App plugins and environment plugins.
|
@@ -3252,16 +3240,7 @@ interface TransformPluginContext extends rollup.TransformPluginContext {
|
|
3252
3240
|
* Environment Plugins are closer to regular rollup plugins. They can't define
|
3253
3241
|
* app level hooks (like config, configResolved, configureServer, etc).
|
3254
3242
|
*/
|
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 EnvironmentPlugin<A = any> extends rollup.Plugin<A> {
|
3243
|
+
interface Plugin<A = any> extends rollup.Plugin<A> {
|
3265
3244
|
/**
|
3266
3245
|
* Perform custom handling of HMR updates.
|
3267
3246
|
* The handler receives a context containing changed filename, timestamp, a
|
@@ -3302,11 +3281,6 @@ interface EnvironmentPlugin<A = any> extends rollup.Plugin<A> {
|
|
3302
3281
|
*/
|
3303
3282
|
ssr?: boolean;
|
3304
3283
|
}) => 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
|
-
interface Plugin<A = any> extends EnvironmentPlugin<A> {
|
3310
3284
|
/**
|
3311
3285
|
* Opt-in this plugin into the shared plugins pipeline.
|
3312
3286
|
* For backward-compatibility, plugins are re-recreated for each environment
|
@@ -3334,6 +3308,11 @@ interface Plugin<A = any> extends EnvironmentPlugin<A> {
|
|
3334
3308
|
* Apply the plugin only for serve or build, or on certain conditions.
|
3335
3309
|
*/
|
3336
3310
|
apply?: 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
|
3311
|
+
/**
|
3312
|
+
* Define environments where this plugin should be active
|
3313
|
+
* By default, the plugin is active in all environments
|
3314
|
+
*/
|
3315
|
+
applyToEnvironment?: (environment: Environment) => boolean;
|
3337
3316
|
/**
|
3338
3317
|
* Modify vite config before it's resolved. The hook can either mutate the
|
3339
3318
|
* passed-in config directly, or return a partial config object that will be
|
@@ -3394,14 +3373,21 @@ interface Plugin<A = any> extends EnvironmentPlugin<A> {
|
|
3394
3373
|
* `{ order: 'pre', handler: hook }`
|
3395
3374
|
*/
|
3396
3375
|
transformIndexHtml?: IndexHtmlTransform;
|
3397
|
-
/**
|
3398
|
-
* Inject per environment plugins after the shared plugin
|
3399
|
-
*/
|
3400
|
-
environmentPlugins?: (environment: PluginEnvironment) => PluginOption[] | undefined;
|
3401
3376
|
/**
|
3402
3377
|
* @deprecated
|
3403
|
-
*
|
3404
|
-
*
|
3378
|
+
* Perform custom handling of HMR updates.
|
3379
|
+
* The handler receives a context containing changed filename, timestamp, a
|
3380
|
+
* list of modules affected by the file change, and the dev server instance.
|
3381
|
+
*
|
3382
|
+
* - The hook can return a filtered list of modules to narrow down the update.
|
3383
|
+
* e.g. for a Vue SFC, we can narrow down the part to update by comparing
|
3384
|
+
* the descriptors.
|
3385
|
+
*
|
3386
|
+
* - The hook can also return an empty array and then perform custom updates
|
3387
|
+
* by sending a custom hmr payload via server.ws.send().
|
3388
|
+
*
|
3389
|
+
* - If the hook doesn't return a value, the hmr update will be performed as
|
3390
|
+
* normal.
|
3405
3391
|
*/
|
3406
3392
|
handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
|
3407
3393
|
}
|
@@ -3409,8 +3395,9 @@ type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
|
|
3409
3395
|
type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
|
3410
3396
|
[P in K]: NonNullable<Plugin[P]>;
|
3411
3397
|
};
|
3412
|
-
type
|
3413
|
-
type
|
3398
|
+
type Thenable<T> = T | Promise<T>;
|
3399
|
+
type FalsyPlugin = false | null | undefined;
|
3400
|
+
type PluginOption = Thenable<Plugin | FalsyPlugin | PluginOption[]>;
|
3414
3401
|
|
3415
3402
|
interface JsonOptions {
|
3416
3403
|
/**
|
@@ -3427,7 +3414,7 @@ interface JsonOptions {
|
|
3427
3414
|
}
|
3428
3415
|
|
3429
3416
|
type SSRTarget = 'node' | 'webworker';
|
3430
|
-
type
|
3417
|
+
type SsrDepOptimizationConfig = DepOptimizationConfig;
|
3431
3418
|
/**
|
3432
3419
|
* @deprecated use environments.ssr
|
3433
3420
|
*/
|
@@ -3463,7 +3450,7 @@ interface SSROptions {
|
|
3463
3450
|
* @experimental
|
3464
3451
|
* @deprecated
|
3465
3452
|
*/
|
3466
|
-
optimizeDeps?:
|
3453
|
+
optimizeDeps?: SsrDepOptimizationConfig;
|
3467
3454
|
/**
|
3468
3455
|
* @deprecated
|
3469
3456
|
*/
|
@@ -3488,7 +3475,7 @@ interface SSROptions {
|
|
3488
3475
|
}
|
3489
3476
|
interface ResolvedSSROptions extends SSROptions {
|
3490
3477
|
target: SSRTarget;
|
3491
|
-
optimizeDeps:
|
3478
|
+
optimizeDeps: SsrDepOptimizationConfig;
|
3492
3479
|
}
|
3493
3480
|
|
3494
3481
|
interface ConfigEnv {
|
@@ -3524,7 +3511,7 @@ declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
3524
3511
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3525
3512
|
interface DevEnvironmentOptions {
|
3526
3513
|
/**
|
3527
|
-
* Files
|
3514
|
+
* Files to be pre-transformed. Supports glob patterns.
|
3528
3515
|
*/
|
3529
3516
|
warmup?: string[];
|
3530
3517
|
/**
|
@@ -3553,7 +3540,7 @@ interface DevEnvironmentOptions {
|
|
3553
3540
|
/**
|
3554
3541
|
* Optimize deps config
|
3555
3542
|
*/
|
3556
|
-
optimizeDeps?:
|
3543
|
+
optimizeDeps?: DepOptimizationOptions;
|
3557
3544
|
/**
|
3558
3545
|
* create the Dev Environment instance
|
3559
3546
|
*/
|
@@ -3891,7 +3878,7 @@ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, c
|
|
3891
3878
|
|
3892
3879
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3893
3880
|
|
3894
|
-
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, options
|
3881
|
+
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, options: DevEnvironmentSetup): DevEnvironment;
|
3895
3882
|
|
3896
3883
|
/**
|
3897
3884
|
* @experimental
|
@@ -3920,14 +3907,14 @@ declare function createServerModuleRunner(environment: DevEnvironment, options?:
|
|
3920
3907
|
* @experimental
|
3921
3908
|
*/
|
3922
3909
|
declare class ServerHMRConnector implements ModuleRunnerHMRConnection {
|
3923
|
-
private
|
3910
|
+
private hotChannel;
|
3924
3911
|
private handlers;
|
3925
3912
|
private hmrClient;
|
3926
3913
|
private connected;
|
3927
|
-
constructor(
|
3914
|
+
constructor(hotChannel: ServerHotChannel);
|
3928
3915
|
isReady(): boolean;
|
3929
3916
|
send(message: string): void;
|
3930
|
-
onUpdate(handler: (payload:
|
3917
|
+
onUpdate(handler: (payload: HotPayload) => void): void;
|
3931
3918
|
}
|
3932
3919
|
|
3933
3920
|
interface ModuleRunnerTransformOptions {
|
@@ -3972,6 +3959,12 @@ declare const rollupVersion: string;
|
|
3972
3959
|
declare function normalizePath(id: string): string;
|
3973
3960
|
declare function mergeConfig<D extends Record<string, any>, O extends Record<string, any>>(defaults: D extends Function ? never : D, overrides: O extends Function ? never : O, isRoot?: boolean): Record<string, any>;
|
3974
3961
|
declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
|
3962
|
+
/**
|
3963
|
+
* Creates a function that hides the complexities of a WeakMap with an initial value
|
3964
|
+
* to implement object metadata. Used by plugins to implement cross hooks per
|
3965
|
+
* environment metadata
|
3966
|
+
*/
|
3967
|
+
declare function createWeakData<Key extends object | symbol, Data>(initial: (key: Key) => Data): (key: Key) => Data;
|
3975
3968
|
|
3976
3969
|
interface SendOptions {
|
3977
3970
|
etag?: string;
|
@@ -4011,4 +4004,4 @@ interface ManifestChunk {
|
|
4011
4004
|
dynamicImports?: string[];
|
4012
4005
|
}
|
4013
4006
|
|
4014
|
-
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 DevEnvironmentOptions, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, EnvironmentModuleGraph, EnvironmentModuleNode, type
|
4007
|
+
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 DevEnvironmentOptions, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotUpdateContext, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, RemoteEnvironmentTransport, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, 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, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, createWeakData, 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 };
|