vite 6.0.0-beta.1 → 6.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +66 -1010
- package/README.md +4 -4
- package/bin/vite.js +5 -0
- package/client.d.ts +10 -0
- package/dist/client/client.mjs +344 -105
- package/dist/node/chunks/{dep-IQS-Za7F.js → dep-3RmXg9uo.js} +0 -8
- package/dist/node/chunks/{dep-DiM5uMHt.js → dep-Ck0pJQmh.js} +4 -175
- package/dist/node/chunks/{dep-BZ_CwQkz.js → dep-DiRA7B7B.js} +15738 -30463
- package/dist/node/chunks/{dep-D-7KCb9p.js → dep-DnSxfB-q.js} +704 -443
- package/dist/node/chunks/{dep-BZeeNeMJ.js → dep-ifLmJA8Z.js} +286 -127
- package/dist/node/cli.js +21 -37
- package/dist/node/constants.js +19 -11
- package/dist/node/index.d.ts +1649 -1602
- package/dist/node/index.js +13 -153
- package/dist/node/module-runner.d.ts +154 -141
- package/dist/node/module-runner.js +374 -221
- package/dist/node-cjs/publicUtils.cjs +363 -184
- package/index.cjs +35 -3
- package/index.d.cts +1 -1
- package/package.json +44 -33
- package/types/hmrPayload.d.ts +5 -0
- package/types/internal/cssPreprocessorOptions.d.ts +63 -0
- package/types/internal/lightningcssOptions.d.ts +18 -0
package/dist/node/index.d.ts
CHANGED
@@ -15,7 +15,7 @@ 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 {
|
18
|
+
import { FetchFunctionOptions, FetchResult, ModuleRunnerOptions, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
|
19
19
|
export { FetchFunction, FetchResult } from 'vite/module-runner';
|
20
20
|
import { BuildOptions as esbuild_BuildOptions, TransformOptions as esbuild_TransformOptions, TransformResult as esbuild_TransformResult } from 'esbuild';
|
21
21
|
export { TransformOptions as EsbuildTransformOptions, version as esbuildVersion } from 'esbuild';
|
@@ -26,6 +26,9 @@ export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../.
|
|
26
26
|
import { SecureContextOptions } from 'node:tls';
|
27
27
|
import { ZlibOptions } from 'node:zlib';
|
28
28
|
import * as PostCSS from 'postcss';
|
29
|
+
import { LightningCSSOptions } from '../../types/internal/lightningcssOptions.js';
|
30
|
+
export { LightningCSSOptions } from '../../types/internal/lightningcssOptions.js';
|
31
|
+
import { SassLegacyPreprocessBaseOptions, SassModernPreprocessBaseOptions, LessPreprocessorBaseOptions, StylusPreprocessorBaseOptions } from '../../types/internal/cssPreprocessorOptions.js';
|
29
32
|
export { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap } from '../../types/importGlob.js';
|
30
33
|
export { ChunkMetadata } from '../../types/metadata.js';
|
31
34
|
|
@@ -617,9 +620,11 @@ interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
617
620
|
/**
|
618
621
|
* webpack-dev-server style bypass function
|
619
622
|
*/
|
620
|
-
bypass?: (req: http.IncomingMessage,
|
623
|
+
bypass?: (req: http.IncomingMessage,
|
624
|
+
/** undefined for WebSocket upgrade requests */
|
625
|
+
res: http.ServerResponse | undefined, options: ProxyOptions) => void | null | undefined | false | string;
|
621
626
|
/**
|
622
|
-
* rewrite the Origin header of a WebSocket request to match the
|
627
|
+
* rewrite the Origin header of a WebSocket request to match the target
|
623
628
|
*
|
624
629
|
* **Exercise caution as rewriting the Origin can leave the proxying open to [CSRF attacks](https://owasp.org/www-community/attacks/csrf).**
|
625
630
|
*/
|
@@ -649,6 +654,7 @@ interface LoggerOptions {
|
|
649
654
|
prefix?: string;
|
650
655
|
allowClearScreen?: boolean;
|
651
656
|
customLogger?: Logger;
|
657
|
+
console?: Console;
|
652
658
|
}
|
653
659
|
declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
|
654
660
|
|
@@ -754,8 +760,8 @@ interface PreviewServer {
|
|
754
760
|
*/
|
755
761
|
httpServer: HttpServer;
|
756
762
|
/**
|
757
|
-
* The resolved urls Vite prints on the CLI.
|
758
|
-
*
|
763
|
+
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
|
764
|
+
* if the server is not listening on any port.
|
759
765
|
*/
|
760
766
|
resolvedUrls: ResolvedServerUrls | null;
|
761
767
|
/**
|
@@ -822,17 +828,6 @@ declare class UnknownEnvironment extends BaseEnvironment {
|
|
822
828
|
mode: "unknown";
|
823
829
|
}
|
824
830
|
|
825
|
-
interface FetchModuleOptions {
|
826
|
-
cached?: boolean;
|
827
|
-
inlineSourceMap?: boolean;
|
828
|
-
processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
|
829
|
-
}
|
830
|
-
/**
|
831
|
-
* Fetch module information for Vite runner.
|
832
|
-
* @experimental
|
833
|
-
*/
|
834
|
-
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
835
|
-
|
836
831
|
declare class ScanEnvironment extends BaseEnvironment {
|
837
832
|
mode: "scan";
|
838
833
|
get pluginContainer(): EnvironmentPluginContainer;
|
@@ -932,8 +927,8 @@ type DepOptimizationOptions = DepOptimizationConfig & {
|
|
932
927
|
* will crawl those entry points instead.
|
933
928
|
*
|
934
929
|
* If neither of these fit your needs, you can specify custom entries using
|
935
|
-
* this option - the value should be a
|
936
|
-
* (https://github.com/
|
930
|
+
* this option - the value should be a tinyglobby pattern or array of patterns
|
931
|
+
* (https://github.com/SuperchupuDev/tinyglobby) that are relative from
|
937
932
|
* vite project root. This will overwrite default entries inference.
|
938
933
|
*/
|
939
934
|
entries?: string | string[];
|
@@ -1139,6 +1134,7 @@ declare class ModuleGraph {
|
|
1139
1134
|
idToModuleMap: Map<string, ModuleNode>;
|
1140
1135
|
etagToModuleMap: Map<string, ModuleNode>;
|
1141
1136
|
fileToModulesMap: Map<string, Set<ModuleNode>>;
|
1137
|
+
private moduleNodeCache;
|
1142
1138
|
constructor(moduleGraphs: {
|
1143
1139
|
client: () => EnvironmentModuleGraph;
|
1144
1140
|
ssr: () => EnvironmentModuleGraph;
|
@@ -1193,6 +1189,38 @@ interface HmrContext {
|
|
1193
1189
|
server: ViteDevServer;
|
1194
1190
|
}
|
1195
1191
|
interface HotChannelClient {
|
1192
|
+
send(payload: HotPayload): void;
|
1193
|
+
}
|
1194
|
+
/** @deprecated use `HotChannelClient` instead */
|
1195
|
+
type HMRBroadcasterClient = HotChannelClient;
|
1196
|
+
type HotChannelListener<T extends string = string> = (data: InferCustomEventPayload<T>, client: HotChannelClient) => void;
|
1197
|
+
interface HotChannel<Api = any> {
|
1198
|
+
/**
|
1199
|
+
* Broadcast events to all clients
|
1200
|
+
*/
|
1201
|
+
send?(payload: HotPayload): void;
|
1202
|
+
/**
|
1203
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
1204
|
+
*/
|
1205
|
+
on?<T extends string>(event: T, listener: HotChannelListener<T>): void;
|
1206
|
+
on?(event: 'connection', listener: () => void): void;
|
1207
|
+
/**
|
1208
|
+
* Unregister event listener
|
1209
|
+
*/
|
1210
|
+
off?(event: string, listener: Function): void;
|
1211
|
+
/**
|
1212
|
+
* Start listening for messages
|
1213
|
+
*/
|
1214
|
+
listen?(): void;
|
1215
|
+
/**
|
1216
|
+
* Disconnect all clients, called when server is closed or restarted.
|
1217
|
+
*/
|
1218
|
+
close?(): Promise<unknown> | void;
|
1219
|
+
api?: Api;
|
1220
|
+
}
|
1221
|
+
/** @deprecated use `HotChannel` instead */
|
1222
|
+
type HMRChannel = HotChannel;
|
1223
|
+
interface NormalizedHotChannelClient {
|
1196
1224
|
/**
|
1197
1225
|
* Send event to the client
|
1198
1226
|
*/
|
@@ -1202,9 +1230,7 @@ interface HotChannelClient {
|
|
1202
1230
|
*/
|
1203
1231
|
send(event: string, payload?: CustomPayload['data']): void;
|
1204
1232
|
}
|
1205
|
-
|
1206
|
-
type HMRBroadcasterClient = HotChannelClient;
|
1207
|
-
interface HotChannel {
|
1233
|
+
interface NormalizedHotChannel<Api = any> {
|
1208
1234
|
/**
|
1209
1235
|
* Broadcast events to all clients
|
1210
1236
|
*/
|
@@ -1216,12 +1242,17 @@ interface HotChannel {
|
|
1216
1242
|
/**
|
1217
1243
|
* Handle custom event emitted by `import.meta.hot.send`
|
1218
1244
|
*/
|
1219
|
-
on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client:
|
1245
|
+
on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client: NormalizedHotChannelClient) => void): void;
|
1220
1246
|
on(event: 'connection', listener: () => void): void;
|
1221
1247
|
/**
|
1222
1248
|
* Unregister event listener
|
1223
1249
|
*/
|
1224
1250
|
off(event: string, listener: Function): void;
|
1251
|
+
handleInvoke(payload: HotPayload): Promise<{
|
1252
|
+
r: any;
|
1253
|
+
} | {
|
1254
|
+
e: any;
|
1255
|
+
}>;
|
1225
1256
|
/**
|
1226
1257
|
* Start listening for messages
|
1227
1258
|
*/
|
@@ -1229,22 +1260,20 @@ interface HotChannel {
|
|
1229
1260
|
/**
|
1230
1261
|
* Disconnect all clients, called when server is closed or restarted.
|
1231
1262
|
*/
|
1232
|
-
close(): void;
|
1233
|
-
|
1234
|
-
/** @deprecated use `HotChannel` instead */
|
1235
|
-
type HMRChannel = HotChannel;
|
1236
|
-
interface ServerHotChannel extends HotChannel {
|
1237
|
-
api: {
|
1238
|
-
innerEmitter: EventEmitter;
|
1239
|
-
outsideEmitter: EventEmitter;
|
1240
|
-
};
|
1263
|
+
close(): Promise<unknown> | void;
|
1264
|
+
api?: Api;
|
1241
1265
|
}
|
1266
|
+
type ServerHotChannelApi = {
|
1267
|
+
innerEmitter: EventEmitter;
|
1268
|
+
outsideEmitter: EventEmitter;
|
1269
|
+
};
|
1270
|
+
type ServerHotChannel = HotChannel<ServerHotChannelApi>;
|
1242
1271
|
/** @deprecated use `ServerHotChannel` instead */
|
1243
1272
|
type ServerHMRChannel = ServerHotChannel;
|
1244
1273
|
declare function createServerHotChannel(): ServerHotChannel;
|
1245
1274
|
/** @deprecated use `environment.hot` instead */
|
1246
|
-
interface HotBroadcaster extends
|
1247
|
-
readonly channels:
|
1275
|
+
interface HotBroadcaster extends NormalizedHotChannel {
|
1276
|
+
readonly channels: NormalizedHotChannel[];
|
1248
1277
|
/**
|
1249
1278
|
* A noop.
|
1250
1279
|
* @deprecated
|
@@ -1255,1488 +1284,1578 @@ interface HotBroadcaster extends HotChannel {
|
|
1255
1284
|
/** @deprecated use `environment.hot` instead */
|
1256
1285
|
type HMRBroadcaster = HotBroadcaster;
|
1257
1286
|
|
1258
|
-
|
1259
|
-
|
1260
|
-
constructor(options: {
|
1261
|
-
send: (data: any) => void;
|
1262
|
-
onMessage: (handler: (data: any) => void) => void;
|
1263
|
-
});
|
1264
|
-
register(environment: DevEnvironment): void;
|
1265
|
-
}
|
1287
|
+
// Modified and inlined to avoid extra dependency
|
1288
|
+
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts
|
1266
1289
|
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1290
|
+
declare const WebSocketAlias: typeof WebSocket
|
1291
|
+
interface WebSocketAlias extends WebSocket {}
|
1292
|
+
|
1293
|
+
// WebSocket socket.
|
1294
|
+
declare class WebSocket extends EventEmitter {
|
1295
|
+
/** The connection is not yet open. */
|
1296
|
+
static readonly CONNECTING: 0
|
1297
|
+
/** The connection is open and ready to communicate. */
|
1298
|
+
static readonly OPEN: 1
|
1299
|
+
/** The connection is in the process of closing. */
|
1300
|
+
static readonly CLOSING: 2
|
1301
|
+
/** The connection is closed. */
|
1302
|
+
static readonly CLOSED: 3
|
1303
|
+
|
1304
|
+
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
|
1305
|
+
readonly bufferedAmount: number
|
1306
|
+
readonly extensions: string
|
1307
|
+
/** Indicates whether the websocket is paused */
|
1308
|
+
readonly isPaused: boolean
|
1309
|
+
readonly protocol: string
|
1310
|
+
/** The current state of the connection */
|
1311
|
+
readonly readyState:
|
1312
|
+
| typeof WebSocket.CONNECTING
|
1313
|
+
| typeof WebSocket.OPEN
|
1314
|
+
| typeof WebSocket.CLOSING
|
1315
|
+
| typeof WebSocket.CLOSED
|
1316
|
+
readonly url: string
|
1317
|
+
|
1318
|
+
/** The connection is not yet open. */
|
1319
|
+
readonly CONNECTING: 0
|
1320
|
+
/** The connection is open and ready to communicate. */
|
1321
|
+
readonly OPEN: 1
|
1322
|
+
/** The connection is in the process of closing. */
|
1323
|
+
readonly CLOSING: 2
|
1324
|
+
/** The connection is closed. */
|
1325
|
+
readonly CLOSED: 3
|
1326
|
+
|
1327
|
+
onopen: ((event: WebSocket.Event) => void) | null
|
1328
|
+
onerror: ((event: WebSocket.ErrorEvent) => void) | null
|
1329
|
+
onclose: ((event: WebSocket.CloseEvent) => void) | null
|
1330
|
+
onmessage: ((event: WebSocket.MessageEvent) => void) | null
|
1331
|
+
|
1332
|
+
constructor(address: null)
|
1333
|
+
constructor(
|
1334
|
+
address: string | URL,
|
1335
|
+
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
1336
|
+
)
|
1337
|
+
constructor(
|
1338
|
+
address: string | URL,
|
1339
|
+
protocols?: string | string[],
|
1340
|
+
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
1341
|
+
)
|
1342
|
+
|
1343
|
+
close(code?: number, data?: string | Buffer): void
|
1344
|
+
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
1345
|
+
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
1346
|
+
send(data: any, cb?: (err?: Error) => void): void
|
1347
|
+
send(
|
1348
|
+
data: any,
|
1349
|
+
options: {
|
1350
|
+
mask?: boolean | undefined
|
1351
|
+
binary?: boolean | undefined
|
1352
|
+
compress?: boolean | undefined
|
1353
|
+
fin?: boolean | undefined
|
1354
|
+
},
|
1355
|
+
cb?: (err?: Error) => void,
|
1356
|
+
): void
|
1357
|
+
terminate(): void
|
1307
1358
|
|
1308
|
-
interface RollupCommonJSOptions {
|
1309
|
-
/**
|
1310
|
-
* A minimatch pattern, or array of patterns, which specifies the files in
|
1311
|
-
* the build the plugin should operate on. By default, all files with
|
1312
|
-
* extension `".cjs"` or those in `extensions` are included, but you can
|
1313
|
-
* narrow this list by only including specific files. These files will be
|
1314
|
-
* analyzed and transpiled if either the analysis does not find ES module
|
1315
|
-
* specific statements or `transformMixedEsModules` is `true`.
|
1316
|
-
* @default undefined
|
1317
|
-
*/
|
1318
|
-
include?: string | RegExp | readonly (string | RegExp)[]
|
1319
|
-
/**
|
1320
|
-
* A minimatch pattern, or array of patterns, which specifies the files in
|
1321
|
-
* the build the plugin should _ignore_. By default, all files with
|
1322
|
-
* extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
1323
|
-
* can exclude additional files. See also the `include` option.
|
1324
|
-
* @default undefined
|
1325
|
-
*/
|
1326
|
-
exclude?: string | RegExp | readonly (string | RegExp)[]
|
1327
|
-
/**
|
1328
|
-
* For extensionless imports, search for extensions other than .js in the
|
1329
|
-
* order specified. Note that you need to make sure that non-JavaScript files
|
1330
|
-
* are transpiled by another plugin first.
|
1331
|
-
* @default [ '.js' ]
|
1332
|
-
*/
|
1333
|
-
extensions?: ReadonlyArray<string>
|
1334
|
-
/**
|
1335
|
-
* If true then uses of `global` won't be dealt with by this plugin
|
1336
|
-
* @default false
|
1337
|
-
*/
|
1338
|
-
ignoreGlobal?: boolean
|
1339
|
-
/**
|
1340
|
-
* If false, skips source map generation for CommonJS modules. This will
|
1341
|
-
* improve performance.
|
1342
|
-
* @default true
|
1343
|
-
*/
|
1344
|
-
sourceMap?: boolean
|
1345
|
-
/**
|
1346
|
-
* Some `require` calls cannot be resolved statically to be translated to
|
1347
|
-
* imports.
|
1348
|
-
* When this option is set to `false`, the generated code will either
|
1349
|
-
* directly throw an error when such a call is encountered or, when
|
1350
|
-
* `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
1351
|
-
* configured dynamic require target.
|
1352
|
-
* Setting this option to `true` will instead leave the `require` call in the
|
1353
|
-
* code or use it as a fallback for `dynamicRequireTargets`.
|
1354
|
-
* @default false
|
1355
|
-
*/
|
1356
|
-
ignoreDynamicRequires?: boolean
|
1357
|
-
/**
|
1358
|
-
* Instructs the plugin whether to enable mixed module transformations. This
|
1359
|
-
* is useful in scenarios with modules that contain a mix of ES `import`
|
1360
|
-
* statements and CommonJS `require` expressions. Set to `true` if `require`
|
1361
|
-
* calls should be transformed to imports in mixed modules, or `false` if the
|
1362
|
-
* `require` expressions should survive the transformation. The latter can be
|
1363
|
-
* important if the code contains environment detection, or you are coding
|
1364
|
-
* for an environment with special treatment for `require` calls such as
|
1365
|
-
* ElectronJS. See also the `ignore` option.
|
1366
|
-
* @default false
|
1367
|
-
*/
|
1368
|
-
transformMixedEsModules?: boolean
|
1369
1359
|
/**
|
1370
|
-
*
|
1371
|
-
*
|
1372
|
-
*
|
1373
|
-
* CommonJS semantics as the order of side effects like log statements may
|
1374
|
-
* change. But it is especially problematic when there are circular `require`
|
1375
|
-
* calls between CommonJS modules as those often rely on the lazy execution of
|
1376
|
-
* nested `require` calls.
|
1377
|
-
*
|
1378
|
-
* Setting this option to `true` will wrap all CommonJS files in functions
|
1379
|
-
* which are executed when they are required for the first time, preserving
|
1380
|
-
* NodeJS semantics. Note that this can have an impact on the size and
|
1381
|
-
* performance of the generated code.
|
1382
|
-
*
|
1383
|
-
* The default value of `"auto"` will only wrap CommonJS files when they are
|
1384
|
-
* part of a CommonJS dependency cycle, e.g. an index file that is required by
|
1385
|
-
* many of its dependencies. All other CommonJS files are hoisted. This is the
|
1386
|
-
* recommended setting for most code bases.
|
1387
|
-
*
|
1388
|
-
* `false` will entirely prevent wrapping and hoist all files. This may still
|
1389
|
-
* work depending on the nature of cyclic dependencies but will often cause
|
1390
|
-
* problems.
|
1391
|
-
*
|
1392
|
-
* You can also provide a minimatch pattern, or array of patterns, to only
|
1393
|
-
* specify a subset of files which should be wrapped in functions for proper
|
1394
|
-
* `require` semantics.
|
1395
|
-
*
|
1396
|
-
* `"debug"` works like `"auto"` but after bundling, it will display a warning
|
1397
|
-
* containing a list of ids that have been wrapped which can be used as
|
1398
|
-
* minimatch pattern for fine-tuning.
|
1399
|
-
* @default "auto"
|
1360
|
+
* Pause the websocket causing it to stop emitting events. Some events can still be
|
1361
|
+
* emitted after this is called, until all buffered data is consumed. This method
|
1362
|
+
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
1400
1363
|
*/
|
1401
|
-
|
1364
|
+
pause(): void
|
1402
1365
|
/**
|
1403
|
-
*
|
1404
|
-
*
|
1405
|
-
* @default []
|
1366
|
+
* Make a paused socket resume emitting events. This method is a noop if the ready
|
1367
|
+
* state is `CONNECTING` or `CLOSED`.
|
1406
1368
|
*/
|
1407
|
-
|
1408
|
-
/**
|
1409
|
-
* In most cases, where `require` calls are inside a `try-catch` clause,
|
1410
|
-
* they should be left unconverted as it requires an optional dependency
|
1411
|
-
* that may or may not be installed beside the rolled up package.
|
1412
|
-
* Due to the conversion of `require` to a static `import` - the call is
|
1413
|
-
* hoisted to the top of the file, outside the `try-catch` clause.
|
1414
|
-
*
|
1415
|
-
* - `true`: Default. All `require` calls inside a `try` will be left unconverted.
|
1416
|
-
* - `false`: All `require` calls inside a `try` will be converted as if the
|
1417
|
-
* `try-catch` clause is not there.
|
1418
|
-
* - `remove`: Remove all `require` calls from inside any `try` block.
|
1419
|
-
* - `string[]`: Pass an array containing the IDs to left unconverted.
|
1420
|
-
* - `((id: string) => boolean|'remove')`: Pass a function that controls
|
1421
|
-
* individual IDs.
|
1422
|
-
*
|
1423
|
-
* @default true
|
1424
|
-
*/
|
1425
|
-
ignoreTryCatch?:
|
1426
|
-
| boolean
|
1427
|
-
| 'remove'
|
1428
|
-
| ReadonlyArray<string>
|
1429
|
-
| ((id: string) => boolean | 'remove')
|
1430
|
-
/**
|
1431
|
-
* Controls how to render imports from external dependencies. By default,
|
1432
|
-
* this plugin assumes that all external dependencies are CommonJS. This
|
1433
|
-
* means they are rendered as default imports to be compatible with e.g.
|
1434
|
-
* NodeJS where ES modules can only import a default export from a CommonJS
|
1435
|
-
* dependency.
|
1436
|
-
*
|
1437
|
-
* If you set `esmExternals` to `true`, this plugin assumes that all
|
1438
|
-
* external dependencies are ES modules and respect the
|
1439
|
-
* `requireReturnsDefault` option. If that option is not set, they will be
|
1440
|
-
* rendered as namespace imports.
|
1441
|
-
*
|
1442
|
-
* You can also supply an array of ids to be treated as ES modules, or a
|
1443
|
-
* function that will be passed each external id to determine whether it is
|
1444
|
-
* an ES module.
|
1445
|
-
* @default false
|
1446
|
-
*/
|
1447
|
-
esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
|
1448
|
-
/**
|
1449
|
-
* Controls what is returned when requiring an ES module from a CommonJS file.
|
1450
|
-
* When using the `esmExternals` option, this will also apply to external
|
1451
|
-
* modules. By default, this plugin will render those imports as namespace
|
1452
|
-
* imports i.e.
|
1453
|
-
*
|
1454
|
-
* ```js
|
1455
|
-
* // input
|
1456
|
-
* const foo = require('foo');
|
1457
|
-
*
|
1458
|
-
* // output
|
1459
|
-
* import * as foo from 'foo';
|
1460
|
-
* ```
|
1461
|
-
*
|
1462
|
-
* However, there are some situations where this may not be desired.
|
1463
|
-
* For these situations, you can change Rollup's behaviour either globally or
|
1464
|
-
* per module. To change it globally, set the `requireReturnsDefault` option
|
1465
|
-
* to one of the following values:
|
1466
|
-
*
|
1467
|
-
* - `false`: This is the default, requiring an ES module returns its
|
1468
|
-
* namespace. This is the only option that will also add a marker
|
1469
|
-
* `__esModule: true` to the namespace to support interop patterns in
|
1470
|
-
* CommonJS modules that are transpiled ES modules.
|
1471
|
-
* - `"namespace"`: Like `false`, requiring an ES module returns its
|
1472
|
-
* namespace, but the plugin does not add the `__esModule` marker and thus
|
1473
|
-
* creates more efficient code. For external dependencies when using
|
1474
|
-
* `esmExternals: true`, no additional interop code is generated.
|
1475
|
-
* - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
1476
|
-
* Rollup: If a module has a default export and no named exports, requiring
|
1477
|
-
* that module returns the default export. In all other cases, the namespace
|
1478
|
-
* is returned. For external dependencies when using `esmExternals: true`, a
|
1479
|
-
* corresponding interop helper is added.
|
1480
|
-
* - `"preferred"`: If a module has a default export, requiring that module
|
1481
|
-
* always returns the default export, no matter whether additional named
|
1482
|
-
* exports exist. This is similar to how previous versions of this plugin
|
1483
|
-
* worked. Again for external dependencies when using `esmExternals: true`,
|
1484
|
-
* an interop helper is added.
|
1485
|
-
* - `true`: This will always try to return the default export on require
|
1486
|
-
* without checking if it actually exists. This can throw at build time if
|
1487
|
-
* there is no default export. This is how external dependencies are handled
|
1488
|
-
* when `esmExternals` is not used. The advantage over the other options is
|
1489
|
-
* that, like `false`, this does not add an interop helper for external
|
1490
|
-
* dependencies, keeping the code lean.
|
1491
|
-
*
|
1492
|
-
* To change this for individual modules, you can supply a function for
|
1493
|
-
* `requireReturnsDefault` instead. This function will then be called once for
|
1494
|
-
* each required ES module or external dependency with the corresponding id
|
1495
|
-
* and allows you to return different values for different modules.
|
1496
|
-
* @default false
|
1497
|
-
*/
|
1498
|
-
requireReturnsDefault?:
|
1499
|
-
| boolean
|
1500
|
-
| 'auto'
|
1501
|
-
| 'preferred'
|
1502
|
-
| 'namespace'
|
1503
|
-
| ((id: string) => boolean | 'auto' | 'preferred' | 'namespace')
|
1504
|
-
|
1505
|
-
/**
|
1506
|
-
* @default "auto"
|
1507
|
-
*/
|
1508
|
-
defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto')
|
1509
|
-
/**
|
1510
|
-
* Some modules contain dynamic `require` calls, or require modules that
|
1511
|
-
* contain circular dependencies, which are not handled well by static
|
1512
|
-
* imports. Including those modules as `dynamicRequireTargets` will simulate a
|
1513
|
-
* CommonJS (NodeJS-like) environment for them with support for dynamic
|
1514
|
-
* dependencies. It also enables `strictRequires` for those modules.
|
1515
|
-
*
|
1516
|
-
* Note: In extreme cases, this feature may result in some paths being
|
1517
|
-
* rendered as absolute in the final bundle. The plugin tries to avoid
|
1518
|
-
* exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
1519
|
-
* with paths that are far away from your project's folder, that may require
|
1520
|
-
* replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
|
1521
|
-
*/
|
1522
|
-
dynamicRequireTargets?: string | ReadonlyArray<string>
|
1523
|
-
/**
|
1524
|
-
* To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
|
1525
|
-
* that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
|
1526
|
-
* may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
|
1527
|
-
* home directory name. By default, it uses the current working directory.
|
1528
|
-
*/
|
1529
|
-
dynamicRequireRoot?: string
|
1530
|
-
}
|
1531
|
-
|
1532
|
-
interface RollupDynamicImportVarsOptions {
|
1533
|
-
/**
|
1534
|
-
* Files to include in this plugin (default all).
|
1535
|
-
* @default []
|
1536
|
-
*/
|
1537
|
-
include?: string | RegExp | (string | RegExp)[]
|
1538
|
-
/**
|
1539
|
-
* Files to exclude in this plugin (default none).
|
1540
|
-
* @default []
|
1541
|
-
*/
|
1542
|
-
exclude?: string | RegExp | (string | RegExp)[]
|
1543
|
-
/**
|
1544
|
-
* By default, the plugin quits the build process when it encounters an error. If you set this option to true, it will throw a warning instead and leave the code untouched.
|
1545
|
-
* @default false
|
1546
|
-
*/
|
1547
|
-
warnOnError?: boolean
|
1548
|
-
}
|
1369
|
+
resume(): void
|
1549
1370
|
|
1550
|
-
//
|
1551
|
-
|
1552
|
-
|
1371
|
+
// HTML5 WebSocket events
|
1372
|
+
addEventListener(
|
1373
|
+
method: 'message',
|
1374
|
+
cb: (event: WebSocket.MessageEvent) => void,
|
1375
|
+
options?: WebSocket.EventListenerOptions,
|
1376
|
+
): void
|
1377
|
+
addEventListener(
|
1378
|
+
method: 'close',
|
1379
|
+
cb: (event: WebSocket.CloseEvent) => void,
|
1380
|
+
options?: WebSocket.EventListenerOptions,
|
1381
|
+
): void
|
1382
|
+
addEventListener(
|
1383
|
+
method: 'error',
|
1384
|
+
cb: (event: WebSocket.ErrorEvent) => void,
|
1385
|
+
options?: WebSocket.EventListenerOptions,
|
1386
|
+
): void
|
1387
|
+
addEventListener(
|
1388
|
+
method: 'open',
|
1389
|
+
cb: (event: WebSocket.Event) => void,
|
1390
|
+
options?: WebSocket.EventListenerOptions,
|
1391
|
+
): void
|
1553
1392
|
|
1554
|
-
|
1555
|
-
|
1393
|
+
removeEventListener(
|
1394
|
+
method: 'message',
|
1395
|
+
cb: (event: WebSocket.MessageEvent) => void,
|
1396
|
+
): void
|
1397
|
+
removeEventListener(
|
1398
|
+
method: 'close',
|
1399
|
+
cb: (event: WebSocket.CloseEvent) => void,
|
1400
|
+
): void
|
1401
|
+
removeEventListener(
|
1402
|
+
method: 'error',
|
1403
|
+
cb: (event: WebSocket.ErrorEvent) => void,
|
1404
|
+
): void
|
1405
|
+
removeEventListener(
|
1406
|
+
method: 'open',
|
1407
|
+
cb: (event: WebSocket.Event) => void,
|
1408
|
+
): void
|
1556
1409
|
|
1557
|
-
|
1558
|
-
|
1410
|
+
// Events
|
1411
|
+
on(
|
1412
|
+
event: 'close',
|
1413
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
1414
|
+
): this
|
1415
|
+
on(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
1416
|
+
on(
|
1417
|
+
event: 'upgrade',
|
1418
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
1419
|
+
): this
|
1420
|
+
on(
|
1421
|
+
event: 'message',
|
1422
|
+
listener: (
|
1423
|
+
this: WebSocket,
|
1424
|
+
data: WebSocket.RawData,
|
1425
|
+
isBinary: boolean,
|
1426
|
+
) => void,
|
1427
|
+
): this
|
1428
|
+
on(event: 'open', listener: (this: WebSocket) => void): this
|
1429
|
+
on(
|
1430
|
+
event: 'ping' | 'pong',
|
1431
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
1432
|
+
): this
|
1433
|
+
on(
|
1434
|
+
event: 'unexpected-response',
|
1435
|
+
listener: (
|
1436
|
+
this: WebSocket,
|
1437
|
+
request: ClientRequest,
|
1438
|
+
response: IncomingMessage,
|
1439
|
+
) => void,
|
1440
|
+
): this
|
1441
|
+
on(
|
1442
|
+
event: string | symbol,
|
1443
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
1444
|
+
): this
|
1559
1445
|
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1446
|
+
once(
|
1447
|
+
event: 'close',
|
1448
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
1449
|
+
): this
|
1450
|
+
once(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
1451
|
+
once(
|
1452
|
+
event: 'upgrade',
|
1453
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
1454
|
+
): this
|
1455
|
+
once(
|
1456
|
+
event: 'message',
|
1457
|
+
listener: (
|
1458
|
+
this: WebSocket,
|
1459
|
+
data: WebSocket.RawData,
|
1460
|
+
isBinary: boolean,
|
1461
|
+
) => void,
|
1462
|
+
): this
|
1463
|
+
once(event: 'open', listener: (this: WebSocket) => void): this
|
1464
|
+
once(
|
1465
|
+
event: 'ping' | 'pong',
|
1466
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
1467
|
+
): this
|
1468
|
+
once(
|
1469
|
+
event: 'unexpected-response',
|
1470
|
+
listener: (
|
1471
|
+
this: WebSocket,
|
1472
|
+
request: ClientRequest,
|
1473
|
+
response: IncomingMessage,
|
1474
|
+
) => void,
|
1475
|
+
): this
|
1476
|
+
once(
|
1477
|
+
event: string | symbol,
|
1478
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
1479
|
+
): this
|
1567
1480
|
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
pure_funcs?: string[]
|
1603
|
-
pure_new?: boolean
|
1604
|
-
pure_getters?: boolean | 'strict'
|
1605
|
-
reduce_funcs?: boolean
|
1606
|
-
reduce_vars?: boolean
|
1607
|
-
sequences?: boolean | number
|
1608
|
-
side_effects?: boolean
|
1609
|
-
switches?: boolean
|
1610
|
-
toplevel?: boolean
|
1611
|
-
top_retain?: null | string | string[] | RegExp
|
1612
|
-
typeofs?: boolean
|
1613
|
-
unsafe_arrows?: boolean
|
1614
|
-
unsafe?: boolean
|
1615
|
-
unsafe_comps?: boolean
|
1616
|
-
unsafe_Function?: boolean
|
1617
|
-
unsafe_math?: boolean
|
1618
|
-
unsafe_symbols?: boolean
|
1619
|
-
unsafe_methods?: boolean
|
1620
|
-
unsafe_proto?: boolean
|
1621
|
-
unsafe_regexp?: boolean
|
1622
|
-
unsafe_undefined?: boolean
|
1623
|
-
unused?: boolean
|
1624
|
-
}
|
1481
|
+
off(
|
1482
|
+
event: 'close',
|
1483
|
+
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
1484
|
+
): this
|
1485
|
+
off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
1486
|
+
off(
|
1487
|
+
event: 'upgrade',
|
1488
|
+
listener: (this: WebSocket, request: IncomingMessage) => void,
|
1489
|
+
): this
|
1490
|
+
off(
|
1491
|
+
event: 'message',
|
1492
|
+
listener: (
|
1493
|
+
this: WebSocket,
|
1494
|
+
data: WebSocket.RawData,
|
1495
|
+
isBinary: boolean,
|
1496
|
+
) => void,
|
1497
|
+
): this
|
1498
|
+
off(event: 'open', listener: (this: WebSocket) => void): this
|
1499
|
+
off(
|
1500
|
+
event: 'ping' | 'pong',
|
1501
|
+
listener: (this: WebSocket, data: Buffer) => void,
|
1502
|
+
): this
|
1503
|
+
off(
|
1504
|
+
event: 'unexpected-response',
|
1505
|
+
listener: (
|
1506
|
+
this: WebSocket,
|
1507
|
+
request: ClientRequest,
|
1508
|
+
response: IncomingMessage,
|
1509
|
+
) => void,
|
1510
|
+
): this
|
1511
|
+
off(
|
1512
|
+
event: string | symbol,
|
1513
|
+
listener: (this: WebSocket, ...args: any[]) => void,
|
1514
|
+
): this
|
1625
1515
|
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1516
|
+
addListener(
|
1517
|
+
event: 'close',
|
1518
|
+
listener: (code: number, reason: Buffer) => void,
|
1519
|
+
): this
|
1520
|
+
addListener(event: 'error', listener: (err: Error) => void): this
|
1521
|
+
addListener(
|
1522
|
+
event: 'upgrade',
|
1523
|
+
listener: (request: IncomingMessage) => void,
|
1524
|
+
): this
|
1525
|
+
addListener(
|
1526
|
+
event: 'message',
|
1527
|
+
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
1528
|
+
): this
|
1529
|
+
addListener(event: 'open', listener: () => void): this
|
1530
|
+
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
1531
|
+
addListener(
|
1532
|
+
event: 'unexpected-response',
|
1533
|
+
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
1534
|
+
): this
|
1535
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this
|
1632
1536
|
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1537
|
+
removeListener(
|
1538
|
+
event: 'close',
|
1539
|
+
listener: (code: number, reason: Buffer) => void,
|
1540
|
+
): this
|
1541
|
+
removeListener(event: 'error', listener: (err: Error) => void): this
|
1542
|
+
removeListener(
|
1543
|
+
event: 'upgrade',
|
1544
|
+
listener: (request: IncomingMessage) => void,
|
1545
|
+
): this
|
1546
|
+
removeListener(
|
1547
|
+
event: 'message',
|
1548
|
+
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
1549
|
+
): this
|
1550
|
+
removeListener(event: 'open', listener: () => void): this
|
1551
|
+
removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
1552
|
+
removeListener(
|
1553
|
+
event: 'unexpected-response',
|
1554
|
+
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
1555
|
+
): this
|
1556
|
+
removeListener(
|
1557
|
+
event: string | symbol,
|
1558
|
+
listener: (...args: any[]) => void,
|
1559
|
+
): this
|
1560
|
+
}
|
1644
1561
|
|
1562
|
+
declare namespace WebSocket {
|
1645
1563
|
/**
|
1646
|
-
*
|
1564
|
+
* Data represents the raw message payload received over the WebSocket.
|
1647
1565
|
*/
|
1648
|
-
|
1649
|
-
/**
|
1650
|
-
* Obtains the nth most favored (usually shortest) identifier to rename a variable to.
|
1651
|
-
* The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
|
1652
|
-
* This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
|
1653
|
-
* @param n The ordinal of the identifier.
|
1654
|
-
*/
|
1655
|
-
get(n: number): string
|
1656
|
-
}
|
1566
|
+
type RawData = Buffer | ArrayBuffer | Buffer[]
|
1657
1567
|
|
1658
1568
|
/**
|
1659
|
-
*
|
1569
|
+
* Data represents the message payload received over the WebSocket.
|
1660
1570
|
*/
|
1661
|
-
|
1662
|
-
/**
|
1663
|
-
* Modifies the internal weighting of the input characters by the specified delta.
|
1664
|
-
* Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
|
1665
|
-
* @param chars The characters to modify the weighting of.
|
1666
|
-
* @param delta The numeric weight to add to the characters.
|
1667
|
-
*/
|
1668
|
-
consider(chars: string, delta: number): number
|
1669
|
-
/**
|
1670
|
-
* Resets character weights.
|
1671
|
-
*/
|
1672
|
-
reset(): void
|
1673
|
-
/**
|
1674
|
-
* Sorts identifiers by character frequency, in preparation for calls to get(n).
|
1675
|
-
*/
|
1676
|
-
sort(): void
|
1677
|
-
}
|
1678
|
-
|
1679
|
-
export interface ManglePropertiesOptions {
|
1680
|
-
builtins?: boolean
|
1681
|
-
debug?: boolean
|
1682
|
-
keep_quoted?: boolean | 'strict'
|
1683
|
-
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
1684
|
-
regex?: RegExp | string
|
1685
|
-
reserved?: string[]
|
1686
|
-
}
|
1571
|
+
type Data = string | Buffer | ArrayBuffer | Buffer[]
|
1687
1572
|
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
braces?: boolean
|
1693
|
-
comments?:
|
1694
|
-
| boolean
|
1695
|
-
| 'all'
|
1696
|
-
| 'some'
|
1697
|
-
| RegExp
|
1698
|
-
| ((
|
1699
|
-
node: any,
|
1700
|
-
comment: {
|
1701
|
-
value: string
|
1702
|
-
type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
|
1703
|
-
pos: number
|
1704
|
-
line: number
|
1705
|
-
col: number
|
1706
|
-
},
|
1707
|
-
) => boolean)
|
1708
|
-
ecma?: ECMA
|
1709
|
-
ie8?: boolean
|
1710
|
-
keep_numbers?: boolean
|
1711
|
-
indent_level?: number
|
1712
|
-
indent_start?: number
|
1713
|
-
inline_script?: boolean
|
1714
|
-
keep_quoted_props?: boolean
|
1715
|
-
max_line_len?: number | false
|
1716
|
-
preamble?: string
|
1717
|
-
preserve_annotations?: boolean
|
1718
|
-
quote_keys?: boolean
|
1719
|
-
quote_style?: OutputQuoteStyle
|
1720
|
-
safari10?: boolean
|
1721
|
-
semicolons?: boolean
|
1722
|
-
shebang?: boolean
|
1723
|
-
shorthand?: boolean
|
1724
|
-
source_map?: SourceMapOptions
|
1725
|
-
webkit?: boolean
|
1726
|
-
width?: number
|
1727
|
-
wrap_iife?: boolean
|
1728
|
-
wrap_func_args?: boolean
|
1729
|
-
}
|
1573
|
+
/**
|
1574
|
+
* CertMeta represents the accepted types for certificate & key data.
|
1575
|
+
*/
|
1576
|
+
type CertMeta = string | string[] | Buffer | Buffer[]
|
1730
1577
|
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1578
|
+
/**
|
1579
|
+
* VerifyClientCallbackSync is a synchronous callback used to inspect the
|
1580
|
+
* incoming message. The return value (boolean) of the function determines
|
1581
|
+
* whether or not to accept the handshake.
|
1582
|
+
*/
|
1583
|
+
type VerifyClientCallbackSync = (info: {
|
1584
|
+
origin: string
|
1585
|
+
secure: boolean
|
1586
|
+
req: IncomingMessage
|
1587
|
+
}) => boolean
|
1737
1588
|
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1589
|
+
/**
|
1590
|
+
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
|
1591
|
+
* incoming message. The return value (boolean) of the function determines
|
1592
|
+
* whether or not to accept the handshake.
|
1593
|
+
*/
|
1594
|
+
type VerifyClientCallbackAsync = (
|
1595
|
+
info: { origin: string; secure: boolean; req: IncomingMessage },
|
1596
|
+
callback: (
|
1597
|
+
res: boolean,
|
1598
|
+
code?: number,
|
1599
|
+
message?: string,
|
1600
|
+
headers?: OutgoingHttpHeaders,
|
1601
|
+
) => void,
|
1602
|
+
) => void
|
1603
|
+
|
1604
|
+
interface ClientOptions extends SecureContextOptions {
|
1605
|
+
protocol?: string | undefined
|
1606
|
+
followRedirects?: boolean | undefined
|
1607
|
+
generateMask?(mask: Buffer): void
|
1608
|
+
handshakeTimeout?: number | undefined
|
1609
|
+
maxRedirects?: number | undefined
|
1610
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
1611
|
+
localAddress?: string | undefined
|
1612
|
+
protocolVersion?: number | undefined
|
1613
|
+
headers?: { [key: string]: string } | undefined
|
1614
|
+
origin?: string | undefined
|
1615
|
+
agent?: Agent | undefined
|
1616
|
+
host?: string | undefined
|
1617
|
+
family?: number | undefined
|
1618
|
+
checkServerIdentity?(servername: string, cert: CertMeta): boolean
|
1619
|
+
rejectUnauthorized?: boolean | undefined
|
1620
|
+
maxPayload?: number | undefined
|
1621
|
+
skipUTF8Validation?: boolean | undefined
|
1755
1622
|
}
|
1756
1623
|
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1624
|
+
interface PerMessageDeflateOptions {
|
1625
|
+
serverNoContextTakeover?: boolean | undefined
|
1626
|
+
clientNoContextTakeover?: boolean | undefined
|
1627
|
+
serverMaxWindowBits?: number | undefined
|
1628
|
+
clientMaxWindowBits?: number | undefined
|
1629
|
+
zlibDeflateOptions?:
|
1630
|
+
| {
|
1631
|
+
flush?: number | undefined
|
1632
|
+
finishFlush?: number | undefined
|
1633
|
+
chunkSize?: number | undefined
|
1634
|
+
windowBits?: number | undefined
|
1635
|
+
level?: number | undefined
|
1636
|
+
memLevel?: number | undefined
|
1637
|
+
strategy?: number | undefined
|
1638
|
+
dictionary?: Buffer | Buffer[] | DataView | undefined
|
1639
|
+
info?: boolean | undefined
|
1640
|
+
}
|
1641
|
+
| undefined
|
1642
|
+
zlibInflateOptions?: ZlibOptions | undefined
|
1643
|
+
threshold?: number | undefined
|
1644
|
+
concurrencyLimit?: number | undefined
|
1761
1645
|
}
|
1762
1646
|
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
includeSources?: boolean
|
1767
|
-
filename?: string
|
1768
|
-
root?: string
|
1769
|
-
asObject?: boolean
|
1770
|
-
url?: string | 'inline'
|
1647
|
+
interface Event {
|
1648
|
+
type: string
|
1649
|
+
target: WebSocket
|
1771
1650
|
}
|
1772
|
-
}
|
1773
1651
|
|
1774
|
-
interface
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
*/
|
1781
|
-
maxWorkers?: number;
|
1782
|
-
}
|
1652
|
+
interface ErrorEvent {
|
1653
|
+
error: any
|
1654
|
+
message: string
|
1655
|
+
type: string
|
1656
|
+
target: WebSocket
|
1657
|
+
}
|
1783
1658
|
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
|
1792
|
-
getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
|
1793
|
-
data: {
|
1794
|
-
[field: string]: any;
|
1795
|
-
name: string;
|
1796
|
-
type: string;
|
1797
|
-
version: string;
|
1798
|
-
main: string;
|
1799
|
-
module: string;
|
1800
|
-
browser: string | Record<string, string | false>;
|
1801
|
-
exports: string | Record<string, any> | string[];
|
1802
|
-
imports: Record<string, any>;
|
1803
|
-
dependencies: Record<string, string>;
|
1804
|
-
};
|
1805
|
-
}
|
1659
|
+
interface CloseEvent {
|
1660
|
+
wasClean: boolean
|
1661
|
+
code: number
|
1662
|
+
reason: string
|
1663
|
+
type: string
|
1664
|
+
target: WebSocket
|
1665
|
+
}
|
1806
1666
|
|
1807
|
-
interface
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
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
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1667
|
+
interface MessageEvent {
|
1668
|
+
data: Data
|
1669
|
+
type: string
|
1670
|
+
target: WebSocket
|
1671
|
+
}
|
1672
|
+
|
1673
|
+
interface EventListenerOptions {
|
1674
|
+
once?: boolean | undefined
|
1675
|
+
}
|
1676
|
+
|
1677
|
+
interface ServerOptions {
|
1678
|
+
host?: string | undefined
|
1679
|
+
port?: number | undefined
|
1680
|
+
backlog?: number | undefined
|
1681
|
+
server?: Server | HttpsServer | undefined
|
1682
|
+
verifyClient?:
|
1683
|
+
| VerifyClientCallbackAsync
|
1684
|
+
| VerifyClientCallbackSync
|
1685
|
+
| undefined
|
1686
|
+
handleProtocols?: (
|
1687
|
+
protocols: Set<string>,
|
1688
|
+
request: IncomingMessage,
|
1689
|
+
) => string | false
|
1690
|
+
path?: string | undefined
|
1691
|
+
noServer?: boolean | undefined
|
1692
|
+
clientTracking?: boolean | undefined
|
1693
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
1694
|
+
maxPayload?: number | undefined
|
1695
|
+
skipUTF8Validation?: boolean | undefined
|
1696
|
+
WebSocket?: typeof WebSocket.WebSocket | undefined
|
1697
|
+
}
|
1698
|
+
|
1699
|
+
interface AddressInfo {
|
1700
|
+
address: string
|
1701
|
+
family: string
|
1702
|
+
port: number
|
1703
|
+
}
|
1704
|
+
|
1705
|
+
// WebSocket Server
|
1706
|
+
class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
1707
|
+
options: ServerOptions
|
1708
|
+
path: string
|
1709
|
+
clients: Set<T>
|
1710
|
+
|
1711
|
+
constructor(options?: ServerOptions, callback?: () => void)
|
1712
|
+
|
1713
|
+
address(): AddressInfo | string
|
1714
|
+
close(cb?: (err?: Error) => void): void
|
1715
|
+
handleUpgrade(
|
1716
|
+
request: IncomingMessage,
|
1717
|
+
socket: Duplex,
|
1718
|
+
upgradeHead: Buffer,
|
1719
|
+
callback: (client: T, request: IncomingMessage) => void,
|
1720
|
+
): void
|
1721
|
+
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
1722
|
+
|
1723
|
+
// Events
|
1724
|
+
on(
|
1725
|
+
event: 'connection',
|
1726
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
1727
|
+
): this
|
1728
|
+
on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
1729
|
+
on(
|
1730
|
+
event: 'headers',
|
1731
|
+
cb: (
|
1732
|
+
this: Server<T>,
|
1733
|
+
headers: string[],
|
1734
|
+
request: IncomingMessage,
|
1735
|
+
) => void,
|
1736
|
+
): this
|
1737
|
+
on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
1738
|
+
on(
|
1739
|
+
event: string | symbol,
|
1740
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
1741
|
+
): this
|
1742
|
+
|
1743
|
+
once(
|
1744
|
+
event: 'connection',
|
1745
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
1746
|
+
): this
|
1747
|
+
once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
1748
|
+
once(
|
1749
|
+
event: 'headers',
|
1750
|
+
cb: (
|
1751
|
+
this: Server<T>,
|
1752
|
+
headers: string[],
|
1753
|
+
request: IncomingMessage,
|
1754
|
+
) => void,
|
1755
|
+
): this
|
1756
|
+
once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
1757
|
+
once(
|
1758
|
+
event: string | symbol,
|
1759
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
1760
|
+
): this
|
1761
|
+
|
1762
|
+
off(
|
1763
|
+
event: 'connection',
|
1764
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
|
1765
|
+
): this
|
1766
|
+
off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
1767
|
+
off(
|
1768
|
+
event: 'headers',
|
1769
|
+
cb: (
|
1770
|
+
this: Server<T>,
|
1771
|
+
headers: string[],
|
1772
|
+
request: IncomingMessage,
|
1773
|
+
) => void,
|
1774
|
+
): this
|
1775
|
+
off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
1776
|
+
off(
|
1777
|
+
event: string | symbol,
|
1778
|
+
listener: (this: Server<T>, ...args: any[]) => void,
|
1779
|
+
): this
|
1780
|
+
|
1781
|
+
addListener(
|
1782
|
+
event: 'connection',
|
1783
|
+
cb: (client: T, request: IncomingMessage) => void,
|
1784
|
+
): this
|
1785
|
+
addListener(event: 'error', cb: (err: Error) => void): this
|
1786
|
+
addListener(
|
1787
|
+
event: 'headers',
|
1788
|
+
cb: (headers: string[], request: IncomingMessage) => void,
|
1789
|
+
): this
|
1790
|
+
addListener(event: 'close' | 'listening', cb: () => void): this
|
1791
|
+
addListener(
|
1792
|
+
event: string | symbol,
|
1793
|
+
listener: (...args: any[]) => void,
|
1794
|
+
): this
|
1795
|
+
|
1796
|
+
removeListener(event: 'connection', cb: (client: T) => void): this
|
1797
|
+
removeListener(event: 'error', cb: (err: Error) => void): this
|
1798
|
+
removeListener(
|
1799
|
+
event: 'headers',
|
1800
|
+
cb: (headers: string[], request: IncomingMessage) => void,
|
1801
|
+
): this
|
1802
|
+
removeListener(event: 'close' | 'listening', cb: () => void): this
|
1803
|
+
removeListener(
|
1804
|
+
event: string | symbol,
|
1805
|
+
listener: (...args: any[]) => void,
|
1806
|
+
): this
|
1807
|
+
}
|
1808
|
+
|
1809
|
+
const WebSocketServer: typeof Server
|
1810
|
+
interface WebSocketServer extends Server {}
|
1811
|
+
const WebSocket: typeof WebSocketAlias
|
1812
|
+
interface WebSocket extends WebSocketAlias {}
|
1813
|
+
|
1814
|
+
// WebSocket stream
|
1815
|
+
function createWebSocketStream(
|
1816
|
+
websocket: WebSocket,
|
1817
|
+
options?: DuplexOptions,
|
1818
|
+
): Duplex
|
1819
|
+
}
|
1820
|
+
|
1821
|
+
type WebSocketCustomListener<T> = (data: T, client: WebSocketClient, invoke?: 'send' | `send:${string}`) => void;
|
1822
|
+
declare const isWebSocketServer: unique symbol;
|
1823
|
+
interface WebSocketServer extends NormalizedHotChannel {
|
1950
1824
|
/**
|
1951
|
-
*
|
1952
|
-
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
1953
|
-
* configurations that are suitable for distributing libraries.
|
1954
|
-
* @default false
|
1825
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
1955
1826
|
*/
|
1956
|
-
|
1827
|
+
on: WebSocket.Server['on'] & {
|
1828
|
+
<T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
|
1829
|
+
};
|
1957
1830
|
/**
|
1958
|
-
*
|
1959
|
-
* `rollupOptions.input`.
|
1960
|
-
* @default false
|
1831
|
+
* Unregister event listener.
|
1961
1832
|
*/
|
1962
|
-
|
1833
|
+
off: WebSocket.Server['off'] & {
|
1834
|
+
(event: string, listener: Function): void;
|
1835
|
+
};
|
1963
1836
|
/**
|
1964
|
-
*
|
1965
|
-
* directives in production.
|
1966
|
-
* @default false
|
1837
|
+
* Listen on port and host
|
1967
1838
|
*/
|
1968
|
-
|
1839
|
+
listen(): void;
|
1969
1840
|
/**
|
1970
|
-
*
|
1971
|
-
* @default false
|
1841
|
+
* Disconnect all clients and terminate the server.
|
1972
1842
|
*/
|
1973
|
-
|
1843
|
+
close(): Promise<void>;
|
1844
|
+
[isWebSocketServer]: true;
|
1974
1845
|
/**
|
1975
|
-
*
|
1976
|
-
* By default, it is true for the client and false for other environments.
|
1846
|
+
* Get all connected clients.
|
1977
1847
|
*/
|
1978
|
-
|
1848
|
+
clients: Set<WebSocketClient>;
|
1849
|
+
}
|
1850
|
+
interface WebSocketClient extends HotChannelClient {
|
1979
1851
|
/**
|
1980
|
-
*
|
1981
|
-
*
|
1982
|
-
* @default true
|
1852
|
+
* The raw WebSocket instance
|
1853
|
+
* @advanced
|
1983
1854
|
*/
|
1984
|
-
|
1855
|
+
socket: WebSocket;
|
1856
|
+
}
|
1857
|
+
|
1858
|
+
interface DevEnvironmentContext {
|
1859
|
+
hot: boolean;
|
1860
|
+
transport?: HotChannel | WebSocketServer;
|
1861
|
+
options?: EnvironmentOptions;
|
1862
|
+
remoteRunner?: {
|
1863
|
+
inlineSourceMap?: boolean;
|
1864
|
+
};
|
1865
|
+
depsOptimizer?: DepsOptimizer;
|
1866
|
+
}
|
1867
|
+
declare class DevEnvironment extends BaseEnvironment {
|
1868
|
+
mode: "dev";
|
1869
|
+
moduleGraph: EnvironmentModuleGraph;
|
1870
|
+
depsOptimizer?: DepsOptimizer;
|
1871
|
+
get pluginContainer(): EnvironmentPluginContainer;
|
1985
1872
|
/**
|
1986
|
-
*
|
1987
|
-
*
|
1873
|
+
* Hot channel for this environment. If not provided or disabled,
|
1874
|
+
* it will be a noop channel that does nothing.
|
1875
|
+
*
|
1876
|
+
* @example
|
1877
|
+
* environment.hot.send({ type: 'full-reload' })
|
1988
1878
|
*/
|
1989
|
-
|
1879
|
+
hot: NormalizedHotChannel;
|
1880
|
+
constructor(name: string, config: ResolvedConfig, context: DevEnvironmentContext);
|
1881
|
+
init(options?: {
|
1882
|
+
watcher?: FSWatcher;
|
1883
|
+
/**
|
1884
|
+
* the previous instance used for the environment with the same name
|
1885
|
+
*
|
1886
|
+
* when using, the consumer should check if it's an instance generated from the same class or factory function
|
1887
|
+
*/
|
1888
|
+
previousInstance?: DevEnvironment;
|
1889
|
+
}): Promise<void>;
|
1990
1890
|
/**
|
1991
|
-
*
|
1992
|
-
*
|
1993
|
-
*
|
1891
|
+
* When the dev server is restarted, the methods are called in the following order:
|
1892
|
+
* - new instance `init`
|
1893
|
+
* - previous instance `close`
|
1894
|
+
* - new instance `listen`
|
1994
1895
|
*/
|
1995
|
-
|
1896
|
+
listen(server: ViteDevServer): Promise<void>;
|
1897
|
+
fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<FetchResult>;
|
1898
|
+
reloadModule(module: EnvironmentModuleNode): Promise<void>;
|
1899
|
+
transformRequest(url: string): Promise<TransformResult | null>;
|
1900
|
+
warmupRequest(url: string): Promise<void>;
|
1901
|
+
close(): Promise<void>;
|
1996
1902
|
/**
|
1997
|
-
*
|
1903
|
+
* Calling `await environment.waitForRequestsIdle(id)` will wait until all static imports
|
1904
|
+
* are processed after the first transformRequest call. If called from a load or transform
|
1905
|
+
* plugin hook, the id needs to be passed as a parameter to avoid deadlocks.
|
1906
|
+
* Calling this function after the first static imports section of the module graph has been
|
1907
|
+
* processed will resolve immediately.
|
1908
|
+
* @experimental
|
1998
1909
|
*/
|
1999
|
-
|
1910
|
+
waitForRequestsIdle(ignoredId?: string): Promise<void>;
|
2000
1911
|
}
|
2001
|
-
type BuildOptions = BuildEnvironmentOptions;
|
2002
|
-
interface LibraryOptions {
|
2003
|
-
/**
|
2004
|
-
* Path of library entry
|
2005
|
-
*/
|
2006
|
-
entry: InputOption;
|
2007
|
-
/**
|
2008
|
-
* The name of the exposed global variable. Required when the `formats` option includes
|
2009
|
-
* `umd` or `iife`
|
2010
|
-
*/
|
2011
|
-
name?: string;
|
2012
|
-
/**
|
2013
|
-
* Output bundle formats
|
2014
|
-
* @default ['es', 'umd']
|
2015
|
-
*/
|
2016
|
-
formats?: LibraryFormats[];
|
2017
|
-
/**
|
2018
|
-
* The name of the package file output. The default file name is the name option
|
2019
|
-
* of the project package.json. It can also be defined as a function taking the
|
2020
|
-
* format as an argument.
|
2021
|
-
*/
|
2022
|
-
fileName?: string | ((format: ModuleFormat, entryName: string) => string);
|
2023
|
-
}
|
2024
|
-
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' | 'system';
|
2025
|
-
interface ModulePreloadOptions {
|
2026
|
-
/**
|
2027
|
-
* Whether to inject a module preload polyfill.
|
2028
|
-
* Note: does not apply to library mode.
|
2029
|
-
* @default true
|
2030
|
-
*/
|
2031
|
-
polyfill?: boolean;
|
2032
|
-
/**
|
2033
|
-
* Resolve the list of dependencies to preload for a given dynamic import
|
2034
|
-
* @experimental
|
2035
|
-
*/
|
2036
|
-
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2037
|
-
}
|
2038
|
-
interface ResolvedModulePreloadOptions {
|
2039
|
-
polyfill: boolean;
|
2040
|
-
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2041
|
-
}
|
2042
|
-
type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
|
2043
|
-
hostId: string;
|
2044
|
-
hostType: 'html' | 'js';
|
2045
|
-
}) => string[];
|
2046
|
-
interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> {
|
2047
|
-
modulePreload: false | ResolvedModulePreloadOptions;
|
2048
|
-
}
|
2049
|
-
interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
|
2050
|
-
modulePreload: false | ResolvedModulePreloadOptions;
|
2051
|
-
}
|
2052
|
-
/**
|
2053
|
-
* Bundles a single environment for production.
|
2054
|
-
* Returns a Promise containing the build result.
|
2055
|
-
*/
|
2056
|
-
declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2057
|
-
type RenderBuiltAssetUrl = (filename: string, type: {
|
2058
|
-
type: 'asset' | 'public';
|
2059
|
-
hostId: string;
|
2060
|
-
hostType: 'js' | 'css' | 'html';
|
2061
|
-
ssr: boolean;
|
2062
|
-
}) => string | {
|
2063
|
-
relative?: boolean;
|
2064
|
-
runtime?: string;
|
2065
|
-
} | undefined;
|
2066
|
-
declare class BuildEnvironment extends BaseEnvironment {
|
2067
|
-
mode: "build";
|
2068
|
-
constructor(name: string, config: ResolvedConfig, setup?: {
|
2069
|
-
options?: EnvironmentOptions;
|
2070
|
-
});
|
2071
|
-
init(): Promise<void>;
|
2072
|
-
}
|
2073
|
-
interface ViteBuilder {
|
2074
|
-
environments: Record<string, BuildEnvironment>;
|
2075
|
-
config: ResolvedConfig;
|
2076
|
-
buildApp(): Promise<void>;
|
2077
|
-
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2078
|
-
}
|
2079
|
-
interface BuilderOptions {
|
2080
|
-
sharedConfigBuild?: boolean;
|
2081
|
-
sharedPlugins?: boolean;
|
2082
|
-
entireApp?: boolean;
|
2083
|
-
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2084
|
-
}
|
2085
|
-
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2086
|
-
/**
|
2087
|
-
* Creates a ViteBuilder to orchestrate building multiple environments.
|
2088
|
-
*/
|
2089
|
-
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2090
|
-
|
2091
|
-
type Environment = DevEnvironment | BuildEnvironment | UnknownEnvironment;
|
2092
|
-
|
2093
|
-
declare class EnvironmentPluginContainer {
|
2094
|
-
environment: Environment;
|
2095
|
-
plugins: Plugin[];
|
2096
|
-
watcher?: FSWatcher | undefined;
|
2097
|
-
private _pluginContextMap;
|
2098
|
-
private _resolvedRollupOptions?;
|
2099
|
-
private _processesing;
|
2100
|
-
private _seenResolves;
|
2101
|
-
private _moduleNodeToLoadAddedImports;
|
2102
|
-
getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks'];
|
2103
|
-
getSortedPlugins: PluginHookUtils['getSortedPlugins'];
|
2104
|
-
moduleGraph: EnvironmentModuleGraph | undefined;
|
2105
|
-
watchFiles: Set<string>;
|
2106
|
-
minimalContext: MinimalPluginContext;
|
2107
|
-
private _started;
|
2108
|
-
private _buildStartPromise;
|
2109
|
-
private _closed;
|
2110
|
-
private _updateModuleLoadAddedImports;
|
2111
|
-
private _getAddedImports;
|
2112
|
-
getModuleInfo(id: string): ModuleInfo | null;
|
2113
|
-
private handleHookPromise;
|
2114
|
-
get options(): InputOptions;
|
2115
|
-
resolveRollupOptions(): Promise<InputOptions>;
|
2116
|
-
private _getPluginContext;
|
2117
|
-
private hookParallel;
|
2118
|
-
buildStart(_options?: InputOptions): Promise<void>;
|
2119
|
-
resolveId(rawId: string, importer?: string | undefined, options?: {
|
2120
|
-
attributes?: Record<string, string>;
|
2121
|
-
custom?: CustomPluginOptions;
|
2122
|
-
skip?: Set<Plugin>;
|
2123
|
-
isEntry?: boolean;
|
2124
|
-
}): Promise<PartialResolvedId | null>;
|
2125
|
-
load(id: string): Promise<LoadResult | null>;
|
2126
|
-
transform(code: string, id: string, options?: {
|
2127
|
-
inMap?: SourceDescription['map'];
|
2128
|
-
}): Promise<{
|
2129
|
-
code: string;
|
2130
|
-
map: SourceMap | {
|
2131
|
-
mappings: '';
|
2132
|
-
} | null;
|
2133
|
-
}>;
|
2134
|
-
watchChange(id: string, change: {
|
2135
|
-
event: 'create' | 'update' | 'delete';
|
2136
|
-
}): Promise<void>;
|
2137
|
-
close(): Promise<void>;
|
2138
|
-
}
|
2139
|
-
declare class PluginContainer {
|
2140
|
-
private environments;
|
2141
|
-
constructor(environments: Record<string, Environment>);
|
2142
|
-
private _getEnvironment;
|
2143
|
-
private _getPluginContainer;
|
2144
|
-
getModuleInfo(id: string): ModuleInfo | null;
|
2145
|
-
get options(): InputOptions;
|
2146
|
-
buildStart(_options?: InputOptions): Promise<void>;
|
2147
|
-
watchChange(id: string, change: {
|
2148
|
-
event: 'create' | 'update' | 'delete';
|
2149
|
-
}): Promise<void>;
|
2150
|
-
resolveId(rawId: string, importer?: string, options?: {
|
2151
|
-
attributes?: Record<string, string>;
|
2152
|
-
custom?: CustomPluginOptions;
|
2153
|
-
skip?: Set<Plugin>;
|
2154
|
-
ssr?: boolean;
|
2155
|
-
isEntry?: boolean;
|
2156
|
-
}): Promise<PartialResolvedId | null>;
|
2157
|
-
load(id: string, options?: {
|
2158
|
-
ssr?: boolean;
|
2159
|
-
}): Promise<LoadResult | null>;
|
2160
|
-
transform(code: string, id: string, options?: {
|
2161
|
-
ssr?: boolean;
|
2162
|
-
environment?: Environment;
|
2163
|
-
inMap?: SourceDescription['map'];
|
2164
|
-
}): Promise<{
|
2165
|
-
code: string;
|
2166
|
-
map: SourceMap | {
|
2167
|
-
mappings: '';
|
2168
|
-
} | null;
|
2169
|
-
}>;
|
2170
|
-
close(): Promise<void>;
|
2171
|
-
}
|
2172
|
-
|
2173
|
-
// Modified and inlined to avoid extra dependency
|
2174
|
-
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts
|
2175
|
-
|
2176
|
-
declare const WebSocketAlias: typeof WebSocket
|
2177
|
-
interface WebSocketAlias extends WebSocket {}
|
2178
|
-
|
2179
|
-
// WebSocket socket.
|
2180
|
-
declare class WebSocket extends EventEmitter {
|
2181
|
-
/** The connection is not yet open. */
|
2182
|
-
static readonly CONNECTING: 0
|
2183
|
-
/** The connection is open and ready to communicate. */
|
2184
|
-
static readonly OPEN: 1
|
2185
|
-
/** The connection is in the process of closing. */
|
2186
|
-
static readonly CLOSING: 2
|
2187
|
-
/** The connection is closed. */
|
2188
|
-
static readonly CLOSED: 3
|
2189
|
-
|
2190
|
-
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
|
2191
|
-
readonly bufferedAmount: number
|
2192
|
-
readonly extensions: string
|
2193
|
-
/** Indicates whether the websocket is paused */
|
2194
|
-
readonly isPaused: boolean
|
2195
|
-
readonly protocol: string
|
2196
|
-
/** The current state of the connection */
|
2197
|
-
readonly readyState:
|
2198
|
-
| typeof WebSocket.CONNECTING
|
2199
|
-
| typeof WebSocket.OPEN
|
2200
|
-
| typeof WebSocket.CLOSING
|
2201
|
-
| typeof WebSocket.CLOSED
|
2202
|
-
readonly url: string
|
2203
|
-
|
2204
|
-
/** The connection is not yet open. */
|
2205
|
-
readonly CONNECTING: 0
|
2206
|
-
/** The connection is open and ready to communicate. */
|
2207
|
-
readonly OPEN: 1
|
2208
|
-
/** The connection is in the process of closing. */
|
2209
|
-
readonly CLOSING: 2
|
2210
|
-
/** The connection is closed. */
|
2211
|
-
readonly CLOSED: 3
|
2212
|
-
|
2213
|
-
onopen: ((event: WebSocket.Event) => void) | null
|
2214
|
-
onerror: ((event: WebSocket.ErrorEvent) => void) | null
|
2215
|
-
onclose: ((event: WebSocket.CloseEvent) => void) | null
|
2216
|
-
onmessage: ((event: WebSocket.MessageEvent) => void) | null
|
2217
|
-
|
2218
|
-
constructor(address: null)
|
2219
|
-
constructor(
|
2220
|
-
address: string | URL,
|
2221
|
-
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
2222
|
-
)
|
2223
|
-
constructor(
|
2224
|
-
address: string | URL,
|
2225
|
-
protocols?: string | string[],
|
2226
|
-
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
2227
|
-
)
|
2228
|
-
|
2229
|
-
close(code?: number, data?: string | Buffer): void
|
2230
|
-
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
2231
|
-
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
|
2232
|
-
send(data: any, cb?: (err?: Error) => void): void
|
2233
|
-
send(
|
2234
|
-
data: any,
|
2235
|
-
options: {
|
2236
|
-
mask?: boolean | undefined
|
2237
|
-
binary?: boolean | undefined
|
2238
|
-
compress?: boolean | undefined
|
2239
|
-
fin?: boolean | undefined
|
2240
|
-
},
|
2241
|
-
cb?: (err?: Error) => void,
|
2242
|
-
): void
|
2243
|
-
terminate(): void
|
2244
1912
|
|
1913
|
+
interface RollupCommonJSOptions {
|
2245
1914
|
/**
|
2246
|
-
*
|
2247
|
-
*
|
2248
|
-
*
|
1915
|
+
* A minimatch pattern, or array of patterns, which specifies the files in
|
1916
|
+
* the build the plugin should operate on. By default, all files with
|
1917
|
+
* extension `".cjs"` or those in `extensions` are included, but you can
|
1918
|
+
* narrow this list by only including specific files. These files will be
|
1919
|
+
* analyzed and transpiled if either the analysis does not find ES module
|
1920
|
+
* specific statements or `transformMixedEsModules` is `true`.
|
1921
|
+
* @default undefined
|
2249
1922
|
*/
|
2250
|
-
|
1923
|
+
include?: string | RegExp | readonly (string | RegExp)[]
|
2251
1924
|
/**
|
2252
|
-
*
|
2253
|
-
*
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
method: 'message',
|
2260
|
-
cb: (event: WebSocket.MessageEvent) => void,
|
2261
|
-
options?: WebSocket.EventListenerOptions,
|
2262
|
-
): void
|
2263
|
-
addEventListener(
|
2264
|
-
method: 'close',
|
2265
|
-
cb: (event: WebSocket.CloseEvent) => void,
|
2266
|
-
options?: WebSocket.EventListenerOptions,
|
2267
|
-
): void
|
2268
|
-
addEventListener(
|
2269
|
-
method: 'error',
|
2270
|
-
cb: (event: WebSocket.ErrorEvent) => void,
|
2271
|
-
options?: WebSocket.EventListenerOptions,
|
2272
|
-
): void
|
2273
|
-
addEventListener(
|
2274
|
-
method: 'open',
|
2275
|
-
cb: (event: WebSocket.Event) => void,
|
2276
|
-
options?: WebSocket.EventListenerOptions,
|
2277
|
-
): void
|
2278
|
-
|
2279
|
-
removeEventListener(
|
2280
|
-
method: 'message',
|
2281
|
-
cb: (event: WebSocket.MessageEvent) => void,
|
2282
|
-
): void
|
2283
|
-
removeEventListener(
|
2284
|
-
method: 'close',
|
2285
|
-
cb: (event: WebSocket.CloseEvent) => void,
|
2286
|
-
): void
|
2287
|
-
removeEventListener(
|
2288
|
-
method: 'error',
|
2289
|
-
cb: (event: WebSocket.ErrorEvent) => void,
|
2290
|
-
): void
|
2291
|
-
removeEventListener(
|
2292
|
-
method: 'open',
|
2293
|
-
cb: (event: WebSocket.Event) => void,
|
2294
|
-
): void
|
2295
|
-
|
2296
|
-
// Events
|
2297
|
-
on(
|
2298
|
-
event: 'close',
|
2299
|
-
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2300
|
-
): this
|
2301
|
-
on(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2302
|
-
on(
|
2303
|
-
event: 'upgrade',
|
2304
|
-
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2305
|
-
): this
|
2306
|
-
on(
|
2307
|
-
event: 'message',
|
2308
|
-
listener: (
|
2309
|
-
this: WebSocket,
|
2310
|
-
data: WebSocket.RawData,
|
2311
|
-
isBinary: boolean,
|
2312
|
-
) => void,
|
2313
|
-
): this
|
2314
|
-
on(event: 'open', listener: (this: WebSocket) => void): this
|
2315
|
-
on(
|
2316
|
-
event: 'ping' | 'pong',
|
2317
|
-
listener: (this: WebSocket, data: Buffer) => void,
|
2318
|
-
): this
|
2319
|
-
on(
|
2320
|
-
event: 'unexpected-response',
|
2321
|
-
listener: (
|
2322
|
-
this: WebSocket,
|
2323
|
-
request: ClientRequest,
|
2324
|
-
response: IncomingMessage,
|
2325
|
-
) => void,
|
2326
|
-
): this
|
2327
|
-
on(
|
2328
|
-
event: string | symbol,
|
2329
|
-
listener: (this: WebSocket, ...args: any[]) => void,
|
2330
|
-
): this
|
2331
|
-
|
2332
|
-
once(
|
2333
|
-
event: 'close',
|
2334
|
-
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2335
|
-
): this
|
2336
|
-
once(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2337
|
-
once(
|
2338
|
-
event: 'upgrade',
|
2339
|
-
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2340
|
-
): this
|
2341
|
-
once(
|
2342
|
-
event: 'message',
|
2343
|
-
listener: (
|
2344
|
-
this: WebSocket,
|
2345
|
-
data: WebSocket.RawData,
|
2346
|
-
isBinary: boolean,
|
2347
|
-
) => void,
|
2348
|
-
): this
|
2349
|
-
once(event: 'open', listener: (this: WebSocket) => void): this
|
2350
|
-
once(
|
2351
|
-
event: 'ping' | 'pong',
|
2352
|
-
listener: (this: WebSocket, data: Buffer) => void,
|
2353
|
-
): this
|
2354
|
-
once(
|
2355
|
-
event: 'unexpected-response',
|
2356
|
-
listener: (
|
2357
|
-
this: WebSocket,
|
2358
|
-
request: ClientRequest,
|
2359
|
-
response: IncomingMessage,
|
2360
|
-
) => void,
|
2361
|
-
): this
|
2362
|
-
once(
|
2363
|
-
event: string | symbol,
|
2364
|
-
listener: (this: WebSocket, ...args: any[]) => void,
|
2365
|
-
): this
|
2366
|
-
|
2367
|
-
off(
|
2368
|
-
event: 'close',
|
2369
|
-
listener: (this: WebSocket, code: number, reason: Buffer) => void,
|
2370
|
-
): this
|
2371
|
-
off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
|
2372
|
-
off(
|
2373
|
-
event: 'upgrade',
|
2374
|
-
listener: (this: WebSocket, request: IncomingMessage) => void,
|
2375
|
-
): this
|
2376
|
-
off(
|
2377
|
-
event: 'message',
|
2378
|
-
listener: (
|
2379
|
-
this: WebSocket,
|
2380
|
-
data: WebSocket.RawData,
|
2381
|
-
isBinary: boolean,
|
2382
|
-
) => void,
|
2383
|
-
): this
|
2384
|
-
off(event: 'open', listener: (this: WebSocket) => void): this
|
2385
|
-
off(
|
2386
|
-
event: 'ping' | 'pong',
|
2387
|
-
listener: (this: WebSocket, data: Buffer) => void,
|
2388
|
-
): this
|
2389
|
-
off(
|
2390
|
-
event: 'unexpected-response',
|
2391
|
-
listener: (
|
2392
|
-
this: WebSocket,
|
2393
|
-
request: ClientRequest,
|
2394
|
-
response: IncomingMessage,
|
2395
|
-
) => void,
|
2396
|
-
): this
|
2397
|
-
off(
|
2398
|
-
event: string | symbol,
|
2399
|
-
listener: (this: WebSocket, ...args: any[]) => void,
|
2400
|
-
): this
|
2401
|
-
|
2402
|
-
addListener(
|
2403
|
-
event: 'close',
|
2404
|
-
listener: (code: number, reason: Buffer) => void,
|
2405
|
-
): this
|
2406
|
-
addListener(event: 'error', listener: (err: Error) => void): this
|
2407
|
-
addListener(
|
2408
|
-
event: 'upgrade',
|
2409
|
-
listener: (request: IncomingMessage) => void,
|
2410
|
-
): this
|
2411
|
-
addListener(
|
2412
|
-
event: 'message',
|
2413
|
-
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
2414
|
-
): this
|
2415
|
-
addListener(event: 'open', listener: () => void): this
|
2416
|
-
addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
2417
|
-
addListener(
|
2418
|
-
event: 'unexpected-response',
|
2419
|
-
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
2420
|
-
): this
|
2421
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this
|
2422
|
-
|
2423
|
-
removeListener(
|
2424
|
-
event: 'close',
|
2425
|
-
listener: (code: number, reason: Buffer) => void,
|
2426
|
-
): this
|
2427
|
-
removeListener(event: 'error', listener: (err: Error) => void): this
|
2428
|
-
removeListener(
|
2429
|
-
event: 'upgrade',
|
2430
|
-
listener: (request: IncomingMessage) => void,
|
2431
|
-
): this
|
2432
|
-
removeListener(
|
2433
|
-
event: 'message',
|
2434
|
-
listener: (data: WebSocket.RawData, isBinary: boolean) => void,
|
2435
|
-
): this
|
2436
|
-
removeListener(event: 'open', listener: () => void): this
|
2437
|
-
removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
|
2438
|
-
removeListener(
|
2439
|
-
event: 'unexpected-response',
|
2440
|
-
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
2441
|
-
): this
|
2442
|
-
removeListener(
|
2443
|
-
event: string | symbol,
|
2444
|
-
listener: (...args: any[]) => void,
|
2445
|
-
): this
|
2446
|
-
}
|
2447
|
-
|
2448
|
-
declare namespace WebSocket {
|
1925
|
+
* A minimatch pattern, or array of patterns, which specifies the files in
|
1926
|
+
* the build the plugin should _ignore_. By default, all files with
|
1927
|
+
* extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
1928
|
+
* can exclude additional files. See also the `include` option.
|
1929
|
+
* @default undefined
|
1930
|
+
*/
|
1931
|
+
exclude?: string | RegExp | readonly (string | RegExp)[]
|
2449
1932
|
/**
|
2450
|
-
*
|
1933
|
+
* For extensionless imports, search for extensions other than .js in the
|
1934
|
+
* order specified. Note that you need to make sure that non-JavaScript files
|
1935
|
+
* are transpiled by another plugin first.
|
1936
|
+
* @default [ '.js' ]
|
2451
1937
|
*/
|
2452
|
-
|
2453
|
-
|
1938
|
+
extensions?: ReadonlyArray<string>
|
2454
1939
|
/**
|
2455
|
-
*
|
1940
|
+
* If true then uses of `global` won't be dealt with by this plugin
|
1941
|
+
* @default false
|
2456
1942
|
*/
|
2457
|
-
|
2458
|
-
|
1943
|
+
ignoreGlobal?: boolean
|
2459
1944
|
/**
|
2460
|
-
*
|
1945
|
+
* If false, skips source map generation for CommonJS modules. This will
|
1946
|
+
* improve performance.
|
1947
|
+
* @default true
|
2461
1948
|
*/
|
2462
|
-
|
2463
|
-
|
1949
|
+
sourceMap?: boolean
|
2464
1950
|
/**
|
2465
|
-
*
|
2466
|
-
*
|
2467
|
-
*
|
1951
|
+
* Some `require` calls cannot be resolved statically to be translated to
|
1952
|
+
* imports.
|
1953
|
+
* When this option is set to `false`, the generated code will either
|
1954
|
+
* directly throw an error when such a call is encountered or, when
|
1955
|
+
* `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
1956
|
+
* configured dynamic require target.
|
1957
|
+
* Setting this option to `true` will instead leave the `require` call in the
|
1958
|
+
* code or use it as a fallback for `dynamicRequireTargets`.
|
1959
|
+
* @default false
|
2468
1960
|
*/
|
2469
|
-
|
2470
|
-
origin: string
|
2471
|
-
secure: boolean
|
2472
|
-
req: IncomingMessage
|
2473
|
-
}) => boolean
|
2474
|
-
|
1961
|
+
ignoreDynamicRequires?: boolean
|
2475
1962
|
/**
|
2476
|
-
*
|
2477
|
-
*
|
2478
|
-
*
|
1963
|
+
* Instructs the plugin whether to enable mixed module transformations. This
|
1964
|
+
* is useful in scenarios with modules that contain a mix of ES `import`
|
1965
|
+
* statements and CommonJS `require` expressions. Set to `true` if `require`
|
1966
|
+
* calls should be transformed to imports in mixed modules, or `false` if the
|
1967
|
+
* `require` expressions should survive the transformation. The latter can be
|
1968
|
+
* important if the code contains environment detection, or you are coding
|
1969
|
+
* for an environment with special treatment for `require` calls such as
|
1970
|
+
* ElectronJS. See also the `ignore` option.
|
1971
|
+
* @default false
|
2479
1972
|
*/
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2488
|
-
|
1973
|
+
transformMixedEsModules?: boolean
|
1974
|
+
/**
|
1975
|
+
* By default, this plugin will try to hoist `require` statements as imports
|
1976
|
+
* to the top of each file. While this works well for many code bases and
|
1977
|
+
* allows for very efficient ESM output, it does not perfectly capture
|
1978
|
+
* CommonJS semantics as the order of side effects like log statements may
|
1979
|
+
* change. But it is especially problematic when there are circular `require`
|
1980
|
+
* calls between CommonJS modules as those often rely on the lazy execution of
|
1981
|
+
* nested `require` calls.
|
1982
|
+
*
|
1983
|
+
* Setting this option to `true` will wrap all CommonJS files in functions
|
1984
|
+
* which are executed when they are required for the first time, preserving
|
1985
|
+
* NodeJS semantics. Note that this can have an impact on the size and
|
1986
|
+
* performance of the generated code.
|
1987
|
+
*
|
1988
|
+
* The default value of `"auto"` will only wrap CommonJS files when they are
|
1989
|
+
* part of a CommonJS dependency cycle, e.g. an index file that is required by
|
1990
|
+
* many of its dependencies. All other CommonJS files are hoisted. This is the
|
1991
|
+
* recommended setting for most code bases.
|
1992
|
+
*
|
1993
|
+
* `false` will entirely prevent wrapping and hoist all files. This may still
|
1994
|
+
* work depending on the nature of cyclic dependencies but will often cause
|
1995
|
+
* problems.
|
1996
|
+
*
|
1997
|
+
* You can also provide a minimatch pattern, or array of patterns, to only
|
1998
|
+
* specify a subset of files which should be wrapped in functions for proper
|
1999
|
+
* `require` semantics.
|
2000
|
+
*
|
2001
|
+
* `"debug"` works like `"auto"` but after bundling, it will display a warning
|
2002
|
+
* containing a list of ids that have been wrapped which can be used as
|
2003
|
+
* minimatch pattern for fine-tuning.
|
2004
|
+
* @default "auto"
|
2005
|
+
*/
|
2006
|
+
strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[]
|
2007
|
+
/**
|
2008
|
+
* Sometimes you have to leave require statements unconverted. Pass an array
|
2009
|
+
* containing the IDs or a `id => boolean` function.
|
2010
|
+
* @default []
|
2011
|
+
*/
|
2012
|
+
ignore?: ReadonlyArray<string> | ((id: string) => boolean)
|
2013
|
+
/**
|
2014
|
+
* In most cases, where `require` calls are inside a `try-catch` clause,
|
2015
|
+
* they should be left unconverted as it requires an optional dependency
|
2016
|
+
* that may or may not be installed beside the rolled up package.
|
2017
|
+
* Due to the conversion of `require` to a static `import` - the call is
|
2018
|
+
* hoisted to the top of the file, outside the `try-catch` clause.
|
2019
|
+
*
|
2020
|
+
* - `true`: Default. All `require` calls inside a `try` will be left unconverted.
|
2021
|
+
* - `false`: All `require` calls inside a `try` will be converted as if the
|
2022
|
+
* `try-catch` clause is not there.
|
2023
|
+
* - `remove`: Remove all `require` calls from inside any `try` block.
|
2024
|
+
* - `string[]`: Pass an array containing the IDs to left unconverted.
|
2025
|
+
* - `((id: string) => boolean|'remove')`: Pass a function that controls
|
2026
|
+
* individual IDs.
|
2027
|
+
*
|
2028
|
+
* @default true
|
2029
|
+
*/
|
2030
|
+
ignoreTryCatch?:
|
2031
|
+
| boolean
|
2032
|
+
| 'remove'
|
2033
|
+
| ReadonlyArray<string>
|
2034
|
+
| ((id: string) => boolean | 'remove')
|
2035
|
+
/**
|
2036
|
+
* Controls how to render imports from external dependencies. By default,
|
2037
|
+
* this plugin assumes that all external dependencies are CommonJS. This
|
2038
|
+
* means they are rendered as default imports to be compatible with e.g.
|
2039
|
+
* NodeJS where ES modules can only import a default export from a CommonJS
|
2040
|
+
* dependency.
|
2041
|
+
*
|
2042
|
+
* If you set `esmExternals` to `true`, this plugin assumes that all
|
2043
|
+
* external dependencies are ES modules and respect the
|
2044
|
+
* `requireReturnsDefault` option. If that option is not set, they will be
|
2045
|
+
* rendered as namespace imports.
|
2046
|
+
*
|
2047
|
+
* You can also supply an array of ids to be treated as ES modules, or a
|
2048
|
+
* function that will be passed each external id to determine whether it is
|
2049
|
+
* an ES module.
|
2050
|
+
* @default false
|
2051
|
+
*/
|
2052
|
+
esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
|
2053
|
+
/**
|
2054
|
+
* Controls what is returned when requiring an ES module from a CommonJS file.
|
2055
|
+
* When using the `esmExternals` option, this will also apply to external
|
2056
|
+
* modules. By default, this plugin will render those imports as namespace
|
2057
|
+
* imports i.e.
|
2058
|
+
*
|
2059
|
+
* ```js
|
2060
|
+
* // input
|
2061
|
+
* const foo = require('foo');
|
2062
|
+
*
|
2063
|
+
* // output
|
2064
|
+
* import * as foo from 'foo';
|
2065
|
+
* ```
|
2066
|
+
*
|
2067
|
+
* However, there are some situations where this may not be desired.
|
2068
|
+
* For these situations, you can change Rollup's behaviour either globally or
|
2069
|
+
* per module. To change it globally, set the `requireReturnsDefault` option
|
2070
|
+
* to one of the following values:
|
2071
|
+
*
|
2072
|
+
* - `false`: This is the default, requiring an ES module returns its
|
2073
|
+
* namespace. This is the only option that will also add a marker
|
2074
|
+
* `__esModule: true` to the namespace to support interop patterns in
|
2075
|
+
* CommonJS modules that are transpiled ES modules.
|
2076
|
+
* - `"namespace"`: Like `false`, requiring an ES module returns its
|
2077
|
+
* namespace, but the plugin does not add the `__esModule` marker and thus
|
2078
|
+
* creates more efficient code. For external dependencies when using
|
2079
|
+
* `esmExternals: true`, no additional interop code is generated.
|
2080
|
+
* - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
2081
|
+
* Rollup: If a module has a default export and no named exports, requiring
|
2082
|
+
* that module returns the default export. In all other cases, the namespace
|
2083
|
+
* is returned. For external dependencies when using `esmExternals: true`, a
|
2084
|
+
* corresponding interop helper is added.
|
2085
|
+
* - `"preferred"`: If a module has a default export, requiring that module
|
2086
|
+
* always returns the default export, no matter whether additional named
|
2087
|
+
* exports exist. This is similar to how previous versions of this plugin
|
2088
|
+
* worked. Again for external dependencies when using `esmExternals: true`,
|
2089
|
+
* an interop helper is added.
|
2090
|
+
* - `true`: This will always try to return the default export on require
|
2091
|
+
* without checking if it actually exists. This can throw at build time if
|
2092
|
+
* there is no default export. This is how external dependencies are handled
|
2093
|
+
* when `esmExternals` is not used. The advantage over the other options is
|
2094
|
+
* that, like `false`, this does not add an interop helper for external
|
2095
|
+
* dependencies, keeping the code lean.
|
2096
|
+
*
|
2097
|
+
* To change this for individual modules, you can supply a function for
|
2098
|
+
* `requireReturnsDefault` instead. This function will then be called once for
|
2099
|
+
* each required ES module or external dependency with the corresponding id
|
2100
|
+
* and allows you to return different values for different modules.
|
2101
|
+
* @default false
|
2102
|
+
*/
|
2103
|
+
requireReturnsDefault?:
|
2104
|
+
| boolean
|
2105
|
+
| 'auto'
|
2106
|
+
| 'preferred'
|
2107
|
+
| 'namespace'
|
2108
|
+
| ((id: string) => boolean | 'auto' | 'preferred' | 'namespace')
|
2489
2109
|
|
2490
|
-
|
2491
|
-
|
2492
|
-
|
2493
|
-
|
2494
|
-
|
2495
|
-
|
2496
|
-
|
2497
|
-
|
2498
|
-
|
2499
|
-
|
2500
|
-
|
2501
|
-
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2110
|
+
/**
|
2111
|
+
* @default "auto"
|
2112
|
+
*/
|
2113
|
+
defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto')
|
2114
|
+
/**
|
2115
|
+
* Some modules contain dynamic `require` calls, or require modules that
|
2116
|
+
* contain circular dependencies, which are not handled well by static
|
2117
|
+
* imports. Including those modules as `dynamicRequireTargets` will simulate a
|
2118
|
+
* CommonJS (NodeJS-like) environment for them with support for dynamic
|
2119
|
+
* dependencies. It also enables `strictRequires` for those modules.
|
2120
|
+
*
|
2121
|
+
* Note: In extreme cases, this feature may result in some paths being
|
2122
|
+
* rendered as absolute in the final bundle. The plugin tries to avoid
|
2123
|
+
* exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
2124
|
+
* with paths that are far away from your project's folder, that may require
|
2125
|
+
* replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
|
2126
|
+
*/
|
2127
|
+
dynamicRequireTargets?: string | ReadonlyArray<string>
|
2128
|
+
/**
|
2129
|
+
* To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
|
2130
|
+
* that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
|
2131
|
+
* may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
|
2132
|
+
* home directory name. By default, it uses the current working directory.
|
2133
|
+
*/
|
2134
|
+
dynamicRequireRoot?: string
|
2135
|
+
}
|
2509
2136
|
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
| undefined
|
2528
|
-
zlibInflateOptions?: ZlibOptions | undefined
|
2529
|
-
threshold?: number | undefined
|
2530
|
-
concurrencyLimit?: number | undefined
|
2531
|
-
}
|
2137
|
+
interface RollupDynamicImportVarsOptions {
|
2138
|
+
/**
|
2139
|
+
* Files to include in this plugin (default all).
|
2140
|
+
* @default []
|
2141
|
+
*/
|
2142
|
+
include?: string | RegExp | (string | RegExp)[]
|
2143
|
+
/**
|
2144
|
+
* Files to exclude in this plugin (default none).
|
2145
|
+
* @default []
|
2146
|
+
*/
|
2147
|
+
exclude?: string | RegExp | (string | RegExp)[]
|
2148
|
+
/**
|
2149
|
+
* 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.
|
2150
|
+
* @default false
|
2151
|
+
*/
|
2152
|
+
warnOnError?: boolean
|
2153
|
+
}
|
2532
2154
|
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
}
|
2155
|
+
// Modified and inlined to avoid extra dependency
|
2156
|
+
// Source: https://github.com/terser/terser/blob/master/tools/terser.d.ts
|
2157
|
+
// BSD Licensed https://github.com/terser/terser/blob/master/LICENSE
|
2537
2158
|
|
2538
|
-
|
2539
|
-
|
2540
|
-
message: string
|
2541
|
-
type: string
|
2542
|
-
target: WebSocket
|
2543
|
-
}
|
2159
|
+
declare namespace Terser {
|
2160
|
+
export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
|
2544
2161
|
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2162
|
+
export type ConsoleProperty = keyof typeof console
|
2163
|
+
type DropConsoleOption = boolean | ConsoleProperty[]
|
2164
|
+
|
2165
|
+
export interface ParseOptions {
|
2166
|
+
bare_returns?: boolean
|
2167
|
+
/** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
|
2168
|
+
ecma?: ECMA
|
2169
|
+
html5_comments?: boolean
|
2170
|
+
shebang?: boolean
|
2551
2171
|
}
|
2552
2172
|
|
2553
|
-
interface
|
2554
|
-
|
2555
|
-
|
2556
|
-
|
2173
|
+
export interface CompressOptions {
|
2174
|
+
arguments?: boolean
|
2175
|
+
arrows?: boolean
|
2176
|
+
booleans_as_integers?: boolean
|
2177
|
+
booleans?: boolean
|
2178
|
+
collapse_vars?: boolean
|
2179
|
+
comparisons?: boolean
|
2180
|
+
computed_props?: boolean
|
2181
|
+
conditionals?: boolean
|
2182
|
+
dead_code?: boolean
|
2183
|
+
defaults?: boolean
|
2184
|
+
directives?: boolean
|
2185
|
+
drop_console?: DropConsoleOption
|
2186
|
+
drop_debugger?: boolean
|
2187
|
+
ecma?: ECMA
|
2188
|
+
evaluate?: boolean
|
2189
|
+
expression?: boolean
|
2190
|
+
global_defs?: object
|
2191
|
+
hoist_funs?: boolean
|
2192
|
+
hoist_props?: boolean
|
2193
|
+
hoist_vars?: boolean
|
2194
|
+
ie8?: boolean
|
2195
|
+
if_return?: boolean
|
2196
|
+
inline?: boolean | InlineFunctions
|
2197
|
+
join_vars?: boolean
|
2198
|
+
keep_classnames?: boolean | RegExp
|
2199
|
+
keep_fargs?: boolean
|
2200
|
+
keep_fnames?: boolean | RegExp
|
2201
|
+
keep_infinity?: boolean
|
2202
|
+
loops?: boolean
|
2203
|
+
module?: boolean
|
2204
|
+
negate_iife?: boolean
|
2205
|
+
passes?: number
|
2206
|
+
properties?: boolean
|
2207
|
+
pure_funcs?: string[]
|
2208
|
+
pure_new?: boolean
|
2209
|
+
pure_getters?: boolean | 'strict'
|
2210
|
+
reduce_funcs?: boolean
|
2211
|
+
reduce_vars?: boolean
|
2212
|
+
sequences?: boolean | number
|
2213
|
+
side_effects?: boolean
|
2214
|
+
switches?: boolean
|
2215
|
+
toplevel?: boolean
|
2216
|
+
top_retain?: null | string | string[] | RegExp
|
2217
|
+
typeofs?: boolean
|
2218
|
+
unsafe_arrows?: boolean
|
2219
|
+
unsafe?: boolean
|
2220
|
+
unsafe_comps?: boolean
|
2221
|
+
unsafe_Function?: boolean
|
2222
|
+
unsafe_math?: boolean
|
2223
|
+
unsafe_symbols?: boolean
|
2224
|
+
unsafe_methods?: boolean
|
2225
|
+
unsafe_proto?: boolean
|
2226
|
+
unsafe_regexp?: boolean
|
2227
|
+
unsafe_undefined?: boolean
|
2228
|
+
unused?: boolean
|
2557
2229
|
}
|
2558
2230
|
|
2559
|
-
|
2560
|
-
|
2231
|
+
export enum InlineFunctions {
|
2232
|
+
Disabled = 0,
|
2233
|
+
SimpleFunctions = 1,
|
2234
|
+
WithArguments = 2,
|
2235
|
+
WithArgumentsAndVariables = 3,
|
2561
2236
|
}
|
2562
2237
|
|
2563
|
-
interface
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
protocols: Set<string>,
|
2574
|
-
request: IncomingMessage,
|
2575
|
-
) => string | false
|
2576
|
-
path?: string | undefined
|
2577
|
-
noServer?: boolean | undefined
|
2578
|
-
clientTracking?: boolean | undefined
|
2579
|
-
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
2580
|
-
maxPayload?: number | undefined
|
2581
|
-
skipUTF8Validation?: boolean | undefined
|
2582
|
-
WebSocket?: typeof WebSocket.WebSocket | undefined
|
2238
|
+
export interface MangleOptions {
|
2239
|
+
eval?: boolean
|
2240
|
+
keep_classnames?: boolean | RegExp
|
2241
|
+
keep_fnames?: boolean | RegExp
|
2242
|
+
module?: boolean
|
2243
|
+
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
2244
|
+
properties?: boolean | ManglePropertiesOptions
|
2245
|
+
reserved?: string[]
|
2246
|
+
safari10?: boolean
|
2247
|
+
toplevel?: boolean
|
2583
2248
|
}
|
2584
2249
|
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2250
|
+
/**
|
2251
|
+
* An identifier mangler for which the output is invariant with respect to the source code.
|
2252
|
+
*/
|
2253
|
+
export interface SimpleIdentifierMangler {
|
2254
|
+
/**
|
2255
|
+
* Obtains the nth most favored (usually shortest) identifier to rename a variable to.
|
2256
|
+
* The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
|
2257
|
+
* This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
|
2258
|
+
* @param n The ordinal of the identifier.
|
2259
|
+
*/
|
2260
|
+
get(n: number): string
|
2589
2261
|
}
|
2590
2262
|
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2263
|
+
/**
|
2264
|
+
* An identifier mangler that leverages character frequency analysis to determine identifier precedence.
|
2265
|
+
*/
|
2266
|
+
export interface WeightedIdentifierMangler extends SimpleIdentifierMangler {
|
2267
|
+
/**
|
2268
|
+
* Modifies the internal weighting of the input characters by the specified delta.
|
2269
|
+
* Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
|
2270
|
+
* @param chars The characters to modify the weighting of.
|
2271
|
+
* @param delta The numeric weight to add to the characters.
|
2272
|
+
*/
|
2273
|
+
consider(chars: string, delta: number): number
|
2274
|
+
/**
|
2275
|
+
* Resets character weights.
|
2276
|
+
*/
|
2277
|
+
reset(): void
|
2278
|
+
/**
|
2279
|
+
* Sorts identifiers by character frequency, in preparation for calls to get(n).
|
2280
|
+
*/
|
2281
|
+
sort(): void
|
2282
|
+
}
|
2598
2283
|
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2607
|
-
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
2284
|
+
export interface ManglePropertiesOptions {
|
2285
|
+
builtins?: boolean
|
2286
|
+
debug?: boolean
|
2287
|
+
keep_quoted?: boolean | 'strict'
|
2288
|
+
nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
|
2289
|
+
regex?: RegExp | string
|
2290
|
+
reserved?: string[]
|
2291
|
+
}
|
2608
2292
|
|
2609
|
-
|
2610
|
-
|
2611
|
-
|
2612
|
-
|
2613
|
-
|
2614
|
-
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
|
2621
|
-
|
2622
|
-
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2293
|
+
export interface FormatOptions {
|
2294
|
+
ascii_only?: boolean
|
2295
|
+
/** @deprecated Not implemented anymore */
|
2296
|
+
beautify?: boolean
|
2297
|
+
braces?: boolean
|
2298
|
+
comments?:
|
2299
|
+
| boolean
|
2300
|
+
| 'all'
|
2301
|
+
| 'some'
|
2302
|
+
| RegExp
|
2303
|
+
| ((
|
2304
|
+
node: any,
|
2305
|
+
comment: {
|
2306
|
+
value: string
|
2307
|
+
type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
|
2308
|
+
pos: number
|
2309
|
+
line: number
|
2310
|
+
col: number
|
2311
|
+
},
|
2312
|
+
) => boolean)
|
2313
|
+
ecma?: ECMA
|
2314
|
+
ie8?: boolean
|
2315
|
+
keep_numbers?: boolean
|
2316
|
+
indent_level?: number
|
2317
|
+
indent_start?: number
|
2318
|
+
inline_script?: boolean
|
2319
|
+
keep_quoted_props?: boolean
|
2320
|
+
max_line_len?: number | false
|
2321
|
+
preamble?: string
|
2322
|
+
preserve_annotations?: boolean
|
2323
|
+
quote_keys?: boolean
|
2324
|
+
quote_style?: OutputQuoteStyle
|
2325
|
+
safari10?: boolean
|
2326
|
+
semicolons?: boolean
|
2327
|
+
shebang?: boolean
|
2328
|
+
shorthand?: boolean
|
2329
|
+
source_map?: SourceMapOptions
|
2330
|
+
webkit?: boolean
|
2331
|
+
width?: number
|
2332
|
+
wrap_iife?: boolean
|
2333
|
+
wrap_func_args?: boolean
|
2334
|
+
}
|
2628
2335
|
|
2629
|
-
|
2630
|
-
|
2631
|
-
|
2632
|
-
|
2633
|
-
|
2634
|
-
|
2635
|
-
event: 'headers',
|
2636
|
-
cb: (
|
2637
|
-
this: Server<T>,
|
2638
|
-
headers: string[],
|
2639
|
-
request: IncomingMessage,
|
2640
|
-
) => void,
|
2641
|
-
): this
|
2642
|
-
once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
2643
|
-
once(
|
2644
|
-
event: string | symbol,
|
2645
|
-
listener: (this: Server<T>, ...args: any[]) => void,
|
2646
|
-
): this
|
2336
|
+
export enum OutputQuoteStyle {
|
2337
|
+
PreferDouble = 0,
|
2338
|
+
AlwaysSingle = 1,
|
2339
|
+
AlwaysDouble = 2,
|
2340
|
+
AlwaysOriginal = 3,
|
2341
|
+
}
|
2647
2342
|
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
2657
|
-
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2343
|
+
export interface MinifyOptions {
|
2344
|
+
compress?: boolean | CompressOptions
|
2345
|
+
ecma?: ECMA
|
2346
|
+
enclose?: boolean | string
|
2347
|
+
ie8?: boolean
|
2348
|
+
keep_classnames?: boolean | RegExp
|
2349
|
+
keep_fnames?: boolean | RegExp
|
2350
|
+
mangle?: boolean | MangleOptions
|
2351
|
+
module?: boolean
|
2352
|
+
nameCache?: object
|
2353
|
+
format?: FormatOptions
|
2354
|
+
/** @deprecated */
|
2355
|
+
output?: FormatOptions
|
2356
|
+
parse?: ParseOptions
|
2357
|
+
safari10?: boolean
|
2358
|
+
sourceMap?: boolean | SourceMapOptions
|
2359
|
+
toplevel?: boolean
|
2360
|
+
}
|
2666
2361
|
|
2667
|
-
|
2668
|
-
|
2669
|
-
|
2670
|
-
|
2671
|
-
|
2672
|
-
addListener(
|
2673
|
-
event: 'headers',
|
2674
|
-
cb: (headers: string[], request: IncomingMessage) => void,
|
2675
|
-
): this
|
2676
|
-
addListener(event: 'close' | 'listening', cb: () => void): this
|
2677
|
-
addListener(
|
2678
|
-
event: string | symbol,
|
2679
|
-
listener: (...args: any[]) => void,
|
2680
|
-
): this
|
2362
|
+
export interface MinifyOutput {
|
2363
|
+
code?: string
|
2364
|
+
map?: object | string
|
2365
|
+
decoded_map?: object | null
|
2366
|
+
}
|
2681
2367
|
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
event: string | symbol,
|
2691
|
-
listener: (...args: any[]) => void,
|
2692
|
-
): this
|
2368
|
+
export interface SourceMapOptions {
|
2369
|
+
/** Source map object, 'inline' or source map file content */
|
2370
|
+
content?: object | string
|
2371
|
+
includeSources?: boolean
|
2372
|
+
filename?: string
|
2373
|
+
root?: string
|
2374
|
+
asObject?: boolean
|
2375
|
+
url?: string | 'inline'
|
2693
2376
|
}
|
2377
|
+
}
|
2694
2378
|
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
|
2379
|
+
interface TerserOptions extends Terser.MinifyOptions {
|
2380
|
+
/**
|
2381
|
+
* Vite-specific option to specify the max number of workers to spawn
|
2382
|
+
* when minifying files with terser.
|
2383
|
+
*
|
2384
|
+
* @default number of CPUs minus 1
|
2385
|
+
*/
|
2386
|
+
maxWorkers?: number;
|
2387
|
+
}
|
2699
2388
|
|
2700
|
-
|
2701
|
-
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2389
|
+
interface EnvironmentResolveOptions {
|
2390
|
+
/**
|
2391
|
+
* @default ['browser', 'module', 'jsnext:main', 'jsnext']
|
2392
|
+
*/
|
2393
|
+
mainFields?: string[];
|
2394
|
+
conditions?: string[];
|
2395
|
+
externalConditions?: string[];
|
2396
|
+
/**
|
2397
|
+
* @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
|
2398
|
+
*/
|
2399
|
+
extensions?: string[];
|
2400
|
+
dedupe?: string[];
|
2401
|
+
/**
|
2402
|
+
* Prevent listed dependencies from being externalized and will get bundled in build.
|
2403
|
+
* Only works in server environments for now. Previously this was `ssr.noExternal`.
|
2404
|
+
* @experimental
|
2405
|
+
*/
|
2406
|
+
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
2407
|
+
/**
|
2408
|
+
* Externalize the given dependencies and their transitive dependencies.
|
2409
|
+
* Only works in server environments for now. Previously this was `ssr.external`.
|
2410
|
+
* @experimental
|
2411
|
+
*/
|
2412
|
+
external?: string[] | true;
|
2413
|
+
}
|
2414
|
+
interface ResolveOptions extends EnvironmentResolveOptions {
|
2415
|
+
/**
|
2416
|
+
* @default false
|
2417
|
+
*/
|
2418
|
+
preserveSymlinks?: boolean;
|
2419
|
+
}
|
2420
|
+
interface ResolvePluginOptions {
|
2421
|
+
root: string;
|
2422
|
+
isBuild: boolean;
|
2423
|
+
isProduction: boolean;
|
2424
|
+
packageCache?: PackageCache;
|
2425
|
+
/**
|
2426
|
+
* src code mode also attempts the following:
|
2427
|
+
* - resolving /xxx as URLs
|
2428
|
+
* - resolving bare imports from optimized deps
|
2429
|
+
*/
|
2430
|
+
asSrc?: boolean;
|
2431
|
+
tryIndex?: boolean;
|
2432
|
+
tryPrefix?: string;
|
2433
|
+
preferRelative?: boolean;
|
2434
|
+
isRequire?: boolean;
|
2435
|
+
isFromTsImporter?: boolean;
|
2436
|
+
scan?: boolean;
|
2437
|
+
/**
|
2438
|
+
* @deprecated environment.config are used instead
|
2439
|
+
*/
|
2440
|
+
ssrConfig?: SSROptions;
|
2441
|
+
}
|
2442
|
+
interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {
|
2443
|
+
}
|
2444
|
+
|
2445
|
+
/** Cache for package.json resolution and package.json contents */
|
2446
|
+
type PackageCache = Map<string, PackageData>;
|
2447
|
+
interface PackageData {
|
2448
|
+
dir: string;
|
2449
|
+
hasSideEffects: (id: string) => boolean | 'no-treeshake' | null;
|
2450
|
+
setResolvedCache: (key: string, entry: string, options: InternalResolveOptions) => void;
|
2451
|
+
getResolvedCache: (key: string, options: InternalResolveOptions) => string | undefined;
|
2452
|
+
data: {
|
2453
|
+
[field: string]: any;
|
2454
|
+
name: string;
|
2455
|
+
type: string;
|
2456
|
+
version: string;
|
2457
|
+
main: string;
|
2458
|
+
module: string;
|
2459
|
+
browser: string | Record<string, string | false>;
|
2460
|
+
exports: string | Record<string, any> | string[];
|
2461
|
+
imports: Record<string, any>;
|
2462
|
+
dependencies: Record<string, string>;
|
2463
|
+
};
|
2464
|
+
}
|
2465
|
+
|
2466
|
+
interface BuildEnvironmentOptions {
|
2467
|
+
/**
|
2468
|
+
* Compatibility transform target. The transform is performed with esbuild
|
2469
|
+
* and the lowest supported target is es2015/es6. Note this only handles
|
2470
|
+
* syntax transformation and does not cover polyfills (except for dynamic
|
2471
|
+
* import)
|
2472
|
+
*
|
2473
|
+
* Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
|
2474
|
+
* transpile targeting browsers that natively support dynamic es module imports.
|
2475
|
+
* https://caniuse.com/es6-module-dynamic-import
|
2476
|
+
*
|
2477
|
+
* Another special value is 'esnext' - which only performs minimal transpiling
|
2478
|
+
* (for minification compat) and assumes native dynamic imports support.
|
2479
|
+
*
|
2480
|
+
* For custom targets, see https://esbuild.github.io/api/#target and
|
2481
|
+
* https://esbuild.github.io/content-types/#javascript for more details.
|
2482
|
+
* @default 'modules'
|
2483
|
+
*/
|
2484
|
+
target?: 'modules' | esbuild_TransformOptions['target'] | false;
|
2485
|
+
/**
|
2486
|
+
* whether to inject module preload polyfill.
|
2487
|
+
* Note: does not apply to library mode.
|
2488
|
+
* @default true
|
2489
|
+
* @deprecated use `modulePreload.polyfill` instead
|
2490
|
+
*/
|
2491
|
+
polyfillModulePreload?: boolean;
|
2492
|
+
/**
|
2493
|
+
* Configure module preload
|
2494
|
+
* Note: does not apply to library mode.
|
2495
|
+
* @default true
|
2496
|
+
*/
|
2497
|
+
modulePreload?: boolean | ModulePreloadOptions;
|
2498
|
+
/**
|
2499
|
+
* Directory relative from `root` where build output will be placed. If the
|
2500
|
+
* directory exists, it will be removed before the build.
|
2501
|
+
* @default 'dist'
|
2502
|
+
*/
|
2503
|
+
outDir?: string;
|
2504
|
+
/**
|
2505
|
+
* Directory relative from `outDir` where the built js/css/image assets will
|
2506
|
+
* be placed.
|
2507
|
+
* @default 'assets'
|
2508
|
+
*/
|
2509
|
+
assetsDir?: string;
|
2510
|
+
/**
|
2511
|
+
* Static asset files smaller than this number (in bytes) will be inlined as
|
2512
|
+
* base64 strings. If a callback is passed, a boolean can be returned to opt-in
|
2513
|
+
* or opt-out of inlining. If nothing is returned the default logic applies.
|
2514
|
+
*
|
2515
|
+
* Default limit is `4096` (4 KiB). Set to `0` to disable.
|
2516
|
+
* @default 4096
|
2517
|
+
*/
|
2518
|
+
assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
|
2519
|
+
/**
|
2520
|
+
* Whether to code-split CSS. When enabled, CSS in async chunks will be
|
2521
|
+
* inlined as strings in the chunk and inserted via dynamically created
|
2522
|
+
* style tags when the chunk is loaded.
|
2523
|
+
* @default true
|
2524
|
+
*/
|
2525
|
+
cssCodeSplit?: boolean;
|
2526
|
+
/**
|
2527
|
+
* An optional separate target for CSS minification.
|
2528
|
+
* As esbuild only supports configuring targets to mainstream
|
2529
|
+
* browsers, users may need this option when they are targeting
|
2530
|
+
* a niche browser that comes with most modern JavaScript features
|
2531
|
+
* but has poor CSS support, e.g. Android WeChat WebView, which
|
2532
|
+
* doesn't support the #RGBA syntax.
|
2533
|
+
* @default target
|
2534
|
+
*/
|
2535
|
+
cssTarget?: esbuild_TransformOptions['target'] | false;
|
2536
|
+
/**
|
2537
|
+
* Override CSS minification specifically instead of defaulting to `build.minify`,
|
2538
|
+
* so you can configure minification for JS and CSS separately.
|
2539
|
+
* @default 'esbuild'
|
2540
|
+
*/
|
2541
|
+
cssMinify?: boolean | 'esbuild' | 'lightningcss';
|
2542
|
+
/**
|
2543
|
+
* If `true`, a separate sourcemap file will be created. If 'inline', the
|
2544
|
+
* sourcemap will be appended to the resulting output file as data URI.
|
2545
|
+
* 'hidden' works like `true` except that the corresponding sourcemap
|
2546
|
+
* comments in the bundled files are suppressed.
|
2547
|
+
* @default false
|
2548
|
+
*/
|
2549
|
+
sourcemap?: boolean | 'inline' | 'hidden';
|
2550
|
+
/**
|
2551
|
+
* Set to `false` to disable minification, or specify the minifier to use.
|
2552
|
+
* Available options are 'terser' or 'esbuild'.
|
2553
|
+
* @default 'esbuild'
|
2554
|
+
*/
|
2555
|
+
minify?: boolean | 'terser' | 'esbuild';
|
2556
|
+
/**
|
2557
|
+
* Options for terser
|
2558
|
+
* https://terser.org/docs/api-reference#minify-options
|
2559
|
+
*
|
2560
|
+
* In addition, you can also pass a `maxWorkers: number` option to specify the
|
2561
|
+
* max number of workers to spawn. Defaults to the number of CPUs minus 1.
|
2562
|
+
*/
|
2563
|
+
terserOptions?: TerserOptions;
|
2564
|
+
/**
|
2565
|
+
* Will be merged with internal rollup options.
|
2566
|
+
* https://rollupjs.org/configuration-options/
|
2567
|
+
*/
|
2568
|
+
rollupOptions?: RollupOptions;
|
2569
|
+
/**
|
2570
|
+
* Options to pass on to `@rollup/plugin-commonjs`
|
2571
|
+
*/
|
2572
|
+
commonjsOptions?: RollupCommonJSOptions;
|
2573
|
+
/**
|
2574
|
+
* Options to pass on to `@rollup/plugin-dynamic-import-vars`
|
2575
|
+
*/
|
2576
|
+
dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
|
2577
|
+
/**
|
2578
|
+
* Whether to write bundle to disk
|
2579
|
+
* @default true
|
2580
|
+
*/
|
2581
|
+
write?: boolean;
|
2582
|
+
/**
|
2583
|
+
* Empty outDir on write.
|
2584
|
+
* @default true when outDir is a sub directory of project root
|
2585
|
+
*/
|
2586
|
+
emptyOutDir?: boolean | null;
|
2587
|
+
/**
|
2588
|
+
* Copy the public directory to outDir on write.
|
2589
|
+
* @default true
|
2590
|
+
*/
|
2591
|
+
copyPublicDir?: boolean;
|
2592
|
+
/**
|
2593
|
+
* Whether to emit a .vite/manifest.json under assets dir to map hash-less filenames
|
2594
|
+
* to their hashed versions. Useful when you want to generate your own HTML
|
2595
|
+
* instead of using the one generated by Vite.
|
2596
|
+
*
|
2597
|
+
* Example:
|
2598
|
+
*
|
2599
|
+
* ```json
|
2600
|
+
* {
|
2601
|
+
* "main.js": {
|
2602
|
+
* "file": "main.68fe3fad.js",
|
2603
|
+
* "css": "main.e6b63442.css",
|
2604
|
+
* "imports": [...],
|
2605
|
+
* "dynamicImports": [...]
|
2606
|
+
* }
|
2607
|
+
* }
|
2608
|
+
* ```
|
2609
|
+
* @default false
|
2610
|
+
*/
|
2611
|
+
manifest?: boolean | string;
|
2612
|
+
/**
|
2613
|
+
* Build in library mode. The value should be the global name of the lib in
|
2614
|
+
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
2615
|
+
* configurations that are suitable for distributing libraries.
|
2616
|
+
* @default false
|
2617
|
+
*/
|
2618
|
+
lib?: LibraryOptions | false;
|
2619
|
+
/**
|
2620
|
+
* Produce SSR oriented build. Note this requires specifying SSR entry via
|
2621
|
+
* `rollupOptions.input`.
|
2622
|
+
* @default false
|
2623
|
+
*/
|
2624
|
+
ssr?: boolean | string;
|
2625
|
+
/**
|
2626
|
+
* Generate SSR manifest for determining style links and asset preload
|
2627
|
+
* directives in production.
|
2628
|
+
* @default false
|
2629
|
+
*/
|
2630
|
+
ssrManifest?: boolean | string;
|
2631
|
+
/**
|
2632
|
+
* Emit assets during SSR.
|
2633
|
+
* @default false
|
2634
|
+
*/
|
2635
|
+
ssrEmitAssets?: boolean;
|
2636
|
+
/**
|
2637
|
+
* Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
|
2638
|
+
* By default, it is true for the client and false for other environments.
|
2639
|
+
*/
|
2640
|
+
emitAssets?: boolean;
|
2641
|
+
/**
|
2642
|
+
* Set to false to disable reporting compressed chunk sizes.
|
2643
|
+
* Can slightly improve build speed.
|
2644
|
+
* @default true
|
2645
|
+
*/
|
2646
|
+
reportCompressedSize?: boolean;
|
2647
|
+
/**
|
2648
|
+
* Adjust chunk size warning limit (in kB).
|
2649
|
+
* @default 500
|
2650
|
+
*/
|
2651
|
+
chunkSizeWarningLimit?: number;
|
2652
|
+
/**
|
2653
|
+
* Rollup watch options
|
2654
|
+
* https://rollupjs.org/configuration-options/#watch
|
2655
|
+
* @default null
|
2656
|
+
*/
|
2657
|
+
watch?: WatcherOptions | null;
|
2658
|
+
/**
|
2659
|
+
* create the Build Environment instance
|
2660
|
+
*/
|
2661
|
+
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
|
2662
|
+
}
|
2663
|
+
type BuildOptions = BuildEnvironmentOptions;
|
2664
|
+
interface LibraryOptions {
|
2665
|
+
/**
|
2666
|
+
* Path of library entry
|
2667
|
+
*/
|
2668
|
+
entry: InputOption;
|
2669
|
+
/**
|
2670
|
+
* The name of the exposed global variable. Required when the `formats` option includes
|
2671
|
+
* `umd` or `iife`
|
2672
|
+
*/
|
2673
|
+
name?: string;
|
2674
|
+
/**
|
2675
|
+
* Output bundle formats
|
2676
|
+
* @default ['es', 'umd']
|
2677
|
+
*/
|
2678
|
+
formats?: LibraryFormats[];
|
2679
|
+
/**
|
2680
|
+
* The name of the package file output. The default file name is the name option
|
2681
|
+
* of the project package.json. It can also be defined as a function taking the
|
2682
|
+
* format as an argument.
|
2683
|
+
*/
|
2684
|
+
fileName?: string | ((format: ModuleFormat, entryName: string) => string);
|
2685
|
+
/**
|
2686
|
+
* The name of the CSS file output if the library imports CSS. Defaults to the
|
2687
|
+
* same value as `build.lib.fileName` if it's set a string, otherwise it falls
|
2688
|
+
* back to the name option of the project package.json.
|
2689
|
+
*/
|
2690
|
+
cssFileName?: string;
|
2691
|
+
}
|
2692
|
+
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' | 'system';
|
2693
|
+
interface ModulePreloadOptions {
|
2694
|
+
/**
|
2695
|
+
* Whether to inject a module preload polyfill.
|
2696
|
+
* Note: does not apply to library mode.
|
2697
|
+
* @default true
|
2698
|
+
*/
|
2699
|
+
polyfill?: boolean;
|
2700
|
+
/**
|
2701
|
+
* Resolve the list of dependencies to preload for a given dynamic import
|
2702
|
+
* @experimental
|
2703
|
+
*/
|
2704
|
+
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2705
|
+
}
|
2706
|
+
interface ResolvedModulePreloadOptions {
|
2707
|
+
polyfill: boolean;
|
2708
|
+
resolveDependencies?: ResolveModulePreloadDependenciesFn;
|
2709
|
+
}
|
2710
|
+
type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
|
2711
|
+
hostId: string;
|
2712
|
+
hostType: 'html' | 'js';
|
2713
|
+
}) => string[];
|
2714
|
+
interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> {
|
2715
|
+
modulePreload: false | ResolvedModulePreloadOptions;
|
2716
|
+
}
|
2717
|
+
interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
|
2718
|
+
modulePreload: false | ResolvedModulePreloadOptions;
|
2719
|
+
}
|
2720
|
+
/**
|
2721
|
+
* Bundles a single environment for production.
|
2722
|
+
* Returns a Promise containing the build result.
|
2723
|
+
*/
|
2724
|
+
declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2725
|
+
type RenderBuiltAssetUrl = (filename: string, type: {
|
2726
|
+
type: 'asset' | 'public';
|
2727
|
+
hostId: string;
|
2728
|
+
hostType: 'js' | 'css' | 'html';
|
2729
|
+
ssr: boolean;
|
2730
|
+
}) => string | {
|
2731
|
+
relative?: boolean;
|
2732
|
+
runtime?: string;
|
2733
|
+
} | undefined;
|
2734
|
+
declare class BuildEnvironment extends BaseEnvironment {
|
2735
|
+
mode: "build";
|
2736
|
+
constructor(name: string, config: ResolvedConfig, setup?: {
|
2737
|
+
options?: EnvironmentOptions;
|
2738
|
+
});
|
2739
|
+
init(): Promise<void>;
|
2705
2740
|
}
|
2706
|
-
|
2707
|
-
|
2708
|
-
|
2709
|
-
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2741
|
+
interface ViteBuilder {
|
2742
|
+
environments: Record<string, BuildEnvironment>;
|
2743
|
+
config: ResolvedConfig;
|
2744
|
+
buildApp(): Promise<void>;
|
2745
|
+
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2746
|
+
}
|
2747
|
+
interface BuilderOptions {
|
2713
2748
|
/**
|
2714
|
-
*
|
2749
|
+
* Whether to share the config instance among environments to align with the behavior of dev server.
|
2750
|
+
*
|
2751
|
+
* @default false
|
2752
|
+
* @experimental
|
2715
2753
|
*/
|
2716
|
-
|
2754
|
+
sharedConfigBuild?: boolean;
|
2717
2755
|
/**
|
2718
|
-
*
|
2756
|
+
* Whether to share the plugin instances among environments to align with the behavior of dev server.
|
2757
|
+
*
|
2758
|
+
* @default false
|
2759
|
+
* @experimental
|
2719
2760
|
*/
|
2761
|
+
sharedPlugins?: boolean;
|
2762
|
+
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2763
|
+
}
|
2764
|
+
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2765
|
+
/**
|
2766
|
+
* Creates a ViteBuilder to orchestrate building multiple environments.
|
2767
|
+
* @experimental
|
2768
|
+
*/
|
2769
|
+
declare function createBuilder(inlineConfig?: InlineConfig, useLegacyBuilder?: null | boolean): Promise<ViteBuilder>;
|
2770
|
+
|
2771
|
+
type Environment = DevEnvironment | BuildEnvironment | UnknownEnvironment;
|
2772
|
+
/**
|
2773
|
+
* Creates a function that hides the complexities of a WeakMap with an initial value
|
2774
|
+
* to implement object metadata. Used by plugins to implement cross hooks per
|
2775
|
+
* environment metadata
|
2776
|
+
*
|
2777
|
+
* @experimental
|
2778
|
+
*/
|
2779
|
+
declare function perEnvironmentState<State>(initial: (environment: Environment) => State): (context: PluginContext) => State;
|
2780
|
+
|
2781
|
+
declare class EnvironmentPluginContainer {
|
2782
|
+
environment: Environment;
|
2783
|
+
plugins: Plugin[];
|
2784
|
+
watcher?: FSWatcher | undefined;
|
2785
|
+
private _pluginContextMap;
|
2786
|
+
private _resolvedRollupOptions?;
|
2787
|
+
private _processesing;
|
2788
|
+
private _seenResolves;
|
2789
|
+
private _moduleNodeToLoadAddedImports;
|
2790
|
+
getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks'];
|
2791
|
+
getSortedPlugins: PluginHookUtils['getSortedPlugins'];
|
2792
|
+
moduleGraph: EnvironmentModuleGraph | undefined;
|
2793
|
+
watchFiles: Set<string>;
|
2794
|
+
minimalContext: MinimalPluginContext;
|
2795
|
+
private _started;
|
2796
|
+
private _buildStartPromise;
|
2797
|
+
private _closed;
|
2798
|
+
private _updateModuleLoadAddedImports;
|
2799
|
+
private _getAddedImports;
|
2800
|
+
getModuleInfo(id: string): ModuleInfo | null;
|
2801
|
+
private handleHookPromise;
|
2802
|
+
get options(): InputOptions;
|
2803
|
+
resolveRollupOptions(): Promise<InputOptions>;
|
2804
|
+
private _getPluginContext;
|
2805
|
+
private hookParallel;
|
2806
|
+
buildStart(_options?: InputOptions): Promise<void>;
|
2807
|
+
resolveId(rawId: string, importer?: string | undefined, options?: {
|
2808
|
+
attributes?: Record<string, string>;
|
2809
|
+
custom?: CustomPluginOptions;
|
2810
|
+
skip?: Set<Plugin>;
|
2811
|
+
isEntry?: boolean;
|
2812
|
+
}): Promise<PartialResolvedId | null>;
|
2813
|
+
load(id: string): Promise<LoadResult | null>;
|
2814
|
+
transform(code: string, id: string, options?: {
|
2815
|
+
inMap?: SourceDescription['map'];
|
2816
|
+
}): Promise<{
|
2817
|
+
code: string;
|
2818
|
+
map: SourceMap | {
|
2819
|
+
mappings: '';
|
2820
|
+
} | null;
|
2821
|
+
}>;
|
2822
|
+
watchChange(id: string, change: {
|
2823
|
+
event: 'create' | 'update' | 'delete';
|
2824
|
+
}): Promise<void>;
|
2720
2825
|
close(): Promise<void>;
|
2721
|
-
/**
|
2722
|
-
* Handle custom event emitted by `import.meta.hot.send`
|
2723
|
-
*/
|
2724
|
-
on: WebSocket.Server['on'] & {
|
2725
|
-
<T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
|
2726
|
-
};
|
2727
|
-
/**
|
2728
|
-
* Unregister event listener.
|
2729
|
-
*/
|
2730
|
-
off: WebSocket.Server['off'] & {
|
2731
|
-
(event: string, listener: Function): void;
|
2732
|
-
};
|
2733
2826
|
}
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2739
|
-
|
2827
|
+
declare class PluginContainer {
|
2828
|
+
private environments;
|
2829
|
+
constructor(environments: Record<string, Environment>);
|
2830
|
+
private _getEnvironment;
|
2831
|
+
private _getPluginContainer;
|
2832
|
+
getModuleInfo(id: string): ModuleInfo | null;
|
2833
|
+
get options(): InputOptions;
|
2834
|
+
buildStart(_options?: InputOptions): Promise<void>;
|
2835
|
+
watchChange(id: string, change: {
|
2836
|
+
event: 'create' | 'update' | 'delete';
|
2837
|
+
}): Promise<void>;
|
2838
|
+
resolveId(rawId: string, importer?: string, options?: {
|
2839
|
+
attributes?: Record<string, string>;
|
2840
|
+
custom?: CustomPluginOptions;
|
2841
|
+
skip?: Set<Plugin>;
|
2842
|
+
ssr?: boolean;
|
2843
|
+
isEntry?: boolean;
|
2844
|
+
}): Promise<PartialResolvedId | null>;
|
2845
|
+
load(id: string, options?: {
|
2846
|
+
ssr?: boolean;
|
2847
|
+
}): Promise<LoadResult | null>;
|
2848
|
+
transform(code: string, id: string, options?: {
|
2849
|
+
ssr?: boolean;
|
2850
|
+
environment?: Environment;
|
2851
|
+
inMap?: SourceDescription['map'];
|
2852
|
+
}): Promise<{
|
2853
|
+
code: string;
|
2854
|
+
map: SourceMap | {
|
2855
|
+
mappings: '';
|
2856
|
+
} | null;
|
2857
|
+
}>;
|
2858
|
+
close(): Promise<void>;
|
2740
2859
|
}
|
2741
2860
|
|
2742
2861
|
interface ServerOptions extends CommonServerOptions {
|
@@ -2765,7 +2884,7 @@ interface ServerOptions extends CommonServerOptions {
|
|
2765
2884
|
};
|
2766
2885
|
/**
|
2767
2886
|
* chokidar watch options or null to disable FS watching
|
2768
|
-
* https://github.com/paulmillr/chokidar#api
|
2887
|
+
* https://github.com/paulmillr/chokidar/tree/3.6.0#api
|
2769
2888
|
*/
|
2770
2889
|
watch?: WatchOptions | null;
|
2771
2890
|
/**
|
@@ -2810,7 +2929,7 @@ interface ServerOptions extends CommonServerOptions {
|
|
2810
2929
|
* @default false
|
2811
2930
|
* @experimental
|
2812
2931
|
*/
|
2813
|
-
|
2932
|
+
perEnvironmentStartEndDuringDev?: boolean;
|
2814
2933
|
/**
|
2815
2934
|
* Run HMR tasks, by default the HMR propagation is done in parallel for all environments
|
2816
2935
|
* @experimental
|
@@ -2844,16 +2963,9 @@ interface FileSystemServeOptions {
|
|
2844
2963
|
* This will have higher priority than `allow`.
|
2845
2964
|
* picomatch patterns are supported.
|
2846
2965
|
*
|
2847
|
-
* @default ['.env', '.env.*', '*.crt', '
|
2966
|
+
* @default ['.env', '.env.*', '*.{crt,pem}', '**\/.git/**']
|
2848
2967
|
*/
|
2849
2968
|
deny?: string[];
|
2850
|
-
/**
|
2851
|
-
* Enable caching of fs calls. It is enabled by default if no custom watch ignored patterns are provided.
|
2852
|
-
*
|
2853
|
-
* @experimental
|
2854
|
-
* @default undefined
|
2855
|
-
*/
|
2856
|
-
cachedChecks?: boolean;
|
2857
2969
|
}
|
2858
2970
|
type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
2859
2971
|
type HttpServer = http.Server | Http2SecureServer;
|
@@ -2877,8 +2989,9 @@ interface ViteDevServer {
|
|
2877
2989
|
*/
|
2878
2990
|
httpServer: HttpServer | null;
|
2879
2991
|
/**
|
2880
|
-
*
|
2881
|
-
*
|
2992
|
+
* Chokidar watcher instance. If `config.server.watch` is set to `null`,
|
2993
|
+
* it will not watch any files and calling `add` or `unwatch` will have no effect.
|
2994
|
+
* https://github.com/paulmillr/chokidar/tree/3.6.0#api
|
2882
2995
|
*/
|
2883
2996
|
watcher: FSWatcher;
|
2884
2997
|
/**
|
@@ -2906,8 +3019,8 @@ interface ViteDevServer {
|
|
2906
3019
|
*/
|
2907
3020
|
moduleGraph: ModuleGraph;
|
2908
3021
|
/**
|
2909
|
-
* The resolved urls Vite prints on the CLI. null
|
2910
|
-
*
|
3022
|
+
* The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
|
3023
|
+
* in middleware mode or if the server is not listening on any port.
|
2911
3024
|
*/
|
2912
3025
|
resolvedUrls: ResolvedServerUrls | null;
|
2913
3026
|
/**
|
@@ -3002,128 +3115,21 @@ interface ESBuildOptions extends esbuild_TransformOptions {
|
|
3002
3115
|
type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
|
3003
3116
|
map: SourceMap;
|
3004
3117
|
};
|
3005
|
-
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
3006
|
-
|
3007
|
-
interface FsUtils {
|
3008
|
-
existsSync: (path: string) => boolean;
|
3009
|
-
isDirectory: (path: string) => boolean;
|
3010
|
-
tryResolveRealFile: (path: string, preserveSymlinks?: boolean) => string | undefined;
|
3011
|
-
tryResolveRealFileWithExtensions: (path: string, extensions: string[], preserveSymlinks?: boolean) => string | undefined;
|
3012
|
-
tryResolveRealFileOrType: (path: string, preserveSymlinks?: boolean) => {
|
3013
|
-
path?: string;
|
3014
|
-
type: 'directory' | 'file';
|
3015
|
-
} | undefined;
|
3016
|
-
initWatcher?: (watcher: FSWatcher) => void;
|
3017
|
-
}
|
3118
|
+
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<ESBuildTransformResult>;
|
3018
3119
|
|
3019
|
-
interface
|
3020
|
-
/**
|
3021
|
-
* @default ['browser', 'module', 'jsnext:main', 'jsnext']
|
3022
|
-
*/
|
3023
|
-
mainFields?: string[];
|
3024
|
-
conditions?: string[];
|
3025
|
-
externalConditions?: string[];
|
3026
|
-
/**
|
3027
|
-
* @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
|
3028
|
-
*/
|
3029
|
-
extensions?: string[];
|
3030
|
-
dedupe?: string[];
|
3031
|
-
/**
|
3032
|
-
* external/noExternal logic, this only works for certain environments
|
3033
|
-
* Previously this was ssr.external/ssr.noExternal
|
3034
|
-
* TODO: better abstraction that works for the client environment too?
|
3035
|
-
*/
|
3036
|
-
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
3037
|
-
external?: string[] | true;
|
3038
|
-
}
|
3039
|
-
interface ResolveOptions extends EnvironmentResolveOptions {
|
3040
|
-
/**
|
3041
|
-
* @default false
|
3042
|
-
*/
|
3043
|
-
preserveSymlinks?: boolean;
|
3044
|
-
}
|
3045
|
-
interface ResolvePluginOptions {
|
3046
|
-
root: string;
|
3047
|
-
isBuild: boolean;
|
3048
|
-
isProduction: boolean;
|
3049
|
-
packageCache?: PackageCache;
|
3050
|
-
fsUtils?: FsUtils;
|
3120
|
+
interface JsonOptions {
|
3051
3121
|
/**
|
3052
|
-
*
|
3053
|
-
*
|
3054
|
-
* - resolving bare imports from optimized deps
|
3122
|
+
* Generate a named export for every property of the JSON object
|
3123
|
+
* @default true
|
3055
3124
|
*/
|
3056
|
-
|
3057
|
-
tryIndex?: boolean;
|
3058
|
-
tryPrefix?: string;
|
3059
|
-
preferRelative?: boolean;
|
3060
|
-
isRequire?: boolean;
|
3061
|
-
webCompatible?: boolean;
|
3062
|
-
isFromTsImporter?: boolean;
|
3063
|
-
tryEsmOnly?: boolean;
|
3064
|
-
scan?: boolean;
|
3065
|
-
ssrOptimizeCheck?: boolean;
|
3125
|
+
namedExports?: boolean;
|
3066
3126
|
/**
|
3067
|
-
*
|
3127
|
+
* Generate performant output as JSON.parse("stringified").
|
3128
|
+
*
|
3129
|
+
* When set to 'auto', the data will be stringified only if the data is bigger than 10kB.
|
3130
|
+
* @default 'auto'
|
3068
3131
|
*/
|
3069
|
-
|
3070
|
-
}
|
3071
|
-
interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {
|
3072
|
-
}
|
3073
|
-
|
3074
|
-
// This file is autogenerated by build-prefixes.js. DO NOT EDIT!
|
3075
|
-
|
3076
|
-
interface Targets {
|
3077
|
-
android?: number,
|
3078
|
-
chrome?: number,
|
3079
|
-
edge?: number,
|
3080
|
-
firefox?: number,
|
3081
|
-
ie?: number,
|
3082
|
-
ios_saf?: number,
|
3083
|
-
opera?: number,
|
3084
|
-
safari?: number,
|
3085
|
-
samsung?: number
|
3086
|
-
}
|
3087
|
-
|
3088
|
-
interface Drafts {
|
3089
|
-
/** Whether to enable @custom-media rules. */
|
3090
|
-
customMedia?: boolean
|
3091
|
-
}
|
3092
|
-
|
3093
|
-
interface NonStandard {
|
3094
|
-
/** Whether to enable the non-standard >>> and /deep/ selector combinators used by Angular and Vue. */
|
3095
|
-
deepSelectorCombinator?: boolean
|
3096
|
-
}
|
3097
|
-
|
3098
|
-
interface PseudoClasses {
|
3099
|
-
hover?: string,
|
3100
|
-
active?: string,
|
3101
|
-
focus?: string,
|
3102
|
-
focusVisible?: string,
|
3103
|
-
focusWithin?: string
|
3104
|
-
}
|
3105
|
-
|
3106
|
-
interface CSSModulesConfig {
|
3107
|
-
/** The pattern to use when renaming class names and other identifiers. Default is `[hash]_[local]`. */
|
3108
|
-
pattern?: string,
|
3109
|
-
/** Whether to rename dashed identifiers, e.g. custom properties. */
|
3110
|
-
dashedIdents?: boolean
|
3111
|
-
}
|
3112
|
-
|
3113
|
-
/**
|
3114
|
-
* Options are spread, so you can also use options that are not typed here like
|
3115
|
-
* visitor (not exposed because it would impact too much the bundle size)
|
3116
|
-
*/
|
3117
|
-
type LightningCSSOptions = {
|
3118
|
-
targets?: Targets
|
3119
|
-
include?: number
|
3120
|
-
exclude?: number
|
3121
|
-
drafts?: Drafts
|
3122
|
-
nonStandard?: NonStandard
|
3123
|
-
pseudoClasses?: PseudoClasses
|
3124
|
-
unusedSymbols?: string[]
|
3125
|
-
cssModules?: CSSModulesConfig
|
3126
|
-
errorRecovery?: boolean
|
3132
|
+
stringify?: boolean | 'auto';
|
3127
3133
|
}
|
3128
3134
|
|
3129
3135
|
interface CSSOptions {
|
@@ -3146,7 +3152,13 @@ interface CSSOptions {
|
|
3146
3152
|
* In addition to options specific to each processors, Vite supports `additionalData` option.
|
3147
3153
|
* The `additionalData` option can be used to inject extra code for each style content.
|
3148
3154
|
*/
|
3149
|
-
preprocessorOptions?:
|
3155
|
+
preprocessorOptions?: {
|
3156
|
+
scss?: SassPreprocessorOptions;
|
3157
|
+
sass?: SassPreprocessorOptions;
|
3158
|
+
less?: LessPreprocessorOptions;
|
3159
|
+
styl?: StylusPreprocessorOptions;
|
3160
|
+
stylus?: StylusPreprocessorOptions;
|
3161
|
+
};
|
3150
3162
|
/**
|
3151
3163
|
* If this option is set, preprocessors will run in workers when possible.
|
3152
3164
|
* `true` means the number of CPUs minus 1.
|
@@ -3181,10 +3193,8 @@ interface CSSModulesOptions {
|
|
3181
3193
|
*/
|
3182
3194
|
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
|
3183
3195
|
}
|
3184
|
-
type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & {
|
3185
|
-
lightningcss?: LightningCSSOptions
|
3186
|
-
targets: LightningCSSOptions['targets'];
|
3187
|
-
};
|
3196
|
+
type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & Required<Pick<CSSOptions, 'transformer'>> & {
|
3197
|
+
lightningcss?: LightningCSSOptions;
|
3188
3198
|
};
|
3189
3199
|
interface PreprocessCSSResult {
|
3190
3200
|
code: string;
|
@@ -3197,6 +3207,24 @@ interface PreprocessCSSResult {
|
|
3197
3207
|
*/
|
3198
3208
|
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
|
3199
3209
|
declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
|
3210
|
+
type PreprocessorAdditionalDataResult = string | {
|
3211
|
+
content: string;
|
3212
|
+
map?: ExistingRawSourceMap;
|
3213
|
+
};
|
3214
|
+
type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>);
|
3215
|
+
type SassPreprocessorOptions = {
|
3216
|
+
additionalData?: PreprocessorAdditionalData;
|
3217
|
+
} & (({
|
3218
|
+
api: 'legacy';
|
3219
|
+
} & SassLegacyPreprocessBaseOptions) | ({
|
3220
|
+
api?: 'modern' | 'modern-compiler';
|
3221
|
+
} & SassModernPreprocessBaseOptions));
|
3222
|
+
type LessPreprocessorOptions = {
|
3223
|
+
additionalData?: PreprocessorAdditionalData;
|
3224
|
+
} & LessPreprocessorBaseOptions;
|
3225
|
+
type StylusPreprocessorOptions = {
|
3226
|
+
additionalData?: PreprocessorAdditionalData;
|
3227
|
+
} & StylusPreprocessorBaseOptions;
|
3200
3228
|
|
3201
3229
|
interface HtmlTagDescriptor {
|
3202
3230
|
tag: string;
|
@@ -3287,7 +3315,7 @@ interface ResolveIdPluginContext extends rollup.PluginContext, PluginContextExte
|
|
3287
3315
|
interface TransformPluginContext extends rollup.TransformPluginContext, PluginContextExtension {
|
3288
3316
|
}
|
3289
3317
|
declare module 'rollup' {
|
3290
|
-
interface
|
3318
|
+
interface MinimalPluginContext extends PluginContextExtension {
|
3291
3319
|
}
|
3292
3320
|
}
|
3293
3321
|
/**
|
@@ -3370,8 +3398,9 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3370
3398
|
/**
|
3371
3399
|
* Define environments where this plugin should be active
|
3372
3400
|
* By default, the plugin is active in all environments
|
3401
|
+
* @experimental
|
3373
3402
|
*/
|
3374
|
-
applyToEnvironment?: (environment:
|
3403
|
+
applyToEnvironment?: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption;
|
3375
3404
|
/**
|
3376
3405
|
* Modify vite config before it's resolved. The hook can either mutate the
|
3377
3406
|
* passed-in config directly, or return a partial config object that will be
|
@@ -3391,7 +3420,13 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3391
3420
|
* hook instead of the config hook. Leaving the config hook only for modifying the root
|
3392
3421
|
* default environment config.
|
3393
3422
|
*/
|
3394
|
-
configEnvironment?: ObjectHook<(this: void, name: string, config: EnvironmentOptions, env: ConfigEnv
|
3423
|
+
configEnvironment?: ObjectHook<(this: void, name: string, config: EnvironmentOptions, env: ConfigEnv & {
|
3424
|
+
/**
|
3425
|
+
* Whether this environment is SSR environment and `ssr.target` is set to `'webworker'`.
|
3426
|
+
* Only intended to be used for backward compatibility.
|
3427
|
+
*/
|
3428
|
+
isSsrTargetWebworker?: boolean;
|
3429
|
+
}) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>;
|
3395
3430
|
/**
|
3396
3431
|
* Use this hook to read and store the final resolved vite config.
|
3397
3432
|
*/
|
@@ -3456,20 +3491,10 @@ type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
|
|
3456
3491
|
type Thenable<T> = T | Promise<T>;
|
3457
3492
|
type FalsyPlugin = false | null | undefined;
|
3458
3493
|
type PluginOption = Thenable<Plugin | FalsyPlugin | PluginOption[]>;
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
* @default true
|
3464
|
-
*/
|
3465
|
-
namedExports?: boolean;
|
3466
|
-
/**
|
3467
|
-
* Generate performant output as JSON.parse("stringified").
|
3468
|
-
* Enabling this will disable namedExports.
|
3469
|
-
* @default false
|
3470
|
-
*/
|
3471
|
-
stringify?: boolean;
|
3472
|
-
}
|
3494
|
+
/**
|
3495
|
+
* @experimental
|
3496
|
+
*/
|
3497
|
+
declare function perEnvironmentPlugin(name: string, applyToEnvironment: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption): Plugin;
|
3473
3498
|
|
3474
3499
|
type SSRTarget = 'node' | 'webworker';
|
3475
3500
|
type SsrDepOptimizationConfig = DepOptimizationConfig;
|
@@ -3479,7 +3504,7 @@ interface SSROptions {
|
|
3479
3504
|
/**
|
3480
3505
|
* Define the target for the ssr build. The browser field in package.json
|
3481
3506
|
* is ignored for node but used if webworker is the target
|
3482
|
-
* This option
|
3507
|
+
* This option will be removed in a future major version
|
3483
3508
|
* @default 'node'
|
3484
3509
|
*/
|
3485
3510
|
target?: SSRTarget;
|
@@ -3507,6 +3532,7 @@ interface SSROptions {
|
|
3507
3532
|
* @default []
|
3508
3533
|
*/
|
3509
3534
|
externalConditions?: string[];
|
3535
|
+
mainFields?: string[];
|
3510
3536
|
};
|
3511
3537
|
}
|
3512
3538
|
interface ResolvedSSROptions extends SSROptions {
|
@@ -3544,6 +3570,8 @@ type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject |
|
|
3544
3570
|
declare function defineConfig(config: UserConfig): UserConfig;
|
3545
3571
|
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
3546
3572
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
3573
|
+
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
3574
|
+
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
3547
3575
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3548
3576
|
interface CreateDevEnvironmentContext {
|
3549
3577
|
ws: WebSocketServer;
|
@@ -3576,10 +3604,6 @@ interface DevEnvironmentOptions {
|
|
3576
3604
|
* sourcemap path and returns whether to ignore the source path.
|
3577
3605
|
*/
|
3578
3606
|
sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
|
3579
|
-
/**
|
3580
|
-
* Optimize deps config
|
3581
|
-
*/
|
3582
|
-
optimizeDeps?: DepOptimizationOptions;
|
3583
3607
|
/**
|
3584
3608
|
* create the Dev Environment instance
|
3585
3609
|
*/
|
@@ -3598,7 +3622,9 @@ interface DevEnvironmentOptions {
|
|
3598
3622
|
*/
|
3599
3623
|
moduleRunnerTransform?: boolean;
|
3600
3624
|
}
|
3601
|
-
type ResolvedDevEnvironmentOptions = Required<DevEnvironmentOptions
|
3625
|
+
type ResolvedDevEnvironmentOptions = Omit<Required<DevEnvironmentOptions>, 'sourcemapIgnoreList'> & {
|
3626
|
+
sourcemapIgnoreList: Exclude<DevEnvironmentOptions['sourcemapIgnoreList'], false | undefined>;
|
3627
|
+
};
|
3602
3628
|
type AllResolveOptions = ResolveOptions & {
|
3603
3629
|
alias?: AliasOptions;
|
3604
3630
|
};
|
@@ -3618,10 +3644,14 @@ interface SharedEnvironmentOptions {
|
|
3618
3644
|
*/
|
3619
3645
|
consumer?: 'client' | 'server';
|
3620
3646
|
/**
|
3621
|
-
*
|
3622
|
-
*
|
3647
|
+
* If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime.
|
3648
|
+
* Otherwise, it is statically replaced as an empty object.
|
3649
|
+
*/
|
3650
|
+
keepProcessEnv?: boolean;
|
3651
|
+
/**
|
3652
|
+
* Optimize deps config
|
3623
3653
|
*/
|
3624
|
-
|
3654
|
+
optimizeDeps?: DepOptimizationOptions;
|
3625
3655
|
}
|
3626
3656
|
interface EnvironmentOptions extends SharedEnvironmentOptions {
|
3627
3657
|
/**
|
@@ -3638,11 +3668,12 @@ type ResolvedEnvironmentOptions = {
|
|
3638
3668
|
define?: Record<string, any>;
|
3639
3669
|
resolve: ResolvedResolveOptions;
|
3640
3670
|
consumer: 'client' | 'server';
|
3641
|
-
|
3671
|
+
keepProcessEnv?: boolean;
|
3672
|
+
optimizeDeps: DepOptimizationOptions;
|
3642
3673
|
dev: ResolvedDevEnvironmentOptions;
|
3643
3674
|
build: ResolvedBuildEnvironmentOptions;
|
3644
3675
|
};
|
3645
|
-
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'consumer' | '
|
3676
|
+
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'consumer' | 'resolve'> & {
|
3646
3677
|
resolve?: AllResolveOptions;
|
3647
3678
|
};
|
3648
3679
|
interface UserConfig extends DefaultEnvironmentOptions {
|
@@ -3708,6 +3739,7 @@ interface UserConfig extends DefaultEnvironmentOptions {
|
|
3708
3739
|
assetsInclude?: string | RegExp | (string | RegExp)[];
|
3709
3740
|
/**
|
3710
3741
|
* Builder specific options
|
3742
|
+
* @experimental
|
3711
3743
|
*/
|
3712
3744
|
builder?: BuilderOptions;
|
3713
3745
|
/**
|
@@ -3874,7 +3906,7 @@ interface InlineConfig extends UserConfig {
|
|
3874
3906
|
configFile?: string | false;
|
3875
3907
|
envFile?: false;
|
3876
3908
|
}
|
3877
|
-
type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments'> & {
|
3909
|
+
type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'json' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments' | 'server' | 'preview'> & {
|
3878
3910
|
configFile: string | undefined;
|
3879
3911
|
configFileDependencies: string[];
|
3880
3912
|
inlineConfig: InlineConfig;
|
@@ -3893,10 +3925,12 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
|
|
3893
3925
|
};
|
3894
3926
|
plugins: readonly Plugin[];
|
3895
3927
|
css: ResolvedCSSOptions;
|
3928
|
+
json: Required<JsonOptions>;
|
3896
3929
|
esbuild: ESBuildOptions | false;
|
3897
3930
|
server: ResolvedServerOptions;
|
3898
3931
|
dev: ResolvedDevEnvironmentOptions;
|
3899
|
-
|
3932
|
+
/** @experimental */
|
3933
|
+
builder: ResolvedBuilderOptions | undefined;
|
3900
3934
|
build: ResolvedBuildOptions;
|
3901
3935
|
preview: ResolvedPreviewOptions;
|
3902
3936
|
ssr: ResolvedSSROptions;
|
@@ -3933,8 +3967,6 @@ declare function createIdResolver(config: ResolvedConfig, options?: Partial<Inte
|
|
3933
3967
|
|
3934
3968
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3935
3969
|
|
3936
|
-
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, context: DevEnvironmentContext): DevEnvironment;
|
3937
|
-
|
3938
3970
|
/**
|
3939
3971
|
* @experimental
|
3940
3972
|
*/
|
@@ -3943,7 +3975,6 @@ interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | '
|
|
3943
3975
|
* Disable HMR or configure HMR logger.
|
3944
3976
|
*/
|
3945
3977
|
hmr?: false | {
|
3946
|
-
connection?: ModuleRunnerHMRConnection;
|
3947
3978
|
logger?: ModuleRunnerHmr['logger'];
|
3948
3979
|
};
|
3949
3980
|
/**
|
@@ -3957,20 +3988,32 @@ interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | '
|
|
3957
3988
|
*/
|
3958
3989
|
declare function createServerModuleRunner(environment: DevEnvironment, options?: ServerModuleRunnerOptions): ModuleRunner;
|
3959
3990
|
|
3991
|
+
declare function createRunnableDevEnvironment(name: string, config: ResolvedConfig, context?: RunnableDevEnvironmentContext): DevEnvironment;
|
3992
|
+
interface RunnableDevEnvironmentContext extends Omit<DevEnvironmentContext, 'hot'> {
|
3993
|
+
runner?: (environment: RunnableDevEnvironment, options?: ServerModuleRunnerOptions) => ModuleRunner;
|
3994
|
+
runnerOptions?: ServerModuleRunnerOptions;
|
3995
|
+
hot?: boolean;
|
3996
|
+
}
|
3997
|
+
declare function isRunnableDevEnvironment(environment: Environment): environment is RunnableDevEnvironment;
|
3998
|
+
declare class RunnableDevEnvironment extends DevEnvironment {
|
3999
|
+
private _runner;
|
4000
|
+
private _runnerFactory;
|
4001
|
+
private _runnerOptions;
|
4002
|
+
constructor(name: string, config: ResolvedConfig, context: RunnableDevEnvironmentContext);
|
4003
|
+
get runner(): ModuleRunner;
|
4004
|
+
close(): Promise<void>;
|
4005
|
+
}
|
4006
|
+
|
4007
|
+
interface FetchModuleOptions {
|
4008
|
+
cached?: boolean;
|
4009
|
+
inlineSourceMap?: boolean;
|
4010
|
+
startOffset?: number;
|
4011
|
+
}
|
3960
4012
|
/**
|
3961
|
-
*
|
4013
|
+
* Fetch module information for Vite runner.
|
3962
4014
|
* @experimental
|
3963
4015
|
*/
|
3964
|
-
declare
|
3965
|
-
private hotChannel;
|
3966
|
-
private handlers;
|
3967
|
-
private hmrClient;
|
3968
|
-
private connected;
|
3969
|
-
constructor(hotChannel: ServerHotChannel);
|
3970
|
-
isReady(): boolean;
|
3971
|
-
send(message: string): void;
|
3972
|
-
onUpdate(handler: (payload: HotPayload) => void): void;
|
3973
|
-
}
|
4016
|
+
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
3974
4017
|
|
3975
4018
|
interface ModuleRunnerTransformOptions {
|
3976
4019
|
json?: {
|
@@ -3982,6 +4025,10 @@ declare function ssrTransform(code: string, inMap: SourceMap | {
|
|
3982
4025
|
} | null, url: string, originalCode: string, options?: ModuleRunnerTransformOptions): Promise<TransformResult | null>;
|
3983
4026
|
|
3984
4027
|
declare const VERSION: string;
|
4028
|
+
declare const DEFAULT_CLIENT_MAIN_FIELDS: readonly string[];
|
4029
|
+
declare const DEFAULT_SERVER_MAIN_FIELDS: readonly string[];
|
4030
|
+
declare const DEFAULT_CLIENT_CONDITIONS: readonly string[];
|
4031
|
+
declare const DEFAULT_SERVER_CONDITIONS: readonly string[];
|
3985
4032
|
|
3986
4033
|
declare const isCSSRequest: (request: string) => boolean;
|
3987
4034
|
/**
|
@@ -4056,4 +4103,4 @@ interface ManifestChunk {
|
|
4056
4103
|
dynamicImports?: string[];
|
4057
4104
|
}
|
4058
4105
|
|
4059
|
-
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type
|
4106
|
+
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHMRChannel, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
|