diff --git a/.changeset/curly-balloons-fry.md b/.changeset/curly-balloons-fry.md new file mode 100644 index 0000000000..709d88b7ce --- /dev/null +++ b/.changeset/curly-balloons-fry.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +Use a dynamic `import()` to load ESM-only `p-map` dependency to avoid issues on Node 20.18 and below diff --git a/contributors.yml b/contributors.yml index 08dd3651a3..746e4d4053 100644 --- a/contributors.yml +++ b/contributors.yml @@ -452,3 +452,4 @@ - zeromask1337 - zheng-chuang - zxTomw +- HeyyyNeo diff --git a/packages/react-router-dev/vite/plugin.ts b/packages/react-router-dev/vite/plugin.ts index 27a5a22cae..81cd7e0bb3 100644 --- a/packages/react-router-dev/vite/plugin.ts +++ b/packages/react-router-dev/vite/plugin.ts @@ -36,7 +36,6 @@ import pick from "lodash/pick"; import jsesc from "jsesc"; import colors from "picocolors"; import kebabCase from "lodash/kebabCase"; -import pMap from "p-map"; import * as Typegen from "../typegen"; import type { RouteManifestEntry, RouteManifest } from "../config/routes"; @@ -2815,7 +2814,8 @@ async function handlePrerender( concurrency = prerender.unstable_concurrency ?? 1; } - await pMap(build.prerender, prerenderSinglePath, { concurrency }); + const pMap = await import("p-map"); + await pMap.default(build.prerender, prerenderSinglePath, { concurrency }); } function getStaticPrerenderPaths(routes: DataRouteObject[]) {