@timber-js/app 0.2.0-alpha.85 → 0.2.0-alpha.86

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/index.js CHANGED
@@ -445,6 +445,19 @@ function rewriteStacktrace(stack, moduleGraph) {
445
445
  };
446
446
  }
447
447
  /**
448
+ * Source-map an error's stack trace using the Vite dev server's module graph.
449
+ *
450
+ * Exported so that the fallback error renderer (fallback-error.ts) can
451
+ * source-map errors before rendering the dev error page. Without this,
452
+ * the dev error page shows transpiled positions (e.g. page.tsx:1:1 instead
453
+ * of page.tsx:4:9).
454
+ *
455
+ * See TIM-811.
456
+ */
457
+ function fixErrorStacktrace(server, error, phase) {
458
+ fixStacktraceForEnvironment(server, error, phase ?? classifyErrorPhase(error, server.config.root));
459
+ }
460
+ /**
448
461
  * Send an error to Vite's browser overlay and log it to stderr.
449
462
  *
450
463
  * Uses `server.ssrFixStacktrace()` to map stack traces back to source,
@@ -1321,6 +1334,10 @@ function createTimberMiddleware(server, projectRoot) {
1321
1334
  if (typeof setHandler === "function") setHandler((error, _phase, debugComponents) => {
1322
1335
  sendErrorToOverlay(server, error, classifyErrorPhase(error, projectRoot), projectRoot, debugComponents);
1323
1336
  });
1337
+ const setSourceMap = rscModule.setDevSourceMapHandler;
1338
+ if (typeof setSourceMap === "function") setSourceMap((error) => {
1339
+ fixErrorStacktrace(server, error);
1340
+ });
1324
1341
  } catch (error) {
1325
1342
  if (error instanceof Error) {
1326
1343
  addTimberContext(error);