vite 5.2.8 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.mjs +4 -1
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-2j8ZV8Rx.js → dep-BD8Vf02W.js} +1 -1
- package/dist/node/chunks/{dep-D6I3Q2TL.js → dep-DPzWXNBe.js} +1 -1
- package/dist/node/chunks/{dep-whKeNLxG.js → dep-gq9_cnPm.js} +35276 -34160
- package/dist/node/cli.js +52 -23
- package/dist/node/index.d.ts +765 -393
- package/dist/node/index.js +57 -15
- package/dist/node/{types.d-aGj9QkWt.d.ts → module-runner.d.ts} +135 -82
- package/dist/node/{runtime.js → module-runner.js} +115 -83
- package/dist/node-cjs/publicUtils.cjs +24 -14
- package/package.json +9 -9
- package/types/hmrPayload.d.ts +1 -1
- package/dist/node/runtime.d.ts +0 -63
package/dist/node/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { PluginHooks, RollupError,
|
2
|
+
import { PluginHooks, RollupError, InputOptions, CustomPluginOptions, PartialResolvedId, SourceDescription, SourceMap, LoadResult, ModuleInfo, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, SourceMapInput, ExistingRawSourceMap, OutputBundle, OutputChunk, ObjectHook, ResolveIdResult, GetManualChunk } from 'rollup';
|
3
3
|
import * as rollup from 'rollup';
|
4
4
|
export { rollup as Rollup };
|
5
5
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
@@ -15,21 +15,19 @@ 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 { F as FetchResult, H as HMRLogger } from './types.d-aGj9QkWt.js';
|
19
|
-
export { a as FetchFunction } from './types.d-aGj9QkWt.js';
|
20
18
|
import { SecureContextOptions } from 'node:tls';
|
21
19
|
import { ZlibOptions } from 'node:zlib';
|
22
20
|
import { HMRPayload, CustomPayload } from '../../types/hmrPayload.js';
|
23
21
|
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, PrunePayload, Update, UpdatePayload } from '../../types/hmrPayload.js';
|
24
22
|
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
25
23
|
export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../../types/customEvent.js';
|
26
|
-
import {
|
24
|
+
import { FetchResult, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
|
25
|
+
export { FetchFunction, FetchResult } from 'vite/module-runner';
|
26
|
+
import { BuildOptions as esbuild_BuildOptions, TransformOptions as esbuild_TransformOptions, TransformResult as esbuild_TransformResult } from 'esbuild';
|
27
27
|
export { TransformOptions as EsbuildTransformOptions, version as esbuildVersion } from 'esbuild';
|
28
28
|
import * as PostCSS from 'postcss';
|
29
|
-
import { ViteRuntimeOptions, ViteModuleRunner, ViteRuntime, HMRRuntimeConnection } from 'vite/runtime';
|
30
29
|
export { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap } from '../../types/importGlob.js';
|
31
30
|
export { ChunkMetadata } from '../../types/metadata.js';
|
32
|
-
import '../../types/hot.js';
|
33
31
|
|
34
32
|
interface Alias {
|
35
33
|
find: string | RegExp
|
@@ -784,90 +782,6 @@ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
|
|
784
782
|
action?(server: Server): void | Promise<void>;
|
785
783
|
};
|
786
784
|
|
787
|
-
interface TransformResult {
|
788
|
-
code: string;
|
789
|
-
map: SourceMap | {
|
790
|
-
mappings: '';
|
791
|
-
} | null;
|
792
|
-
etag?: string;
|
793
|
-
deps?: string[];
|
794
|
-
dynamicDeps?: string[];
|
795
|
-
}
|
796
|
-
interface TransformOptions {
|
797
|
-
ssr?: boolean;
|
798
|
-
html?: boolean;
|
799
|
-
}
|
800
|
-
|
801
|
-
declare class ModuleNode {
|
802
|
-
/**
|
803
|
-
* Public served url path, starts with /
|
804
|
-
*/
|
805
|
-
url: string;
|
806
|
-
/**
|
807
|
-
* Resolved file system path + query
|
808
|
-
*/
|
809
|
-
id: string | null;
|
810
|
-
file: string | null;
|
811
|
-
type: 'js' | 'css';
|
812
|
-
info?: ModuleInfo;
|
813
|
-
meta?: Record<string, any>;
|
814
|
-
importers: Set<ModuleNode>;
|
815
|
-
clientImportedModules: Set<ModuleNode>;
|
816
|
-
ssrImportedModules: Set<ModuleNode>;
|
817
|
-
acceptedHmrDeps: Set<ModuleNode>;
|
818
|
-
acceptedHmrExports: Set<string> | null;
|
819
|
-
importedBindings: Map<string, Set<string>> | null;
|
820
|
-
isSelfAccepting?: boolean;
|
821
|
-
transformResult: TransformResult | null;
|
822
|
-
ssrTransformResult: TransformResult | null;
|
823
|
-
ssrModule: Record<string, any> | null;
|
824
|
-
ssrError: Error | null;
|
825
|
-
lastHMRTimestamp: number;
|
826
|
-
lastInvalidationTimestamp: number;
|
827
|
-
/**
|
828
|
-
* @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
|
829
|
-
*/
|
830
|
-
constructor(url: string, setIsSelfAccepting?: boolean);
|
831
|
-
get importedModules(): Set<ModuleNode>;
|
832
|
-
}
|
833
|
-
type ResolvedUrl = [
|
834
|
-
url: string,
|
835
|
-
resolvedId: string,
|
836
|
-
meta: object | null | undefined
|
837
|
-
];
|
838
|
-
declare class ModuleGraph {
|
839
|
-
private resolveId;
|
840
|
-
urlToModuleMap: Map<string, ModuleNode>;
|
841
|
-
idToModuleMap: Map<string, ModuleNode>;
|
842
|
-
etagToModuleMap: Map<string, ModuleNode>;
|
843
|
-
fileToModulesMap: Map<string, Set<ModuleNode>>;
|
844
|
-
safeModulesPath: Set<string>;
|
845
|
-
constructor(resolveId: (url: string, ssr: boolean) => Promise<PartialResolvedId | null>);
|
846
|
-
getModuleByUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode | undefined>;
|
847
|
-
getModuleById(id: string): ModuleNode | undefined;
|
848
|
-
getModulesByFile(file: string): Set<ModuleNode> | undefined;
|
849
|
-
onFileChange(file: string): void;
|
850
|
-
onFileDelete(file: string): void;
|
851
|
-
invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean,
|
852
|
-
): void;
|
853
|
-
invalidateAll(): void;
|
854
|
-
/**
|
855
|
-
* Update the module graph based on a module's updated imports information
|
856
|
-
* If there are dependencies that no longer have any importers, they are
|
857
|
-
* returned as a Set.
|
858
|
-
*
|
859
|
-
* @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
|
860
|
-
* This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
|
861
|
-
*/
|
862
|
-
updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | ModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean, ssr?: boolean,
|
863
|
-
): Promise<Set<ModuleNode> | undefined>;
|
864
|
-
ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
|
865
|
-
createFileOnlyEntry(file: string): ModuleNode;
|
866
|
-
resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
|
867
|
-
updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr: boolean): void;
|
868
|
-
getModuleByEtag(etag: string): ModuleNode | undefined;
|
869
|
-
}
|
870
|
-
|
871
785
|
/**
|
872
786
|
* This file is refactored into TypeScript based on
|
873
787
|
* https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
|
@@ -875,18 +789,19 @@ declare class ModuleGraph {
|
|
875
789
|
|
876
790
|
interface PluginContainer {
|
877
791
|
options: InputOptions;
|
878
|
-
getModuleInfo(id: string): ModuleInfo | null;
|
879
792
|
buildStart(options: InputOptions): Promise<void>;
|
880
|
-
resolveId(id: string, importer
|
793
|
+
resolveId(id: string, importer: string | undefined, options?: {
|
881
794
|
attributes?: Record<string, string>;
|
882
795
|
custom?: CustomPluginOptions;
|
883
796
|
skip?: Set<Plugin>;
|
884
797
|
ssr?: boolean;
|
798
|
+
environment?: PluginEnvironment;
|
885
799
|
isEntry?: boolean;
|
886
800
|
}): Promise<PartialResolvedId | null>;
|
887
801
|
transform(code: string, id: string, options?: {
|
888
802
|
inMap?: SourceDescription['map'];
|
889
803
|
ssr?: boolean;
|
804
|
+
environment?: PluginEnvironment;
|
890
805
|
}): Promise<{
|
891
806
|
code: string;
|
892
807
|
map: SourceMap | {
|
@@ -895,6 +810,7 @@ interface PluginContainer {
|
|
895
810
|
}>;
|
896
811
|
load(id: string, options?: {
|
897
812
|
ssr?: boolean;
|
813
|
+
environment?: PluginEnvironment;
|
898
814
|
}): Promise<LoadResult | null>;
|
899
815
|
watchChange(id: string, change: {
|
900
816
|
event: 'create' | 'update' | 'delete';
|
@@ -1429,12 +1345,408 @@ declare namespace WebSocket {
|
|
1429
1345
|
const WebSocket: typeof WebSocketAlias
|
1430
1346
|
interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
1431
1347
|
|
1432
|
-
// WebSocket stream
|
1433
|
-
function createWebSocketStream(
|
1434
|
-
websocket: WebSocket,
|
1435
|
-
options?: DuplexOptions,
|
1436
|
-
): Duplex
|
1348
|
+
// WebSocket stream
|
1349
|
+
function createWebSocketStream(
|
1350
|
+
websocket: WebSocket,
|
1351
|
+
options?: DuplexOptions,
|
1352
|
+
): Duplex
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
declare class Environment {
|
1356
|
+
name: string;
|
1357
|
+
config: ResolvedConfig;
|
1358
|
+
options: ResolvedEnvironmentOptions;
|
1359
|
+
get logger(): Logger;
|
1360
|
+
constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
interface FetchModuleOptions {
|
1364
|
+
inlineSourceMap?: boolean;
|
1365
|
+
processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
|
1366
|
+
}
|
1367
|
+
/**
|
1368
|
+
* Fetch module information for Vite runner.
|
1369
|
+
* @experimental
|
1370
|
+
*/
|
1371
|
+
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
1372
|
+
|
1373
|
+
type ExportsData = {
|
1374
|
+
hasImports: boolean;
|
1375
|
+
exports: readonly string[];
|
1376
|
+
jsxLoader?: boolean;
|
1377
|
+
};
|
1378
|
+
interface DepsOptimizer {
|
1379
|
+
init: () => Promise<void>;
|
1380
|
+
metadata: DepOptimizationMetadata;
|
1381
|
+
scanProcessing?: Promise<void>;
|
1382
|
+
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
1383
|
+
run: () => void;
|
1384
|
+
isOptimizedDepFile: (id: string) => boolean;
|
1385
|
+
isOptimizedDepUrl: (url: string) => boolean;
|
1386
|
+
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
|
1387
|
+
close: () => Promise<void>;
|
1388
|
+
options: DepOptimizationOptions;
|
1389
|
+
}
|
1390
|
+
interface DepOptimizationConfig {
|
1391
|
+
/**
|
1392
|
+
* Force optimize listed dependencies (must be resolvable import paths,
|
1393
|
+
* cannot be globs).
|
1394
|
+
*/
|
1395
|
+
include?: string[];
|
1396
|
+
/**
|
1397
|
+
* Do not optimize these dependencies (must be resolvable import paths,
|
1398
|
+
* cannot be globs).
|
1399
|
+
*/
|
1400
|
+
exclude?: string[];
|
1401
|
+
/**
|
1402
|
+
* Forces ESM interop when importing these dependencies. Some legacy
|
1403
|
+
* packages advertise themselves as ESM but use `require` internally
|
1404
|
+
* @experimental
|
1405
|
+
*/
|
1406
|
+
needsInterop?: string[];
|
1407
|
+
/**
|
1408
|
+
* Options to pass to esbuild during the dep scanning and optimization
|
1409
|
+
*
|
1410
|
+
* Certain options are omitted since changing them would not be compatible
|
1411
|
+
* with Vite's dep optimization.
|
1412
|
+
*
|
1413
|
+
* - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
|
1414
|
+
* - `plugins` are merged with Vite's dep plugin
|
1415
|
+
*
|
1416
|
+
* https://esbuild.github.io/api
|
1417
|
+
*/
|
1418
|
+
esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
|
1419
|
+
/**
|
1420
|
+
* List of file extensions that can be optimized. A corresponding esbuild
|
1421
|
+
* plugin must exist to handle the specific extension.
|
1422
|
+
*
|
1423
|
+
* By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
|
1424
|
+
* allows specifying additional extensions.
|
1425
|
+
*
|
1426
|
+
* @experimental
|
1427
|
+
*/
|
1428
|
+
extensions?: string[];
|
1429
|
+
/**
|
1430
|
+
* Deps optimization during build was removed in Vite 5.1. This option is
|
1431
|
+
* now redundant and will be removed in a future version. Switch to using
|
1432
|
+
* `optimizeDeps.noDiscovery` and an empty or undefined `optimizeDeps.include`.
|
1433
|
+
* true or 'dev' disables the optimizer, false or 'build' leaves it enabled.
|
1434
|
+
* @default 'build'
|
1435
|
+
* @deprecated
|
1436
|
+
* @experimental
|
1437
|
+
*/
|
1438
|
+
disabled?: boolean | 'build' | 'dev';
|
1439
|
+
/**
|
1440
|
+
* Automatic dependency discovery. When `noDiscovery` is true, only dependencies
|
1441
|
+
* listed in `include` will be optimized. The scanner isn't run for cold start
|
1442
|
+
* in this case. CJS-only dependencies must be present in `include` during dev.
|
1443
|
+
* @default false
|
1444
|
+
* @experimental
|
1445
|
+
*/
|
1446
|
+
noDiscovery?: boolean;
|
1447
|
+
/**
|
1448
|
+
* When enabled, it will hold the first optimized deps results until all static
|
1449
|
+
* imports are crawled on cold start. This avoids the need for full-page reloads
|
1450
|
+
* when new dependencies are discovered and they trigger the generation of new
|
1451
|
+
* common chunks. If all dependencies are found by the scanner plus the explicitely
|
1452
|
+
* defined ones in `include`, it is better to disable this option to let the
|
1453
|
+
* browser process more requests in parallel.
|
1454
|
+
* @default true
|
1455
|
+
* @experimental
|
1456
|
+
*/
|
1457
|
+
holdUntilCrawlEnd?: boolean;
|
1458
|
+
}
|
1459
|
+
type DepOptimizationOptions = DepOptimizationConfig & {
|
1460
|
+
/**
|
1461
|
+
* By default, Vite will crawl your `index.html` to detect dependencies that
|
1462
|
+
* need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
|
1463
|
+
* will crawl those entry points instead.
|
1464
|
+
*
|
1465
|
+
* If neither of these fit your needs, you can specify custom entries using
|
1466
|
+
* this option - the value should be a fast-glob pattern or array of patterns
|
1467
|
+
* (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
|
1468
|
+
* vite project root. This will overwrite default entries inference.
|
1469
|
+
*/
|
1470
|
+
entries?: string | string[];
|
1471
|
+
/**
|
1472
|
+
* Force dep pre-optimization regardless of whether deps have changed.
|
1473
|
+
* @experimental
|
1474
|
+
*/
|
1475
|
+
force?: boolean;
|
1476
|
+
};
|
1477
|
+
interface OptimizedDepInfo {
|
1478
|
+
id: string;
|
1479
|
+
file: string;
|
1480
|
+
src?: string;
|
1481
|
+
needsInterop?: boolean;
|
1482
|
+
browserHash?: string;
|
1483
|
+
fileHash?: string;
|
1484
|
+
/**
|
1485
|
+
* During optimization, ids can still be resolved to their final location
|
1486
|
+
* but the bundles may not yet be saved to disk
|
1487
|
+
*/
|
1488
|
+
processing?: Promise<void>;
|
1489
|
+
/**
|
1490
|
+
* ExportData cache, discovered deps will parse the src entry to get exports
|
1491
|
+
* data used both to define if interop is needed and when pre-bundling
|
1492
|
+
*/
|
1493
|
+
exportsData?: Promise<ExportsData>;
|
1494
|
+
}
|
1495
|
+
interface DepOptimizationMetadata {
|
1496
|
+
/**
|
1497
|
+
* The main hash is determined by user config and dependency lockfiles.
|
1498
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
1499
|
+
*/
|
1500
|
+
hash: string;
|
1501
|
+
/**
|
1502
|
+
* This hash is determined by dependency lockfiles.
|
1503
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
1504
|
+
*/
|
1505
|
+
lockfileHash: string;
|
1506
|
+
/**
|
1507
|
+
* This hash is determined by user config.
|
1508
|
+
* This is checked on server startup to avoid unnecessary re-bundles.
|
1509
|
+
*/
|
1510
|
+
configHash: string;
|
1511
|
+
/**
|
1512
|
+
* The browser hash is determined by the main hash plus additional dependencies
|
1513
|
+
* discovered at runtime. This is used to invalidate browser requests to
|
1514
|
+
* optimized deps.
|
1515
|
+
*/
|
1516
|
+
browserHash: string;
|
1517
|
+
/**
|
1518
|
+
* Metadata for each already optimized dependency
|
1519
|
+
*/
|
1520
|
+
optimized: Record<string, OptimizedDepInfo>;
|
1521
|
+
/**
|
1522
|
+
* Metadata for non-entry optimized chunks and dynamic imports
|
1523
|
+
*/
|
1524
|
+
chunks: Record<string, OptimizedDepInfo>;
|
1525
|
+
/**
|
1526
|
+
* Metadata for each newly discovered dependency after processing
|
1527
|
+
*/
|
1528
|
+
discovered: Record<string, OptimizedDepInfo>;
|
1529
|
+
/**
|
1530
|
+
* OptimizedDepInfo list
|
1531
|
+
*/
|
1532
|
+
depInfoList: OptimizedDepInfo[];
|
1533
|
+
}
|
1534
|
+
/**
|
1535
|
+
* Scan and optimize dependencies within a project.
|
1536
|
+
* Used by Vite CLI when running `vite optimize`.
|
1537
|
+
*/
|
1538
|
+
declare function optimizeDeps(environment: Environment, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
1539
|
+
|
1540
|
+
declare class RemoteEnvironmentTransport {
|
1541
|
+
private readonly options;
|
1542
|
+
constructor(options: {
|
1543
|
+
send: (data: any) => void;
|
1544
|
+
onMessage: (handler: (data: any) => void) => void;
|
1545
|
+
});
|
1546
|
+
register(environment: DevEnvironment): void;
|
1547
|
+
}
|
1548
|
+
|
1549
|
+
interface DevEnvironmentSetup {
|
1550
|
+
hot?: false | HMRChannel;
|
1551
|
+
options?: EnvironmentOptions;
|
1552
|
+
runner?: FetchModuleOptions & {
|
1553
|
+
transport?: RemoteEnvironmentTransport;
|
1554
|
+
};
|
1555
|
+
}
|
1556
|
+
declare class DevEnvironment extends Environment {
|
1557
|
+
mode: "dev";
|
1558
|
+
moduleGraph: EnvironmentModuleGraph;
|
1559
|
+
server: ViteDevServer;
|
1560
|
+
depsOptimizer?: DepsOptimizer;
|
1561
|
+
/**
|
1562
|
+
* HMR channel for this environment. If not provided or disabled,
|
1563
|
+
* it will be a noop channel that does nothing.
|
1564
|
+
*
|
1565
|
+
* @example
|
1566
|
+
* environment.hot.send({ type: 'full-reload' })
|
1567
|
+
*/
|
1568
|
+
hot: HMRChannel;
|
1569
|
+
constructor(server: ViteDevServer, name: string, setup?: {
|
1570
|
+
hot?: false | HMRChannel;
|
1571
|
+
options?: EnvironmentOptions;
|
1572
|
+
runner?: FetchModuleOptions & {
|
1573
|
+
transport?: RemoteEnvironmentTransport;
|
1574
|
+
};
|
1575
|
+
depsOptimizer?: DepsOptimizer;
|
1576
|
+
});
|
1577
|
+
fetchModule(id: string, importer?: string): Promise<FetchResult>;
|
1578
|
+
transformRequest(url: string): Promise<TransformResult | null>;
|
1579
|
+
warmupRequest(url: string): Promise<void>;
|
1580
|
+
close(): Promise<void>;
|
1581
|
+
}
|
1582
|
+
|
1583
|
+
interface TransformResult {
|
1584
|
+
code: string;
|
1585
|
+
map: SourceMap | {
|
1586
|
+
mappings: '';
|
1587
|
+
} | null;
|
1588
|
+
etag?: string;
|
1589
|
+
deps?: string[];
|
1590
|
+
dynamicDeps?: string[];
|
1591
|
+
}
|
1592
|
+
interface TransformOptions {
|
1593
|
+
/**
|
1594
|
+
* @deprecated infered from environment
|
1595
|
+
*/
|
1596
|
+
ssr?: boolean;
|
1597
|
+
/**
|
1598
|
+
* TODO: should this be internal?
|
1599
|
+
*/
|
1600
|
+
html?: boolean;
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
declare class EnvironmentModuleNode {
|
1604
|
+
environment: string;
|
1605
|
+
/**
|
1606
|
+
* Public served url path, starts with /
|
1607
|
+
*/
|
1608
|
+
url: string;
|
1609
|
+
/**
|
1610
|
+
* Resolved file system path + query
|
1611
|
+
*/
|
1612
|
+
id: string | null;
|
1613
|
+
file: string | null;
|
1614
|
+
type: 'js' | 'css';
|
1615
|
+
info?: ModuleInfo;
|
1616
|
+
meta?: Record<string, any>;
|
1617
|
+
importers: Set<EnvironmentModuleNode>;
|
1618
|
+
importedModules: Set<EnvironmentModuleNode>;
|
1619
|
+
acceptedHmrDeps: Set<EnvironmentModuleNode>;
|
1620
|
+
acceptedHmrExports: Set<string> | null;
|
1621
|
+
importedBindings: Map<string, Set<string>> | null;
|
1622
|
+
isSelfAccepting?: boolean;
|
1623
|
+
transformResult: TransformResult | null;
|
1624
|
+
ssrModule: Record<string, any> | null;
|
1625
|
+
ssrError: Error | null;
|
1626
|
+
lastHMRTimestamp: number;
|
1627
|
+
lastInvalidationTimestamp: number;
|
1628
|
+
/**
|
1629
|
+
* @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
|
1630
|
+
*/
|
1631
|
+
constructor(url: string, environment: string, setIsSelfAccepting?: boolean);
|
1632
|
+
}
|
1633
|
+
type ResolvedUrl = [
|
1634
|
+
url: string,
|
1635
|
+
resolvedId: string,
|
1636
|
+
meta: object | null | undefined
|
1637
|
+
];
|
1638
|
+
declare class EnvironmentModuleGraph {
|
1639
|
+
environment: string;
|
1640
|
+
urlToModuleMap: Map<string, EnvironmentModuleNode>;
|
1641
|
+
idToModuleMap: Map<string, EnvironmentModuleNode>;
|
1642
|
+
etagToModuleMap: Map<string, EnvironmentModuleNode>;
|
1643
|
+
fileToModulesMap: Map<string, Set<EnvironmentModuleNode>>;
|
1644
|
+
constructor(environment: string, resolveId: (url: string) => Promise<PartialResolvedId | null>);
|
1645
|
+
getModuleByUrl(rawUrl: string): Promise<EnvironmentModuleNode | undefined>;
|
1646
|
+
getModuleById(id: string): EnvironmentModuleNode | undefined;
|
1647
|
+
getModulesByFile(file: string): Set<EnvironmentModuleNode> | undefined;
|
1648
|
+
onFileChange(file: string): void;
|
1649
|
+
onFileDelete(file: string): void;
|
1650
|
+
invalidateModule(mod: EnvironmentModuleNode, seen?: Set<EnvironmentModuleNode>, timestamp?: number, isHmr?: boolean,
|
1651
|
+
): void;
|
1652
|
+
invalidateAll(): void;
|
1653
|
+
/**
|
1654
|
+
* Update the module graph based on a module's updated imports information
|
1655
|
+
* If there are dependencies that no longer have any importers, they are
|
1656
|
+
* returned as a Set.
|
1657
|
+
*
|
1658
|
+
* @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
|
1659
|
+
* This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
|
1660
|
+
*/
|
1661
|
+
updateModuleInfo(mod: EnvironmentModuleNode, importedModules: Set<string | EnvironmentModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | EnvironmentModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean,
|
1662
|
+
): Promise<Set<EnvironmentModuleNode> | undefined>;
|
1663
|
+
ensureEntryFromUrl(rawUrl: string, setIsSelfAccepting?: boolean): Promise<EnvironmentModuleNode>;
|
1664
|
+
createFileOnlyEntry(file: string): EnvironmentModuleNode;
|
1665
|
+
resolveUrl(url: string): Promise<ResolvedUrl>;
|
1666
|
+
updateModuleTransformResult(mod: EnvironmentModuleNode, result: TransformResult | null): void;
|
1667
|
+
getModuleByEtag(etag: string): EnvironmentModuleNode | undefined;
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
/**
|
1671
|
+
* Backward compatible ModuleNode and ModuleGraph with mixed nodes from both the client and ssr enviornments
|
1672
|
+
* It would be good to take the types names for the new EnvironmentModuleNode and EnvironmentModuleGraph but we can't
|
1673
|
+
* do that at this point without breaking to much code in the ecosystem.
|
1674
|
+
* We are going to deprecate these types and we can try to use them back in the future.
|
1675
|
+
*/
|
1676
|
+
declare class ModuleNode {
|
1677
|
+
_moduleGraph: ModuleGraph;
|
1678
|
+
_clientModule: EnvironmentModuleNode | undefined;
|
1679
|
+
_ssrModule: EnvironmentModuleNode | undefined;
|
1680
|
+
constructor(moduleGraph: ModuleGraph, clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode);
|
1681
|
+
_get<T extends keyof EnvironmentModuleNode>(prop: T): EnvironmentModuleNode[T];
|
1682
|
+
_wrapModuleSet(prop: ModuleSetNames, module: EnvironmentModuleNode | undefined): Set<ModuleNode>;
|
1683
|
+
_getModuleSetUnion(prop: 'importedModules' | 'importers'): Set<ModuleNode>;
|
1684
|
+
get url(): string;
|
1685
|
+
get id(): string | null;
|
1686
|
+
get file(): string | null;
|
1687
|
+
get type(): 'js' | 'css';
|
1688
|
+
get info(): ModuleInfo | undefined;
|
1689
|
+
get meta(): Record<string, any> | undefined;
|
1690
|
+
get importers(): Set<ModuleNode>;
|
1691
|
+
get clientImportedModules(): Set<ModuleNode>;
|
1692
|
+
get ssrImportedModules(): Set<ModuleNode>;
|
1693
|
+
get importedModules(): Set<ModuleNode>;
|
1694
|
+
get acceptedHmrDeps(): Set<ModuleNode>;
|
1695
|
+
get acceptedHmrExports(): Set<string> | null;
|
1696
|
+
get importedBindings(): Map<string, Set<string>> | null;
|
1697
|
+
get isSelfAccepting(): boolean | undefined;
|
1698
|
+
get transformResult(): TransformResult | null;
|
1699
|
+
set transformResult(value: TransformResult | null);
|
1700
|
+
get ssrTransformResult(): TransformResult | null;
|
1701
|
+
set ssrTransformResult(value: TransformResult | null);
|
1702
|
+
get ssrModule(): Record<string, any> | null;
|
1703
|
+
get ssrError(): Error | null;
|
1704
|
+
get lastHMRTimestamp(): number;
|
1705
|
+
set lastHMRTimestamp(value: number);
|
1706
|
+
get lastInvalidationTimestamp(): number;
|
1707
|
+
get invalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined;
|
1708
|
+
get ssrInvalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined;
|
1709
|
+
}
|
1710
|
+
declare class ModuleGraph {
|
1711
|
+
urlToModuleMap: Map<string, ModuleNode>;
|
1712
|
+
idToModuleMap: Map<string, ModuleNode>;
|
1713
|
+
etagToModuleMap: Map<string, ModuleNode>;
|
1714
|
+
fileToModulesMap: Map<string, Set<ModuleNode>>;
|
1715
|
+
constructor(moduleGraphs: {
|
1716
|
+
client: () => EnvironmentModuleGraph;
|
1717
|
+
ssr: () => EnvironmentModuleGraph;
|
1718
|
+
});
|
1719
|
+
/** @deprecated */
|
1720
|
+
getModuleById(id: string): ModuleNode | undefined;
|
1721
|
+
/** @deprecated */
|
1722
|
+
getModuleByUrl(url: string, ssr?: boolean): Promise<ModuleNode | undefined>;
|
1723
|
+
/** @deprecated */
|
1724
|
+
getModulesByFile(file: string): Set<ModuleNode> | undefined;
|
1725
|
+
/** @deprecated */
|
1726
|
+
onFileChange(file: string): void;
|
1727
|
+
/** @deprecated */
|
1728
|
+
onFileDelete(file: string): void;
|
1729
|
+
/** @deprecated */
|
1730
|
+
invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean,
|
1731
|
+
): void;
|
1732
|
+
/** @deprecated */
|
1733
|
+
invalidateAll(): void;
|
1734
|
+
/** @deprecated */
|
1735
|
+
ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
|
1736
|
+
/** @deprecated */
|
1737
|
+
createFileOnlyEntry(file: string): ModuleNode;
|
1738
|
+
/** @deprecated */
|
1739
|
+
resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
|
1740
|
+
/** @deprecated */
|
1741
|
+
updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr?: boolean): void;
|
1742
|
+
/** @deprecated */
|
1743
|
+
getModuleByEtag(etag: string): ModuleNode | undefined;
|
1744
|
+
getBackwardCompatibleBrowserModuleNode(clientModule: EnvironmentModuleNode): ModuleNode;
|
1745
|
+
getBackwardCompatibleServerModuleNode(ssrModule: EnvironmentModuleNode): ModuleNode;
|
1746
|
+
getBackwardCompatibleModuleNode(mod: EnvironmentModuleNode): ModuleNode;
|
1747
|
+
getBackwardCompatibleModuleNodeDual(clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode): ModuleNode;
|
1437
1748
|
}
|
1749
|
+
type ModuleSetNames = 'acceptedHmrDeps' | 'importedModules';
|
1438
1750
|
|
1439
1751
|
interface HmrOptions {
|
1440
1752
|
protocol?: string;
|
@@ -1446,6 +1758,19 @@ interface HmrOptions {
|
|
1446
1758
|
overlay?: boolean;
|
1447
1759
|
server?: Server;
|
1448
1760
|
}
|
1761
|
+
interface HotUpdateContext {
|
1762
|
+
type: 'create' | 'update' | 'delete';
|
1763
|
+
file: string;
|
1764
|
+
timestamp: number;
|
1765
|
+
modules: Array<EnvironmentModuleNode>;
|
1766
|
+
read: () => string | Promise<string>;
|
1767
|
+
server: ViteDevServer;
|
1768
|
+
environment: DevEnvironment;
|
1769
|
+
}
|
1770
|
+
/**
|
1771
|
+
* @deprecated
|
1772
|
+
* Used by handleHotUpdate for backward compatibility with mixed client and ssr moduleGraph
|
1773
|
+
**/
|
1449
1774
|
interface HmrContext {
|
1450
1775
|
file: string;
|
1451
1776
|
timestamp: number;
|
@@ -1563,6 +1888,7 @@ interface ServerOptions extends CommonServerOptions {
|
|
1563
1888
|
/**
|
1564
1889
|
* Warm-up files to transform and cache the results in advance. This improves the
|
1565
1890
|
* initial page load during server starts and prevents transform waterfalls.
|
1891
|
+
* @deprecated use dev.warmup / environment.ssr.dev.warmup
|
1566
1892
|
*/
|
1567
1893
|
warmup?: {
|
1568
1894
|
/**
|
@@ -1604,6 +1930,7 @@ interface ServerOptions extends CommonServerOptions {
|
|
1604
1930
|
/**
|
1605
1931
|
* Pre-transform known direct imports
|
1606
1932
|
* @default true
|
1933
|
+
* @deprecated use dev.preTransformRequests
|
1607
1934
|
*/
|
1608
1935
|
preTransformRequests?: boolean;
|
1609
1936
|
/**
|
@@ -1613,8 +1940,14 @@ interface ServerOptions extends CommonServerOptions {
|
|
1613
1940
|
* By default, it excludes all paths containing `node_modules`. You can pass `false` to
|
1614
1941
|
* disable this behavior, or, for full control, a function that takes the source path and
|
1615
1942
|
* sourcemap path and returns whether to ignore the source path.
|
1943
|
+
* @deprecated use dev.sourcemapIgnoreList
|
1616
1944
|
*/
|
1617
1945
|
sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
|
1946
|
+
/**
|
1947
|
+
* Run HMR tasks, by default the HMR propagation is done in parallel for all environments
|
1948
|
+
* @experimental
|
1949
|
+
*/
|
1950
|
+
hotUpdateEnvironments?: (server: ViteDevServer, hmr: (environment: DevEnvironment) => Promise<void>) => Promise<void>;
|
1618
1951
|
}
|
1619
1952
|
interface ResolvedServerOptions extends Omit<ServerOptions, 'fs' | 'middlewareMode' | 'sourcemapIgnoreList'> {
|
1620
1953
|
fs: Required<FileSystemServeOptions>;
|
@@ -1690,15 +2023,21 @@ interface ViteDevServer {
|
|
1690
2023
|
*
|
1691
2024
|
* Always sends a message to at least a WebSocket client. Any third party can
|
1692
2025
|
* add a channel to the broadcaster to process messages
|
2026
|
+
* @deprecated use `environments.get(id).hot` instead
|
1693
2027
|
*/
|
1694
2028
|
hot: HMRBroadcaster;
|
1695
2029
|
/**
|
1696
2030
|
* Rollup plugin container that can run plugin hooks on a given file
|
1697
2031
|
*/
|
1698
2032
|
pluginContainer: PluginContainer;
|
2033
|
+
/**
|
2034
|
+
* Module execution environments attached to the Vite server.
|
2035
|
+
*/
|
2036
|
+
environments: Record<'client' | 'ssr' | (string & {}), DevEnvironment>;
|
1699
2037
|
/**
|
1700
2038
|
* Module graph that tracks the import relationships, url to file mapping
|
1701
2039
|
* and hmr state.
|
2040
|
+
* @deprecated use environment module graphs instead
|
1702
2041
|
*/
|
1703
2042
|
moduleGraph: ModuleGraph;
|
1704
2043
|
/**
|
@@ -1709,12 +2048,14 @@ interface ViteDevServer {
|
|
1709
2048
|
/**
|
1710
2049
|
* Programmatically resolve, load and transform a URL and get the result
|
1711
2050
|
* without going through the http request pipeline.
|
2051
|
+
* @deprecated use environment.transformRequest
|
1712
2052
|
*/
|
1713
2053
|
transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
|
1714
2054
|
/**
|
1715
2055
|
* Same as `transformRequest` but only warm up the URLs so the next request
|
1716
2056
|
* will already be cached. The function will never throw as it handles and
|
1717
2057
|
* reports errors internally.
|
2058
|
+
* @deprecated use environment.warmupRequest
|
1718
2059
|
*/
|
1719
2060
|
warmupRequest(url: string, options?: TransformOptions): Promise<void>;
|
1720
2061
|
/**
|
@@ -1733,11 +2074,6 @@ interface ViteDevServer {
|
|
1733
2074
|
ssrLoadModule(url: string, opts?: {
|
1734
2075
|
fixStacktrace?: boolean;
|
1735
2076
|
}): Promise<Record<string, any>>;
|
1736
|
-
/**
|
1737
|
-
* Fetch information about the module for Vite SSR runtime.
|
1738
|
-
* @experimental
|
1739
|
-
*/
|
1740
|
-
ssrFetchModule(id: string, importer?: string): Promise<FetchResult>;
|
1741
2077
|
/**
|
1742
2078
|
* Returns a fixed version of the given stack
|
1743
2079
|
*/
|
@@ -1751,6 +2087,11 @@ interface ViteDevServer {
|
|
1751
2087
|
* API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
|
1752
2088
|
*/
|
1753
2089
|
reloadModule(module: ModuleNode): Promise<void>;
|
2090
|
+
/**
|
2091
|
+
* Triggers HMR for an environment module in the module graph.
|
2092
|
+
* If `hmr` is false, this is a no-op.
|
2093
|
+
*/
|
2094
|
+
reloadEnvironmentModule(module: EnvironmentModuleNode): Promise<void>;
|
1754
2095
|
/**
|
1755
2096
|
* Start the server.
|
1756
2097
|
*/
|
@@ -2286,7 +2627,7 @@ interface TerserOptions extends Terser.MinifyOptions {
|
|
2286
2627
|
maxWorkers?: number;
|
2287
2628
|
}
|
2288
2629
|
|
2289
|
-
interface
|
2630
|
+
interface BuildEnvironmentOptions {
|
2290
2631
|
/**
|
2291
2632
|
* Compatibility transform target. The transform is performed with esbuild
|
2292
2633
|
* and the lowest supported target is es2015/es6. Note this only handles
|
@@ -2429,13 +2770,6 @@ interface BuildOptions {
|
|
2429
2770
|
* @default false
|
2430
2771
|
*/
|
2431
2772
|
manifest?: boolean | string;
|
2432
|
-
/**
|
2433
|
-
* Build in library mode. The value should be the global name of the lib in
|
2434
|
-
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
2435
|
-
* configurations that are suitable for distributing libraries.
|
2436
|
-
* @default false
|
2437
|
-
*/
|
2438
|
-
lib?: LibraryOptions | false;
|
2439
2773
|
/**
|
2440
2774
|
* Produce SSR oriented build. Note this requires specifying SSR entry via
|
2441
2775
|
* `rollupOptions.input`.
|
@@ -2451,8 +2785,16 @@ interface BuildOptions {
|
|
2451
2785
|
/**
|
2452
2786
|
* Emit assets during SSR.
|
2453
2787
|
* @default false
|
2788
|
+
* @deprecated use emitAssets
|
2454
2789
|
*/
|
2455
2790
|
ssrEmitAssets?: boolean;
|
2791
|
+
/**
|
2792
|
+
* Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
|
2793
|
+
* By default, it is true for the client and false for other environments.
|
2794
|
+
* TODO: Should this be true for all environments by default? Or should this be
|
2795
|
+
* controlled by the builder so so we can avoid emitting duplicated assets.
|
2796
|
+
*/
|
2797
|
+
emitAssets?: boolean;
|
2456
2798
|
/**
|
2457
2799
|
* Set to false to disable reporting compressed chunk sizes.
|
2458
2800
|
* Can slightly improve build speed.
|
@@ -2470,6 +2812,19 @@ interface BuildOptions {
|
|
2470
2812
|
* @default null
|
2471
2813
|
*/
|
2472
2814
|
watch?: WatcherOptions | null;
|
2815
|
+
/**
|
2816
|
+
* create the Build Environment instance
|
2817
|
+
*/
|
2818
|
+
createEnvironment?: (builder: ViteBuilder, name: string) => Promise<BuildEnvironment> | BuildEnvironment;
|
2819
|
+
}
|
2820
|
+
interface BuildOptions extends BuildEnvironmentOptions {
|
2821
|
+
/**
|
2822
|
+
* Build in library mode. The value should be the global name of the lib in
|
2823
|
+
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
2824
|
+
* configurations that are suitable for distributing libraries.
|
2825
|
+
* @default false
|
2826
|
+
*/
|
2827
|
+
lib?: LibraryOptions | false;
|
2473
2828
|
}
|
2474
2829
|
interface LibraryOptions {
|
2475
2830
|
/**
|
@@ -2515,6 +2870,9 @@ type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], con
|
|
2515
2870
|
hostId: string;
|
2516
2871
|
hostType: 'html' | 'js';
|
2517
2872
|
}) => string[];
|
2873
|
+
interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> {
|
2874
|
+
modulePreload: false | ResolvedModulePreloadOptions;
|
2875
|
+
}
|
2518
2876
|
interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
|
2519
2877
|
modulePreload: false | ResolvedModulePreloadOptions;
|
2520
2878
|
}
|
@@ -2532,228 +2890,41 @@ type RenderBuiltAssetUrl = (filename: string, type: {
|
|
2532
2890
|
relative?: boolean;
|
2533
2891
|
runtime?: string;
|
2534
2892
|
} | undefined;
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
* This option is not respected. Use `build.minify` instead.
|
2542
|
-
*/
|
2543
|
-
minify?: never;
|
2544
|
-
}
|
2545
|
-
type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
|
2546
|
-
map: SourceMap;
|
2547
|
-
};
|
2548
|
-
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
2549
|
-
|
2550
|
-
type ExportsData = {
|
2551
|
-
hasImports: boolean;
|
2552
|
-
exports: readonly string[];
|
2553
|
-
jsxLoader?: boolean;
|
2554
|
-
};
|
2555
|
-
interface DepsOptimizer {
|
2556
|
-
metadata: DepOptimizationMetadata;
|
2557
|
-
scanProcessing?: Promise<void>;
|
2558
|
-
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
2559
|
-
run: () => void;
|
2560
|
-
isOptimizedDepFile: (id: string) => boolean;
|
2561
|
-
isOptimizedDepUrl: (url: string) => boolean;
|
2562
|
-
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
|
2563
|
-
close: () => Promise<void>;
|
2564
|
-
options: DepOptimizationOptions;
|
2893
|
+
declare class BuildEnvironment extends Environment {
|
2894
|
+
mode: "build";
|
2895
|
+
builder: ViteBuilder;
|
2896
|
+
constructor(builder: ViteBuilder, name: string, setup?: {
|
2897
|
+
options?: EnvironmentOptions;
|
2898
|
+
});
|
2565
2899
|
}
|
2566
|
-
interface
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
include?: string[];
|
2572
|
-
/**
|
2573
|
-
* Do not optimize these dependencies (must be resolvable import paths,
|
2574
|
-
* cannot be globs).
|
2575
|
-
*/
|
2576
|
-
exclude?: string[];
|
2577
|
-
/**
|
2578
|
-
* Forces ESM interop when importing these dependencies. Some legacy
|
2579
|
-
* packages advertise themselves as ESM but use `require` internally
|
2580
|
-
* @experimental
|
2581
|
-
*/
|
2582
|
-
needsInterop?: string[];
|
2583
|
-
/**
|
2584
|
-
* Options to pass to esbuild during the dep scanning and optimization
|
2585
|
-
*
|
2586
|
-
* Certain options are omitted since changing them would not be compatible
|
2587
|
-
* with Vite's dep optimization.
|
2588
|
-
*
|
2589
|
-
* - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
|
2590
|
-
* - `plugins` are merged with Vite's dep plugin
|
2591
|
-
*
|
2592
|
-
* https://esbuild.github.io/api
|
2593
|
-
*/
|
2594
|
-
esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
|
2595
|
-
/**
|
2596
|
-
* List of file extensions that can be optimized. A corresponding esbuild
|
2597
|
-
* plugin must exist to handle the specific extension.
|
2598
|
-
*
|
2599
|
-
* By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
|
2600
|
-
* allows specifying additional extensions.
|
2601
|
-
*
|
2602
|
-
* @experimental
|
2603
|
-
*/
|
2604
|
-
extensions?: string[];
|
2605
|
-
/**
|
2606
|
-
* Deps optimization during build was removed in Vite 5.1. This option is
|
2607
|
-
* now redundant and will be removed in a future version. Switch to using
|
2608
|
-
* `optimizeDeps.noDiscovery` and an empty or undefined `optimizeDeps.include`.
|
2609
|
-
* true or 'dev' disables the optimizer, false or 'build' leaves it enabled.
|
2610
|
-
* @default 'build'
|
2611
|
-
* @deprecated
|
2612
|
-
* @experimental
|
2613
|
-
*/
|
2614
|
-
disabled?: boolean | 'build' | 'dev';
|
2615
|
-
/**
|
2616
|
-
* Automatic dependency discovery. When `noDiscovery` is true, only dependencies
|
2617
|
-
* listed in `include` will be optimized. The scanner isn't run for cold start
|
2618
|
-
* in this case. CJS-only dependencies must be present in `include` during dev.
|
2619
|
-
* @default false
|
2620
|
-
* @experimental
|
2621
|
-
*/
|
2622
|
-
noDiscovery?: boolean;
|
2623
|
-
/**
|
2624
|
-
* When enabled, it will hold the first optimized deps results until all static
|
2625
|
-
* imports are crawled on cold start. This avoids the need for full-page reloads
|
2626
|
-
* when new dependencies are discovered and they trigger the generation of new
|
2627
|
-
* common chunks. If all dependencies are found by the scanner plus the explicitely
|
2628
|
-
* defined ones in `include`, it is better to disable this option to let the
|
2629
|
-
* browser process more requests in parallel.
|
2630
|
-
* @default true
|
2631
|
-
* @experimental
|
2632
|
-
*/
|
2633
|
-
holdUntilCrawlEnd?: boolean;
|
2900
|
+
interface ViteBuilder {
|
2901
|
+
environments: Record<string, BuildEnvironment>;
|
2902
|
+
config: ResolvedConfig;
|
2903
|
+
buildEnvironments(): Promise<void>;
|
2904
|
+
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2634
2905
|
}
|
2635
|
-
|
2636
|
-
|
2637
|
-
* By default, Vite will crawl your `index.html` to detect dependencies that
|
2638
|
-
* need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
|
2639
|
-
* will crawl those entry points instead.
|
2640
|
-
*
|
2641
|
-
* If neither of these fit your needs, you can specify custom entries using
|
2642
|
-
* this option - the value should be a fast-glob pattern or array of patterns
|
2643
|
-
* (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
|
2644
|
-
* vite project root. This will overwrite default entries inference.
|
2645
|
-
*/
|
2646
|
-
entries?: string | string[];
|
2647
|
-
/**
|
2648
|
-
* Force dep pre-optimization regardless of whether deps have changed.
|
2649
|
-
* @experimental
|
2650
|
-
*/
|
2651
|
-
force?: boolean;
|
2652
|
-
};
|
2653
|
-
interface OptimizedDepInfo {
|
2654
|
-
id: string;
|
2655
|
-
file: string;
|
2656
|
-
src?: string;
|
2657
|
-
needsInterop?: boolean;
|
2658
|
-
browserHash?: string;
|
2659
|
-
fileHash?: string;
|
2660
|
-
/**
|
2661
|
-
* During optimization, ids can still be resolved to their final location
|
2662
|
-
* but the bundles may not yet be saved to disk
|
2663
|
-
*/
|
2664
|
-
processing?: Promise<void>;
|
2665
|
-
/**
|
2666
|
-
* ExportData cache, discovered deps will parse the src entry to get exports
|
2667
|
-
* data used both to define if interop is needed and when pre-bundling
|
2668
|
-
*/
|
2669
|
-
exportsData?: Promise<ExportsData>;
|
2906
|
+
interface BuilderOptions {
|
2907
|
+
buildEnvironments?: (builder: ViteBuilder, build: (environment: BuildEnvironment) => Promise<void>) => Promise<void>;
|
2670
2908
|
}
|
2671
|
-
|
2672
|
-
|
2673
|
-
|
2674
|
-
* This is checked on server startup to avoid unnecessary re-bundles.
|
2675
|
-
*/
|
2676
|
-
hash: string;
|
2677
|
-
/**
|
2678
|
-
* This hash is determined by dependency lockfiles.
|
2679
|
-
* This is checked on server startup to avoid unnecessary re-bundles.
|
2680
|
-
*/
|
2681
|
-
lockfileHash: string;
|
2682
|
-
/**
|
2683
|
-
* This hash is determined by user config.
|
2684
|
-
* This is checked on server startup to avoid unnecessary re-bundles.
|
2685
|
-
*/
|
2686
|
-
configHash: string;
|
2687
|
-
/**
|
2688
|
-
* The browser hash is determined by the main hash plus additional dependencies
|
2689
|
-
* discovered at runtime. This is used to invalidate browser requests to
|
2690
|
-
* optimized deps.
|
2691
|
-
*/
|
2692
|
-
browserHash: string;
|
2693
|
-
/**
|
2694
|
-
* Metadata for each already optimized dependency
|
2695
|
-
*/
|
2696
|
-
optimized: Record<string, OptimizedDepInfo>;
|
2697
|
-
/**
|
2698
|
-
* Metadata for non-entry optimized chunks and dynamic imports
|
2699
|
-
*/
|
2700
|
-
chunks: Record<string, OptimizedDepInfo>;
|
2701
|
-
/**
|
2702
|
-
* Metadata for each newly discovered dependency after processing
|
2703
|
-
*/
|
2704
|
-
discovered: Record<string, OptimizedDepInfo>;
|
2705
|
-
/**
|
2706
|
-
* OptimizedDepInfo list
|
2707
|
-
*/
|
2708
|
-
depInfoList: OptimizedDepInfo[];
|
2909
|
+
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2910
|
+
interface BuilderInlineConfig extends Omit<InlineConfig, 'plugins'> {
|
2911
|
+
plugins?: () => PluginOption[];
|
2709
2912
|
}
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
2714
|
-
|
2715
|
-
|
2716
|
-
type SSRTarget = 'node' | 'webworker';
|
2717
|
-
type SsrDepOptimizationOptions = DepOptimizationConfig;
|
2718
|
-
interface SSROptions {
|
2719
|
-
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
2720
|
-
external?: string[] | true;
|
2721
|
-
/**
|
2722
|
-
* Define the target for the ssr build. The browser field in package.json
|
2723
|
-
* is ignored for node but used if webworker is the target
|
2724
|
-
* @default 'node'
|
2725
|
-
*/
|
2726
|
-
target?: SSRTarget;
|
2913
|
+
declare function createViteBuilder(builderOptions?: BuilderOptions, defaultBuilderInlineConfig?: BuilderInlineConfig): Promise<ViteBuilder>;
|
2914
|
+
|
2915
|
+
interface ESBuildOptions extends esbuild_TransformOptions {
|
2916
|
+
include?: string | RegExp | string[] | RegExp[];
|
2917
|
+
exclude?: string | RegExp | string[] | RegExp[];
|
2918
|
+
jsxInject?: string;
|
2727
2919
|
/**
|
2728
|
-
*
|
2729
|
-
* During build:
|
2730
|
-
* no external CJS dependencies are optimized by default
|
2731
|
-
* During dev:
|
2732
|
-
* explicit no external CJS dependencies are optimized by default
|
2733
|
-
* @experimental
|
2920
|
+
* This option is not respected. Use `build.minify` instead.
|
2734
2921
|
*/
|
2735
|
-
|
2736
|
-
resolve?: {
|
2737
|
-
/**
|
2738
|
-
* Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
|
2739
|
-
*
|
2740
|
-
* Use this to override the default ssr conditions for the ssr build.
|
2741
|
-
*
|
2742
|
-
* @default rootConfig.resolve.conditions
|
2743
|
-
*/
|
2744
|
-
conditions?: string[];
|
2745
|
-
/**
|
2746
|
-
* Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
|
2747
|
-
*
|
2748
|
-
* @default []
|
2749
|
-
*/
|
2750
|
-
externalConditions?: string[];
|
2751
|
-
};
|
2752
|
-
}
|
2753
|
-
interface ResolvedSSROptions extends SSROptions {
|
2754
|
-
target: SSRTarget;
|
2755
|
-
optimizeDeps: SsrDepOptimizationOptions;
|
2922
|
+
minify?: never;
|
2756
2923
|
}
|
2924
|
+
type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
|
2925
|
+
map: SourceMap;
|
2926
|
+
};
|
2927
|
+
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
2757
2928
|
|
2758
2929
|
interface FsUtils {
|
2759
2930
|
existsSync: (path: string) => boolean;
|
@@ -2773,6 +2944,7 @@ interface ResolveOptions {
|
|
2773
2944
|
*/
|
2774
2945
|
mainFields?: string[];
|
2775
2946
|
conditions?: string[];
|
2947
|
+
externalConditions?: string[];
|
2776
2948
|
/**
|
2777
2949
|
* @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
|
2778
2950
|
*/
|
@@ -2782,12 +2954,18 @@ interface ResolveOptions {
|
|
2782
2954
|
* @default false
|
2783
2955
|
*/
|
2784
2956
|
preserveSymlinks?: boolean;
|
2957
|
+
/**
|
2958
|
+
* external/noExternal logic, this only works for certain environments
|
2959
|
+
* Previously this was ssr.external/ssr.noExternal
|
2960
|
+
* TODO: better abstraction that works for the client environment too?
|
2961
|
+
*/
|
2962
|
+
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
2963
|
+
external?: string[] | true;
|
2785
2964
|
}
|
2786
|
-
interface
|
2965
|
+
interface ResolvePluginOptions {
|
2787
2966
|
root: string;
|
2788
2967
|
isBuild: boolean;
|
2789
2968
|
isProduction: boolean;
|
2790
|
-
ssrConfig?: SSROptions;
|
2791
2969
|
packageCache?: PackageCache;
|
2792
2970
|
fsUtils?: FsUtils;
|
2793
2971
|
/**
|
@@ -2800,12 +2978,18 @@ interface InternalResolveOptions extends Required<ResolveOptions> {
|
|
2800
2978
|
tryPrefix?: string;
|
2801
2979
|
preferRelative?: boolean;
|
2802
2980
|
isRequire?: boolean;
|
2981
|
+
nodeCompatible?: boolean;
|
2982
|
+
webCompatible?: boolean;
|
2803
2983
|
isFromTsImporter?: boolean;
|
2804
2984
|
tryEsmOnly?: boolean;
|
2805
2985
|
scan?: boolean;
|
2806
2986
|
ssrOptimizeCheck?: boolean;
|
2807
|
-
|
2808
|
-
|
2987
|
+
/**
|
2988
|
+
* @deprecated environment.options are used instead
|
2989
|
+
*/
|
2990
|
+
ssrConfig?: SSROptions;
|
2991
|
+
}
|
2992
|
+
interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {
|
2809
2993
|
}
|
2810
2994
|
|
2811
2995
|
// This file is autogenerated by build-prefixes.js. DO NOT EDIT!
|
@@ -2898,6 +3082,7 @@ interface CSSOptions {
|
|
2898
3082
|
* Enables css sourcemaps during dev
|
2899
3083
|
* @default false
|
2900
3084
|
* @experimental
|
3085
|
+
* @deprecated use dev.sourcemap instead
|
2901
3086
|
*/
|
2902
3087
|
devSourcemap?: boolean;
|
2903
3088
|
/**
|
@@ -2931,7 +3116,7 @@ interface PreprocessCSSResult {
|
|
2931
3116
|
/**
|
2932
3117
|
* @experimental
|
2933
3118
|
*/
|
2934
|
-
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
|
3119
|
+
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig, environment?: Environment): Promise<PreprocessCSSResult>;
|
2935
3120
|
declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
|
2936
3121
|
|
2937
3122
|
interface HtmlTagDescriptor {
|
@@ -3001,7 +3186,22 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3001
3186
|
*
|
3002
3187
|
* If a plugin should be applied only for server or build, a function format
|
3003
3188
|
* config file can be used to conditional determine the plugins to use.
|
3189
|
+
*
|
3190
|
+
* The current module environment can be accessed from the context for the
|
3191
|
+
* buildStart, resolveId, transform, load, and buildEnd, hooks
|
3192
|
+
*
|
3193
|
+
* The current environment can be accessed from the context for the
|
3194
|
+
* buildStart, resolveId, transform, load, and buildEnd, hooks. It can be a dev
|
3195
|
+
* or a build environment. Plugins can use this.environment.mode === 'dev' to
|
3196
|
+
* check if they have access to dev specific APIs.
|
3004
3197
|
*/
|
3198
|
+
type PluginEnvironment = DevEnvironment | BuildEnvironment;
|
3199
|
+
interface PluginContext extends rollup.PluginContext {
|
3200
|
+
environment?: PluginEnvironment;
|
3201
|
+
}
|
3202
|
+
interface TransformPluginContext extends rollup.TransformPluginContext {
|
3203
|
+
environment?: PluginEnvironment;
|
3204
|
+
}
|
3005
3205
|
interface Plugin<A = any> extends rollup.Plugin<A> {
|
3006
3206
|
/**
|
3007
3207
|
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
|
@@ -3030,6 +3230,17 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3030
3230
|
* plugins inside the `config` hook will have no effect.
|
3031
3231
|
*/
|
3032
3232
|
config?: ObjectHook<(this: void, config: UserConfig, env: ConfigEnv) => Omit<UserConfig, 'plugins'> | null | void | Promise<Omit<UserConfig, 'plugins'> | null | void>>;
|
3233
|
+
/**
|
3234
|
+
* Modify environment configs before it's resolved. The hook can either mutate the
|
3235
|
+
* passed-in environment config directly, or return a partial config object that will be
|
3236
|
+
* deeply merged into existing config.
|
3237
|
+
* This hook is called for each environment with a partially resolved environment config
|
3238
|
+
* that already accounts for the default environment config values set at the root level.
|
3239
|
+
* If plugins need to modify the config of a given environment, they should do it in this
|
3240
|
+
* hook instead of the config hook. Leaving the config hook only for modifying the root
|
3241
|
+
* default environment config.
|
3242
|
+
*/
|
3243
|
+
configEnvironment?: ObjectHook<(this: void, name: string, config: EnvironmentOptions, env: ConfigEnv) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>;
|
3033
3244
|
/**
|
3034
3245
|
* Use this hook to read and store the final resolved vite config.
|
3035
3246
|
*/
|
@@ -3070,6 +3281,12 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3070
3281
|
* `{ order: 'pre', handler: hook }`
|
3071
3282
|
*/
|
3072
3283
|
transformIndexHtml?: IndexHtmlTransform;
|
3284
|
+
/**
|
3285
|
+
* @deprecated
|
3286
|
+
* Compat support, ctx.modules is a backward compatible ModuleNode array
|
3287
|
+
* with the mixed client and ssr moduleGraph. Use hotUpdate instead
|
3288
|
+
*/
|
3289
|
+
handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
|
3073
3290
|
/**
|
3074
3291
|
* Perform custom handling of HMR updates.
|
3075
3292
|
* The handler receives a context containing changed filename, timestamp, a
|
@@ -3085,20 +3302,29 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3085
3302
|
* - If the hook doesn't return a value, the hmr update will be performed as
|
3086
3303
|
* normal.
|
3087
3304
|
*/
|
3088
|
-
|
3305
|
+
hotUpdate?: ObjectHook<(this: void, ctx: HotUpdateContext) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
|
3089
3306
|
/**
|
3090
3307
|
* extend hooks with ssr flag
|
3091
3308
|
*/
|
3092
3309
|
resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
|
3093
3310
|
attributes: Record<string, string>;
|
3094
3311
|
custom?: CustomPluginOptions;
|
3312
|
+
/**
|
3313
|
+
* @deprecated use this.environment
|
3314
|
+
*/
|
3095
3315
|
ssr?: boolean;
|
3096
3316
|
isEntry: boolean;
|
3097
3317
|
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
3098
3318
|
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
3319
|
+
/**
|
3320
|
+
* @deprecated use this.environment
|
3321
|
+
*/
|
3099
3322
|
ssr?: boolean;
|
3100
3323
|
}) => Promise<LoadResult> | LoadResult>;
|
3101
3324
|
transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
|
3325
|
+
/**
|
3326
|
+
* @deprecated use this.environment
|
3327
|
+
*/
|
3102
3328
|
ssr?: boolean;
|
3103
3329
|
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
3104
3330
|
}
|
@@ -3121,6 +3347,71 @@ interface JsonOptions {
|
|
3121
3347
|
stringify?: boolean;
|
3122
3348
|
}
|
3123
3349
|
|
3350
|
+
type SSRTarget = 'node' | 'webworker';
|
3351
|
+
type SsrDepOptimizationOptions = DepOptimizationConfig;
|
3352
|
+
/**
|
3353
|
+
* @deprecated use environments.ssr
|
3354
|
+
*/
|
3355
|
+
interface SSROptions {
|
3356
|
+
/**
|
3357
|
+
* @deprecated use environment.resolve.noExternal
|
3358
|
+
*/
|
3359
|
+
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
3360
|
+
/**
|
3361
|
+
* @deprecated use environment.resolve.external
|
3362
|
+
*/
|
3363
|
+
external?: string[] | true;
|
3364
|
+
/**
|
3365
|
+
* Define the target for the ssr build. The browser field in package.json
|
3366
|
+
* is ignored for node but used if webworker is the target
|
3367
|
+
*
|
3368
|
+
* if (ssr.target === 'webworker') {
|
3369
|
+
* build.rollupOptions.entryFileNames = '[name].js'
|
3370
|
+
* build.rollupOptions.inlineDynamicImports = (typeof input === 'string' || Object.keys(input).length === 1))
|
3371
|
+
* webCompatible = true
|
3372
|
+
* }
|
3373
|
+
*
|
3374
|
+
* @default 'node'
|
3375
|
+
* @deprecated use environment.webCompatible
|
3376
|
+
*/
|
3377
|
+
target?: SSRTarget;
|
3378
|
+
/**
|
3379
|
+
* Control over which dependencies are optimized during SSR and esbuild options
|
3380
|
+
* During build:
|
3381
|
+
* no external CJS dependencies are optimized by default
|
3382
|
+
* During dev:
|
3383
|
+
* explicit no external CJS dependencies are optimized by default
|
3384
|
+
* @experimental
|
3385
|
+
* @deprecated
|
3386
|
+
*/
|
3387
|
+
optimizeDeps?: SsrDepOptimizationOptions;
|
3388
|
+
/**
|
3389
|
+
* @deprecated
|
3390
|
+
*/
|
3391
|
+
resolve?: {
|
3392
|
+
/**
|
3393
|
+
* Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
|
3394
|
+
*
|
3395
|
+
* Use this to override the default ssr conditions for the ssr build.
|
3396
|
+
*
|
3397
|
+
* @default rootConfig.resolve.conditions
|
3398
|
+
* @deprecated
|
3399
|
+
*/
|
3400
|
+
conditions?: string[];
|
3401
|
+
/**
|
3402
|
+
* Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
|
3403
|
+
*
|
3404
|
+
* @default []
|
3405
|
+
* @deprecated
|
3406
|
+
*/
|
3407
|
+
externalConditions?: string[];
|
3408
|
+
};
|
3409
|
+
}
|
3410
|
+
interface ResolvedSSROptions extends SSROptions {
|
3411
|
+
target: SSRTarget;
|
3412
|
+
optimizeDeps: SsrDepOptimizationOptions;
|
3413
|
+
}
|
3414
|
+
|
3124
3415
|
interface ConfigEnv {
|
3125
3416
|
/**
|
3126
3417
|
* 'serve': during dev (`vite` command)
|
@@ -3153,7 +3444,92 @@ declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
3153
3444
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
3154
3445
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3155
3446
|
type PluginOption = Plugin | false | null | undefined | PluginOption[] | Promise<Plugin | false | null | undefined | PluginOption[]>;
|
3156
|
-
interface
|
3447
|
+
interface DevEnvironmentOptions {
|
3448
|
+
/**
|
3449
|
+
* The files to be pre-transformed. Supports glob patterns.
|
3450
|
+
*/
|
3451
|
+
warmup?: {
|
3452
|
+
files: string[];
|
3453
|
+
};
|
3454
|
+
/**
|
3455
|
+
* Pre-transform known direct imports
|
3456
|
+
* @default true
|
3457
|
+
*/
|
3458
|
+
preTransformRequests?: boolean;
|
3459
|
+
/**
|
3460
|
+
* Enables sourcemaps during dev
|
3461
|
+
* @default { js: true }
|
3462
|
+
* @experimental
|
3463
|
+
*/
|
3464
|
+
sourcemap?: boolean | {
|
3465
|
+
js?: boolean;
|
3466
|
+
css?: boolean;
|
3467
|
+
};
|
3468
|
+
/**
|
3469
|
+
* Whether or not to ignore-list source files in the dev server sourcemap, used to populate
|
3470
|
+
* the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
|
3471
|
+
*
|
3472
|
+
* By default, it excludes all paths containing `node_modules`. You can pass `false` to
|
3473
|
+
* disable this behavior, or, for full control, a function that takes the source path and
|
3474
|
+
* sourcemap path and returns whether to ignore the source path.
|
3475
|
+
*/
|
3476
|
+
sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
|
3477
|
+
/**
|
3478
|
+
* Optimize deps config
|
3479
|
+
*/
|
3480
|
+
optimizeDeps?: DepOptimizationConfig;
|
3481
|
+
/**
|
3482
|
+
* create the Dev Environment instance
|
3483
|
+
*/
|
3484
|
+
createEnvironment?: (server: ViteDevServer, name: string) => Promise<DevEnvironment> | DevEnvironment;
|
3485
|
+
/**
|
3486
|
+
* For environments that support a full-reload, like the client, we can short-circuit when
|
3487
|
+
* restarting the server throwing early to stop processing current files. We avoided this for
|
3488
|
+
* SSR requests. Maybe this is no longer needed.
|
3489
|
+
* @experimental
|
3490
|
+
*/
|
3491
|
+
recoverable?: boolean;
|
3492
|
+
}
|
3493
|
+
type ResolvedDevEnvironmentOptions = Required<Omit<DevEnvironmentOptions, 'createEnvironment'>> & {
|
3494
|
+
createEnvironment: ((server: ViteDevServer, name: string) => Promise<DevEnvironment> | DevEnvironment) | undefined;
|
3495
|
+
};
|
3496
|
+
type EnvironmentResolveOptions = ResolveOptions & {
|
3497
|
+
alias?: AliasOptions;
|
3498
|
+
};
|
3499
|
+
interface SharedEnvironmentOptions {
|
3500
|
+
/**
|
3501
|
+
* Configure resolver
|
3502
|
+
*/
|
3503
|
+
resolve?: EnvironmentResolveOptions;
|
3504
|
+
/**
|
3505
|
+
* Runtime Compatibility
|
3506
|
+
* Temporal options, we should remove these in favor of fine-grained control
|
3507
|
+
*/
|
3508
|
+
nodeCompatible?: boolean;
|
3509
|
+
webCompatible?: boolean;
|
3510
|
+
}
|
3511
|
+
interface EnvironmentOptions extends SharedEnvironmentOptions {
|
3512
|
+
/**
|
3513
|
+
* Dev specific options
|
3514
|
+
*/
|
3515
|
+
dev?: DevEnvironmentOptions;
|
3516
|
+
/**
|
3517
|
+
* Build specific options
|
3518
|
+
*/
|
3519
|
+
build?: BuildEnvironmentOptions;
|
3520
|
+
}
|
3521
|
+
type ResolvedEnvironmentResolveOptions = Required<EnvironmentResolveOptions>;
|
3522
|
+
type ResolvedEnvironmentOptions = {
|
3523
|
+
resolve: ResolvedEnvironmentResolveOptions;
|
3524
|
+
nodeCompatible: boolean;
|
3525
|
+
webCompatible: boolean;
|
3526
|
+
dev: ResolvedDevEnvironmentOptions;
|
3527
|
+
build: ResolvedBuildEnvironmentOptions;
|
3528
|
+
};
|
3529
|
+
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'build' | 'nodeCompatible' | 'webCompatible'> & {
|
3530
|
+
build?: BuildOptions;
|
3531
|
+
};
|
3532
|
+
interface UserConfig extends DefaultEnvironmentOptions {
|
3157
3533
|
/**
|
3158
3534
|
* Project root directory. Can be an absolute path, or a path relative from
|
3159
3535
|
* the location of the config file itself.
|
@@ -3198,12 +3574,6 @@ interface UserConfig {
|
|
3198
3574
|
* Array of vite plugins to use.
|
3199
3575
|
*/
|
3200
3576
|
plugins?: PluginOption[];
|
3201
|
-
/**
|
3202
|
-
* Configure resolver
|
3203
|
-
*/
|
3204
|
-
resolve?: ResolveOptions & {
|
3205
|
-
alias?: AliasOptions;
|
3206
|
-
};
|
3207
3577
|
/**
|
3208
3578
|
* HTML related options
|
3209
3579
|
*/
|
@@ -3226,25 +3596,17 @@ interface UserConfig {
|
|
3226
3596
|
*/
|
3227
3597
|
assetsInclude?: string | RegExp | (string | RegExp)[];
|
3228
3598
|
/**
|
3229
|
-
*
|
3599
|
+
* Builder specific options
|
3230
3600
|
*/
|
3231
|
-
|
3601
|
+
builder?: BuilderOptions;
|
3232
3602
|
/**
|
3233
|
-
*
|
3603
|
+
* Server specific options, e.g. host, port, https...
|
3234
3604
|
*/
|
3235
|
-
|
3605
|
+
server?: ServerOptions;
|
3236
3606
|
/**
|
3237
3607
|
* Preview specific options, e.g. host, port, https...
|
3238
3608
|
*/
|
3239
3609
|
preview?: PreviewOptions;
|
3240
|
-
/**
|
3241
|
-
* Dep optimization options
|
3242
|
-
*/
|
3243
|
-
optimizeDeps?: DepOptimizationOptions;
|
3244
|
-
/**
|
3245
|
-
* SSR specific options
|
3246
|
-
*/
|
3247
|
-
ssr?: SSROptions;
|
3248
3610
|
/**
|
3249
3611
|
* Experimental features
|
3250
3612
|
*
|
@@ -3304,6 +3666,20 @@ interface UserConfig {
|
|
3304
3666
|
*/
|
3305
3667
|
rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
|
3306
3668
|
};
|
3669
|
+
/**
|
3670
|
+
* Dep optimization options
|
3671
|
+
*/
|
3672
|
+
optimizeDeps?: DepOptimizationOptions;
|
3673
|
+
/**
|
3674
|
+
* SSR specific options
|
3675
|
+
* We could make SSROptions be a EnvironmentOptions if we can abstract
|
3676
|
+
* external/noExternal for environments in general.
|
3677
|
+
*/
|
3678
|
+
ssr?: SSROptions;
|
3679
|
+
/**
|
3680
|
+
* Environment overrides
|
3681
|
+
*/
|
3682
|
+
environments?: Record<string, EnvironmentOptions>;
|
3307
3683
|
/**
|
3308
3684
|
* Whether your application is a Single Page Application (SPA),
|
3309
3685
|
* a Multi-Page Application (MPA), or Custom Application (SSR
|
@@ -3372,7 +3748,7 @@ interface InlineConfig extends UserConfig {
|
|
3372
3748
|
configFile?: string | false;
|
3373
3749
|
envFile?: false;
|
3374
3750
|
}
|
3375
|
-
type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build'> & {
|
3751
|
+
type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments'> & {
|
3376
3752
|
configFile: string | undefined;
|
3377
3753
|
configFileDependencies: string[];
|
3378
3754
|
inlineConfig: InlineConfig;
|
@@ -3393,6 +3769,8 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
|
|
3393
3769
|
css: ResolvedCSSOptions;
|
3394
3770
|
esbuild: ESBuildOptions | false;
|
3395
3771
|
server: ResolvedServerOptions;
|
3772
|
+
dev: ResolvedDevEnvironmentOptions;
|
3773
|
+
builder: ResolvedBuilderOptions;
|
3396
3774
|
build: ResolvedBuildOptions;
|
3397
3775
|
preview: ResolvedPreviewOptions;
|
3398
3776
|
ssr: ResolvedSSROptions;
|
@@ -3403,6 +3781,7 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
|
|
3403
3781
|
worker: ResolvedWorkerOptions;
|
3404
3782
|
appType: AppType;
|
3405
3783
|
experimental: ExperimentalOptions;
|
3784
|
+
environments: Record<string, ResolvedEnvironmentOptions>;
|
3406
3785
|
} & PluginHookUtils>;
|
3407
3786
|
interface PluginHookUtils {
|
3408
3787
|
getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
|
@@ -3419,15 +3798,44 @@ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, c
|
|
3419
3798
|
|
3420
3799
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3421
3800
|
|
3422
|
-
|
3423
|
-
|
3424
|
-
|
3801
|
+
declare function createNodeDevEnvironment(server: ViteDevServer, name: string, options?: DevEnvironmentSetup): DevEnvironment;
|
3802
|
+
|
3803
|
+
/**
|
3804
|
+
* @experimental
|
3805
|
+
*/
|
3806
|
+
interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | 'fetchModule' | 'hmr' | 'transport'> {
|
3807
|
+
/**
|
3808
|
+
* Disable HMR or configure HMR logger.
|
3809
|
+
*/
|
3810
|
+
hmr?: false | {
|
3811
|
+
connection?: ModuleRunnerHMRConnection;
|
3812
|
+
logger?: ModuleRunnerHmr['logger'];
|
3813
|
+
};
|
3814
|
+
/**
|
3815
|
+
* Provide a custom module runner. This controls how the code is executed.
|
3816
|
+
*/
|
3817
|
+
runner?: ModuleEvaluator;
|
3425
3818
|
}
|
3426
3819
|
/**
|
3427
|
-
*
|
3820
|
+
* Create an instance of the Vite SSR runtime that support HMR.
|
3821
|
+
* @experimental
|
3822
|
+
*/
|
3823
|
+
declare function createServerModuleRunner(environment: DevEnvironment, options?: ServerModuleRunnerOptions): ModuleRunner;
|
3824
|
+
|
3825
|
+
/**
|
3826
|
+
* The connector class to establish HMR communication between the server and the Vite runtime.
|
3428
3827
|
* @experimental
|
3429
3828
|
*/
|
3430
|
-
declare
|
3829
|
+
declare class ServerHMRConnector implements ModuleRunnerHMRConnection {
|
3830
|
+
private handlers;
|
3831
|
+
private hmrChannel;
|
3832
|
+
private hmrClient;
|
3833
|
+
private connected;
|
3834
|
+
constructor(server: ViteDevServer);
|
3835
|
+
isReady(): boolean;
|
3836
|
+
send(message: string): void;
|
3837
|
+
onUpdate(handler: (payload: HMRPayload) => void): void;
|
3838
|
+
}
|
3431
3839
|
|
3432
3840
|
declare const VERSION: string;
|
3433
3841
|
|
@@ -3499,40 +3907,4 @@ interface ManifestChunk {
|
|
3499
3907
|
dynamicImports?: string[];
|
3500
3908
|
}
|
3501
3909
|
|
3502
|
-
|
3503
|
-
* @experimental
|
3504
|
-
*/
|
3505
|
-
interface MainThreadRuntimeOptions extends Omit<ViteRuntimeOptions, 'root' | 'fetchModule' | 'hmr'> {
|
3506
|
-
/**
|
3507
|
-
* Disable HMR or configure HMR logger.
|
3508
|
-
*/
|
3509
|
-
hmr?: false | {
|
3510
|
-
logger?: false | HMRLogger;
|
3511
|
-
};
|
3512
|
-
/**
|
3513
|
-
* Provide a custom module runner. This controls how the code is executed.
|
3514
|
-
*/
|
3515
|
-
runner?: ViteModuleRunner;
|
3516
|
-
}
|
3517
|
-
/**
|
3518
|
-
* Create an instance of the Vite SSR runtime that support HMR.
|
3519
|
-
* @experimental
|
3520
|
-
*/
|
3521
|
-
declare function createViteRuntime(server: ViteDevServer, options?: MainThreadRuntimeOptions): Promise<ViteRuntime>;
|
3522
|
-
|
3523
|
-
/**
|
3524
|
-
* The connector class to establish HMR communication between the server and the Vite runtime.
|
3525
|
-
* @experimental
|
3526
|
-
*/
|
3527
|
-
declare class ServerHMRConnector implements HMRRuntimeConnection {
|
3528
|
-
private handlers;
|
3529
|
-
private hmrChannel;
|
3530
|
-
private hmrClient;
|
3531
|
-
private connected;
|
3532
|
-
constructor(server: ViteDevServer);
|
3533
|
-
isReady(): boolean;
|
3534
|
-
send(message: string): void;
|
3535
|
-
onUpdate(handler: (payload: HMRPayload) => void): void;
|
3536
|
-
}
|
3537
|
-
|
3538
|
-
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type ESBuildOptions, type ESBuildTransformResult, 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 HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type MainThreadRuntimeOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type OptimizedDepInfo, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createFilter, createLogger, createServer, createViteRuntime, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
|
3910
|
+
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, EnvironmentModuleGraph, EnvironmentModuleNode, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotUpdateContext, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type OptimizedDepInfo, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, RemoteEnvironmentTransport, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createFilter, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, createViteBuilder, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
|