fix(vite): source mapping locations (#3624)
Mappings were wrong for a few reasons: - Missing source map generation in one babel transform - setting `compact: false` causes vite to generate incorrect mappings in `vite:import-analysis` - stack traces need to be mapped by vite Fixes https://github.com/denoland/fresh/issues/3609
This commit is contained in:
@@ -154,6 +154,12 @@ export let setBuildCache: <State>(
|
||||
cache: BuildCache<State>,
|
||||
mode: "development" | "production",
|
||||
) => void;
|
||||
export let setErrorInterceptor: <State>(
|
||||
app: App<State>,
|
||||
fn: (err: unknown) => void,
|
||||
) => void;
|
||||
|
||||
const NOOP = () => {};
|
||||
|
||||
/**
|
||||
* Create an application instance that passes the incoming `Request`
|
||||
@@ -162,6 +168,7 @@ export let setBuildCache: <State>(
|
||||
export class App<State> {
|
||||
#getBuildCache: () => BuildCache<State> | null = () => null;
|
||||
#commands: Command<State>[] = [];
|
||||
#onError: (err: unknown) => void = NOOP;
|
||||
|
||||
static {
|
||||
getBuildCache = (app) => app.#getBuildCache();
|
||||
@@ -170,6 +177,9 @@ export class App<State> {
|
||||
app.config.mode = mode;
|
||||
app.#getBuildCache = () => cache;
|
||||
};
|
||||
setErrorInterceptor = (app, fn) => {
|
||||
app.#onError = fn;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,7 +442,7 @@ export class App<State> {
|
||||
try {
|
||||
if (handlers.length === 0) return await next();
|
||||
|
||||
const result = await runMiddlewares(handlers, ctx);
|
||||
const result = await runMiddlewares(handlers, ctx, this.#onError);
|
||||
if (!(result instanceof Response)) {
|
||||
throw new Error(
|
||||
`Expected a "Response" instance to be returned, but got: ${result}`,
|
||||
|
||||
Reference in New Issue
Block a user