vite 7.3.1 → 7.3.3

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.
@@ -6212,6 +6212,21 @@ const buildEsbuildPlugin = () => {
6212
6212
  }
6213
6213
  };
6214
6214
  };
6215
+ const destructuringBugRE = /^(safari|ios)(\d+)(?:\.(\d+))?$/;
6216
+ function needsDestructuringSupportedWorkaround(target) {
6217
+ if (!target) return false;
6218
+ const targets = Array.isArray(target) ? target : [target];
6219
+ for (const t$1 of targets) {
6220
+ const match = destructuringBugRE.exec(t$1);
6221
+ if (!match) continue;
6222
+ const major = Number(match[2]);
6223
+ if (major < 10) continue;
6224
+ if (major < 14) return true;
6225
+ if (major > 14) continue;
6226
+ if ((match[3] ? Number(match[3]) : 0) < (match[1] === "safari" ? 1 : 5)) return true;
6227
+ }
6228
+ return false;
6229
+ }
6215
6230
  function resolveEsbuildTranspileOptions(config$2, format$3) {
6216
6231
  const target = config$2.build.target;
6217
6232
  const minify = config$2.build.minify === "esbuild";
@@ -6225,6 +6240,7 @@ function resolveEsbuildTranspileOptions(config$2, format$3) {
6225
6240
  format: rollupToEsbuildFormatMap[format$3],
6226
6241
  supported: {
6227
6242
  ...defaultEsbuildSupported,
6243
+ ...needsDestructuringSupportedWorkaround(target) ? { destructuring: true } : null,
6228
6244
  ...esbuildOptions.supported
6229
6245
  }
6230
6246
  };
@@ -22552,7 +22568,7 @@ const ERR_DENIED_ID = "ERR_DENIED_ID";
22552
22568
  const debugLoad = createDebugger("vite:load");
22553
22569
  const debugTransform = createDebugger("vite:transform");
22554
22570
  const debugCache$1 = createDebugger("vite:cache");
22555
- function transformRequest(environment, url$3, options$1 = {}) {
22571
+ function transformRequest(environment, url$3, options$1) {
22556
22572
  if (environment._closing && environment.config.dev.recoverable) throwClosedServerError();
22557
22573
  const timestamp = monotonicDateNow();
22558
22574
  url$3 = removeTimestampQuery(url$3);
@@ -22616,7 +22632,7 @@ async function loadAndTransform(environment, id, url$3, options$1, timestamp, mo
22616
22632
  const { config: config$2, pluginContainer, logger } = environment;
22617
22633
  const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url$3, config$2.root) : "";
22618
22634
  const moduleGraph = environment.moduleGraph;
22619
- if (options$1.allowId && !options$1.allowId(id)) {
22635
+ if (!options$1.skipFsCheck && id[0] !== "\0" && isServerAccessDeniedForTransform(config$2, id)) {
22620
22636
  const err$2 = /* @__PURE__ */ new Error(`Denied ID ${id}`);
22621
22637
  err$2.code = ERR_DENIED_ID;
22622
22638
  err$2.id = id;
@@ -22628,7 +22644,7 @@ async function loadAndTransform(environment, id, url$3, options$1, timestamp, mo
22628
22644
  const loadResult = await pluginContainer.load(id);
22629
22645
  if (loadResult == null) {
22630
22646
  const file = cleanUrl(id);
22631
- if (environment.config.consumer === "server" || isFileLoadingAllowed(environment.getTopLevelConfig(), slash(file))) {
22647
+ if (options$1.skipFsCheck || isFileLoadingAllowed(environment.getTopLevelConfig(), slash(file))) {
22632
22648
  try {
22633
22649
  code = await fsp.readFile(file, "utf-8");
22634
22650
  debugLoad?.(`${timeFrom(loadStart)} [fs] ${prettyUrl}`);
@@ -24454,7 +24470,7 @@ const rawRE$1 = /[?&]raw\b/;
24454
24470
  const inlineRE$2 = /[?&]inline\b/;
24455
24471
  const svgRE = /\.svg\b/;
24456
24472
  function isServerAccessDeniedForTransform(config$2, id) {
24457
- if (rawRE$1.test(id) || urlRE$1.test(id) || inlineRE$2.test(id) || svgRE.test(id)) return checkLoadingAccess(config$2, id) !== "allowed";
24473
+ 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";
24458
24474
  return false;
24459
24475
  }
24460
24476
  /**
@@ -24500,31 +24516,35 @@ function transformMiddleware(server) {
24500
24516
  }
24501
24517
  const withoutQuery = cleanUrl(url$3);
24502
24518
  try {
24503
- if (withoutQuery.endsWith(".map")) if (environment.depsOptimizer?.isOptimizedDepUrl(url$3)) {
24504
- const sourcemapPath = url$3.startsWith(FS_PREFIX) ? fsPathFromId(url$3) : normalizePath(path.resolve(server.config.root, url$3.slice(1)));
24505
- try {
24506
- const map$1 = JSON.parse(await fsp.readFile(sourcemapPath, "utf-8"));
24507
- applySourcemapIgnoreList(map$1, sourcemapPath, server.config.server.sourcemapIgnoreList, server.config.logger);
24508
- return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
24509
- } catch {
24510
- const dummySourceMap = {
24511
- version: 3,
24512
- file: sourcemapPath.replace(/\.map$/, ""),
24513
- sources: [],
24514
- sourcesContent: [],
24515
- names: [],
24516
- mappings: ";;;;;;;;;"
24517
- };
24518
- return send(req$4, res, JSON.stringify(dummySourceMap), "json", {
24519
- cacheControl: "no-cache",
24520
- headers: server.config.server.headers
24521
- });
24519
+ if (withoutQuery.endsWith(".map")) {
24520
+ const depsOptimizer = environment.depsOptimizer;
24521
+ if (depsOptimizer?.isOptimizedDepUrl(url$3)) {
24522
+ const sourcemapPath = url$3.startsWith(FS_PREFIX) ? fsPathFromId(url$3) : normalizePath(path.resolve(server.config.root, url$3.slice(1)));
24523
+ if (!depsOptimizer.isOptimizedDepFile(sourcemapPath)) return next();
24524
+ try {
24525
+ const map$1 = JSON.parse(await fsp.readFile(sourcemapPath, "utf-8"));
24526
+ applySourcemapIgnoreList(map$1, sourcemapPath, server.config.server.sourcemapIgnoreList, server.config.logger);
24527
+ return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
24528
+ } catch {
24529
+ const dummySourceMap = {
24530
+ version: 3,
24531
+ file: sourcemapPath.replace(/\.map$/, ""),
24532
+ sources: [],
24533
+ sourcesContent: [],
24534
+ names: [],
24535
+ mappings: ";;;;;;;;;"
24536
+ };
24537
+ return send(req$4, res, JSON.stringify(dummySourceMap), "json", {
24538
+ cacheControl: "no-cache",
24539
+ headers: server.config.server.headers
24540
+ });
24541
+ }
24542
+ } else {
24543
+ const originalUrl = url$3.replace(/\.map($|\?)/, "$1");
24544
+ const map$1 = (await environment.moduleGraph.getModuleByUrl(originalUrl))?.transformResult?.map;
24545
+ if (map$1) return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
24546
+ else return next();
24522
24547
  }
24523
- } else {
24524
- const originalUrl = url$3.replace(/\.map($|\?)/, "$1");
24525
- const map$1 = (await environment.moduleGraph.getModuleByUrl(originalUrl))?.transformResult?.map;
24526
- if (map$1) return send(req$4, res, JSON.stringify(map$1), "json", { headers: server.config.server.headers });
24527
- else return next();
24528
24548
  }
24529
24549
  if (publicDirInRoot && url$3.startsWith(publicPath)) warnAboutExplicitPublicPathInUrl(url$3);
24530
24550
  if (req$4.headers["sec-fetch-dest"] === "script" || isJSRequest(url$3) || isImportRequest(url$3) || isCSSRequest(url$3) || isHTMLProxy(url$3)) {
@@ -24539,9 +24559,7 @@ function transformMiddleware(server) {
24539
24559
  return res.end();
24540
24560
  }
24541
24561
  }
24542
- const result = await environment.transformRequest(url$3, { allowId(id) {
24543
- return id[0] === "\0" || !isServerAccessDeniedForTransform(server.config, id);
24544
- } });
24562
+ const result = await environment.transformRequest(url$3);
24545
24563
  if (result) {
24546
24564
  const depsOptimizer = environment.depsOptimizer;
24547
24565
  const type = isDirectCSSRequest(url$3) ? "css" : "js";
@@ -24591,7 +24609,8 @@ function transformMiddleware(server) {
24591
24609
  if (e$1?.code === ERR_LOAD_URL) return next();
24592
24610
  if (e$1?.code === ERR_DENIED_ID) {
24593
24611
  const id = e$1.id;
24594
- const servingAccessResult = checkLoadingAccess(server.config, id);
24612
+ let servingAccessResult = checkLoadingAccess(server.config, cleanUrl(id));
24613
+ if (servingAccessResult === "allowed") servingAccessResult = checkLoadingAccess(server.config, id);
24595
24614
  if (servingAccessResult === "denied") {
24596
24615
  respondWithAccessDenied(id, server, res);
24597
24616
  return true;
@@ -26326,6 +26345,7 @@ function createServerHotChannel() {
26326
26345
  const innerEmitter = new EventEmitter();
26327
26346
  const outsideEmitter = new EventEmitter();
26328
26347
  return {
26348
+ skipFsCheck: true,
26329
26349
  send(payload) {
26330
26350
  outsideEmitter.emit("send", payload);
26331
26351
  },
@@ -34741,6 +34761,10 @@ var DevEnvironment = class extends BaseEnvironment {
34741
34761
  * @internal
34742
34762
  */
34743
34763
  _remoteRunnerOptions;
34764
+ /**
34765
+ * @internal
34766
+ */
34767
+ _skipFsCheck;
34744
34768
  get pluginContainer() {
34745
34769
  if (!this._pluginContainer) throw new Error(`${this.name} environment.pluginContainer called before initialized`);
34746
34770
  return this._pluginContainer;
@@ -34778,9 +34802,11 @@ var DevEnvironment = class extends BaseEnvironment {
34778
34802
  this.moduleGraph = new EnvironmentModuleGraph(name, (url$3) => this.pluginContainer.resolveId(url$3, void 0));
34779
34803
  this._crawlEndFinder = setupOnCrawlEnd();
34780
34804
  this._remoteRunnerOptions = context.remoteRunner ?? {};
34805
+ this._skipFsCheck = !!(context.transport && !(isWebSocketServer in context.transport) && context.transport.skipFsCheck);
34781
34806
  this.hot = context.transport ? isWebSocketServer in context.transport ? context.transport : normalizeHotChannel(context.transport, context.hot) : normalizeHotChannel({}, context.hot);
34782
34807
  this.hot.setInvokeHandler({
34783
34808
  fetchModule: (id, importer, options$2) => {
34809
+ if (context.disableFetchModule) throw new Error("fetchModule is disabled in this environment");
34784
34810
  return this.fetchModule(id, importer, options$2);
34785
34811
  },
34786
34812
  getBuiltins: async () => {
@@ -34831,12 +34857,12 @@ var DevEnvironment = class extends BaseEnvironment {
34831
34857
  async reloadModule(module$1) {
34832
34858
  if (this.config.server.hmr !== false && module$1.file) updateModules(this, module$1.file, [module$1], monotonicDateNow());
34833
34859
  }
34834
- transformRequest(url$3, options$1) {
34835
- return transformRequest(this, url$3, options$1);
34860
+ transformRequest(url$3) {
34861
+ return transformRequest(this, url$3, { skipFsCheck: this._skipFsCheck });
34836
34862
  }
34837
34863
  async warmupRequest(url$3) {
34838
34864
  try {
34839
- await this.transformRequest(url$3);
34865
+ await transformRequest(this, url$3, { skipFsCheck: true });
34840
34866
  } catch (e$1) {
34841
34867
  if (e$1?.code === ERR_OUTDATED_OPTIMIZED_DEP || e$1?.code === ERR_CLOSED_SERVER) return;
34842
34868
  this.logger.error(buildErrorMessage(e$1, [`Pre-transform error: ${e$1.message}`], false), {
@@ -35218,7 +35244,8 @@ function defineConfig(config$2) {
35218
35244
  function defaultCreateClientDevEnvironment(name, config$2, context) {
35219
35245
  return new DevEnvironment(name, config$2, {
35220
35246
  hot: true,
35221
- transport: context.ws
35247
+ transport: context.ws,
35248
+ disableFetchModule: true
35222
35249
  });
35223
35250
  }
35224
35251
  function defaultCreateDevEnvironment(name, config$2) {
@@ -956,7 +956,6 @@ interface TransformOptions {
956
956
  */
957
957
  ssr?: boolean;
958
958
  }
959
- interface TransformOptionsInternal {}
960
959
  //#endregion
961
960
  //#region src/node/server/moduleGraph.d.ts
962
961
  declare class EnvironmentModuleNode {
@@ -1121,6 +1120,11 @@ interface HotChannelClient {
1121
1120
  }
1122
1121
  type HotChannelListener<T$1 extends string = string> = (data: InferCustomEventPayload<T$1>, client: HotChannelClient) => void;
1123
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;
1124
1128
  /**
1125
1129
  * Broadcast events to all clients
1126
1130
  */
@@ -1565,7 +1569,7 @@ declare class DevEnvironment extends BaseEnvironment {
1565
1569
  listen(server: ViteDevServer): Promise<void>;
1566
1570
  fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<moduleRunner_FetchResult>;
1567
1571
  reloadModule(module: EnvironmentModuleNode): Promise<void>;
1568
- transformRequest(url: string, options?: TransformOptionsInternal): Promise<TransformResult | null>;
1572
+ transformRequest(url: string): Promise<TransformResult | null>;
1569
1573
  warmupRequest(url: string): Promise<void>;
1570
1574
  close(): Promise<void>;
1571
1575
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "7.3.1",
3
+ "version": "7.3.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",