Skip to content

Commit aef0301

Browse files
authored
fix: Ensure stack-trace works w/ CJS (#116)
1 parent 498072d commit aef0301

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/prerender.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { promises as fs } from "node:fs";
44
import MagicString from "magic-string";
55
import { parse as htmlParse } from "node-html-parser";
66
import { SourceMapConsumer } from "source-map";
7-
import { parse as StackTraceParse } from "stack-trace";
87
import { codeFrameColumns } from "@babel/code-frame";
98

109
import type { Plugin, ResolvedConfig } from "vite";
@@ -250,8 +249,8 @@ export function PrerenderPlugin({
250249
);
251250
prerender = m.prerender;
252251
} catch (e) {
253-
const stack = StackTraceParse(e as Error).find(s =>
254-
s.getFileName().includes(tmpDir),
252+
const stack = await import("stack-trace").then(({ parse }) =>
253+
parse(e as Error).find(s => s.getFileName().includes(tmpDir)),
255254
);
256255

257256
const isReferenceError = e instanceof ReferenceError;

0 commit comments

Comments
 (0)