vite 7.3.0 → 7.3.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/dist/node/chunks/config.js +54 -41
- package/dist/node/index.d.ts +14 -2
- package/package.json +1 -1
|
@@ -8918,7 +8918,8 @@ function optimizedDepsPlugin() {
|
|
|
8918
8918
|
if (this.environment.depsOptimizer?.isOptimizedDepFile(id)) return id;
|
|
8919
8919
|
},
|
|
8920
8920
|
async load(id) {
|
|
8921
|
-
const
|
|
8921
|
+
const environment = this.environment;
|
|
8922
|
+
const depsOptimizer = environment.depsOptimizer;
|
|
8922
8923
|
if (depsOptimizer?.isOptimizedDepFile(id)) {
|
|
8923
8924
|
const metadata = depsOptimizer.metadata;
|
|
8924
8925
|
const file = cleanUrl(id);
|
|
@@ -8926,7 +8927,7 @@ function optimizedDepsPlugin() {
|
|
|
8926
8927
|
const browserHash = versionMatch ? versionMatch[1].split("=")[1] : void 0;
|
|
8927
8928
|
const info = optimizedDepInfoFromFile(metadata, file);
|
|
8928
8929
|
if (info) {
|
|
8929
|
-
if (browserHash && info.browserHash !== browserHash) throwOutdatedRequest(id);
|
|
8930
|
+
if (browserHash && info.browserHash !== browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
|
8930
8931
|
try {
|
|
8931
8932
|
await info.processing;
|
|
8932
8933
|
} catch {
|
|
@@ -8935,14 +8936,14 @@ function optimizedDepsPlugin() {
|
|
|
8935
8936
|
const newMetadata = depsOptimizer.metadata;
|
|
8936
8937
|
if (metadata !== newMetadata) {
|
|
8937
8938
|
const currentInfo = optimizedDepInfoFromFile(newMetadata, file);
|
|
8938
|
-
if (info.browserHash !== currentInfo?.browserHash) throwOutdatedRequest(id);
|
|
8939
|
+
if (info.browserHash !== currentInfo?.browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
|
8939
8940
|
}
|
|
8940
8941
|
}
|
|
8941
8942
|
debug$15?.(`load ${import_picocolors$29.default.cyan(file)}`);
|
|
8942
8943
|
try {
|
|
8943
8944
|
return await fsp.readFile(file, "utf-8");
|
|
8944
8945
|
} catch {
|
|
8945
|
-
if (browserHash) throwOutdatedRequest(id);
|
|
8946
|
+
if (browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
|
8946
8947
|
throwFileNotFoundInOptimizedDep(id);
|
|
8947
8948
|
}
|
|
8948
8949
|
}
|
|
@@ -22551,7 +22552,7 @@ const ERR_DENIED_ID = "ERR_DENIED_ID";
|
|
|
22551
22552
|
const debugLoad = createDebugger("vite:load");
|
|
22552
22553
|
const debugTransform = createDebugger("vite:transform");
|
|
22553
22554
|
const debugCache$1 = createDebugger("vite:cache");
|
|
22554
|
-
function transformRequest(environment, url$3, options$1
|
|
22555
|
+
function transformRequest(environment, url$3, options$1) {
|
|
22555
22556
|
if (environment._closing && environment.config.dev.recoverable) throwClosedServerError();
|
|
22556
22557
|
const timestamp = monotonicDateNow();
|
|
22557
22558
|
url$3 = removeTimestampQuery(url$3);
|
|
@@ -22615,7 +22616,7 @@ async function loadAndTransform(environment, id, url$3, options$1, timestamp, mo
|
|
|
22615
22616
|
const { config: config$2, pluginContainer, logger } = environment;
|
|
22616
22617
|
const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url$3, config$2.root) : "";
|
|
22617
22618
|
const moduleGraph = environment.moduleGraph;
|
|
22618
|
-
if (options$1.
|
|
22619
|
+
if (!options$1.skipFsCheck && id[0] !== "\0" && isServerAccessDeniedForTransform(config$2, id)) {
|
|
22619
22620
|
const err$2 = /* @__PURE__ */ new Error(`Denied ID ${id}`);
|
|
22620
22621
|
err$2.code = ERR_DENIED_ID;
|
|
22621
22622
|
err$2.id = id;
|
|
@@ -22627,7 +22628,7 @@ async function loadAndTransform(environment, id, url$3, options$1, timestamp, mo
|
|
|
22627
22628
|
const loadResult = await pluginContainer.load(id);
|
|
22628
22629
|
if (loadResult == null) {
|
|
22629
22630
|
const file = cleanUrl(id);
|
|
22630
|
-
if (
|
|
22631
|
+
if (options$1.skipFsCheck || isFileLoadingAllowed(environment.getTopLevelConfig(), slash(file))) {
|
|
22631
22632
|
try {
|
|
22632
22633
|
code = await fsp.readFile(file, "utf-8");
|
|
22633
22634
|
debugLoad?.(`${timeFrom(loadStart)} [fs] ${prettyUrl}`);
|
|
@@ -24453,7 +24454,7 @@ const rawRE$1 = /[?&]raw\b/;
|
|
|
24453
24454
|
const inlineRE$2 = /[?&]inline\b/;
|
|
24454
24455
|
const svgRE = /\.svg\b/;
|
|
24455
24456
|
function isServerAccessDeniedForTransform(config$2, id) {
|
|
24456
|
-
if (rawRE$1.test(id) || urlRE$1.test(id) || inlineRE$2.test(id) || svgRE.test(id)) return checkLoadingAccess(config$2, id) !== "allowed";
|
|
24457
|
+
if (rawRE$1.test(id) || urlRE$1.test(id) || inlineRE$2.test(id) || svgRE.test(id)) return checkLoadingAccess(config$2, cleanUrl(id)) !== "allowed" || checkLoadingAccess(config$2, id) !== "allowed";
|
|
24457
24458
|
return false;
|
|
24458
24459
|
}
|
|
24459
24460
|
/**
|
|
@@ -24499,31 +24500,35 @@ function transformMiddleware(server) {
|
|
|
24499
24500
|
}
|
|
24500
24501
|
const withoutQuery = cleanUrl(url$3);
|
|
24501
24502
|
try {
|
|
24502
|
-
if (withoutQuery.endsWith(".map"))
|
|
24503
|
-
const
|
|
24504
|
-
|
|
24505
|
-
const
|
|
24506
|
-
|
|
24507
|
-
|
|
24508
|
-
|
|
24509
|
-
|
|
24510
|
-
|
|
24511
|
-
|
|
24512
|
-
|
|
24513
|
-
|
|
24514
|
-
|
|
24515
|
-
|
|
24516
|
-
|
|
24517
|
-
|
|
24518
|
-
|
|
24519
|
-
|
|
24520
|
-
|
|
24503
|
+
if (withoutQuery.endsWith(".map")) {
|
|
24504
|
+
const depsOptimizer = environment.depsOptimizer;
|
|
24505
|
+
if (depsOptimizer?.isOptimizedDepUrl(url$3)) {
|
|
24506
|
+
const sourcemapPath = url$3.startsWith(FS_PREFIX) ? fsPathFromId(url$3) : normalizePath(path.resolve(server.config.root, url$3.slice(1)));
|
|
24507
|
+
if (!depsOptimizer.isOptimizedDepFile(sourcemapPath)) return next();
|
|
24508
|
+
try {
|
|
24509
|
+
const map$1 = JSON.parse(await fsp.readFile(sourcemapPath, "utf-8"));
|
|
24510
|
+
applySourcemapIgnoreList(map$1, sourcemapPath, server.config.server.sourcemapIgnoreList, server.config.logger);
|
|
24511
|
+
return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
|
|
24512
|
+
} catch {
|
|
24513
|
+
const dummySourceMap = {
|
|
24514
|
+
version: 3,
|
|
24515
|
+
file: sourcemapPath.replace(/\.map$/, ""),
|
|
24516
|
+
sources: [],
|
|
24517
|
+
sourcesContent: [],
|
|
24518
|
+
names: [],
|
|
24519
|
+
mappings: ";;;;;;;;;"
|
|
24520
|
+
};
|
|
24521
|
+
return send(req$4, res, JSON.stringify(dummySourceMap), "json", {
|
|
24522
|
+
cacheControl: "no-cache",
|
|
24523
|
+
headers: server.config.server.headers
|
|
24524
|
+
});
|
|
24525
|
+
}
|
|
24526
|
+
} else {
|
|
24527
|
+
const originalUrl = url$3.replace(/\.map($|\?)/, "$1");
|
|
24528
|
+
const map$1 = (await environment.moduleGraph.getModuleByUrl(originalUrl))?.transformResult?.map;
|
|
24529
|
+
if (map$1) return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
|
|
24530
|
+
else return next();
|
|
24521
24531
|
}
|
|
24522
|
-
} else {
|
|
24523
|
-
const originalUrl = url$3.replace(/\.map($|\?)/, "$1");
|
|
24524
|
-
const map$1 = (await environment.moduleGraph.getModuleByUrl(originalUrl))?.transformResult?.map;
|
|
24525
|
-
if (map$1) return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
|
|
24526
|
-
else return next();
|
|
24527
24532
|
}
|
|
24528
24533
|
if (publicDirInRoot && url$3.startsWith(publicPath)) warnAboutExplicitPublicPathInUrl(url$3);
|
|
24529
24534
|
if (req$4.headers["sec-fetch-dest"] === "script" || isJSRequest(url$3) || isImportRequest(url$3) || isCSSRequest(url$3) || isHTMLProxy(url$3)) {
|
|
@@ -24538,9 +24543,7 @@ function transformMiddleware(server) {
|
|
|
24538
24543
|
return res.end();
|
|
24539
24544
|
}
|
|
24540
24545
|
}
|
|
24541
|
-
const result = await environment.transformRequest(url$3
|
|
24542
|
-
return id[0] === "\0" || !isServerAccessDeniedForTransform(server.config, id);
|
|
24543
|
-
} });
|
|
24546
|
+
const result = await environment.transformRequest(url$3);
|
|
24544
24547
|
if (result) {
|
|
24545
24548
|
const depsOptimizer = environment.depsOptimizer;
|
|
24546
24549
|
const type = isDirectCSSRequest(url$3) ? "css" : "js";
|
|
@@ -24590,7 +24593,8 @@ function transformMiddleware(server) {
|
|
|
24590
24593
|
if (e$1?.code === ERR_LOAD_URL) return next();
|
|
24591
24594
|
if (e$1?.code === ERR_DENIED_ID) {
|
|
24592
24595
|
const id = e$1.id;
|
|
24593
|
-
|
|
24596
|
+
let servingAccessResult = checkLoadingAccess(server.config, cleanUrl(id));
|
|
24597
|
+
if (servingAccessResult === "allowed") servingAccessResult = checkLoadingAccess(server.config, id);
|
|
24594
24598
|
if (servingAccessResult === "denied") {
|
|
24595
24599
|
respondWithAccessDenied(id, server, res);
|
|
24596
24600
|
return true;
|
|
@@ -26325,6 +26329,7 @@ function createServerHotChannel() {
|
|
|
26325
26329
|
const innerEmitter = new EventEmitter();
|
|
26326
26330
|
const outsideEmitter = new EventEmitter();
|
|
26327
26331
|
return {
|
|
26332
|
+
skipFsCheck: true,
|
|
26328
26333
|
send(payload) {
|
|
26329
26334
|
outsideEmitter.emit("send", payload);
|
|
26330
26335
|
},
|
|
@@ -34740,6 +34745,10 @@ var DevEnvironment = class extends BaseEnvironment {
|
|
|
34740
34745
|
* @internal
|
|
34741
34746
|
*/
|
|
34742
34747
|
_remoteRunnerOptions;
|
|
34748
|
+
/**
|
|
34749
|
+
* @internal
|
|
34750
|
+
*/
|
|
34751
|
+
_skipFsCheck;
|
|
34743
34752
|
get pluginContainer() {
|
|
34744
34753
|
if (!this._pluginContainer) throw new Error(`${this.name} environment.pluginContainer called before initialized`);
|
|
34745
34754
|
return this._pluginContainer;
|
|
@@ -34777,9 +34786,11 @@ var DevEnvironment = class extends BaseEnvironment {
|
|
|
34777
34786
|
this.moduleGraph = new EnvironmentModuleGraph(name, (url$3) => this.pluginContainer.resolveId(url$3, void 0));
|
|
34778
34787
|
this._crawlEndFinder = setupOnCrawlEnd();
|
|
34779
34788
|
this._remoteRunnerOptions = context.remoteRunner ?? {};
|
|
34789
|
+
this._skipFsCheck = !!(context.transport && !(isWebSocketServer in context.transport) && context.transport.skipFsCheck);
|
|
34780
34790
|
this.hot = context.transport ? isWebSocketServer in context.transport ? context.transport : normalizeHotChannel(context.transport, context.hot) : normalizeHotChannel({}, context.hot);
|
|
34781
34791
|
this.hot.setInvokeHandler({
|
|
34782
34792
|
fetchModule: (id, importer, options$2) => {
|
|
34793
|
+
if (context.disableFetchModule) throw new Error("fetchModule is disabled in this environment");
|
|
34783
34794
|
return this.fetchModule(id, importer, options$2);
|
|
34784
34795
|
},
|
|
34785
34796
|
getBuiltins: async () => {
|
|
@@ -34830,12 +34841,12 @@ var DevEnvironment = class extends BaseEnvironment {
|
|
|
34830
34841
|
async reloadModule(module$1) {
|
|
34831
34842
|
if (this.config.server.hmr !== false && module$1.file) updateModules(this, module$1.file, [module$1], monotonicDateNow());
|
|
34832
34843
|
}
|
|
34833
|
-
transformRequest(url$3
|
|
34834
|
-
return transformRequest(this, url$3,
|
|
34844
|
+
transformRequest(url$3) {
|
|
34845
|
+
return transformRequest(this, url$3, { skipFsCheck: this._skipFsCheck });
|
|
34835
34846
|
}
|
|
34836
34847
|
async warmupRequest(url$3) {
|
|
34837
34848
|
try {
|
|
34838
|
-
await
|
|
34849
|
+
await transformRequest(this, url$3, { skipFsCheck: true });
|
|
34839
34850
|
} catch (e$1) {
|
|
34840
34851
|
if (e$1?.code === ERR_OUTDATED_OPTIMIZED_DEP || e$1?.code === ERR_CLOSED_SERVER) return;
|
|
34841
34852
|
this.logger.error(buildErrorMessage(e$1, [`Pre-transform error: ${e$1.message}`], false), {
|
|
@@ -35217,7 +35228,8 @@ function defineConfig(config$2) {
|
|
|
35217
35228
|
function defaultCreateClientDevEnvironment(name, config$2, context) {
|
|
35218
35229
|
return new DevEnvironment(name, config$2, {
|
|
35219
35230
|
hot: true,
|
|
35220
|
-
transport: context.ws
|
|
35231
|
+
transport: context.ws,
|
|
35232
|
+
disableFetchModule: true
|
|
35221
35233
|
});
|
|
35222
35234
|
}
|
|
35223
35235
|
function defaultCreateDevEnvironment(name, config$2) {
|
|
@@ -35284,7 +35296,8 @@ const configDefaults = Object.freeze({
|
|
|
35284
35296
|
extensions: [],
|
|
35285
35297
|
disabled: "build",
|
|
35286
35298
|
holdUntilCrawlEnd: true,
|
|
35287
|
-
force: false
|
|
35299
|
+
force: false,
|
|
35300
|
+
ignoreOutdatedRequests: false
|
|
35288
35301
|
},
|
|
35289
35302
|
ssr: ssrConfigDefaults,
|
|
35290
35303
|
environments: {},
|
package/dist/node/index.d.ts
CHANGED
|
@@ -847,6 +847,14 @@ interface DepOptimizationConfig {
|
|
|
847
847
|
* @experimental
|
|
848
848
|
*/
|
|
849
849
|
holdUntilCrawlEnd?: boolean;
|
|
850
|
+
/**
|
|
851
|
+
* When enabled, Vite will not throw an error when an outdated optimized
|
|
852
|
+
* dependency is requested. Enabling this option may cause a single module
|
|
853
|
+
* to have a multiple reference.
|
|
854
|
+
* @default false
|
|
855
|
+
* @experimental
|
|
856
|
+
*/
|
|
857
|
+
ignoreOutdatedRequests?: boolean;
|
|
850
858
|
}
|
|
851
859
|
type DepOptimizationOptions = DepOptimizationConfig & {
|
|
852
860
|
/**
|
|
@@ -948,7 +956,6 @@ interface TransformOptions {
|
|
|
948
956
|
*/
|
|
949
957
|
ssr?: boolean;
|
|
950
958
|
}
|
|
951
|
-
interface TransformOptionsInternal {}
|
|
952
959
|
//#endregion
|
|
953
960
|
//#region src/node/server/moduleGraph.d.ts
|
|
954
961
|
declare class EnvironmentModuleNode {
|
|
@@ -1113,6 +1120,11 @@ interface HotChannelClient {
|
|
|
1113
1120
|
}
|
|
1114
1121
|
type HotChannelListener<T$1 extends string = string> = (data: InferCustomEventPayload<T$1>, client: HotChannelClient) => void;
|
|
1115
1122
|
interface HotChannel<Api = any> {
|
|
1123
|
+
/**
|
|
1124
|
+
* When true, the fs access check is skipped in fetchModule.
|
|
1125
|
+
* Set this for transports that is not exposed over the network.
|
|
1126
|
+
*/
|
|
1127
|
+
skipFsCheck?: boolean;
|
|
1116
1128
|
/**
|
|
1117
1129
|
* Broadcast events to all clients
|
|
1118
1130
|
*/
|
|
@@ -1557,7 +1569,7 @@ declare class DevEnvironment extends BaseEnvironment {
|
|
|
1557
1569
|
listen(server: ViteDevServer): Promise<void>;
|
|
1558
1570
|
fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<moduleRunner_FetchResult>;
|
|
1559
1571
|
reloadModule(module: EnvironmentModuleNode): Promise<void>;
|
|
1560
|
-
transformRequest(url: string
|
|
1572
|
+
transformRequest(url: string): Promise<TransformResult | null>;
|
|
1561
1573
|
warmupRequest(url: string): Promise<void>;
|
|
1562
1574
|
close(): Promise<void>;
|
|
1563
1575
|
/**
|