vite 6.0.0-alpha.19 → 6.0.0-alpha.20
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/client.d.ts +8 -0
- package/dist/node/chunks/{dep-bCS_cgqC.js → dep-BVDN2Cqw.js} +1 -1
- package/dist/node/chunks/{dep-BWEMV5Th.js → dep-CpuHsFvF.js} +4816 -4550
- package/dist/node/chunks/{dep-MbEgMyUv.js → dep-D1nw2wDG.js} +164 -963
- package/dist/node/cli.js +35 -26
- package/dist/node/index.d.ts +45 -54
- package/dist/node/index.js +3 -3
- package/dist/node/module-runner.d.ts +1 -1
- package/dist/node/module-runner.js +42 -34
- package/dist/node-cjs/publicUtils.cjs +95 -106
- package/index.cjs +0 -2
- package/package.json +14 -8
- package/types/customEvent.d.ts +1 -1
- /package/types/{hotPayload.d.ts → hmrPayload.d.ts} +0 -0
package/dist/node/cli.js
CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
2
2
|
import fs__default from 'node:fs';
|
3
3
|
import { performance } from 'node:perf_hooks';
|
4
4
|
import { EventEmitter } from 'events';
|
5
|
-
import { I as colors, A as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { I as colors, A as createLogger, r as resolveConfig } from './chunks/dep-CpuHsFvF.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -35,7 +35,6 @@ import 'node:assert';
|
|
35
35
|
import 'node:v8';
|
36
36
|
import 'node:worker_threads';
|
37
37
|
import 'crypto';
|
38
|
-
import 'querystring';
|
39
38
|
import 'node:buffer';
|
40
39
|
import 'node:readline';
|
41
40
|
import 'zlib';
|
@@ -43,6 +42,7 @@ import 'buffer';
|
|
43
42
|
import 'https';
|
44
43
|
import 'tls';
|
45
44
|
import 'assert';
|
45
|
+
import 'querystring';
|
46
46
|
import 'node:zlib';
|
47
47
|
|
48
48
|
function toArr(any) {
|
@@ -736,7 +736,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
736
736
|
`[boolean] force the optimizer to ignore the cache and re-bundle`
|
737
737
|
).action(async (root, options) => {
|
738
738
|
filterDuplicateOptions(options);
|
739
|
-
const { createServer } = await import('./chunks/dep-
|
739
|
+
const { createServer } = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.M; });
|
740
740
|
try {
|
741
741
|
const server = await createServer({
|
742
742
|
root,
|
@@ -826,36 +826,45 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
826
826
|
).option("--manifest [name]", `[boolean | string] emit build manifest json`).option("--ssrManifest [name]", `[boolean | string] emit ssr manifest json`).option(
|
827
827
|
"--emptyOutDir",
|
828
828
|
`[boolean] force empty outDir when it's outside of root`
|
829
|
-
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--
|
829
|
+
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as builder.entireApp`).action(
|
830
830
|
async (root, options) => {
|
831
831
|
filterDuplicateOptions(options);
|
832
|
-
const
|
832
|
+
const build = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.N; });
|
833
833
|
const buildOptions = cleanGlobalCLIOptions(
|
834
834
|
cleanBuilderCLIOptions(options)
|
835
835
|
);
|
836
|
-
const config = {
|
837
|
-
root,
|
838
|
-
base: options.base,
|
839
|
-
mode: options.mode,
|
840
|
-
configFile: options.config,
|
841
|
-
logLevel: options.logLevel,
|
842
|
-
clearScreen: options.clearScreen,
|
843
|
-
build: buildOptions
|
844
|
-
};
|
845
836
|
try {
|
846
|
-
const
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
837
|
+
const inlineConfig = {
|
838
|
+
root,
|
839
|
+
base: options.base,
|
840
|
+
mode: options.mode,
|
841
|
+
configFile: options.config,
|
842
|
+
logLevel: options.logLevel,
|
843
|
+
clearScreen: options.clearScreen,
|
844
|
+
build: buildOptions,
|
845
|
+
...options.app ? { builder: { entireApp: true } } : {}
|
846
|
+
};
|
847
|
+
const patchConfig = (resolved) => {
|
848
|
+
if (resolved.builder.entireApp) {
|
849
|
+
return;
|
850
|
+
}
|
851
|
+
const environmentName = resolved.build.ssr ? "ssr" : "client";
|
852
|
+
resolved.build = {
|
853
|
+
...resolved.environments[environmentName].build
|
854
|
+
};
|
855
|
+
};
|
856
|
+
const config = await build.resolveConfigToBuild(
|
857
|
+
inlineConfig,
|
858
|
+
patchConfig
|
859
|
+
);
|
860
|
+
if (config.builder.entireApp) {
|
861
|
+
const builder = await build.createBuilderWithResolvedConfig(
|
862
|
+
inlineConfig,
|
863
|
+
config
|
852
864
|
);
|
853
|
-
} else if (builder.config.builder.entireApp || options.app) {
|
854
865
|
await builder.buildApp();
|
855
866
|
} else {
|
856
|
-
|
857
|
-
const environment = builder.environments[ssr ? "ssr" : "client"];
|
858
|
-
await builder.build(environment);
|
867
|
+
await build.buildWithResolvedConfig(config);
|
859
868
|
}
|
860
869
|
} catch (e) {
|
861
870
|
createLogger(options.logLevel).error(
|
@@ -875,7 +884,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
|
|
875
884
|
).action(
|
876
885
|
async (root, options) => {
|
877
886
|
filterDuplicateOptions(options);
|
878
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
887
|
+
const { optimizeDeps } = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.L; });
|
879
888
|
try {
|
880
889
|
const config = await resolveConfig(
|
881
890
|
{
|
@@ -901,7 +910,7 @@ ${e.stack}`),
|
|
901
910
|
cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
|
902
911
|
async (root, options) => {
|
903
912
|
filterDuplicateOptions(options);
|
904
|
-
const { preview } = await import('./chunks/dep-
|
913
|
+
const { preview } = await import('./chunks/dep-CpuHsFvF.js').then(function (n) { return n.O; });
|
905
914
|
try {
|
906
915
|
const server = await preview({
|
907
916
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -19,8 +19,8 @@ import { FetchResult, FetchFunctionOptions, ModuleRunnerOptions, ModuleRunnerHMR
|
|
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';
|
22
|
-
import { HotPayload, CustomPayload } from '../../types/
|
23
|
-
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/
|
22
|
+
import { HotPayload, CustomPayload } from '../../types/hmrPayload.js';
|
23
|
+
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hmrPayload.js';
|
24
24
|
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
25
25
|
export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../../types/customEvent.js';
|
26
26
|
import { SecureContextOptions } from 'node:tls';
|
@@ -716,7 +716,7 @@ interface CommonServerOptions {
|
|
716
716
|
* https://github.com/expressjs/cors#configuration-options
|
717
717
|
*/
|
718
718
|
interface CorsOptions {
|
719
|
-
origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
719
|
+
origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
720
720
|
methods?: string | string[];
|
721
721
|
allowedHeaders?: string | string[];
|
722
722
|
exposedHeaders?: string | string[];
|
@@ -799,7 +799,6 @@ declare class PartialEnvironment {
|
|
799
799
|
* @deprecated use environment.config instead
|
800
800
|
**/
|
801
801
|
get options(): ResolvedEnvironmentOptions;
|
802
|
-
_options: ResolvedEnvironmentOptions;
|
803
802
|
logger: Logger;
|
804
803
|
constructor(name: string, topLevelConfig: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
805
804
|
}
|
@@ -1014,10 +1013,6 @@ interface TransformOptions {
|
|
1014
1013
|
* @deprecated inferred from environment
|
1015
1014
|
*/
|
1016
1015
|
ssr?: boolean;
|
1017
|
-
/**
|
1018
|
-
* TODO: should this be internal?
|
1019
|
-
*/
|
1020
|
-
html?: boolean;
|
1021
1016
|
}
|
1022
1017
|
|
1023
1018
|
declare class EnvironmentModuleNode {
|
@@ -1256,9 +1251,8 @@ declare class RemoteEnvironmentTransport {
|
|
1256
1251
|
register(environment: DevEnvironment): void;
|
1257
1252
|
}
|
1258
1253
|
|
1259
|
-
interface
|
1254
|
+
interface DevEnvironmentContext {
|
1260
1255
|
hot: false | HotChannel;
|
1261
|
-
watcher?: FSWatcher;
|
1262
1256
|
options?: EnvironmentOptions;
|
1263
1257
|
runner?: FetchModuleOptions & {
|
1264
1258
|
transport?: RemoteEnvironmentTransport;
|
@@ -1268,7 +1262,6 @@ interface DevEnvironmentSetup {
|
|
1268
1262
|
declare class DevEnvironment extends BaseEnvironment {
|
1269
1263
|
mode: "dev";
|
1270
1264
|
moduleGraph: EnvironmentModuleGraph;
|
1271
|
-
watcher?: FSWatcher;
|
1272
1265
|
depsOptimizer?: DepsOptimizer;
|
1273
1266
|
get pluginContainer(): EnvironmentPluginContainer;
|
1274
1267
|
/**
|
@@ -1279,8 +1272,10 @@ declare class DevEnvironment extends BaseEnvironment {
|
|
1279
1272
|
* environment.hot.send({ type: 'full-reload' })
|
1280
1273
|
*/
|
1281
1274
|
hot: HotChannel;
|
1282
|
-
constructor(name: string, config: ResolvedConfig,
|
1283
|
-
init(
|
1275
|
+
constructor(name: string, config: ResolvedConfig, context: DevEnvironmentContext);
|
1276
|
+
init(options?: {
|
1277
|
+
watcher?: FSWatcher;
|
1278
|
+
}): Promise<void>;
|
1284
1279
|
fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<FetchResult>;
|
1285
1280
|
transformRequest(url: string): Promise<TransformResult | null>;
|
1286
1281
|
warmupRequest(url: string): Promise<void>;
|
@@ -1938,6 +1933,13 @@ interface BuildEnvironmentOptions {
|
|
1938
1933
|
* @default false
|
1939
1934
|
*/
|
1940
1935
|
manifest?: boolean | string;
|
1936
|
+
/**
|
1937
|
+
* Build in library mode. The value should be the global name of the lib in
|
1938
|
+
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
1939
|
+
* configurations that are suitable for distributing libraries.
|
1940
|
+
* @default false
|
1941
|
+
*/
|
1942
|
+
lib?: LibraryOptions | false;
|
1941
1943
|
/**
|
1942
1944
|
* Produce SSR oriented build. Note this requires specifying SSR entry via
|
1943
1945
|
* `rollupOptions.input`.
|
@@ -1958,8 +1960,6 @@ interface BuildEnvironmentOptions {
|
|
1958
1960
|
/**
|
1959
1961
|
* Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
|
1960
1962
|
* By default, it is true for the client and false for other environments.
|
1961
|
-
* TODO: Should this be true for all environments by default? Or should this be
|
1962
|
-
* controlled by the builder so so we can avoid emitting duplicated assets.
|
1963
1963
|
*/
|
1964
1964
|
emitAssets?: boolean;
|
1965
1965
|
/**
|
@@ -1984,15 +1984,7 @@ interface BuildEnvironmentOptions {
|
|
1984
1984
|
*/
|
1985
1985
|
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
|
1986
1986
|
}
|
1987
|
-
|
1988
|
-
/**
|
1989
|
-
* Build in library mode. The value should be the global name of the lib in
|
1990
|
-
* UMD mode. This will produce esm + cjs + umd bundle formats with default
|
1991
|
-
* configurations that are suitable for distributing libraries.
|
1992
|
-
* @default false
|
1993
|
-
*/
|
1994
|
-
lib?: LibraryOptions | false;
|
1995
|
-
}
|
1987
|
+
type BuildOptions = BuildEnvironmentOptions;
|
1996
1988
|
interface LibraryOptions {
|
1997
1989
|
/**
|
1998
1990
|
* Path of library entry
|
@@ -2044,7 +2036,7 @@ interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModu
|
|
2044
2036
|
modulePreload: false | ResolvedModulePreloadOptions;
|
2045
2037
|
}
|
2046
2038
|
/**
|
2047
|
-
* Bundles
|
2039
|
+
* Bundles a single environment for production.
|
2048
2040
|
* Returns a Promise containing the build result.
|
2049
2041
|
*/
|
2050
2042
|
declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
@@ -2077,6 +2069,9 @@ interface BuilderOptions {
|
|
2077
2069
|
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2078
2070
|
}
|
2079
2071
|
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2072
|
+
/**
|
2073
|
+
* Creates a ViteBuilder to orchestrate building multiple environments.
|
2074
|
+
*/
|
2080
2075
|
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2081
2076
|
|
2082
2077
|
type Environment = DevEnvironment | BuildEnvironment | ScanEnvironment | FutureCompatEnvironment;
|
@@ -2110,7 +2105,7 @@ declare class EnvironmentPluginContainer {
|
|
2110
2105
|
skip?: Set<Plugin>;
|
2111
2106
|
isEntry?: boolean;
|
2112
2107
|
}): Promise<PartialResolvedId | null>;
|
2113
|
-
load(id: string
|
2108
|
+
load(id: string): Promise<LoadResult | null>;
|
2114
2109
|
transform(code: string, id: string, options?: {
|
2115
2110
|
inMap?: SourceDescription['map'];
|
2116
2111
|
}): Promise<{
|
@@ -2162,6 +2157,7 @@ declare class PluginContainer {
|
|
2162
2157
|
|
2163
2158
|
declare const WebSocketAlias: typeof WebSocket
|
2164
2159
|
interface WebSocketAlias extends WebSocket {}
|
2160
|
+
|
2165
2161
|
// WebSocket socket.
|
2166
2162
|
declare class WebSocket extends EventEmitter {
|
2167
2163
|
/** The connection is not yet open. */
|
@@ -2430,7 +2426,6 @@ declare class WebSocket extends EventEmitter {
|
|
2430
2426
|
listener: (...args: any[]) => void,
|
2431
2427
|
): this
|
2432
2428
|
}
|
2433
|
-
// tslint:disable-line no-empty-interface
|
2434
2429
|
|
2435
2430
|
declare namespace WebSocket {
|
2436
2431
|
/**
|
@@ -2680,9 +2675,9 @@ declare namespace WebSocket {
|
|
2680
2675
|
}
|
2681
2676
|
|
2682
2677
|
const WebSocketServer: typeof Server
|
2683
|
-
interface WebSocketServer extends Server {}
|
2678
|
+
interface WebSocketServer extends Server {}
|
2684
2679
|
const WebSocket: typeof WebSocketAlias
|
2685
|
-
interface WebSocket extends WebSocketAlias {}
|
2680
|
+
interface WebSocket extends WebSocketAlias {}
|
2686
2681
|
|
2687
2682
|
// WebSocket stream
|
2688
2683
|
function createWebSocketStream(
|
@@ -2879,7 +2874,7 @@ interface ViteDevServer {
|
|
2879
2874
|
/**
|
2880
2875
|
* Module execution environments attached to the Vite server.
|
2881
2876
|
*/
|
2882
|
-
environments: Record<'client' | 'ssr' | (string &
|
2877
|
+
environments: Record<'client' | 'ssr' | (string & Record<string, never>), DevEnvironment>;
|
2883
2878
|
/**
|
2884
2879
|
* Module graph that tracks the import relationships, url to file mapping
|
2885
2880
|
* and hmr state.
|
@@ -2988,7 +2983,7 @@ interface ESBuildOptions extends esbuild_TransformOptions {
|
|
2988
2983
|
type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
|
2989
2984
|
map: SourceMap;
|
2990
2985
|
};
|
2991
|
-
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object
|
2986
|
+
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
2992
2987
|
|
2993
2988
|
interface FsUtils {
|
2994
2989
|
existsSync: (path: string) => boolean;
|
@@ -3042,7 +3037,6 @@ interface ResolvePluginOptions {
|
|
3042
3037
|
tryPrefix?: string;
|
3043
3038
|
preferRelative?: boolean;
|
3044
3039
|
isRequire?: boolean;
|
3045
|
-
nodeCompatible?: boolean;
|
3046
3040
|
webCompatible?: boolean;
|
3047
3041
|
isFromTsImporter?: boolean;
|
3048
3042
|
tryEsmOnly?: boolean;
|
@@ -3180,7 +3174,7 @@ interface PreprocessCSSResult {
|
|
3180
3174
|
/**
|
3181
3175
|
* @experimental
|
3182
3176
|
*/
|
3183
|
-
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig
|
3177
|
+
declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
|
3184
3178
|
declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
|
3185
3179
|
|
3186
3180
|
interface HtmlTagDescriptor {
|
@@ -3251,13 +3245,10 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3251
3245
|
* If a plugin should be applied only for server or build, a function format
|
3252
3246
|
* config file can be used to conditional determine the plugins to use.
|
3253
3247
|
*
|
3254
|
-
* The current
|
3255
|
-
*
|
3256
|
-
*
|
3257
|
-
*
|
3258
|
-
* buildStart, resolveId, transform, load, and buildEnd, hooks. It can be a dev
|
3259
|
-
* or a build environment. Plugins can use this.environment.mode === 'dev' to
|
3260
|
-
* check if they have access to dev specific APIs.
|
3248
|
+
* The current environment can be accessed from the context for the all non-global
|
3249
|
+
* hooks (it is not available in config, configResolved, configureServer, etc).
|
3250
|
+
* It can be a dev, build, or scan environment.
|
3251
|
+
* Plugins can use this.environment.mode === 'dev' to guard for dev specific APIs.
|
3261
3252
|
*/
|
3262
3253
|
interface PluginContextExtension {
|
3263
3254
|
/**
|
@@ -3540,6 +3531,9 @@ declare function defineConfig(config: UserConfig): UserConfig;
|
|
3540
3531
|
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
3541
3532
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
3542
3533
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3534
|
+
interface CreateDevEnvironmentContext {
|
3535
|
+
ws: WebSocketServer;
|
3536
|
+
}
|
3543
3537
|
interface DevEnvironmentOptions {
|
3544
3538
|
/**
|
3545
3539
|
* Files to be pre-transformed. Supports glob patterns.
|
@@ -3575,7 +3569,7 @@ interface DevEnvironmentOptions {
|
|
3575
3569
|
/**
|
3576
3570
|
* create the Dev Environment instance
|
3577
3571
|
*/
|
3578
|
-
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<DevEnvironment> | DevEnvironment;
|
3572
|
+
createEnvironment?: (name: string, config: ResolvedConfig, context: CreateDevEnvironmentContext) => Promise<DevEnvironment> | DevEnvironment;
|
3579
3573
|
/**
|
3580
3574
|
* For environments that support a full-reload, like the client, we can short-circuit when
|
3581
3575
|
* restarting the server throwing early to stop processing current files. We avoided this for
|
@@ -3590,13 +3584,16 @@ interface DevEnvironmentOptions {
|
|
3590
3584
|
*/
|
3591
3585
|
moduleRunnerTransform?: boolean;
|
3592
3586
|
}
|
3593
|
-
type ResolvedDevEnvironmentOptions = Required<
|
3594
|
-
createEnvironment: ((name: string, config: ResolvedConfig) => Promise<DevEnvironment> | DevEnvironment) | undefined;
|
3595
|
-
};
|
3587
|
+
type ResolvedDevEnvironmentOptions = Required<DevEnvironmentOptions>;
|
3596
3588
|
type EnvironmentResolveOptions = ResolveOptions & {
|
3597
3589
|
alias?: AliasOptions;
|
3598
3590
|
};
|
3599
3591
|
interface SharedEnvironmentOptions {
|
3592
|
+
/**
|
3593
|
+
* Define global variable replacements.
|
3594
|
+
* Entries will be defined on `window` during dev and replaced during build.
|
3595
|
+
*/
|
3596
|
+
define?: Record<string, any>;
|
3600
3597
|
/**
|
3601
3598
|
* Configure resolver
|
3602
3599
|
*/
|
@@ -3610,7 +3607,6 @@ interface SharedEnvironmentOptions {
|
|
3610
3607
|
* Runtime Compatibility
|
3611
3608
|
* Temporal options, we should remove these in favor of fine-grained control
|
3612
3609
|
*/
|
3613
|
-
nodeCompatible?: boolean;
|
3614
3610
|
webCompatible?: boolean;
|
3615
3611
|
/**
|
3616
3612
|
* Should Vite inject timestamp if module is invalidated
|
@@ -3632,15 +3628,15 @@ interface EnvironmentOptions extends SharedEnvironmentOptions {
|
|
3632
3628
|
}
|
3633
3629
|
type ResolvedEnvironmentResolveOptions = Required<EnvironmentResolveOptions>;
|
3634
3630
|
type ResolvedEnvironmentOptions = {
|
3631
|
+
define?: Record<string, any>;
|
3635
3632
|
resolve: ResolvedEnvironmentResolveOptions;
|
3636
3633
|
consumer: 'client' | 'server';
|
3637
|
-
nodeCompatible: boolean;
|
3638
3634
|
webCompatible: boolean;
|
3639
3635
|
injectInvalidationTimestamp: boolean;
|
3640
3636
|
dev: ResolvedDevEnvironmentOptions;
|
3641
3637
|
build: ResolvedBuildEnvironmentOptions;
|
3642
3638
|
};
|
3643
|
-
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'build' | 'consumer' | '
|
3639
|
+
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'build' | 'consumer' | 'webCompatible' | 'injectInvalidationTimestamp'> & {
|
3644
3640
|
build?: BuildOptions;
|
3645
3641
|
};
|
3646
3642
|
interface UserConfig extends DefaultEnvironmentOptions {
|
@@ -3679,11 +3675,6 @@ interface UserConfig extends DefaultEnvironmentOptions {
|
|
3679
3675
|
* each command, and can be overridden by the command line --mode option.
|
3680
3676
|
*/
|
3681
3677
|
mode?: string;
|
3682
|
-
/**
|
3683
|
-
* Define global variable replacements.
|
3684
|
-
* Entries will be defined on `window` during dev and replaced during build.
|
3685
|
-
*/
|
3686
|
-
define?: Record<string, any>;
|
3687
3678
|
/**
|
3688
3679
|
* Array of vite plugins to use.
|
3689
3680
|
*/
|
@@ -3934,7 +3925,7 @@ declare function createIdResolver(config: ResolvedConfig, options: Partial<Inter
|
|
3934
3925
|
|
3935
3926
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3936
3927
|
|
3937
|
-
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig,
|
3928
|
+
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, context: DevEnvironmentContext): DevEnvironment;
|
3938
3929
|
|
3939
3930
|
/**
|
3940
3931
|
* @experimental
|
@@ -4053,4 +4044,4 @@ interface ManifestChunk {
|
|
4053
4044
|
dynamicImports?: string[];
|
4054
4045
|
}
|
4055
4046
|
|
4056
|
-
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type
|
4047
|
+
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, RemoteEnvironmentTransport, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, createIdResolver, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules, a as arraify } from './chunks/dep-
|
3
|
-
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-CpuHsFvF.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerModuleRunner, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-CpuHsFvF.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import 'node:fs';
|
@@ -36,7 +36,6 @@ import 'node:assert';
|
|
36
36
|
import 'node:v8';
|
37
37
|
import 'node:worker_threads';
|
38
38
|
import 'crypto';
|
39
|
-
import 'querystring';
|
40
39
|
import 'node:buffer';
|
41
40
|
import 'node:readline';
|
42
41
|
import 'zlib';
|
@@ -44,6 +43,7 @@ import 'buffer';
|
|
44
43
|
import 'https';
|
45
44
|
import 'tls';
|
46
45
|
import 'assert';
|
46
|
+
import 'querystring';
|
47
47
|
import 'node:zlib';
|
48
48
|
|
49
49
|
const CSS_LANGS_RE = (
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
|
2
|
-
import { Update, HotPayload } from '../../types/
|
2
|
+
import { Update, HotPayload } from '../../types/hmrPayload.js';
|
3
3
|
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
4
4
|
|
5
5
|
interface SourceMapLike {
|
@@ -98,38 +98,46 @@ for (let i = 0; i < chars.length; i++) {
|
|
98
98
|
const c = chars.charCodeAt(i);
|
99
99
|
intToChar[i] = c, charToInt[c] = i;
|
100
100
|
}
|
101
|
-
function
|
102
|
-
const state = new Int32Array(5), decoded = [];
|
103
|
-
let index = 0;
|
104
|
-
do {
|
105
|
-
const semi = indexOf(mappings, index), line = [];
|
106
|
-
let sorted = !0, lastCol = 0;
|
107
|
-
state[0] = 0;
|
108
|
-
for (let i = index; i < semi; i++) {
|
109
|
-
let seg;
|
110
|
-
i = decodeInteger(mappings, i, state, 0);
|
111
|
-
const col = state[0];
|
112
|
-
col < lastCol && (sorted = !1), lastCol = col, hasMoreVlq(mappings, i, semi) ? (i = decodeInteger(mappings, i, state, 1), i = decodeInteger(mappings, i, state, 2), i = decodeInteger(mappings, i, state, 3), hasMoreVlq(mappings, i, semi) ? (i = decodeInteger(mappings, i, state, 4), seg = [col, state[1], state[2], state[3], state[4]]) : seg = [col, state[1], state[2], state[3]]) : seg = [col], line.push(seg);
|
113
|
-
}
|
114
|
-
sorted || sort(line), decoded.push(line), index = semi + 1;
|
115
|
-
} while (index <= mappings.length);
|
116
|
-
return decoded;
|
117
|
-
}
|
118
|
-
function indexOf(mappings, index) {
|
119
|
-
const idx = mappings.indexOf(";", index);
|
120
|
-
return idx === -1 ? mappings.length : idx;
|
121
|
-
}
|
122
|
-
function decodeInteger(mappings, pos, state, j) {
|
101
|
+
function decodeInteger(reader, relative) {
|
123
102
|
let value = 0, shift = 0, integer = 0;
|
124
103
|
do {
|
125
|
-
const c =
|
104
|
+
const c = reader.next();
|
126
105
|
integer = charToInt[c], value |= (integer & 31) << shift, shift += 5;
|
127
106
|
} while (integer & 32);
|
128
107
|
const shouldNegate = value & 1;
|
129
|
-
return value >>>= 1, shouldNegate && (value = -2147483648 | -value),
|
108
|
+
return value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative + value;
|
109
|
+
}
|
110
|
+
function hasMoreVlq(reader, max) {
|
111
|
+
return reader.pos >= max ? !1 : reader.peek() !== comma;
|
112
|
+
}
|
113
|
+
class StringReader {
|
114
|
+
constructor(buffer) {
|
115
|
+
this.pos = 0, this.buffer = buffer;
|
116
|
+
}
|
117
|
+
next() {
|
118
|
+
return this.buffer.charCodeAt(this.pos++);
|
119
|
+
}
|
120
|
+
peek() {
|
121
|
+
return this.buffer.charCodeAt(this.pos);
|
122
|
+
}
|
123
|
+
indexOf(char) {
|
124
|
+
const { buffer, pos } = this, idx = buffer.indexOf(char, pos);
|
125
|
+
return idx === -1 ? buffer.length : idx;
|
126
|
+
}
|
130
127
|
}
|
131
|
-
function
|
132
|
-
|
128
|
+
function decode(mappings) {
|
129
|
+
const { length } = mappings, reader = new StringReader(mappings), decoded = [];
|
130
|
+
let genColumn = 0, sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;
|
131
|
+
do {
|
132
|
+
const semi = reader.indexOf(";"), line = [];
|
133
|
+
let sorted = !0, lastCol = 0;
|
134
|
+
for (genColumn = 0; reader.pos < semi; ) {
|
135
|
+
let seg;
|
136
|
+
genColumn = decodeInteger(reader, genColumn), genColumn < lastCol && (sorted = !1), lastCol = genColumn, hasMoreVlq(reader, semi) ? (sourcesIndex = decodeInteger(reader, sourcesIndex), sourceLine = decodeInteger(reader, sourceLine), sourceColumn = decodeInteger(reader, sourceColumn), hasMoreVlq(reader, semi) ? (namesIndex = decodeInteger(reader, namesIndex), seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]) : seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]) : seg = [genColumn], line.push(seg), reader.pos++;
|
137
|
+
}
|
138
|
+
sorted || sort(line), decoded.push(line), reader.pos = semi + 1;
|
139
|
+
} while (reader.pos <= length);
|
140
|
+
return decoded;
|
133
141
|
}
|
134
142
|
function sort(line) {
|
135
143
|
line.sort(sortComparator);
|
@@ -306,8 +314,8 @@ class ModuleCacheMap extends Map {
|
|
306
314
|
const mod = this.get(moduleId);
|
307
315
|
if (mod.map) return mod.map;
|
308
316
|
if (!mod.meta || !("code" in mod.meta)) return null;
|
309
|
-
const mapString =
|
310
|
-
|
317
|
+
const mapString = MODULE_RUNNER_SOURCEMAPPING_REGEXP.exec(
|
318
|
+
mod.meta.code
|
311
319
|
)?.[1];
|
312
320
|
if (!mapString) return null;
|
313
321
|
const baseFile = mod.meta.file || moduleId.split("?")[0];
|
@@ -1074,6 +1082,12 @@ class ESModulesEvaluator {
|
|
1074
1082
|
return import(filepath);
|
1075
1083
|
}
|
1076
1084
|
}
|
1085
|
+
let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", nanoid = (size = 21) => {
|
1086
|
+
let id = "", i = size;
|
1087
|
+
for (; i--; )
|
1088
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
1089
|
+
return id;
|
1090
|
+
};
|
1077
1091
|
class RemoteRunnerTransport {
|
1078
1092
|
constructor(options) {
|
1079
1093
|
this.options = options, this.options.onMessage(async (data) => {
|
@@ -1106,12 +1120,6 @@ class RemoteRunnerTransport {
|
|
1106
1120
|
return this.resolve("fetchModule", id, importer);
|
1107
1121
|
}
|
1108
1122
|
}
|
1109
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
1110
|
-
function nanoid(size = 21) {
|
1111
|
-
let id = "", i = size;
|
1112
|
-
for (; i--; ) id += urlAlphabet[Math.random() * 64 | 0];
|
1113
|
-
return id;
|
1114
|
-
}
|
1115
1123
|
export {
|
1116
1124
|
ESModulesEvaluator,
|
1117
1125
|
ModuleCacheMap,
|