Skip to content

Commit ce40434

Browse files
authored
Fix Node 20.18 ESM issue (#14624)
1 parent 716be85 commit ce40434

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
Import ESM package `pkg-types` with a dynamic import to avoid issues on Node 20.18 and below

.github/workflows/integration-full.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: ./.github/workflows/shared-integration.yml
3232
with:
3333
os: "ubuntu-latest"
34-
node_version: "[20, 22]"
34+
node_version: "[20.18, 22]"
3535
browser: '["chromium", "firefox"]'
3636

3737
integration-windows:
@@ -49,5 +49,5 @@ jobs:
4949
uses: ./.github/workflows/shared-integration.yml
5050
with:
5151
os: "macos-latest"
52-
node_version: "[20, 22]"
52+
node_version: "[20.18, 22]"
5353
browser: '["webkit"]'

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
node:
29-
- 20
29+
- 20.18
3030
- 22
3131

3232
runs-on: ubuntu-latest

packages/react-router-dev/cli/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { readFile, writeFile } from "node:fs/promises";
33
import * as path from "node:path";
44
import exitHook from "exit-hook";
55
import colors from "picocolors";
6-
import { readPackageJSON } from "pkg-types";
76
// Workaround for "ERR_REQUIRE_CYCLE_MODULE" in Node 22.10.0+
87
import "react-router";
98

@@ -138,6 +137,8 @@ export async function generateEntry(
138137
return;
139138
}
140139

140+
// TODO(v8): Remove - only required for Node 20.18 and below
141+
let { readPackageJSON } = await import("pkg-types");
141142
let pkgJson = await readPackageJSON(rootDirectory);
142143
let deps = pkgJson.dependencies ?? {};
143144

packages/react-router-dev/config/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import chokidar, {
88
type EmitArgs as ChokidarEmitArgs,
99
} from "chokidar";
1010
import colors from "picocolors";
11-
import { readPackageJSON, sortPackage, updatePackage } from "pkg-types";
1211
import pick from "lodash/pick";
1312
import omit from "lodash/omit";
1413
import cloneDeep from "lodash/cloneDeep";
@@ -933,6 +932,10 @@ export async function resolveEntryFiles({
933932
);
934933
}
935934

935+
// TODO(v8): Remove - only required for Node 20.18 and below
936+
let { readPackageJSON, sortPackage, updatePackage } = await import(
937+
"pkg-types"
938+
);
936939
let packageJsonDirectory = Path.dirname(packageJsonPath);
937940
let pkgJson = await readPackageJSON(packageJsonDirectory);
938941
let deps = pkgJson.dependencies ?? {};

0 commit comments

Comments
 (0)