Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Running typedoc fails for ESM config with Node v23.0.0 #2752

Closed
bnichell opened this issue Oct 18, 2024 · 0 comments
Closed

Running typedoc fails for ESM config with Node v23.0.0 #2752

bnichell opened this issue Oct 18, 2024 · 0 comments
Labels
bug Functionality does not match expectation
Milestone

Comments

@bnichell
Copy link

bnichell commented Oct 18, 2024

Search terms

typedoc.config.js typedoc.config.mjs ECMAScript modules

Expected Behavior

The existing ESM typedoc configuration still functions correctly with Node v23.0.0

Actual Behavior

Following error is raised, when running typedoc:

[error] Unknown option '__esModule' You may have meant:
        out
        json
        theme
        readme
        sort
        help
        locales
        exclude
        emit
        name
        version
[error] Unknown option 'default' You may have meant:
        out
        emit
        help
        defaultCategory
        watch

Steps to reproduce the bug

Prerequisite:

  • use a ESM typescript configuration, e.g.:
    /** @type {Partial<import('typedoc').TypeDocOptions>} */
    const config = {
        entryPoints: ["./src/index.ts", "./src/secondary-entry.ts"],
        out: "doc",
    };
    
    export default config;
  • use node v23.0.0
  • package.json requirements, mentioned in the node docs1

When running typedoc, the above-mentioned error is raised, because following statement returns an object { __esModule: true, default: { /* typedoc config */ } }1:

fileContent = await require(file);

Following Workaround can be used to avoid the issue:

/** @type {Partial<import('typedoc').TypeDocOptions>} */
const config = {
    entryPoints: ["./src/index.ts", "./src/secondary-entry.ts"],
    out: "doc",
};
    
export default config;
export { config as 'module.exports' } // dummy CommonJS export

Environment

  • Typedoc version: 0.26.8
  • TypeScript version: 5.6.3
  • Node.js version: 23.0.0
  • OS: Ubuntu 22.04

Footnotes

  1. https://nodejs.org/docs/latest/api/modules.html#loading-ecmascript-modules-using-require 2

@bnichell bnichell added the bug Functionality does not match expectation label Oct 18, 2024
@Gerrit0 Gerrit0 added this to the v0.26.11 milestone Oct 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants