Skip to content

Commit

Permalink
Fix ESM config files on Node 23
Browse files Browse the repository at this point in the history
Resolves #2752
  • Loading branch information
Gerrit0 committed Oct 18, 2024
1 parent 0e1afae commit 23f29f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 4 additions & 13 deletions src/lib/utils/options/readers/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 23f29f3

Please sign in to comment.