vite 6.0.0-alpha.2 → 6.0.0-alpha.4
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 +9 -8
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-E4cF1RpV.js → dep-8UjKy9Ch.js} +27040 -27127
- package/dist/node/chunks/{dep-DKZVy3_n.js → dep-BJOLgJFH.js} +1 -1
- package/dist/node/chunks/dep-C7zR1Rh8.js +233 -0
- package/dist/node/chunks/{dep-DK04Q0H9.js → dep-m9gtlanK.js} +1 -1
- package/dist/node/cli.js +43 -73
- package/dist/node/index.d.ts +167 -83
- package/dist/node/index.js +9 -120
- package/dist/node/module-runner.d.ts +11 -10
- package/dist/node/module-runner.js +55 -44
- package/dist/node-cjs/publicUtils.cjs +72 -33
- package/index.cjs +1 -0
- package/package.json +3 -3
package/dist/node/index.d.ts
CHANGED
@@ -632,6 +632,7 @@ interface Logger {
|
|
632
632
|
interface LogOptions {
|
633
633
|
clear?: boolean;
|
634
634
|
timestamp?: boolean;
|
635
|
+
environment?: string;
|
635
636
|
}
|
636
637
|
interface LogErrorOptions extends LogOptions {
|
637
638
|
error?: Error | RollupError | null;
|
@@ -787,6 +788,29 @@ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
|
|
787
788
|
* https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
|
788
789
|
*/
|
789
790
|
|
791
|
+
interface BoundedPluginContainer {
|
792
|
+
options: InputOptions;
|
793
|
+
buildStart(options: InputOptions): Promise<void>;
|
794
|
+
resolveId(id: string, importer: string | undefined, options?: {
|
795
|
+
attributes?: Record<string, string>;
|
796
|
+
custom?: CustomPluginOptions;
|
797
|
+
skip?: Set<Plugin>;
|
798
|
+
isEntry?: boolean;
|
799
|
+
}): Promise<PartialResolvedId | null>;
|
800
|
+
transform(code: string, id: string, options?: {
|
801
|
+
inMap?: SourceDescription['map'];
|
802
|
+
}): Promise<{
|
803
|
+
code: string;
|
804
|
+
map: SourceMap | {
|
805
|
+
mappings: '';
|
806
|
+
} | null;
|
807
|
+
}>;
|
808
|
+
load(id: string, options?: {}): Promise<LoadResult | null>;
|
809
|
+
watchChange(id: string, change: {
|
810
|
+
event: 'create' | 'update' | 'delete';
|
811
|
+
}): Promise<void>;
|
812
|
+
close(): Promise<void>;
|
813
|
+
}
|
790
814
|
interface PluginContainer {
|
791
815
|
options: InputOptions;
|
792
816
|
buildStart(options: InputOptions): Promise<void>;
|
@@ -1353,9 +1377,11 @@ declare namespace WebSocket {
|
|
1353
1377
|
}
|
1354
1378
|
|
1355
1379
|
declare class Environment {
|
1380
|
+
#private;
|
1356
1381
|
name: string;
|
1357
1382
|
config: ResolvedConfig;
|
1358
1383
|
options: ResolvedEnvironmentOptions;
|
1384
|
+
get plugins(): BoundedPlugin[];
|
1359
1385
|
get logger(): Logger;
|
1360
1386
|
constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
|
1361
1387
|
}
|
@@ -1370,8 +1396,14 @@ interface FetchModuleOptions {
|
|
1370
1396
|
*/
|
1371
1397
|
declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
|
1372
1398
|
|
1399
|
+
declare class ScanEnvironment extends Environment {
|
1400
|
+
mode: "scan";
|
1401
|
+
get pluginContainer(): BoundedPluginContainer;
|
1402
|
+
init(): Promise<void>;
|
1403
|
+
}
|
1404
|
+
|
1373
1405
|
type ExportsData = {
|
1374
|
-
|
1406
|
+
hasModuleSyntax: boolean;
|
1375
1407
|
exports: readonly string[];
|
1376
1408
|
jsxLoader?: boolean;
|
1377
1409
|
};
|
@@ -1531,11 +1563,6 @@ interface DepOptimizationMetadata {
|
|
1531
1563
|
*/
|
1532
1564
|
depInfoList: OptimizedDepInfo[];
|
1533
1565
|
}
|
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
1566
|
|
1540
1567
|
declare class RemoteEnvironmentTransport {
|
1541
1568
|
private readonly options;
|
@@ -1548,16 +1575,19 @@ declare class RemoteEnvironmentTransport {
|
|
1548
1575
|
|
1549
1576
|
interface DevEnvironmentSetup {
|
1550
1577
|
hot?: false | HMRChannel;
|
1578
|
+
watcher?: FSWatcher;
|
1551
1579
|
options?: EnvironmentOptions;
|
1552
1580
|
runner?: FetchModuleOptions & {
|
1553
1581
|
transport?: RemoteEnvironmentTransport;
|
1554
1582
|
};
|
1583
|
+
depsOptimizer?: DepsOptimizer;
|
1555
1584
|
}
|
1556
1585
|
declare class DevEnvironment extends Environment {
|
1557
1586
|
mode: "dev";
|
1558
1587
|
moduleGraph: EnvironmentModuleGraph;
|
1559
|
-
|
1588
|
+
watcher?: FSWatcher;
|
1560
1589
|
depsOptimizer?: DepsOptimizer;
|
1590
|
+
get pluginContainer(): BoundedPluginContainer;
|
1561
1591
|
/**
|
1562
1592
|
* HMR channel for this environment. If not provided or disabled,
|
1563
1593
|
* it will be a noop channel that does nothing.
|
@@ -1566,18 +1596,21 @@ declare class DevEnvironment extends Environment {
|
|
1566
1596
|
* environment.hot.send({ type: 'full-reload' })
|
1567
1597
|
*/
|
1568
1598
|
hot: HMRChannel;
|
1569
|
-
constructor(
|
1570
|
-
|
1571
|
-
options?: EnvironmentOptions;
|
1572
|
-
runner?: FetchModuleOptions & {
|
1573
|
-
transport?: RemoteEnvironmentTransport;
|
1574
|
-
};
|
1575
|
-
depsOptimizer?: DepsOptimizer;
|
1576
|
-
});
|
1599
|
+
constructor(name: string, config: ResolvedConfig, setup?: DevEnvironmentSetup);
|
1600
|
+
init(): Promise<void>;
|
1577
1601
|
fetchModule(id: string, importer?: string): Promise<FetchResult>;
|
1578
1602
|
transformRequest(url: string): Promise<TransformResult | null>;
|
1579
1603
|
warmupRequest(url: string): Promise<void>;
|
1580
1604
|
close(): Promise<void>;
|
1605
|
+
/**
|
1606
|
+
* Calling `await environment.waitForRequestsIdle(id)` will wait until all static imports
|
1607
|
+
* are processed after the first transformRequest call. If called from a load or transform
|
1608
|
+
* plugin hook, the id needs to be passed as a parameter to avoid deadlocks.
|
1609
|
+
* Calling this function after the first static imports section of the module graph has been
|
1610
|
+
* processed will resolve immediately.
|
1611
|
+
* @experimental
|
1612
|
+
*/
|
1613
|
+
waitForRequestsIdle(ignoredId?: string): Promise<void>;
|
1581
1614
|
}
|
1582
1615
|
|
1583
1616
|
interface TransformResult {
|
@@ -1585,6 +1618,7 @@ interface TransformResult {
|
|
1585
1618
|
map: SourceMap | {
|
1586
1619
|
mappings: '';
|
1587
1620
|
} | null;
|
1621
|
+
ssr?: boolean;
|
1588
1622
|
etag?: string;
|
1589
1623
|
deps?: string[];
|
1590
1624
|
dynamicDeps?: string[];
|
@@ -2023,11 +2057,12 @@ interface ViteDevServer {
|
|
2023
2057
|
*
|
2024
2058
|
* Always sends a message to at least a WebSocket client. Any third party can
|
2025
2059
|
* add a channel to the broadcaster to process messages
|
2026
|
-
* @deprecated use `
|
2060
|
+
* @deprecated use `environment.hot` instead
|
2027
2061
|
*/
|
2028
2062
|
hot: HMRBroadcaster;
|
2029
2063
|
/**
|
2030
2064
|
* Rollup plugin container that can run plugin hooks on a given file
|
2065
|
+
* @deprecated use `environment.pluginContainer` instead
|
2031
2066
|
*/
|
2032
2067
|
pluginContainer: PluginContainer;
|
2033
2068
|
/**
|
@@ -2037,7 +2072,7 @@ interface ViteDevServer {
|
|
2037
2072
|
/**
|
2038
2073
|
* Module graph that tracks the import relationships, url to file mapping
|
2039
2074
|
* and hmr state.
|
2040
|
-
* @deprecated use environment
|
2075
|
+
* @deprecated use `environment.moduleGraph` instead
|
2041
2076
|
*/
|
2042
2077
|
moduleGraph: ModuleGraph;
|
2043
2078
|
/**
|
@@ -2064,6 +2099,7 @@ interface ViteDevServer {
|
|
2064
2099
|
transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
|
2065
2100
|
/**
|
2066
2101
|
* Transform module code into SSR format.
|
2102
|
+
* TODO: expose this to any environment?
|
2067
2103
|
*/
|
2068
2104
|
ssrTransform(code: string, inMap: SourceMap | {
|
2069
2105
|
mappings: '';
|
@@ -2124,6 +2160,7 @@ interface ViteDevServer {
|
|
2124
2160
|
* passed as a parameter to avoid deadlocks. Calling this function after the first
|
2125
2161
|
* static imports section of the module graph has been processed will resolve immediately.
|
2126
2162
|
* @experimental
|
2163
|
+
* @deprecated use environment.waitForRequestsIdle()
|
2127
2164
|
*/
|
2128
2165
|
waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
|
2129
2166
|
}
|
@@ -2815,7 +2852,7 @@ interface BuildEnvironmentOptions {
|
|
2815
2852
|
/**
|
2816
2853
|
* create the Build Environment instance
|
2817
2854
|
*/
|
2818
|
-
createEnvironment?: (
|
2855
|
+
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
|
2819
2856
|
}
|
2820
2857
|
interface BuildOptions extends BuildEnvironmentOptions {
|
2821
2858
|
/**
|
@@ -2892,25 +2929,24 @@ type RenderBuiltAssetUrl = (filename: string, type: {
|
|
2892
2929
|
} | undefined;
|
2893
2930
|
declare class BuildEnvironment extends Environment {
|
2894
2931
|
mode: "build";
|
2895
|
-
|
2896
|
-
constructor(builder: ViteBuilder, name: string, setup?: {
|
2932
|
+
constructor(name: string, config: ResolvedConfig, setup?: {
|
2897
2933
|
options?: EnvironmentOptions;
|
2898
2934
|
});
|
2899
2935
|
}
|
2900
2936
|
interface ViteBuilder {
|
2901
2937
|
environments: Record<string, BuildEnvironment>;
|
2902
2938
|
config: ResolvedConfig;
|
2903
|
-
|
2939
|
+
buildApp(): Promise<void>;
|
2904
2940
|
build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
2905
2941
|
}
|
2906
2942
|
interface BuilderOptions {
|
2907
|
-
|
2943
|
+
sharedConfigBuild?: boolean;
|
2944
|
+
sharedPlugins?: boolean;
|
2945
|
+
entireApp?: boolean;
|
2946
|
+
buildApp?: (builder: ViteBuilder) => Promise<void>;
|
2908
2947
|
}
|
2909
2948
|
type ResolvedBuilderOptions = Required<BuilderOptions>;
|
2910
|
-
|
2911
|
-
plugins?: () => PluginOption[];
|
2912
|
-
}
|
2913
|
-
declare function createViteBuilder(builderOptions?: BuilderOptions, defaultBuilderInlineConfig?: BuilderInlineConfig): Promise<ViteBuilder>;
|
2949
|
+
declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder>;
|
2914
2950
|
|
2915
2951
|
interface ESBuildOptions extends esbuild_TransformOptions {
|
2916
2952
|
include?: string | RegExp | string[] | RegExp[];
|
@@ -3195,14 +3231,86 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3195
3231
|
* or a build environment. Plugins can use this.environment.mode === 'dev' to
|
3196
3232
|
* check if they have access to dev specific APIs.
|
3197
3233
|
*/
|
3198
|
-
type PluginEnvironment = DevEnvironment | BuildEnvironment;
|
3234
|
+
type PluginEnvironment = DevEnvironment | BuildEnvironment | ScanEnvironment;
|
3199
3235
|
interface PluginContext extends rollup.PluginContext {
|
3200
3236
|
environment?: PluginEnvironment;
|
3201
3237
|
}
|
3238
|
+
interface ResolveIdPluginContext extends rollup.PluginContext {
|
3239
|
+
environment?: PluginEnvironment;
|
3240
|
+
}
|
3202
3241
|
interface TransformPluginContext extends rollup.TransformPluginContext {
|
3203
3242
|
environment?: PluginEnvironment;
|
3204
3243
|
}
|
3205
|
-
|
3244
|
+
/**
|
3245
|
+
* There are two types of plugins in Vite. App plugins and environment plugins.
|
3246
|
+
* Environment Plugins are defined by a constructor function that will be called
|
3247
|
+
* once per each environment allowing users to have completely different plugins
|
3248
|
+
* for each of them. The constructor gets the resolved environment after the server
|
3249
|
+
* and builder has already been created simplifying config access and cache
|
3250
|
+
* managementfor for environment specific plugins.
|
3251
|
+
* Environment Plugins are closer to regular rollup plugins. They can't define
|
3252
|
+
* app level hooks (like config, configResolved, configureServer, etc).
|
3253
|
+
*/
|
3254
|
+
interface BasePlugin<A = any> extends rollup.Plugin<A> {
|
3255
|
+
/**
|
3256
|
+
* Perform custom handling of HMR updates.
|
3257
|
+
* The handler receives a context containing changed filename, timestamp, a
|
3258
|
+
* list of modules affected by the file change, and the dev server instance.
|
3259
|
+
*
|
3260
|
+
* - The hook can return a filtered list of modules to narrow down the update.
|
3261
|
+
* e.g. for a Vue SFC, we can narrow down the part to update by comparing
|
3262
|
+
* the descriptors.
|
3263
|
+
*
|
3264
|
+
* - The hook can also return an empty array and then perform custom updates
|
3265
|
+
* by sending a custom hmr payload via server.hot.send().
|
3266
|
+
*
|
3267
|
+
* - If the hook doesn't return a value, the hmr update will be performed as
|
3268
|
+
* normal.
|
3269
|
+
*/
|
3270
|
+
hotUpdate?: ObjectHook<(this: void, ctx: HotUpdateContext) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
|
3271
|
+
/**
|
3272
|
+
* extend hooks with ssr flag
|
3273
|
+
*/
|
3274
|
+
resolveId?: ObjectHook<(this: ResolveIdPluginContext, source: string, importer: string | undefined, options: {
|
3275
|
+
attributes: Record<string, string>;
|
3276
|
+
custom?: CustomPluginOptions;
|
3277
|
+
/**
|
3278
|
+
* @deprecated use this.environment
|
3279
|
+
*/
|
3280
|
+
ssr?: boolean;
|
3281
|
+
isEntry: boolean;
|
3282
|
+
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
3283
|
+
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
3284
|
+
/**
|
3285
|
+
* @deprecated use this.environment
|
3286
|
+
*/
|
3287
|
+
ssr?: boolean;
|
3288
|
+
}) => Promise<LoadResult> | LoadResult>;
|
3289
|
+
transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
|
3290
|
+
/**
|
3291
|
+
* @deprecated use this.environment
|
3292
|
+
*/
|
3293
|
+
ssr?: boolean;
|
3294
|
+
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
3295
|
+
}
|
3296
|
+
type BoundedPlugin<A = any> = BasePlugin<A>;
|
3297
|
+
interface Plugin<A = any> extends BasePlugin<A> {
|
3298
|
+
/**
|
3299
|
+
* Opt-in this plugin into the shared plugins pipeline.
|
3300
|
+
* For backward-compatibility, plugins are re-recreated for each environment
|
3301
|
+
* during `vite build --app`
|
3302
|
+
* We have an opt-in per plugin, and a general `builder.sharedPlugins`
|
3303
|
+
* In a future major, we'll flip the default to be shared by default
|
3304
|
+
* @experimental
|
3305
|
+
*/
|
3306
|
+
sharedDuringBuild?: boolean;
|
3307
|
+
/**
|
3308
|
+
* Spawn the plugin into multiple plugins based on the environment.
|
3309
|
+
* This hook is called when the config has already been resolved, allowing to
|
3310
|
+
* create per environment plugin pipelines or easily inject plugins for a
|
3311
|
+
* only specific environments.
|
3312
|
+
*/
|
3313
|
+
create?: (environment: PluginEnvironment) => BoundedPluginOption;
|
3206
3314
|
/**
|
3207
3315
|
* Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
|
3208
3316
|
* is still subject to the `order` property in the hook object.
|
@@ -3287,51 +3395,15 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3287
3395
|
* with the mixed client and ssr moduleGraph. Use hotUpdate instead
|
3288
3396
|
*/
|
3289
3397
|
handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
|
3290
|
-
/**
|
3291
|
-
* Perform custom handling of HMR updates.
|
3292
|
-
* The handler receives a context containing changed filename, timestamp, a
|
3293
|
-
* list of modules affected by the file change, and the dev server instance.
|
3294
|
-
*
|
3295
|
-
* - The hook can return a filtered list of modules to narrow down the update.
|
3296
|
-
* e.g. for a Vue SFC, we can narrow down the part to update by comparing
|
3297
|
-
* the descriptors.
|
3298
|
-
*
|
3299
|
-
* - The hook can also return an empty array and then perform custom updates
|
3300
|
-
* by sending a custom hmr payload via server.hot.send().
|
3301
|
-
*
|
3302
|
-
* - If the hook doesn't return a value, the hmr update will be performed as
|
3303
|
-
* normal.
|
3304
|
-
*/
|
3305
|
-
hotUpdate?: ObjectHook<(this: void, ctx: HotUpdateContext) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
|
3306
|
-
/**
|
3307
|
-
* extend hooks with ssr flag
|
3308
|
-
*/
|
3309
|
-
resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
|
3310
|
-
attributes: Record<string, string>;
|
3311
|
-
custom?: CustomPluginOptions;
|
3312
|
-
/**
|
3313
|
-
* @deprecated use this.environment
|
3314
|
-
*/
|
3315
|
-
ssr?: boolean;
|
3316
|
-
isEntry: boolean;
|
3317
|
-
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
3318
|
-
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
3319
|
-
/**
|
3320
|
-
* @deprecated use this.environment
|
3321
|
-
*/
|
3322
|
-
ssr?: boolean;
|
3323
|
-
}) => Promise<LoadResult> | LoadResult>;
|
3324
|
-
transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
|
3325
|
-
/**
|
3326
|
-
* @deprecated use this.environment
|
3327
|
-
*/
|
3328
|
-
ssr?: boolean;
|
3329
|
-
}) => Promise<rollup.TransformResult> | rollup.TransformResult>;
|
3330
3398
|
}
|
3331
3399
|
type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
|
3332
3400
|
type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
|
3333
3401
|
[P in K]: NonNullable<Plugin[P]>;
|
3334
3402
|
};
|
3403
|
+
type MaybeBoundedPlugin = BoundedPlugin | false | null | undefined;
|
3404
|
+
type BoundedPluginOption = MaybeBoundedPlugin | BoundedPluginOption[] | Promise<MaybeBoundedPlugin | BoundedPluginOption[]>;
|
3405
|
+
type MaybePlugin = Plugin | false | null | undefined;
|
3406
|
+
type PluginOption = MaybePlugin | PluginOption[] | Promise<MaybePlugin | PluginOption[]>;
|
3335
3407
|
|
3336
3408
|
interface JsonOptions {
|
3337
3409
|
/**
|
@@ -3443,17 +3515,14 @@ declare function defineConfig(config: UserConfig): UserConfig;
|
|
3443
3515
|
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
3444
3516
|
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
3445
3517
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
3446
|
-
type PluginOption = Plugin | false | null | undefined | PluginOption[] | Promise<Plugin | false | null | undefined | PluginOption[]>;
|
3447
3518
|
interface DevEnvironmentOptions {
|
3448
3519
|
/**
|
3449
|
-
*
|
3520
|
+
* Files tßo be pre-transformed. Supports glob patterns.
|
3450
3521
|
*/
|
3451
|
-
warmup?:
|
3452
|
-
files: string[];
|
3453
|
-
};
|
3522
|
+
warmup?: string[];
|
3454
3523
|
/**
|
3455
3524
|
* Pre-transform known direct imports
|
3456
|
-
*
|
3525
|
+
* defaults to true for the client environment, false for the rest
|
3457
3526
|
*/
|
3458
3527
|
preTransformRequests?: boolean;
|
3459
3528
|
/**
|
@@ -3481,7 +3550,7 @@ interface DevEnvironmentOptions {
|
|
3481
3550
|
/**
|
3482
3551
|
* create the Dev Environment instance
|
3483
3552
|
*/
|
3484
|
-
createEnvironment?: (
|
3553
|
+
createEnvironment?: (name: string, config: ResolvedConfig) => Promise<DevEnvironment> | DevEnvironment;
|
3485
3554
|
/**
|
3486
3555
|
* For environments that support a full-reload, like the client, we can short-circuit when
|
3487
3556
|
* restarting the server throwing early to stop processing current files. We avoided this for
|
@@ -3489,9 +3558,15 @@ interface DevEnvironmentOptions {
|
|
3489
3558
|
* @experimental
|
3490
3559
|
*/
|
3491
3560
|
recoverable?: boolean;
|
3561
|
+
/**
|
3562
|
+
* For environments associated with a module runner.
|
3563
|
+
* By default it is true for the client environment and false for non-client environments.
|
3564
|
+
* This option can also be used instead of the removed config.experimental.skipSsrTransform.
|
3565
|
+
*/
|
3566
|
+
moduleRunnerTransform?: boolean;
|
3492
3567
|
}
|
3493
3568
|
type ResolvedDevEnvironmentOptions = Required<Omit<DevEnvironmentOptions, 'createEnvironment'>> & {
|
3494
|
-
createEnvironment: ((
|
3569
|
+
createEnvironment: ((name: string, config: ResolvedConfig) => Promise<DevEnvironment> | DevEnvironment) | undefined;
|
3495
3570
|
};
|
3496
3571
|
type EnvironmentResolveOptions = ResolveOptions & {
|
3497
3572
|
alias?: AliasOptions;
|
@@ -3507,6 +3582,13 @@ interface SharedEnvironmentOptions {
|
|
3507
3582
|
*/
|
3508
3583
|
nodeCompatible?: boolean;
|
3509
3584
|
webCompatible?: boolean;
|
3585
|
+
/**
|
3586
|
+
* Should Vite inject timestamp if module is invalidated
|
3587
|
+
* Disabling this will break built-in HMR support
|
3588
|
+
* @experimental
|
3589
|
+
* @default true
|
3590
|
+
*/
|
3591
|
+
injectInvalidationTimestamp?: boolean;
|
3510
3592
|
}
|
3511
3593
|
interface EnvironmentOptions extends SharedEnvironmentOptions {
|
3512
3594
|
/**
|
@@ -3523,6 +3605,7 @@ type ResolvedEnvironmentOptions = {
|
|
3523
3605
|
resolve: ResolvedEnvironmentResolveOptions;
|
3524
3606
|
nodeCompatible: boolean;
|
3525
3607
|
webCompatible: boolean;
|
3608
|
+
injectInvalidationTimestamp: boolean;
|
3526
3609
|
dev: ResolvedDevEnvironmentOptions;
|
3527
3610
|
build: ResolvedBuildEnvironmentOptions;
|
3528
3611
|
};
|
@@ -3788,7 +3871,7 @@ interface PluginHookUtils {
|
|
3788
3871
|
getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
|
3789
3872
|
}
|
3790
3873
|
type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
|
3791
|
-
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean): Promise<ResolvedConfig>;
|
3874
|
+
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean, patchConfig?: ((config: ResolvedConfig) => void) | undefined): Promise<ResolvedConfig>;
|
3792
3875
|
declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
|
3793
3876
|
declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger): Promise<{
|
3794
3877
|
path: string;
|
@@ -3798,7 +3881,7 @@ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, c
|
|
3798
3881
|
|
3799
3882
|
declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
|
3800
3883
|
|
3801
|
-
declare function createNodeDevEnvironment(
|
3884
|
+
declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, options?: DevEnvironmentSetup): DevEnvironment;
|
3802
3885
|
|
3803
3886
|
/**
|
3804
3887
|
* @experimental
|
@@ -3812,9 +3895,9 @@ interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | '
|
|
3812
3895
|
logger?: ModuleRunnerHmr['logger'];
|
3813
3896
|
};
|
3814
3897
|
/**
|
3815
|
-
* Provide a custom module
|
3898
|
+
* Provide a custom module evaluator. This controls how the code is executed.
|
3816
3899
|
*/
|
3817
|
-
|
3900
|
+
evaluator?: ModuleEvaluator;
|
3818
3901
|
}
|
3819
3902
|
/**
|
3820
3903
|
* Create an instance of the Vite SSR runtime that support HMR.
|
@@ -3827,11 +3910,11 @@ declare function createServerModuleRunner(environment: DevEnvironment, options?:
|
|
3827
3910
|
* @experimental
|
3828
3911
|
*/
|
3829
3912
|
declare class ServerHMRConnector implements ModuleRunnerHMRConnection {
|
3830
|
-
private handlers;
|
3831
3913
|
private hmrChannel;
|
3914
|
+
private handlers;
|
3832
3915
|
private hmrClient;
|
3833
3916
|
private connected;
|
3834
|
-
constructor(
|
3917
|
+
constructor(hmrChannel: ServerHMRChannel);
|
3835
3918
|
isReady(): boolean;
|
3836
3919
|
send(message: string): void;
|
3837
3920
|
onUpdate(handler: (payload: HMRPayload) => void): void;
|
@@ -3888,6 +3971,7 @@ declare function searchForWorkspaceRoot(current: string, root?: string): string;
|
|
3888
3971
|
|
3889
3972
|
/**
|
3890
3973
|
* Check if the url is allowed to be served, via the `server.fs` config.
|
3974
|
+
* @deprecate use isFileLoadingAllowed
|
3891
3975
|
*/
|
3892
3976
|
declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
|
3893
3977
|
|
@@ -3907,4 +3991,4 @@ interface ManifestChunk {
|
|
3907
3991
|
dynamicImports?: string[];
|
3908
3992
|
}
|
3909
3993
|
|
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,
|
3994
|
+
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, 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 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 ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, 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, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
|
package/dist/node/index.js
CHANGED
@@ -1,17 +1,16 @@
|
|
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, b as build, h as buildErrorMessage,
|
4
|
-
import { existsSync, readFileSync } from 'node:fs';
|
5
|
-
import { ModuleRunner, ESModulesEvaluator } from 'vite/module-runner';
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-8UjKy9Ch.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, h as buildErrorMessage, e as createBuilder, u as createFilter, j as createNodeDevEnvironment, c as createServer, m as createServerModuleRunner, d as defineConfig, k as fetchModule, f as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, o as mergeConfig, n as normalizePath, g as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-8UjKy9Ch.js';
|
6
4
|
export { VERSION as version } from './constants.js';
|
7
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
|
+
export { c as createLogger } from './chunks/dep-C7zR1Rh8.js';
|
7
|
+
import 'node:fs';
|
8
8
|
import 'node:fs/promises';
|
9
9
|
import 'node:path';
|
10
10
|
import 'node:url';
|
11
11
|
import 'node:util';
|
12
12
|
import 'node:perf_hooks';
|
13
13
|
import 'node:module';
|
14
|
-
import 'tty';
|
15
14
|
import 'path';
|
16
15
|
import 'fs';
|
17
16
|
import 'events';
|
@@ -19,6 +18,7 @@ import 'assert';
|
|
19
18
|
import 'node:child_process';
|
20
19
|
import 'node:http';
|
21
20
|
import 'node:https';
|
21
|
+
import 'tty';
|
22
22
|
import 'util';
|
23
23
|
import 'net';
|
24
24
|
import 'url';
|
@@ -29,19 +29,20 @@ import 'child_process';
|
|
29
29
|
import 'node:os';
|
30
30
|
import 'node:crypto';
|
31
31
|
import 'node:dns';
|
32
|
+
import 'vite/module-runner';
|
33
|
+
import 'module';
|
32
34
|
import 'node:assert';
|
33
35
|
import 'node:v8';
|
34
|
-
import 'module';
|
35
36
|
import 'node:worker_threads';
|
36
37
|
import 'node:events';
|
37
38
|
import 'crypto';
|
39
|
+
import 'querystring';
|
38
40
|
import 'node:buffer';
|
39
41
|
import 'node:readline';
|
40
42
|
import 'zlib';
|
41
43
|
import 'buffer';
|
42
44
|
import 'https';
|
43
45
|
import 'tls';
|
44
|
-
import 'querystring';
|
45
46
|
import 'node:zlib';
|
46
47
|
|
47
48
|
// This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
|
@@ -199,116 +200,4 @@ class RemoteEnvironmentTransport {
|
|
199
200
|
}
|
200
201
|
}
|
201
202
|
|
202
|
-
|
203
|
-
hmrChannel;
|
204
|
-
constructor(hmrChannel) {
|
205
|
-
this.hmrChannel = hmrChannel;
|
206
|
-
}
|
207
|
-
send(...args) {
|
208
|
-
let payload;
|
209
|
-
if (typeof args[0] === 'string') {
|
210
|
-
payload = {
|
211
|
-
type: 'custom',
|
212
|
-
event: args[0],
|
213
|
-
data: args[1],
|
214
|
-
};
|
215
|
-
}
|
216
|
-
else {
|
217
|
-
payload = args[0];
|
218
|
-
}
|
219
|
-
if (payload.type !== 'custom') {
|
220
|
-
throw new Error('Cannot send non-custom events from the client to the server.');
|
221
|
-
}
|
222
|
-
this.hmrChannel.send(payload);
|
223
|
-
}
|
224
|
-
}
|
225
|
-
/**
|
226
|
-
* The connector class to establish HMR communication between the server and the Vite runtime.
|
227
|
-
* @experimental
|
228
|
-
*/
|
229
|
-
class ServerHMRConnector {
|
230
|
-
handlers = [];
|
231
|
-
hmrChannel;
|
232
|
-
hmrClient;
|
233
|
-
connected = false;
|
234
|
-
constructor(server) {
|
235
|
-
const hmrChannel = server.hot?.channels.find((c) => c.name === 'ssr');
|
236
|
-
if (!hmrChannel) {
|
237
|
-
throw new Error("Your version of Vite doesn't support HMR during SSR. Please, use Vite 5.1 or higher.");
|
238
|
-
}
|
239
|
-
this.hmrClient = new ServerHMRBroadcasterClient(hmrChannel);
|
240
|
-
hmrChannel.api.outsideEmitter.on('send', (payload) => {
|
241
|
-
this.handlers.forEach((listener) => listener(payload));
|
242
|
-
});
|
243
|
-
this.hmrChannel = hmrChannel;
|
244
|
-
}
|
245
|
-
isReady() {
|
246
|
-
return this.connected;
|
247
|
-
}
|
248
|
-
send(message) {
|
249
|
-
const payload = JSON.parse(message);
|
250
|
-
this.hmrChannel.api.innerEmitter.emit(payload.event, payload.data, this.hmrClient);
|
251
|
-
}
|
252
|
-
onUpdate(handler) {
|
253
|
-
this.handlers.push(handler);
|
254
|
-
handler({ type: 'connected' });
|
255
|
-
this.connected = true;
|
256
|
-
}
|
257
|
-
}
|
258
|
-
|
259
|
-
function createHMROptions(server, options) {
|
260
|
-
if (server.config.server.hmr === false || options.hmr === false) {
|
261
|
-
return false;
|
262
|
-
}
|
263
|
-
if (options.hmr?.connection) {
|
264
|
-
return {
|
265
|
-
connection: options.hmr.connection,
|
266
|
-
logger: options.hmr.logger,
|
267
|
-
};
|
268
|
-
}
|
269
|
-
const connection = new ServerHMRConnector(server);
|
270
|
-
return {
|
271
|
-
connection,
|
272
|
-
logger: options.hmr?.logger,
|
273
|
-
};
|
274
|
-
}
|
275
|
-
const prepareStackTrace = {
|
276
|
-
retrieveFile(id) {
|
277
|
-
if (existsSync(id)) {
|
278
|
-
return readFileSync(id, 'utf-8');
|
279
|
-
}
|
280
|
-
},
|
281
|
-
};
|
282
|
-
function resolveSourceMapOptions(options) {
|
283
|
-
if (options.sourcemapInterceptor != null) {
|
284
|
-
if (options.sourcemapInterceptor === 'prepareStackTrace') {
|
285
|
-
return prepareStackTrace;
|
286
|
-
}
|
287
|
-
if (typeof options.sourcemapInterceptor === 'object') {
|
288
|
-
return { ...prepareStackTrace, ...options.sourcemapInterceptor };
|
289
|
-
}
|
290
|
-
return options.sourcemapInterceptor;
|
291
|
-
}
|
292
|
-
if (typeof process !== 'undefined' && 'setSourceMapsEnabled' in process) {
|
293
|
-
return 'node';
|
294
|
-
}
|
295
|
-
return prepareStackTrace;
|
296
|
-
}
|
297
|
-
/**
|
298
|
-
* Create an instance of the Vite SSR runtime that support HMR.
|
299
|
-
* @experimental
|
300
|
-
*/
|
301
|
-
function createServerModuleRunner(environment, options = {}) {
|
302
|
-
const hmr = createHMROptions(environment.server, options);
|
303
|
-
return new ModuleRunner({
|
304
|
-
...options,
|
305
|
-
root: environment.config.root,
|
306
|
-
transport: {
|
307
|
-
fetchModule: (id, importer) => environment.fetchModule(id, importer),
|
308
|
-
},
|
309
|
-
hmr,
|
310
|
-
sourcemapInterceptor: resolveSourceMapOptions(options),
|
311
|
-
}, options.runner || new ESModulesEvaluator());
|
312
|
-
}
|
313
|
-
|
314
|
-
export { RemoteEnvironmentTransport, ServerHMRConnector, createServerModuleRunner, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
|
203
|
+
export { RemoteEnvironmentTransport, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
|