Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion scripts/eval-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,12 @@ function propagateInheritedBraintrustState(braintrust: BraintrustModule) {

async function loadFiles(files: string[]): Promise<unknown[]> {
const modules: unknown[] = [];
const forceEsm = envFlag("BT_EVAL_FORCE_ESM");
for (const file of files) {
const fileUrl = pathToFileURL(file).href;
const preferRequire =
file.endsWith(".ts") || file.endsWith(".tsx") || file.endsWith(".cjs");
!forceEsm &&
(file.endsWith(".ts") || file.endsWith(".tsx") || file.endsWith(".cjs"));

if (preferRequire) {
try {
Expand Down Expand Up @@ -799,6 +801,9 @@ async function loadFiles(files: string[]): Promise<unknown[]> {
}

function shouldTryRequire(file: string, err: unknown): boolean {
if (envFlag("BT_EVAL_FORCE_ESM")) {
return false;
}
if (process.env.BT_EVAL_CJS === "1" || file.endsWith(".cjs")) {
return true;
}
Expand Down
Loading
Loading