vite 6.3.0-beta.0 → 6.3.0-beta.2
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 +0 -15
- package/dist/client/client.mjs +44 -11
- package/dist/node/chunks/{dep-2sb0gr4n.js → dep-B8BdvHtp.js} +1 -1
- package/dist/node/chunks/{dep-BXITORG_.js → dep-BVYvZuv7.js} +1 -1
- package/dist/node/chunks/{dep-Bt1yO2CH.js → dep-jcjTW_IO.js} +933 -2155
- package/dist/node/cli.js +6 -5
- package/dist/node/index.d.ts +17 -11
- package/dist/node/index.js +3 -2
- package/dist/node/module-runner.js +64 -62
- package/dist/node-cjs/publicUtils.cjs +244 -545
- package/package.json +2 -1
- package/types/metadata.d.ts +4 -1
package/dist/node/cli.js
CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
2
2
|
import fs__default from 'node:fs';
|
3
3
|
import { performance } from 'node:perf_hooks';
|
4
4
|
import { EventEmitter } from 'events';
|
5
|
-
import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-jcjTW_IO.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -13,6 +13,7 @@ import 'picomatch';
|
|
13
13
|
import 'esbuild';
|
14
14
|
import 'path';
|
15
15
|
import 'fs';
|
16
|
+
import 'fdir';
|
16
17
|
import 'node:child_process';
|
17
18
|
import 'node:http';
|
18
19
|
import 'node:https';
|
@@ -747,7 +748,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
747
748
|
`[boolean] force the optimizer to ignore the cache and re-bundle`
|
748
749
|
).action(async (root, options) => {
|
749
750
|
filterDuplicateOptions(options);
|
750
|
-
const { createServer } = await import('./chunks/dep-
|
751
|
+
const { createServer } = await import('./chunks/dep-jcjTW_IO.js').then(function (n) { return n.S; });
|
751
752
|
try {
|
752
753
|
const server = await createServer({
|
753
754
|
root,
|
@@ -842,7 +843,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
842
843
|
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
|
843
844
|
async (root, options) => {
|
844
845
|
filterDuplicateOptions(options);
|
845
|
-
const { createBuilder } = await import('./chunks/dep-
|
846
|
+
const { createBuilder } = await import('./chunks/dep-jcjTW_IO.js').then(function (n) { return n.T; });
|
846
847
|
const buildOptions = cleanGlobalCLIOptions(
|
847
848
|
cleanBuilderCLIOptions(options)
|
848
849
|
);
|
@@ -881,7 +882,7 @@ cli.command(
|
|
881
882
|
).action(
|
882
883
|
async (root, options) => {
|
883
884
|
filterDuplicateOptions(options);
|
884
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
885
|
+
const { optimizeDeps } = await import('./chunks/dep-jcjTW_IO.js').then(function (n) { return n.R; });
|
885
886
|
try {
|
886
887
|
const config = await resolveConfig(
|
887
888
|
{
|
@@ -908,7 +909,7 @@ ${e.stack}`),
|
|
908
909
|
cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
|
909
910
|
async (root, options) => {
|
910
911
|
filterDuplicateOptions(options);
|
911
|
-
const { preview } = await import('./chunks/dep-
|
912
|
+
const { preview } = await import('./chunks/dep-jcjTW_IO.js').then(function (n) { return n.U; });
|
912
913
|
try {
|
913
914
|
const server = await preview({
|
914
915
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -848,7 +848,7 @@ declare class BaseEnvironment extends PartialEnvironment {
|
|
848
848
|
* const isDev = environment.mode === 'dev' // good
|
849
849
|
* ```
|
850
850
|
*
|
851
|
-
* You should also not check against `"unknown"`
|
851
|
+
* You should also not check against `"unknown"` specifically. It's
|
852
852
|
* a placeholder for more possible environment types.
|
853
853
|
*/
|
854
854
|
declare class UnknownEnvironment extends BaseEnvironment {
|
@@ -3200,9 +3200,9 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
|
|
3200
3200
|
handler: IndexHtmlTransformHook;
|
3201
3201
|
};
|
3202
3202
|
|
3203
|
-
type StringFilter = string | RegExp | Array<
|
3204
|
-
include?:
|
3205
|
-
exclude?:
|
3203
|
+
type StringFilter<Value = string | RegExp> = Value | Array<Value> | {
|
3204
|
+
include?: Value | Array<Value>;
|
3205
|
+
exclude?: Value | Array<Value>;
|
3206
3206
|
};
|
3207
3207
|
|
3208
3208
|
/**
|
@@ -3287,7 +3287,7 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3287
3287
|
isEntry: boolean;
|
3288
3288
|
}) => Promise<ResolveIdResult> | ResolveIdResult, {
|
3289
3289
|
filter?: {
|
3290
|
-
id?: StringFilter
|
3290
|
+
id?: StringFilter<RegExp>;
|
3291
3291
|
};
|
3292
3292
|
}>;
|
3293
3293
|
load?: ObjectHook<(this: PluginContext, id: string, options?: {
|
@@ -3401,8 +3401,13 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
|
|
3401
3401
|
* The hook receives the following arguments:
|
3402
3402
|
*
|
3403
3403
|
* - html: string
|
3404
|
-
* - ctx
|
3405
|
-
*
|
3404
|
+
* - ctx: IndexHtmlTransformContext, which contains:
|
3405
|
+
* - path: public path when served
|
3406
|
+
* - filename: filename on disk
|
3407
|
+
* - server?: ViteDevServer (only present during serve)
|
3408
|
+
* - bundle?: rollup.OutputBundle (only present during build)
|
3409
|
+
* - chunk?: rollup.OutputChunk
|
3410
|
+
* - originalUrl?: string
|
3406
3411
|
*
|
3407
3412
|
* It can either return a transformed string, or a list of html tag
|
3408
3413
|
* descriptors that will be injected into the `<head>` or `<body>`.
|
@@ -3741,7 +3746,7 @@ type ResolvedEnvironmentOptions = {
|
|
3741
3746
|
dev: ResolvedDevEnvironmentOptions;
|
3742
3747
|
build: ResolvedBuildEnvironmentOptions;
|
3743
3748
|
};
|
3744
|
-
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'consumer' | 'resolve'> & {
|
3749
|
+
type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'consumer' | 'resolve' | 'keepProcessEnv'> & {
|
3745
3750
|
resolve?: AllResolveOptions;
|
3746
3751
|
};
|
3747
3752
|
interface UserConfig extends DefaultEnvironmentOptions {
|
@@ -3855,7 +3860,7 @@ interface UserConfig extends DefaultEnvironmentOptions {
|
|
3855
3860
|
* root.
|
3856
3861
|
* @default root
|
3857
3862
|
*/
|
3858
|
-
envDir?: string;
|
3863
|
+
envDir?: string | false;
|
3859
3864
|
/**
|
3860
3865
|
* Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
|
3861
3866
|
* @default 'VITE_'
|
@@ -3983,6 +3988,7 @@ interface InlineConfig extends UserConfig {
|
|
3983
3988
|
configFile?: string | false;
|
3984
3989
|
/** @experimental */
|
3985
3990
|
configLoader?: 'bundle' | 'runner' | 'native';
|
3991
|
+
/** @deprecated */
|
3986
3992
|
envFile?: false;
|
3987
3993
|
forceOptimizeDeps?: boolean;
|
3988
3994
|
}
|
@@ -3998,7 +4004,7 @@ interface ResolvedConfig extends Readonly<Omit<UserConfig, 'plugins' | 'css' | '
|
|
3998
4004
|
mode: string;
|
3999
4005
|
isWorker: boolean;
|
4000
4006
|
isProduction: boolean;
|
4001
|
-
envDir: string;
|
4007
|
+
envDir: string | false;
|
4002
4008
|
env: Record<string, any>;
|
4003
4009
|
resolve: Required<ResolveOptions> & {
|
4004
4010
|
alias: Alias[];
|
@@ -4204,7 +4210,7 @@ declare function isFileServingAllowed(config: ResolvedConfig, url: string): bool
|
|
4204
4210
|
declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
|
4205
4211
|
declare function isFileLoadingAllowed(config: ResolvedConfig, filePath: string): boolean;
|
4206
4212
|
|
4207
|
-
declare function loadEnv(mode: string, envDir: string, prefixes?: string | string[]): Record<string, string>;
|
4213
|
+
declare function loadEnv(mode: string, envDir: string | false, prefixes?: string | string[]): Record<string, string>;
|
4208
4214
|
declare function resolveEnvPrefix({ envPrefix, }: UserConfig): string[];
|
4209
4215
|
|
4210
4216
|
type Manifest = Record<string, ManifestChunk>;
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-
|
3
|
-
export { B as BuildEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-jcjTW_IO.js';
|
3
|
+
export { B as BuildEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-jcjTW_IO.js';
|
4
4
|
export { defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import 'node:fs';
|
@@ -14,6 +14,7 @@ import 'node:crypto';
|
|
14
14
|
import 'picomatch';
|
15
15
|
import 'path';
|
16
16
|
import 'fs';
|
17
|
+
import 'fdir';
|
17
18
|
import 'node:child_process';
|
18
19
|
import 'node:http';
|
19
20
|
import 'node:https';
|
@@ -466,7 +466,7 @@ class HMRClient {
|
|
466
466
|
});
|
467
467
|
}
|
468
468
|
warnFailedUpdate(err, path) {
|
469
|
-
err.message.includes("fetch")
|
469
|
+
(!(err instanceof Error) || !err.message.includes("fetch")) && this.logger.error(err), this.logger.error(
|
470
470
|
`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`
|
471
471
|
);
|
472
472
|
}
|
@@ -722,67 +722,9 @@ const createInvokeableTransport = (transport) => {
|
|
722
722
|
debug: (...msg) => console.log("[vite]", ...msg),
|
723
723
|
error: (error) => console.log("[vite]", error)
|
724
724
|
};
|
725
|
-
function createHMRHandler(
|
725
|
+
function createHMRHandler(handler) {
|
726
726
|
const queue = new Queue();
|
727
|
-
return (payload) => queue.enqueue(() =>
|
728
|
-
}
|
729
|
-
async function handleHotPayload(runner, payload) {
|
730
|
-
const hmrClient = runner.hmrClient;
|
731
|
-
if (!(!hmrClient || runner.isClosed()))
|
732
|
-
switch (payload.type) {
|
733
|
-
case "connected":
|
734
|
-
hmrClient.logger.debug("connected.");
|
735
|
-
break;
|
736
|
-
case "update":
|
737
|
-
await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(
|
738
|
-
payload.updates.map(async (update) => {
|
739
|
-
if (update.type === "js-update")
|
740
|
-
return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
|
741
|
-
hmrClient.logger.error("css hmr is not supported in runner mode.");
|
742
|
-
})
|
743
|
-
), await hmrClient.notifyListeners("vite:afterUpdate", payload);
|
744
|
-
break;
|
745
|
-
case "custom": {
|
746
|
-
await hmrClient.notifyListeners(payload.event, payload.data);
|
747
|
-
break;
|
748
|
-
}
|
749
|
-
case "full-reload": {
|
750
|
-
const { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(
|
751
|
-
runner,
|
752
|
-
getModulesByFile(runner, slash(triggeredBy))
|
753
|
-
) : findAllEntrypoints(runner);
|
754
|
-
if (!clearEntrypointUrls.size) break;
|
755
|
-
hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
|
756
|
-
for (const url of clearEntrypointUrls)
|
757
|
-
try {
|
758
|
-
await runner.import(url);
|
759
|
-
} catch (err) {
|
760
|
-
err.code !== ERR_OUTDATED_OPTIMIZED_DEP && hmrClient.logger.error(
|
761
|
-
`An error happened during full reload
|
762
|
-
${err.message}
|
763
|
-
${err.stack}`
|
764
|
-
);
|
765
|
-
}
|
766
|
-
break;
|
767
|
-
}
|
768
|
-
case "prune":
|
769
|
-
await hmrClient.notifyListeners("vite:beforePrune", payload), await hmrClient.prunePaths(payload.paths);
|
770
|
-
break;
|
771
|
-
case "error": {
|
772
|
-
await hmrClient.notifyListeners("vite:error", payload);
|
773
|
-
const err = payload.err;
|
774
|
-
hmrClient.logger.error(
|
775
|
-
`Internal Server Error
|
776
|
-
${err.message}
|
777
|
-
${err.stack}`
|
778
|
-
);
|
779
|
-
break;
|
780
|
-
}
|
781
|
-
case "ping":
|
782
|
-
break;
|
783
|
-
default:
|
784
|
-
return payload;
|
785
|
-
}
|
727
|
+
return (payload) => queue.enqueue(() => handler(payload));
|
786
728
|
}
|
787
729
|
class Queue {
|
788
730
|
queue = [];
|
@@ -805,6 +747,66 @@ class Queue {
|
|
805
747
|
}), !0) : !1;
|
806
748
|
}
|
807
749
|
}
|
750
|
+
function createHMRHandlerForRunner(runner) {
|
751
|
+
return createHMRHandler(async (payload) => {
|
752
|
+
const hmrClient = runner.hmrClient;
|
753
|
+
if (!(!hmrClient || runner.isClosed()))
|
754
|
+
switch (payload.type) {
|
755
|
+
case "connected":
|
756
|
+
hmrClient.logger.debug("connected.");
|
757
|
+
break;
|
758
|
+
case "update":
|
759
|
+
await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(
|
760
|
+
payload.updates.map(async (update) => {
|
761
|
+
if (update.type === "js-update")
|
762
|
+
return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
|
763
|
+
hmrClient.logger.error("css hmr is not supported in runner mode.");
|
764
|
+
})
|
765
|
+
), await hmrClient.notifyListeners("vite:afterUpdate", payload);
|
766
|
+
break;
|
767
|
+
case "custom": {
|
768
|
+
await hmrClient.notifyListeners(payload.event, payload.data);
|
769
|
+
break;
|
770
|
+
}
|
771
|
+
case "full-reload": {
|
772
|
+
const { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(
|
773
|
+
runner,
|
774
|
+
getModulesByFile(runner, slash(triggeredBy))
|
775
|
+
) : findAllEntrypoints(runner);
|
776
|
+
if (!clearEntrypointUrls.size) break;
|
777
|
+
hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
|
778
|
+
for (const url of clearEntrypointUrls)
|
779
|
+
try {
|
780
|
+
await runner.import(url);
|
781
|
+
} catch (err) {
|
782
|
+
err.code !== ERR_OUTDATED_OPTIMIZED_DEP && hmrClient.logger.error(
|
783
|
+
`An error happened during full reload
|
784
|
+
${err.message}
|
785
|
+
${err.stack}`
|
786
|
+
);
|
787
|
+
}
|
788
|
+
break;
|
789
|
+
}
|
790
|
+
case "prune":
|
791
|
+
await hmrClient.notifyListeners("vite:beforePrune", payload), await hmrClient.prunePaths(payload.paths);
|
792
|
+
break;
|
793
|
+
case "error": {
|
794
|
+
await hmrClient.notifyListeners("vite:error", payload);
|
795
|
+
const err = payload.err;
|
796
|
+
hmrClient.logger.error(
|
797
|
+
`Internal Server Error
|
798
|
+
${err.message}
|
799
|
+
${err.stack}`
|
800
|
+
);
|
801
|
+
break;
|
802
|
+
}
|
803
|
+
case "ping":
|
804
|
+
break;
|
805
|
+
default:
|
806
|
+
return payload;
|
807
|
+
}
|
808
|
+
});
|
809
|
+
}
|
808
810
|
function getModulesByFile(runner, file) {
|
809
811
|
const nodes = runner.evaluatedModules.getModulesByFile(file);
|
810
812
|
return nodes ? [...nodes].map((node) => node.id) : [];
|
@@ -1078,7 +1080,7 @@ class ModuleRunner {
|
|
1078
1080
|
throw new Error(
|
1079
1081
|
"HMR is not supported by this runner transport, but `hmr` option was set to true"
|
1080
1082
|
);
|
1081
|
-
this.transport.connect(
|
1083
|
+
this.transport.connect(createHMRHandlerForRunner(this));
|
1082
1084
|
} else
|
1083
1085
|
this.transport.connect?.();
|
1084
1086
|
options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|