vite 6.0.0-alpha.17 → 6.0.0-alpha.18
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 +1 -59
- package/dist/node/chunks/{dep-DJVII9WQ.js → dep-70g8Z1cd.js} +3 -3
- package/dist/node/chunks/{dep-DVlS5vGL.js → dep-DXWVQosX.js} +7121 -12048
- package/dist/node/chunks/{dep-CNsiFGD3.js → dep-DlhHXrzk.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +83 -35
- package/dist/node/index.js +2 -2
- package/dist/node/module-runner.d.ts +18 -7
- package/dist/node/module-runner.js +35 -50
- package/dist/node-cjs/publicUtils.cjs +2 -19
- package/package.json +9 -11
- package/types/customEvent.d.ts +1 -0
package/dist/node/cli.js
CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
2
2
|
import fs 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-DXWVQosX.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -766,7 +766,7 @@ cli
|
|
766
766
|
filterDuplicateOptions(options);
|
767
767
|
// output structure is preserved even after bundling so require()
|
768
768
|
// is ok here
|
769
|
-
const { createServer } = await import('./chunks/dep-
|
769
|
+
const { createServer } = await import('./chunks/dep-DXWVQosX.js').then(function (n) { return n.M; });
|
770
770
|
try {
|
771
771
|
const server = await createServer({
|
772
772
|
root,
|
@@ -847,7 +847,7 @@ cli
|
|
847
847
|
.option('--app', `[boolean] same as builder.entireApp`)
|
848
848
|
.action(async (root, options) => {
|
849
849
|
filterDuplicateOptions(options);
|
850
|
-
const { createBuilder, buildEnvironment } = await import('./chunks/dep-
|
850
|
+
const { createBuilder, buildEnvironment } = await import('./chunks/dep-DXWVQosX.js').then(function (n) { return n.N; });
|
851
851
|
const buildOptions = cleanGlobalCLIOptions(cleanBuilderCLIOptions(options));
|
852
852
|
const config = {
|
853
853
|
root,
|
@@ -888,7 +888,7 @@ cli
|
|
888
888
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
889
889
|
.action(async (root, options) => {
|
890
890
|
filterDuplicateOptions(options);
|
891
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
891
|
+
const { optimizeDeps } = await import('./chunks/dep-DXWVQosX.js').then(function (n) { return n.L; });
|
892
892
|
try {
|
893
893
|
const config = await resolveConfig({
|
894
894
|
root,
|
@@ -914,7 +914,7 @@ cli
|
|
914
914
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
915
915
|
.action(async (root, options) => {
|
916
916
|
filterDuplicateOptions(options);
|
917
|
-
const { preview } = await import('./chunks/dep-
|
917
|
+
const { preview } = await import('./chunks/dep-DXWVQosX.js').then(function (n) { return n.O; });
|
918
918
|
try {
|
919
919
|
const server = await preview({
|
920
920
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, InputOptions, CustomPluginOptions,
|
2
|
+
import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, MinimalPluginContext, InputOptions, CustomPluginOptions, LoadResult, SourceDescription, 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,12 +15,12 @@ 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 { FetchResult, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
|
18
|
+
import { FetchResult, FetchFunctionOptions, 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';
|
22
22
|
import { HotPayload, CustomPayload } from '../../types/hotPayload.js';
|
23
|
-
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hotPayload.js';
|
23
|
+
export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hotPayload.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';
|
@@ -803,6 +803,7 @@ declare class FutureCompatEnvironment extends BaseEnvironment {
|
|
803
803
|
}
|
804
804
|
|
805
805
|
interface FetchModuleOptions {
|
806
|
+
cached?: boolean;
|
806
807
|
inlineSourceMap?: boolean;
|
807
808
|
processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
|
808
809
|
}
|
@@ -1074,7 +1075,7 @@ declare class EnvironmentModuleGraph {
|
|
1074
1075
|
}
|
1075
1076
|
|
1076
1077
|
/**
|
1077
|
-
* Backward compatible ModuleNode and ModuleGraph with mixed nodes from both the client and ssr
|
1078
|
+
* Backward compatible ModuleNode and ModuleGraph with mixed nodes from both the client and ssr environments
|
1078
1079
|
* It would be good to take the types names for the new EnvironmentModuleNode and EnvironmentModuleGraph but we can't
|
1079
1080
|
* do that at this point without breaking to much code in the ecosystem.
|
1080
1081
|
* We are going to deprecate these types and we can try to use them back in the future.
|
@@ -1262,7 +1263,7 @@ declare class DevEnvironment extends BaseEnvironment {
|
|
1262
1263
|
hot: HotChannel;
|
1263
1264
|
constructor(name: string, config: ResolvedConfig, setup: DevEnvironmentSetup);
|
1264
1265
|
init(): Promise<void>;
|
1265
|
-
fetchModule(id: string, importer?: string): Promise<FetchResult>;
|
1266
|
+
fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<FetchResult>;
|
1266
1267
|
transformRequest(url: string): Promise<TransformResult | null>;
|
1267
1268
|
warmupRequest(url: string): Promise<void>;
|
1268
1269
|
close(): Promise<void>;
|
@@ -1992,7 +1993,7 @@ interface LibraryOptions {
|
|
1992
1993
|
*/
|
1993
1994
|
fileName?: string | ((format: ModuleFormat, entryName: string) => string);
|
1994
1995
|
}
|
1995
|
-
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
|
1996
|
+
type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' | 'system';
|
1996
1997
|
interface ModulePreloadOptions {
|
1997
1998
|
/**
|
1998
1999
|
* Whether to inject a module preload polyfill.
|
@@ -2058,20 +2059,36 @@ declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder
|
|
2058
2059
|
|
2059
2060
|
type Environment = DevEnvironment | BuildEnvironment | ScanEnvironment | FutureCompatEnvironment;
|
2060
2061
|
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2062
|
+
declare class EnvironmentPluginContainer {
|
2063
|
+
environment: Environment;
|
2064
|
+
plugins: Plugin[];
|
2065
|
+
watcher?: FSWatcher | undefined;
|
2066
|
+
private _pluginContextMap;
|
2067
|
+
private _resolvedRollupOptions?;
|
2068
|
+
private _processesing;
|
2069
|
+
private _seenResolves;
|
2070
|
+
private _moduleNodeToLoadAddedImports;
|
2071
|
+
getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks'];
|
2072
|
+
getSortedPlugins: PluginHookUtils['getSortedPlugins'];
|
2073
|
+
moduleGraph: EnvironmentModuleGraph | undefined;
|
2074
|
+
watchFiles: Set<string>;
|
2075
|
+
minimalContext: MinimalPluginContext;
|
2076
|
+
private _closed;
|
2077
|
+
private _updateModuleLoadAddedImports;
|
2078
|
+
private _getAddedImports;
|
2079
|
+
private handleHookPromise;
|
2080
|
+
get options(): InputOptions;
|
2081
|
+
resolveRollupOptions(): Promise<InputOptions>;
|
2082
|
+
private _getPluginContext;
|
2083
|
+
private hookParallel;
|
2084
|
+
buildStart(_options?: InputOptions): Promise<void>;
|
2085
|
+
resolveId(rawId: string, importer?: string | undefined, options?: {
|
2070
2086
|
attributes?: Record<string, string>;
|
2071
2087
|
custom?: CustomPluginOptions;
|
2072
2088
|
skip?: Set<Plugin>;
|
2073
2089
|
isEntry?: boolean;
|
2074
2090
|
}): Promise<PartialResolvedId | null>;
|
2091
|
+
load(id: string, options?: {}): Promise<LoadResult | null>;
|
2075
2092
|
transform(code: string, id: string, options?: {
|
2076
2093
|
inMap?: SourceDescription['map'];
|
2077
2094
|
}): Promise<{
|
@@ -2080,38 +2097,39 @@ interface EnvironmentPluginContainer {
|
|
2080
2097
|
mappings: '';
|
2081
2098
|
} | null;
|
2082
2099
|
}>;
|
2083
|
-
load(id: string, options?: {}): Promise<LoadResult | null>;
|
2084
2100
|
watchChange(id: string, change: {
|
2085
2101
|
event: 'create' | 'update' | 'delete';
|
2086
2102
|
}): Promise<void>;
|
2087
2103
|
close(): Promise<void>;
|
2088
2104
|
}
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2105
|
+
declare class PluginContainer {
|
2106
|
+
private environments;
|
2107
|
+
constructor(environments: Record<string, Environment>);
|
2108
|
+
private _getEnvironment;
|
2109
|
+
private _getPluginContainer;
|
2110
|
+
get options(): InputOptions;
|
2111
|
+
buildStart(_options?: InputOptions): Promise<void>;
|
2112
|
+
resolveId(rawId: string, importer?: string, options?: {
|
2093
2113
|
attributes?: Record<string, string>;
|
2094
2114
|
custom?: CustomPluginOptions;
|
2095
2115
|
skip?: Set<Plugin>;
|
2096
2116
|
ssr?: boolean;
|
2097
|
-
environment?: Environment;
|
2098
2117
|
isEntry?: boolean;
|
2099
2118
|
}): Promise<PartialResolvedId | null>;
|
2119
|
+
load(id: string, options?: {
|
2120
|
+
ssr?: boolean;
|
2121
|
+
}): Promise<LoadResult | null>;
|
2100
2122
|
transform(code: string, id: string, options?: {
|
2101
|
-
inMap?: SourceDescription['map'];
|
2102
2123
|
ssr?: boolean;
|
2103
2124
|
environment?: Environment;
|
2125
|
+
inMap?: SourceDescription['map'];
|
2104
2126
|
}): Promise<{
|
2105
2127
|
code: string;
|
2106
2128
|
map: SourceMap | {
|
2107
2129
|
mappings: '';
|
2108
2130
|
} | null;
|
2109
2131
|
}>;
|
2110
|
-
|
2111
|
-
ssr?: boolean;
|
2112
|
-
environment?: Environment;
|
2113
|
-
}): Promise<LoadResult | null>;
|
2114
|
-
watchChange(id: string, change: {
|
2132
|
+
watchChange(_id: string, _change: {
|
2115
2133
|
event: 'create' | 'update' | 'delete';
|
2116
2134
|
}): Promise<void>;
|
2117
2135
|
close(): Promise<void>;
|
@@ -2691,6 +2709,11 @@ interface ServerOptions extends CommonServerOptions {
|
|
2691
2709
|
* Configure HMR-specific options (port, host, path & protocol)
|
2692
2710
|
*/
|
2693
2711
|
hmr?: HmrOptions | boolean;
|
2712
|
+
/**
|
2713
|
+
* Do not start the websocket connection.
|
2714
|
+
* @experimental
|
2715
|
+
*/
|
2716
|
+
ws?: false;
|
2694
2717
|
/**
|
2695
2718
|
* Warm-up files to transform and cache the results in advance. This improves the
|
2696
2719
|
* initial page load during server starts and prevents transform waterfalls.
|
@@ -3218,7 +3241,10 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3218
3241
|
* check if they have access to dev specific APIs.
|
3219
3242
|
*/
|
3220
3243
|
interface PluginContextExtension {
|
3221
|
-
|
3244
|
+
/**
|
3245
|
+
* Vite-specific environment instance
|
3246
|
+
*/
|
3247
|
+
environment: Environment;
|
3222
3248
|
}
|
3223
3249
|
interface PluginContext extends rollup.PluginContext, PluginContextExtension {
|
3224
3250
|
}
|
@@ -3478,6 +3504,15 @@ interface ResolvedSSROptions extends SSROptions {
|
|
3478
3504
|
optimizeDeps: SsrDepOptimizationConfig;
|
3479
3505
|
}
|
3480
3506
|
|
3507
|
+
interface FutureDeprecationWarningsOptions {
|
3508
|
+
pluginHookHandleHotUpdate?: boolean;
|
3509
|
+
pluginHookSsrArgument?: boolean;
|
3510
|
+
serverModuleGraph?: boolean;
|
3511
|
+
serverHot?: boolean;
|
3512
|
+
serverTransformRequest?: boolean;
|
3513
|
+
ssrLoadModule?: boolean;
|
3514
|
+
}
|
3515
|
+
|
3481
3516
|
interface ConfigEnv {
|
3482
3517
|
/**
|
3483
3518
|
* 'serve': during dev (`vite` command)
|
@@ -3692,6 +3727,10 @@ interface UserConfig extends DefaultEnvironmentOptions {
|
|
3692
3727
|
* @experimental
|
3693
3728
|
*/
|
3694
3729
|
experimental?: ExperimentalOptions;
|
3730
|
+
/**
|
3731
|
+
* Options to opt-in to future behavior
|
3732
|
+
*/
|
3733
|
+
future?: FutureOptions;
|
3695
3734
|
/**
|
3696
3735
|
* Legacy options
|
3697
3736
|
*
|
@@ -3773,6 +3812,14 @@ interface HTMLOptions {
|
|
3773
3812
|
*/
|
3774
3813
|
cspNonce?: string;
|
3775
3814
|
}
|
3815
|
+
interface FutureOptions {
|
3816
|
+
/**
|
3817
|
+
* Emit warning messages for deprecated/will-deprecated features at runtime.
|
3818
|
+
*
|
3819
|
+
* Setting to `true` to enable all warnings
|
3820
|
+
*/
|
3821
|
+
deprecationWarnings?: boolean | FutureDeprecationWarningsOptions;
|
3822
|
+
}
|
3776
3823
|
interface ExperimentalOptions {
|
3777
3824
|
/**
|
3778
3825
|
* Append fake `&lang.(ext)` when queries are specified, to preserve the file extension for following plugins to process.
|
@@ -3876,6 +3923,13 @@ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, c
|
|
3876
3923
|
dependencies: string[];
|
3877
3924
|
} | null>;
|
3878
3925
|
|
3926
|
+
type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: string, aliasOnly?: boolean) => Promise<string | undefined>;
|
3927
|
+
/**
|
3928
|
+
* Create an internal resolver to be used in special scenarios, e.g.
|
3929
|
+
* optimizer and handling css @imports
|
3930
|
+
*/
|
3931
|
+
declare function createIdResolver(config: ResolvedConfig, options: Partial<InternalResolveOptions>): ResolveIdFn;
|
3932
|
+
|
3879
3933
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3880
3934
|
|
3881
3935
|
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, options: DevEnvironmentSetup): DevEnvironment;
|
@@ -3959,12 +4013,6 @@ declare const rollupVersion: string;
|
|
3959
4013
|
declare function normalizePath(id: string): string;
|
3960
4014
|
declare function mergeConfig<D extends Record<string, any>, O extends Record<string, any>>(defaults: D extends Function ? never : D, overrides: O extends Function ? never : O, isRoot?: boolean): Record<string, any>;
|
3961
4015
|
declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
|
3962
|
-
/**
|
3963
|
-
* Creates a function that hides the complexities of a WeakMap with an initial value
|
3964
|
-
* to implement object metadata. Used by plugins to implement cross hooks per
|
3965
|
-
* environment metadata
|
3966
|
-
*/
|
3967
|
-
declare function createWeakData<Key extends object | symbol, Data>(initial: (key: Key) => Data): (key: Key) => Data;
|
3968
4016
|
|
3969
4017
|
interface SendOptions {
|
3970
4018
|
etag?: string;
|
@@ -4004,4 +4052,4 @@ interface ManifestChunk {
|
|
4004
4052
|
dynamicImports?: string[];
|
4005
4053
|
}
|
4006
4054
|
|
4007
|
-
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentOptions, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotUpdateContext, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin,
|
4055
|
+
export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentOptions, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotUpdateContext, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, RemoteEnvironmentTransport, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, ServerHMRConnector, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, 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,
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-DXWVQosX.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-DXWVQosX.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import 'node:fs';
|
@@ -217,14 +217,20 @@ interface ModuleCache {
|
|
217
217
|
evaluated?: boolean;
|
218
218
|
map?: DecodedMap;
|
219
219
|
meta?: ResolvedResult;
|
220
|
-
timestamp?: number;
|
221
220
|
/**
|
222
221
|
* Module ids that imports this module
|
223
222
|
*/
|
224
223
|
importers?: Set<string>;
|
225
224
|
imports?: Set<string>;
|
226
225
|
}
|
227
|
-
type FetchResult = ExternalFetchResult | ViteFetchResult;
|
226
|
+
type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
|
227
|
+
interface CachedFetchResult {
|
228
|
+
/**
|
229
|
+
* If module cached in the runner, we can just confirm
|
230
|
+
* it wasn't invalidated on the server side.
|
231
|
+
*/
|
232
|
+
cache: true;
|
233
|
+
}
|
228
234
|
interface ExternalFetchResult {
|
229
235
|
/**
|
230
236
|
* The path to the externalized module starting with file://,
|
@@ -247,16 +253,21 @@ interface ViteFetchResult {
|
|
247
253
|
/**
|
248
254
|
* File path of the module on disk.
|
249
255
|
* This will be resolved as import.meta.url/filename
|
256
|
+
* Will be equal to `null` for virtual modules
|
250
257
|
*/
|
251
258
|
file: string | null;
|
259
|
+
/**
|
260
|
+
* Invalidate module on the client side.
|
261
|
+
*/
|
262
|
+
invalidate: boolean;
|
252
263
|
}
|
253
264
|
type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
|
254
265
|
id: string;
|
255
266
|
};
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
267
|
+
type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
|
268
|
+
interface FetchFunctionOptions {
|
269
|
+
cached?: boolean;
|
270
|
+
}
|
260
271
|
interface ModuleRunnerHmr {
|
261
272
|
/**
|
262
273
|
* Configure how HMR communicates between the client and the server.
|
@@ -332,4 +343,4 @@ declare class ESModulesEvaluator implements ModuleEvaluator {
|
|
332
343
|
runExternalModule(filepath: string): Promise<any>;
|
333
344
|
}
|
334
345
|
|
335
|
-
export { ESModulesEvaluator, type FetchFunction, type FetchResult, type HMRConnection, type HMRLogger, type ModuleCache, ModuleCacheMap, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHMRConnection, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, RemoteRunnerTransport, type ResolvedResult, type RunnerTransport, type SSRImportBaseMetadata as SSRImportMetadata, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
346
|
+
export { ESModulesEvaluator, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRConnection, type HMRLogger, type ModuleCache, ModuleCacheMap, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHMRConnection, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, RemoteRunnerTransport, type ResolvedResult, type RunnerTransport, type SSRImportBaseMetadata as SSRImportMetadata, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
@@ -51,24 +51,22 @@ function normalizeString(path, allowAboveRoot) {
|
|
51
51
|
char = "/";
|
52
52
|
}
|
53
53
|
if (char === "/") {
|
54
|
-
if (!(lastSlash === index - 1 || dots === 1))
|
55
|
-
if (
|
56
|
-
if (res.length
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
continue;
|
64
|
-
}
|
54
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
55
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
56
|
+
if (res.length > 2) {
|
57
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
58
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
59
|
+
continue;
|
60
|
+
} else if (res.length > 0) {
|
61
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
62
|
+
continue;
|
65
63
|
}
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
}
|
65
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
66
|
+
} else
|
67
|
+
res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
69
68
|
lastSlash = index, dots = 0;
|
70
|
-
} else
|
71
|
-
char === "." && dots !== -1 ? ++dots : dots = -1;
|
69
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
72
70
|
}
|
73
71
|
return res;
|
74
72
|
}
|
@@ -77,15 +75,7 @@ const isAbsolute = function(p) {
|
|
77
75
|
}, dirname = function(p) {
|
78
76
|
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
79
77
|
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
80
|
-
}, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g
|
81
|
-
function parseUrl(url) {
|
82
|
-
const idQuery = url.split("?")[1];
|
83
|
-
let timestamp = 0;
|
84
|
-
return {
|
85
|
-
query: idQuery ? ("?" + idQuery).replace(timestampRegex, (substring, tsString, nextItem) => (timestamp = Number(tsString), substring[0] === "?" && nextItem === "&" ? "?" : "")) : "",
|
86
|
-
timestamp
|
87
|
-
};
|
88
|
-
}
|
78
|
+
}, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
|
89
79
|
function encodePathChars(filepath) {
|
90
80
|
return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf(`
|
91
81
|
`) !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
|
@@ -503,11 +493,11 @@ class HMRClient {
|
|
503
493
|
}
|
504
494
|
}
|
505
495
|
function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
|
506
|
-
if (!metadata?.isDynamicImport &&
|
496
|
+
if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
|
507
497
|
const missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
508
498
|
if (missingBindings.length) {
|
509
499
|
const lastBinding = missingBindings[missingBindings.length - 1];
|
510
|
-
throw new SyntaxError(`[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
500
|
+
throw moduleType === "module" ? new SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`) : new SyntaxError(`[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
511
501
|
CommonJS modules can always be imported via the default export, for example using:
|
512
502
|
|
513
503
|
import pkg from '${rawId}';
|
@@ -516,15 +506,6 @@ const {${missingBindings.join(", ")}} = pkg;
|
|
516
506
|
}
|
517
507
|
}
|
518
508
|
}
|
519
|
-
function proxyGuardOnlyEsm(mod, rawId, metadata) {
|
520
|
-
return metadata?.importedNames?.length ? new Proxy(mod, {
|
521
|
-
get(mod2, prop) {
|
522
|
-
if (prop !== "then" && !(prop in mod2))
|
523
|
-
throw new SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${prop.toString()}'`);
|
524
|
-
return mod2[prop];
|
525
|
-
}
|
526
|
-
}) : mod;
|
527
|
-
}
|
528
509
|
const ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_import__", ssrDynamicImportKey = "__vite_ssr_dynamic_import__", ssrExportAllKey = "__vite_ssr_exportAll__", ssrImportMetaKey = "__vite_ssr_import_meta__", noop = () => {
|
529
510
|
}, silentConsole = {
|
530
511
|
debug: noop,
|
@@ -765,8 +746,7 @@ function CallSiteToString() {
|
|
765
746
|
typeName === "[object Object]" && (typeName = "null");
|
766
747
|
const methodName = this.getMethodName();
|
767
748
|
functionName ? (typeName && functionName.indexOf(typeName) !== 0 && (line += `${typeName}.`), line += functionName, methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1 && (line += ` [as ${methodName}]`)) : line += `${typeName}.${methodName || "<anonymous>"}`;
|
768
|
-
} else
|
769
|
-
isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);
|
749
|
+
} else isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);
|
770
750
|
return addSuffix && (line += ` (${fileLocation})`), line;
|
771
751
|
}
|
772
752
|
function cloneCallSite(frame) {
|
@@ -852,10 +832,7 @@ class ModuleRunner {
|
|
852
832
|
resetSourceMapSupport;
|
853
833
|
destroyed = !1;
|
854
834
|
constructor(options, evaluator, debug) {
|
855
|
-
this.options = options, this.evaluator = evaluator, this.debug = debug, this.moduleCache = options.moduleCache ?? new ModuleCacheMap(options.root), this.transport = options.transport, typeof options.hmr == "object" && (this.hmrClient = new HMRClient(options.hmr.logger === !1 ? silentConsole : options.hmr.logger || hmrLogger, options.hmr.connection, ({ acceptedPath,
|
856
|
-
const [acceptedPathWithoutQuery, query] = acceptedPath.split("?"), url = acceptedPathWithoutQuery + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`;
|
857
|
-
return this.import(url);
|
858
|
-
}), options.hmr.connection.onUpdate(createHMRHandler(this))), options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
835
|
+
this.options = options, this.evaluator = evaluator, this.debug = debug, this.moduleCache = options.moduleCache ?? new ModuleCacheMap(options.root), this.transport = options.transport, typeof options.hmr == "object" && (this.hmrClient = new HMRClient(options.hmr.logger === !1 ? silentConsole : options.hmr.logger || hmrLogger, options.hmr.connection, ({ acceptedPath }) => this.import(acceptedPath)), options.hmr.connection.onUpdate(createHMRHandler(this))), options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
859
836
|
}
|
860
837
|
/**
|
861
838
|
* URL to execute. Accepts file path, server path or id relative to the root.
|
@@ -898,7 +875,7 @@ class ModuleRunner {
|
|
898
875
|
if (!("externalize" in fetchResult))
|
899
876
|
return exports;
|
900
877
|
const { id, type } = fetchResult;
|
901
|
-
return type !== "module" && type !== "commonjs"
|
878
|
+
return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, id, type, metadata), exports;
|
902
879
|
}
|
903
880
|
async cachedRequest(id, mod, callstack = [], metadata) {
|
904
881
|
const meta = mod.meta, moduleId = meta.id, { imports, importers } = mod, importee = callstack[callstack.length - 1];
|
@@ -924,15 +901,23 @@ ${getStack()}`);
|
|
924
901
|
async cachedModule(url, importer) {
|
925
902
|
if (this.destroyed)
|
926
903
|
throw new Error("Vite module runner has been destroyed.");
|
904
|
+
this.debug?.("[module runner] fetching", url);
|
927
905
|
const normalized = this.urlToIdMap.get(url);
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
906
|
+
let cachedModule = normalized && this.moduleCache.getByModuleId(normalized);
|
907
|
+
cachedModule || (cachedModule = this.moduleCache.getByModuleId(url));
|
908
|
+
const isCached = !!(typeof cachedModule == "object" && cachedModule.meta), fetchedModule = (
|
909
|
+
// fast return for established externalized pattern
|
910
|
+
url.startsWith("data:") ? { externalize: url, type: "builtin" } : await this.transport.fetchModule(url, importer, {
|
911
|
+
cached: isCached
|
912
|
+
})
|
913
|
+
);
|
914
|
+
if ("cache" in fetchedModule) {
|
915
|
+
if (!cachedModule || !cachedModule.meta)
|
916
|
+
throw new Error(`Module "${url}" was mistakenly invalidated during fetch phase.`);
|
917
|
+
return cachedModule;
|
932
918
|
}
|
933
|
-
|
934
|
-
|
935
|
-
if (mod.timestamp != null && timestamp > 0 && mod.timestamp < timestamp && this.moduleCache.invalidateModule(mod), fetchedModule.id = moduleId, mod.meta = fetchedModule, mod.timestamp = timestamp, file) {
|
919
|
+
const idQuery = url.split("?")[1], query = idQuery ? `?${idQuery}` : "", file = "file" in fetchedModule ? fetchedModule.file : void 0, fileId = file ? `${file}${query}` : url, moduleId = this.moduleCache.normalize(fileId), mod = this.moduleCache.getByModuleId(moduleId);
|
920
|
+
if ("invalidate" in fetchedModule && fetchedModule.invalidate && this.moduleCache.invalidateModule(mod), fetchedModule.id = moduleId, mod.meta = fetchedModule, file) {
|
936
921
|
const fileModules = this.fileToIdMap.get(file) || [];
|
937
922
|
fileModules.push(moduleId), this.fileToIdMap.set(file, fileModules);
|
938
923
|
}
|
@@ -1127,11 +1127,11 @@ function requireNode () {
|
|
1127
1127
|
}
|
1128
1128
|
|
1129
1129
|
/**
|
1130
|
-
* Invokes `util.
|
1130
|
+
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
1131
1131
|
*/
|
1132
1132
|
|
1133
1133
|
function log(...args) {
|
1134
|
-
return process.stderr.write(util.
|
1134
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
1135
1135
|
}
|
1136
1136
|
|
1137
1137
|
/**
|
@@ -3591,22 +3591,6 @@ function normalizeSingleAlias({ find, replacement, customResolver, }) {
|
|
3591
3591
|
}
|
3592
3592
|
return alias;
|
3593
3593
|
}
|
3594
|
-
/**
|
3595
|
-
* Creates a function that hides the complexities of a WeakMap with an initial value
|
3596
|
-
* to implement object metadata. Used by plugins to implement cross hooks per
|
3597
|
-
* environment metadata
|
3598
|
-
*/
|
3599
|
-
function createWeakData(initial) {
|
3600
|
-
const cache = new WeakMap();
|
3601
|
-
return function (key) {
|
3602
|
-
let data = cache.get(key);
|
3603
|
-
if (!data) {
|
3604
|
-
data = initial(key);
|
3605
|
-
cache.set(key, data);
|
3606
|
-
}
|
3607
|
-
return data;
|
3608
|
-
};
|
3609
|
-
}
|
3610
3594
|
|
3611
3595
|
// This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
|
3612
3596
|
// copy from constants.ts
|
@@ -6255,7 +6239,6 @@ function resolveEnvPrefix({ envPrefix = 'VITE_', }) {
|
|
6255
6239
|
exports.esbuildVersion = esbuild.version;
|
6256
6240
|
exports.createFilter = createFilter;
|
6257
6241
|
exports.createLogger = createLogger;
|
6258
|
-
exports.createWeakData = createWeakData;
|
6259
6242
|
exports.isCSSRequest = isCSSRequest;
|
6260
6243
|
exports.isFileLoadingAllowed = isFileLoadingAllowed;
|
6261
6244
|
exports.isFileServingAllowed = isFileServingAllowed;
|