vite 6.0.0-beta.2 → 6.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +17 -215
- package/README.md +4 -4
- package/bin/vite.js +4 -0
- package/dist/client/client.mjs +4 -4
- package/dist/node/chunks/dep-CBTZ9M2V.js +7220 -0
- package/dist/node/chunks/{dep-BHXIdTzn.js → dep-ChZnDG_O.js} +21910 -27644
- package/dist/node/chunks/dep-DHwgfHPT.js +1103 -0
- package/dist/node/chunks/dep-wWOLM6NS.js +593 -0
- package/dist/node/cli.js +8 -10
- package/dist/node/index.d.ts +99 -95
- package/dist/node/index.js +3 -5
- package/dist/node/module-runner.d.ts +4 -4
- package/dist/node/module-runner.js +10 -10
- package/dist/node-cjs/publicUtils.cjs +2761 -2653
- package/index.cjs +1 -1
- package/index.d.cts +1 -1
- package/package.json +6 -6
- package/dist/node/chunks/dep-BabmomGK.js +0 -993
- package/dist/node/chunks/dep-DTHr9Se7.js +0 -6843
- package/dist/node/chunks/dep-IQS-Za7F.js +0 -561
package/dist/node/index.d.ts
CHANGED
@@ -15,7 +15,7 @@ import * as url from 'node:url';
|
|
15
15
|
import { URL } from 'node:url';
|
16
16
|
import * as stream from 'node:stream';
|
17
17
|
import { Duplex, DuplexOptions } from 'node:stream';
|
18
|
-
import { FetchFunctionOptions, FetchResult,
|
18
|
+
import { FetchFunctionOptions, FetchResult, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
|
19
19
|
export { FetchFunction, FetchResult } from 'vite/module-runner';
|
20
20
|
import { BuildOptions as esbuild_BuildOptions, TransformOptions as esbuild_TransformOptions, TransformResult as esbuild_TransformResult } from 'esbuild';
|
21
21
|
export { TransformOptions as EsbuildTransformOptions, version as esbuildVersion } from 'esbuild';
|
@@ -1771,15 +1771,81 @@ interface TerserOptions extends Terser.MinifyOptions {
|
|
1771
1771
|
maxWorkers?: number;
|
1772
1772
|
}
|
1773
1773
|
|
1774
|
+
interface FsUtils {
|
1775
|
+
existsSync: (path: string) => boolean;
|
1776
|
+
isDirectory: (path: string) => boolean;
|
1777
|
+
tryResolveRealFile: (path: string, preserveSymlinks?: boolean) => string | undefined;
|
1778
|
+
tryResolveRealFileWithExtensions: (path: string, extensions: string[], preserveSymlinks?: boolean) => string | undefined;
|
1779
|
+
tryResolveRealFileOrType: (path: string, preserveSymlinks?: boolean) => {
|
1780
|
+
path?: string;
|
1781
|
+
type: 'directory' | 'file';
|
1782
|
+
} | undefined;
|
1783
|
+
initWatcher?: (watcher: FSWatcher) => void;
|
1784
|
+
}
|
1785
|
+
|
1786
|
+
interface EnvironmentResolveOptions {
|
1787
|
+
/**
|
1788
|
+
* @default ['browser', 'module', 'jsnext:main', 'jsnext']
|
1789
|
+
*/
|
1790
|
+
mainFields?: string[];
|
1791
|
+
conditions?: string[];
|
1792
|
+
externalConditions?: string[];
|
1793
|
+
/**
|
1794
|
+
* @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
|
1795
|
+
*/
|
1796
|
+
extensions?: string[];
|
1797
|
+
dedupe?: string[];
|
1798
|
+
/**
|
1799
|
+
* external/noExternal logic, this only works for certain environments
|
1800
|
+
* Previously this was ssr.external/ssr.noExternal
|
1801
|
+
* TODO: better abstraction that works for the client environment too?
|
1802
|
+
*/
|
1803
|
+
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
1804
|
+
external?: string[] | true;
|
1805
|
+
}
|
1806
|
+
interface ResolveOptions extends EnvironmentResolveOptions {
|
1807
|
+
/**
|
1808
|
+
* @default false
|
1809
|
+
*/
|
1810
|
+
preserveSymlinks?: boolean;
|
1811
|
+
}
|
1812
|
+
interface ResolvePluginOptions {
|
1813
|
+
root: string;
|
1814
|
+
isBuild: boolean;
|
1815
|
+
isProduction: boolean;
|
1816
|
+
packageCache?: PackageCache;
|
1817
|
+
fsUtils?: FsUtils;
|
1818
|
+
/**
|
1819
|
+
* src code mode also attempts the following:
|
1820
|
+
* - resolving /xxx as URLs
|
1821
|
+
* - resolving bare imports from optimized deps
|
1822
|
+
*/
|
1823
|
+
asSrc?: boolean;
|
1824
|
+
tryIndex?: boolean;
|
1825
|
+
tryPrefix?: string;
|
1826
|
+
preferRelative?: boolean;
|
1827
|
+
isRequire?: boolean;
|
1828
|
+
webCompatible?: boolean;
|
1829
|
+
isFromTsImporter?: boolean;
|
1830
|
+
tryEsmOnly?: boolean;
|
1831
|
+
scan?: boolean;
|
1832
|
+
ssrOptimizeCheck?: boolean;
|
1833
|
+
/**
|
1834
|
+
* @deprecated environment.config are used instead
|
1835
|
+
*/
|
1836
|
+
ssrConfig?: SSROptions;
|
1837
|
+
}
|
1838
|
+
interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {
|
1839
|
+
}
|
1840
|
+
type InternalResolveOptionsWithOverrideConditions = InternalResolveOptions & {};
|
1841
|
+
|
1774
1842
|
/** Cache for package.json resolution and package.json contents */
|
1775
1843
|
type PackageCache = Map<string, PackageData>;
|
1776
1844
|
interface PackageData {
|
1777
1845
|
dir: string;
|
1778
1846
|
hasSideEffects: (id: string) => boolean | 'no-treeshake' | null;
|
1779
|
-
|
1780
|
-
|
1781
|
-
setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
|
1782
|
-
getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
|
1847
|
+
setResolvedCache: (key: string, entry: string, options: InternalResolveOptionsWithOverrideConditions) => void;
|
1848
|
+
getResolvedCache: (key: string, options: InternalResolveOptionsWithOverrideConditions) => string | undefined;
|
1783
1849
|
data: {
|
1784
1850
|
[field: string]: any;
|
1785
1851
|
name: string;
|
@@ -2996,73 +3062,6 @@ type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
|
|
2996
3062
|
};
|
2997
3063
|
declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
2998
3064
|
|
2999
|
-
interface FsUtils {
|
3000
|
-
existsSync: (path: string) => boolean;
|
3001
|
-
isDirectory: (path: string) => boolean;
|
3002
|
-
tryResolveRealFile: (path: string, preserveSymlinks?: boolean) => string | undefined;
|
3003
|
-
tryResolveRealFileWithExtensions: (path: string, extensions: string[], preserveSymlinks?: boolean) => string | undefined;
|
3004
|
-
tryResolveRealFileOrType: (path: string, preserveSymlinks?: boolean) => {
|
3005
|
-
path?: string;
|
3006
|
-
type: 'directory' | 'file';
|
3007
|
-
} | undefined;
|
3008
|
-
initWatcher?: (watcher: FSWatcher) => void;
|
3009
|
-
}
|
3010
|
-
|
3011
|
-
interface EnvironmentResolveOptions {
|
3012
|
-
/**
|
3013
|
-
* @default ['browser', 'module', 'jsnext:main', 'jsnext']
|
3014
|
-
*/
|
3015
|
-
mainFields?: string[];
|
3016
|
-
conditions?: string[];
|
3017
|
-
externalConditions?: string[];
|
3018
|
-
/**
|
3019
|
-
* @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
|
3020
|
-
*/
|
3021
|
-
extensions?: string[];
|
3022
|
-
dedupe?: string[];
|
3023
|
-
/**
|
3024
|
-
* external/noExternal logic, this only works for certain environments
|
3025
|
-
* Previously this was ssr.external/ssr.noExternal
|
3026
|
-
* TODO: better abstraction that works for the client environment too?
|
3027
|
-
*/
|
3028
|
-
noExternal?: string | RegExp | (string | RegExp)[] | true;
|
3029
|
-
external?: string[] | true;
|
3030
|
-
}
|
3031
|
-
interface ResolveOptions extends EnvironmentResolveOptions {
|
3032
|
-
/**
|
3033
|
-
* @default false
|
3034
|
-
*/
|
3035
|
-
preserveSymlinks?: boolean;
|
3036
|
-
}
|
3037
|
-
interface ResolvePluginOptions {
|
3038
|
-
root: string;
|
3039
|
-
isBuild: boolean;
|
3040
|
-
isProduction: boolean;
|
3041
|
-
packageCache?: PackageCache;
|
3042
|
-
fsUtils?: FsUtils;
|
3043
|
-
/**
|
3044
|
-
* src code mode also attempts the following:
|
3045
|
-
* - resolving /xxx as URLs
|
3046
|
-
* - resolving bare imports from optimized deps
|
3047
|
-
*/
|
3048
|
-
asSrc?: boolean;
|
3049
|
-
tryIndex?: boolean;
|
3050
|
-
tryPrefix?: string;
|
3051
|
-
preferRelative?: boolean;
|
3052
|
-
isRequire?: boolean;
|
3053
|
-
webCompatible?: boolean;
|
3054
|
-
isFromTsImporter?: boolean;
|
3055
|
-
tryEsmOnly?: boolean;
|
3056
|
-
scan?: boolean;
|
3057
|
-
ssrOptimizeCheck?: boolean;
|
3058
|
-
/**
|
3059
|
-
* @deprecated environment.config are used instead
|
3060
|
-
*/
|
3061
|
-
ssrConfig?: SSROptions;
|
3062
|
-
}
|
3063
|
-
interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {
|
3064
|
-
}
|
3065
|
-
|
3066
3065
|
// This file is autogenerated by build-prefixes.js. DO NOT EDIT!
|
3067
3066
|
|
3068
3067
|
interface Targets {
|
@@ -3544,6 +3543,8 @@ type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject |
|
|
3544
3543
|
declare function defineConfig(config: UserConfig): UserConfig;
|
3545
3544
|
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
3546
3545
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
3546
|
+
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
3547
|
+
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
3547
3548
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3548
3549
|
interface CreateDevEnvironmentContext {
|
3549
3550
|
ws: WebSocketServer;
|
@@ -3933,17 +3934,42 @@ declare function createIdResolver(config: ResolvedConfig, options?: Partial<Inte
|
|
3933
3934
|
|
3934
3935
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3935
3936
|
|
3937
|
+
/**
|
3938
|
+
* @experimental
|
3939
|
+
*/
|
3940
|
+
interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | 'fetchModule' | 'hmr' | 'transport'> {
|
3941
|
+
/**
|
3942
|
+
* Disable HMR or configure HMR logger.
|
3943
|
+
*/
|
3944
|
+
hmr?: false | {
|
3945
|
+
connection?: ModuleRunnerHMRConnection;
|
3946
|
+
logger?: ModuleRunnerHmr['logger'];
|
3947
|
+
};
|
3948
|
+
/**
|
3949
|
+
* Provide a custom module evaluator. This controls how the code is executed.
|
3950
|
+
*/
|
3951
|
+
evaluator?: ModuleEvaluator;
|
3952
|
+
}
|
3953
|
+
/**
|
3954
|
+
* Create an instance of the Vite SSR runtime that support HMR.
|
3955
|
+
* @experimental
|
3956
|
+
*/
|
3957
|
+
declare function createServerModuleRunner(environment: DevEnvironment, options?: ServerModuleRunnerOptions): ModuleRunner;
|
3958
|
+
|
3936
3959
|
declare function createRunnableDevEnvironment(name: string, config: ResolvedConfig, context?: RunnableDevEnvironmentContext): DevEnvironment;
|
3937
3960
|
interface RunnableDevEnvironmentContext extends Omit<DevEnvironmentContext, 'hot'> {
|
3938
|
-
runner?: (environment: RunnableDevEnvironment) => ModuleRunner;
|
3961
|
+
runner?: (environment: RunnableDevEnvironment, options?: ServerModuleRunnerOptions) => ModuleRunner;
|
3962
|
+
runnerOptions?: ServerModuleRunnerOptions;
|
3939
3963
|
hot?: false | HotChannel;
|
3940
3964
|
}
|
3941
3965
|
declare function isRunnableDevEnvironment(environment: Environment): environment is RunnableDevEnvironment;
|
3942
3966
|
declare class RunnableDevEnvironment extends DevEnvironment {
|
3943
3967
|
private _runner;
|
3944
3968
|
private _runnerFactory;
|
3969
|
+
private _runnerOptions;
|
3945
3970
|
constructor(name: string, config: ResolvedConfig, context: RunnableDevEnvironmentContext);
|
3946
3971
|
get runner(): ModuleRunner;
|
3972
|
+
close(): Promise<void>;
|
3947
3973
|
}
|
3948
3974
|
|
3949
3975
|
interface FetchModuleOptions {
|
@@ -3957,28 +3983,6 @@ interface FetchModuleOptions {
|
|
3957
3983
|
*/
|
3958
3984
|
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
3959
3985
|
|
3960
|
-
/**
|
3961
|
-
* @experimental
|
3962
|
-
*/
|
3963
|
-
interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | 'fetchModule' | 'hmr' | 'transport'> {
|
3964
|
-
/**
|
3965
|
-
* Disable HMR or configure HMR logger.
|
3966
|
-
*/
|
3967
|
-
hmr?: false | {
|
3968
|
-
connection?: ModuleRunnerHMRConnection;
|
3969
|
-
logger?: ModuleRunnerHmr['logger'];
|
3970
|
-
};
|
3971
|
-
/**
|
3972
|
-
* Provide a custom module evaluator. This controls how the code is executed.
|
3973
|
-
*/
|
3974
|
-
evaluator?: ModuleEvaluator;
|
3975
|
-
}
|
3976
|
-
/**
|
3977
|
-
* Create an instance of the Vite SSR runtime that support HMR.
|
3978
|
-
* @experimental
|
3979
|
-
*/
|
3980
|
-
declare function createServerModuleRunner(environment: DevEnvironment, options?: ServerModuleRunnerOptions): ModuleRunner;
|
3981
|
-
|
3982
3986
|
/**
|
3983
3987
|
* The connector class to establish HMR communication between the server and the Vite runtime.
|
3984
3988
|
* @experimental
|
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, z as createFilter, f as createIdResolver, E as createLogger, k as createRunnableDevEnvironment, c as createServer, u as createServerHotChannel, q as createServerModuleRunner, d as defineConfig, n as fetchModule, g as formatPostcssSourceMap, H as isFileLoadingAllowed, G as isFileServingAllowed, m as isRunnableDevEnvironment, l as loadConfigFromFile, I as loadEnv, y as mergeAlias, x as mergeConfig, v as moduleRunnerTransform, w as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, J as resolveEnvPrefix, A as rollupVersion, F as searchForWorkspaceRoot, C as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-ChZnDG_O.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, z as createFilter, f as createIdResolver, E as createLogger, k as createRunnableDevEnvironment, c as createServer, u as createServerHotChannel, q as createServerModuleRunner, d as defineConfig, n as fetchModule, g as formatPostcssSourceMap, H as isFileLoadingAllowed, G as isFileServingAllowed, m as isRunnableDevEnvironment, l as loadConfigFromFile, I as loadEnv, y as mergeAlias, x as mergeConfig, v as moduleRunnerTransform, w as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, J as resolveEnvPrefix, A as rollupVersion, F as searchForWorkspaceRoot, C as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ChZnDG_O.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import 'node:fs';
|
@@ -13,9 +13,6 @@ import 'node:module';
|
|
13
13
|
import 'tty';
|
14
14
|
import 'path';
|
15
15
|
import 'fs';
|
16
|
-
import 'node:events';
|
17
|
-
import 'node:stream';
|
18
|
-
import 'node:string_decoder';
|
19
16
|
import 'node:child_process';
|
20
17
|
import 'node:http';
|
21
18
|
import 'node:https';
|
@@ -32,6 +29,7 @@ import 'node:crypto';
|
|
32
29
|
import 'node:dns';
|
33
30
|
import 'vite/module-runner';
|
34
31
|
import 'node:readline';
|
32
|
+
import 'node:events';
|
35
33
|
import 'crypto';
|
36
34
|
import 'module';
|
37
35
|
import 'node:assert';
|
@@ -118,7 +118,7 @@ declare class ModuleRunner {
|
|
118
118
|
private readonly resetSourceMapSupport?;
|
119
119
|
private readonly root;
|
120
120
|
private readonly concurrentModuleNodePromises;
|
121
|
-
private
|
121
|
+
private closed;
|
122
122
|
constructor(options: ModuleRunnerOptions, evaluator: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
|
123
123
|
/**
|
124
124
|
* URL to execute. Accepts file path, server path or id relative to the root.
|
@@ -132,11 +132,11 @@ declare class ModuleRunner {
|
|
132
132
|
* Clears all caches, removes all HMR listeners, and resets source map support.
|
133
133
|
* This method doesn't stop the HMR connection.
|
134
134
|
*/
|
135
|
-
|
135
|
+
close(): Promise<void>;
|
136
136
|
/**
|
137
|
-
* Returns `true` if the runtime has been
|
137
|
+
* Returns `true` if the runtime has been closed by calling `close()` method.
|
138
138
|
*/
|
139
|
-
|
139
|
+
isClosed(): boolean;
|
140
140
|
private processImport;
|
141
141
|
private isCircularModule;
|
142
142
|
private isCircularImport;
|
@@ -536,7 +536,7 @@ function createHMRHandler(runner) {
|
|
536
536
|
}
|
537
537
|
async function handleHotPayload(runner, payload) {
|
538
538
|
const hmrClient = runner.hmrClient;
|
539
|
-
if (!(!hmrClient || runner.
|
539
|
+
if (!(!hmrClient || runner.isClosed()))
|
540
540
|
switch (payload.type) {
|
541
541
|
case "connected":
|
542
542
|
hmrClient.logger.debug("connected."), hmrClient.messenger.flush();
|
@@ -864,7 +864,7 @@ class ModuleRunner {
|
|
864
864
|
resetSourceMapSupport;
|
865
865
|
root;
|
866
866
|
concurrentModuleNodePromises = /* @__PURE__ */ new Map();
|
867
|
-
|
867
|
+
closed = !1;
|
868
868
|
/**
|
869
869
|
* URL to execute. Accepts file path, server path or id relative to the root.
|
870
870
|
*/
|
@@ -882,14 +882,14 @@ class ModuleRunner {
|
|
882
882
|
* Clears all caches, removes all HMR listeners, and resets source map support.
|
883
883
|
* This method doesn't stop the HMR connection.
|
884
884
|
*/
|
885
|
-
async
|
886
|
-
this.resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this.
|
885
|
+
async close() {
|
886
|
+
this.resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this.closed = !0;
|
887
887
|
}
|
888
888
|
/**
|
889
|
-
* Returns `true` if the runtime has been
|
889
|
+
* Returns `true` if the runtime has been closed by calling `close()` method.
|
890
890
|
*/
|
891
|
-
|
892
|
-
return this.
|
891
|
+
isClosed() {
|
892
|
+
return this.closed;
|
893
893
|
}
|
894
894
|
processImport(exports, fetchResult, metadata) {
|
895
895
|
if (!("externalize" in fetchResult))
|
@@ -954,8 +954,8 @@ ${getStack()}`
|
|
954
954
|
return cached;
|
955
955
|
}
|
956
956
|
async getModuleInformation(url, importer, cachedModule) {
|
957
|
-
if (this.
|
958
|
-
throw new Error("Vite module runner has been
|
957
|
+
if (this.closed)
|
958
|
+
throw new Error("Vite module runner has been closed.");
|
959
959
|
this.debug?.("[module runner] fetching", url);
|
960
960
|
const isCached = !!(typeof cachedModule == "object" && cachedModule.meta), fetchedModule = (
|
961
961
|
// fast return for established externalized pattern
|
@@ -1020,7 +1020,7 @@ ${getStack()}`
|
|
1020
1020
|
enumerable: !0,
|
1021
1021
|
get: () => {
|
1022
1022
|
if (!this.hmrClient)
|
1023
|
-
throw new Error("[module runner] HMR client was
|
1023
|
+
throw new Error("[module runner] HMR client was closed.");
|
1024
1024
|
return this.debug?.("[module runner] creating hmr context for", mod.url), hotContext ||= new HMRContext(this.hmrClient, mod.url), hotContext;
|
1025
1025
|
},
|
1026
1026
|
set: (value) => {
|