From dfd94ca4572673c41c6272479a373ff2c796022d Mon Sep 17 00:00:00 2001 From: Luke Rucker Date: Wed, 5 Feb 2025 17:06:03 -0500 Subject: [PATCH] Dynamically import p-map --- src/eval_utils/run.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/eval_utils/run.ts b/src/eval_utils/run.ts index 608ed3f6..45fd3c1a 100644 --- a/src/eval_utils/run.ts +++ b/src/eval_utils/run.ts @@ -10,7 +10,6 @@ import cliProgress from "cli-progress"; import { Humanloop, HumanloopClient } from "index"; import _ from "lodash"; -import pMap from "p-map"; import { BooleanEvaluatorStatsResponse, @@ -484,6 +483,10 @@ export async function runEval( ); const totalDatapoints = hlDataset.datapoints!.length; progressBar.start(totalDatapoints, 0); + + // p-map is esm only since v5. Since we're targeting cjs, we need to + // import it dynamically, so it works for both cjs and esm consumers on node < 22. + const { default: pMap } = await import("p-map"); await pMap( hlDataset.datapoints!, async (datapoint) => {