vite 6.3.0-beta.1 → 6.3.0
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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/LICENSE.md +0 -15
- package/dist/client/client.mjs +62 -19
- package/dist/node/chunks/{dep-CY3sqczG.js → dep-BuM4AdeL.js} +139 -831
- package/dist/node/chunks/{dep-DPsCJVuU.js → dep-CQ6IcQaf.js} +1 -1
- package/dist/node/chunks/{dep-W4lxOTyg.js → dep-KUFMcaC7.js} +1 -1
- package/dist/node/cli.js +6 -5
- package/dist/node/index.d.ts +8 -3
- package/dist/node/index.js +3 -2
- package/dist/node/module-runner.d.ts +1 -0
- package/dist/node/module-runner.js +83 -70
- package/package.json +2 -1
- package/types/customEvent.d.ts +1 -0
- package/types/hmrPayload.d.ts +2 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-BuM4AdeL.js';
|
2
2
|
import require$$0$2 from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
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-BuM4AdeL.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-BuM4AdeL.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-BuM4AdeL.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-BuM4AdeL.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-BuM4AdeL.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
@@ -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 {
|
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-BuM4AdeL.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-BuM4AdeL.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';
|
@@ -51,6 +51,7 @@ declare class HMRClient {
|
|
51
51
|
dataMap: Map<string, any>;
|
52
52
|
customListenersMap: CustomListenersMap;
|
53
53
|
ctxToListenersMap: Map<string, CustomListenersMap>;
|
54
|
+
currentFirstInvalidatedBy: string | undefined;
|
54
55
|
constructor(logger: HMRLogger, transport: NormalizedModuleRunnerTransport, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
|
55
56
|
notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>;
|
56
57
|
send(payload: HotPayload): void;
|
@@ -383,12 +383,15 @@ class HMRContext {
|
|
383
383
|
decline() {
|
384
384
|
}
|
385
385
|
invalidate(message) {
|
386
|
+
const firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
|
386
387
|
this.hmrClient.notifyListeners("vite:invalidate", {
|
387
388
|
path: this.ownerPath,
|
388
|
-
message
|
389
|
+
message,
|
390
|
+
firstInvalidatedBy
|
389
391
|
}), this.send("vite:invalidate", {
|
390
392
|
path: this.ownerPath,
|
391
|
-
message
|
393
|
+
message,
|
394
|
+
firstInvalidatedBy
|
392
395
|
}), this.hmrClient.logger.debug(
|
393
396
|
`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`
|
394
397
|
);
|
@@ -439,6 +442,7 @@ class HMRClient {
|
|
439
442
|
dataMap = /* @__PURE__ */ new Map();
|
440
443
|
customListenersMap = /* @__PURE__ */ new Map();
|
441
444
|
ctxToListenersMap = /* @__PURE__ */ new Map();
|
445
|
+
currentFirstInvalidatedBy;
|
442
446
|
async notifyListeners(event, data) {
|
443
447
|
const cbs = this.customListenersMap.get(event);
|
444
448
|
cbs && await Promise.allSettled(cbs.map((cb) => cb(data)));
|
@@ -485,7 +489,7 @@ class HMRClient {
|
|
485
489
|
}
|
486
490
|
}
|
487
491
|
async fetchUpdate(update) {
|
488
|
-
const { path, acceptedPath } = update, mod = this.hotModulesMap.get(path);
|
492
|
+
const { path, acceptedPath, firstInvalidatedBy } = update, mod = this.hotModulesMap.get(path);
|
489
493
|
if (!mod)
|
490
494
|
return;
|
491
495
|
let fetchedModule;
|
@@ -502,12 +506,19 @@ class HMRClient {
|
|
502
506
|
}
|
503
507
|
}
|
504
508
|
return () => {
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
509
|
+
try {
|
510
|
+
this.currentFirstInvalidatedBy = firstInvalidatedBy;
|
511
|
+
for (const { deps, fn } of qualifiedCallbacks)
|
512
|
+
fn(
|
513
|
+
deps.map(
|
514
|
+
(dep) => dep === acceptedPath ? fetchedModule : void 0
|
515
|
+
)
|
516
|
+
);
|
517
|
+
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
518
|
+
this.logger.debug(`hot updated: ${loggedPath}`);
|
519
|
+
} finally {
|
520
|
+
this.currentFirstInvalidatedBy = void 0;
|
521
|
+
}
|
511
522
|
};
|
512
523
|
}
|
513
524
|
}
|
@@ -722,67 +733,9 @@ const createInvokeableTransport = (transport) => {
|
|
722
733
|
debug: (...msg) => console.log("[vite]", ...msg),
|
723
734
|
error: (error) => console.log("[vite]", error)
|
724
735
|
};
|
725
|
-
function createHMRHandler(
|
736
|
+
function createHMRHandler(handler) {
|
726
737
|
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
|
-
}
|
738
|
+
return (payload) => queue.enqueue(() => handler(payload));
|
786
739
|
}
|
787
740
|
class Queue {
|
788
741
|
queue = [];
|
@@ -805,6 +758,66 @@ class Queue {
|
|
805
758
|
}), !0) : !1;
|
806
759
|
}
|
807
760
|
}
|
761
|
+
function createHMRHandlerForRunner(runner) {
|
762
|
+
return createHMRHandler(async (payload) => {
|
763
|
+
const hmrClient = runner.hmrClient;
|
764
|
+
if (!(!hmrClient || runner.isClosed()))
|
765
|
+
switch (payload.type) {
|
766
|
+
case "connected":
|
767
|
+
hmrClient.logger.debug("connected.");
|
768
|
+
break;
|
769
|
+
case "update":
|
770
|
+
await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(
|
771
|
+
payload.updates.map(async (update) => {
|
772
|
+
if (update.type === "js-update")
|
773
|
+
return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
|
774
|
+
hmrClient.logger.error("css hmr is not supported in runner mode.");
|
775
|
+
})
|
776
|
+
), await hmrClient.notifyListeners("vite:afterUpdate", payload);
|
777
|
+
break;
|
778
|
+
case "custom": {
|
779
|
+
await hmrClient.notifyListeners(payload.event, payload.data);
|
780
|
+
break;
|
781
|
+
}
|
782
|
+
case "full-reload": {
|
783
|
+
const { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(
|
784
|
+
runner,
|
785
|
+
getModulesByFile(runner, slash(triggeredBy))
|
786
|
+
) : findAllEntrypoints(runner);
|
787
|
+
if (!clearEntrypointUrls.size) break;
|
788
|
+
hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
|
789
|
+
for (const url of clearEntrypointUrls)
|
790
|
+
try {
|
791
|
+
await runner.import(url);
|
792
|
+
} catch (err) {
|
793
|
+
err.code !== ERR_OUTDATED_OPTIMIZED_DEP && hmrClient.logger.error(
|
794
|
+
`An error happened during full reload
|
795
|
+
${err.message}
|
796
|
+
${err.stack}`
|
797
|
+
);
|
798
|
+
}
|
799
|
+
break;
|
800
|
+
}
|
801
|
+
case "prune":
|
802
|
+
await hmrClient.notifyListeners("vite:beforePrune", payload), await hmrClient.prunePaths(payload.paths);
|
803
|
+
break;
|
804
|
+
case "error": {
|
805
|
+
await hmrClient.notifyListeners("vite:error", payload);
|
806
|
+
const err = payload.err;
|
807
|
+
hmrClient.logger.error(
|
808
|
+
`Internal Server Error
|
809
|
+
${err.message}
|
810
|
+
${err.stack}`
|
811
|
+
);
|
812
|
+
break;
|
813
|
+
}
|
814
|
+
case "ping":
|
815
|
+
break;
|
816
|
+
default:
|
817
|
+
return payload;
|
818
|
+
}
|
819
|
+
});
|
820
|
+
}
|
808
821
|
function getModulesByFile(runner, file) {
|
809
822
|
const nodes = runner.evaluatedModules.getModulesByFile(file);
|
810
823
|
return nodes ? [...nodes].map((node) => node.id) : [];
|
@@ -1078,7 +1091,7 @@ class ModuleRunner {
|
|
1078
1091
|
throw new Error(
|
1079
1092
|
"HMR is not supported by this runner transport, but `hmr` option was set to true"
|
1080
1093
|
);
|
1081
|
-
this.transport.connect(
|
1094
|
+
this.transport.connect(createHMRHandlerForRunner(this));
|
1082
1095
|
} else
|
1083
1096
|
this.transport.connect?.();
|
1084
1097
|
options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vite",
|
3
|
-
"version": "6.3.0
|
3
|
+
"version": "6.3.0",
|
4
4
|
"type": "module",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Evan You",
|
@@ -73,6 +73,7 @@
|
|
73
73
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
74
74
|
"dependencies": {
|
75
75
|
"esbuild": "^0.25.0",
|
76
|
+
"fdir": "^6.4.3",
|
76
77
|
"picomatch": "^4.0.2",
|
77
78
|
"postcss": "^8.5.3",
|
78
79
|
"rollup": "^4.34.9",
|
package/types/customEvent.d.ts
CHANGED