Skip to content

Commit 23f29f3

Browse files
committed
Fix ESM config files on Node 23
Resolves #2752
1 parent 0e1afae commit 23f29f3

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Bug Fixes
44

5+
- Fix support for ESM config files with Node 23, #2752.
56
- Fix type errors when using `"module": "ESNext"` and importing TypeDoc, #2747.
67

78
## v0.26.10 (2024-10-16)

src/lib/utils/options/readers/typedoc.ts

+4-13
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,10 @@ export class TypeDocReader implements OptionsReader {
8484
}
8585
} else {
8686
try {
87-
try {
88-
// eslint-disable-next-line @typescript-eslint/no-require-imports
89-
fileContent = await require(file);
90-
} catch (error: any) {
91-
if (error?.code === "ERR_REQUIRE_ESM") {
92-
// On Windows, we need to ensure this path is a file path.
93-
// Or we'll get ERR_UNSUPPORTED_ESM_URL_SCHEME
94-
const esmPath = pathToFileURL(file).toString();
95-
fileContent = await (await import(esmPath)).default;
96-
} else {
97-
throw error;
98-
}
99-
}
87+
// On Windows, we need to ensure this path is a file path.
88+
// Or we'll get ERR_UNSUPPORTED_ESM_URL_SCHEME
89+
const esmPath = pathToFileURL(file).toString();
90+
fileContent = await (await import(esmPath)).default;
10091
} catch (error) {
10192
logger.error(
10293
logger.i18n.failed_read_options_file_0(nicePath(file)),

0 commit comments

Comments
 (0)