Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ const esbuildOptions: webAssemblyEsbuild.BuildOptions = {
}),
};

const AsyncFunction = async function () {}.constructor;
const AsyncFunction = async function() { }.constructor;

function customPrepareStackTrace(_error: Error, callSites: CallSite[]) {
return callSites.at(2)!.getFileName();
return callSites[2] && callSites[2].getFileName();
}

function getCallerUrl() {
Expand All @@ -120,12 +120,16 @@ function getCallerUrl() {
Error.stackTraceLimit = Infinity;
Error.prepareStackTrace = customPrepareStackTrace;

const callerUrl = new URL(new Error().stack!);
const callerFile = new Error().stack;

Error.stackTraceLimit = stackTraceLimit;
Error.prepareStackTrace = prepareStackTrace;

return callerUrl;
if (callerFile) {
return new URL(callerFile);
} else {
return new URL(import.meta.url);
}
}

async function buildAndEvaluate(
Expand Down