diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb86674c..583bfc061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Bug Fixes +- Fix support for ESM config files with Node 23, #2752. - Fix type errors when using `"module": "ESNext"` and importing TypeDoc, #2747. ## v0.26.10 (2024-10-16) diff --git a/src/lib/utils/options/readers/typedoc.ts b/src/lib/utils/options/readers/typedoc.ts index 0ec0cff7b..7d59e1f17 100644 --- a/src/lib/utils/options/readers/typedoc.ts +++ b/src/lib/utils/options/readers/typedoc.ts @@ -84,19 +84,10 @@ export class TypeDocReader implements OptionsReader { } } else { try { - try { - // eslint-disable-next-line @typescript-eslint/no-require-imports - fileContent = await require(file); - } catch (error: any) { - if (error?.code === "ERR_REQUIRE_ESM") { - // On Windows, we need to ensure this path is a file path. - // Or we'll get ERR_UNSUPPORTED_ESM_URL_SCHEME - const esmPath = pathToFileURL(file).toString(); - fileContent = await (await import(esmPath)).default; - } else { - throw error; - } - } + // On Windows, we need to ensure this path is a file path. + // Or we'll get ERR_UNSUPPORTED_ESM_URL_SCHEME + const esmPath = pathToFileURL(file).toString(); + fileContent = await (await import(esmPath)).default; } catch (error) { logger.error( logger.i18n.failed_read_options_file_0(nicePath(file)),