Unable to setup typedoc in a nx monorepo

See original GitHub issue

Search terms

monorepo, nx

Question

Hey, I am having a similiar setup as in https://github.com/TypeStrong/typedoc/issues/2061 - a pretty large project as nx monorepo, which contains both web (React) apps and some standalone libraries.

I want to generate docs for the libraries which are located at path libs/data

The typedoc config is following, I’ve added one package products just for sake of testing/simplicity, but there are more:

{
  "out": "docs",
  "entryPointStrategy": "packages",
  "entryPoints": [
    "libs/data/products"
  ]
}

The package.json for the products package is following:

{
  "name": "@mycompany/products",
  "version": "0.0.1",
  "main": "./src/index.ts",
  "typedoc": {
    "entryPoint": "./src/index.ts",
    "readmeFile": "./README.md",
    "displayName": "@mycompany/products"
  }
}

However I am getting these errors:

error TS6305: Output file '...../libs/data/products/src/service.d.ts' has not been built from source file '..../libs/data/products/src/service.ts'.
  The file is in the program because:
    Root file specified for compilation
    
error TS6306: Referenced project '....../libs/data/products/tsconfig.lib.json' must have setting "composite": true
error TS6306: Referenced project '....../libs/data/products/tsconfig.spec.json' must have setting "composite": true

Any advices on how to fix it? Thanks in advance. Please note, that I cannot apply same solution of renaming every tsconfig file as mentioned in the linked issue above - the project is too large for that.

Node v.14.18.2 yarn 1.22.19 nx 13.1.2 typedoc 0.23 typescript 4.5.5 (I am aware of compatibiltiy issues with that typedoc version, however, typedoc@0.22 seems to be lack of the child package.json setup)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19

github_iconTop GitHub Comments

1reaction
Gerrit0commented, Oct 16, 2022

@Gerrit0 here is minimal example: https://github.com/MrOnlineCoder/typedoc_nx_issue

With the following changes, documentation generates as expected.

diff --git a/libs/data/services/products-service/package.json b/libs/data/services/products-service/package.json
index 5e81c08..7281d96 100644
--- a/libs/data/services/products-service/package.json
+++ b/libs/data/services/products-service/package.json
@@ -4,6 +4,7 @@
   "typedoc": {
     "entryPoint": "./src/index.ts",
     "readmeFile": "./README.md",
-    "displayName": "@myapp/products-service"
+    "displayName": "@myapp/products-service",
+    "tsconfig": "tsconfig.lib.json"
   }
 }

Update: I’ve tried updating to latest typedoc version with tsconfig option support for separate packages and setting it to ‘tsconfig.lib.json’, but it didn’t work too:

TypeError: context.checker.getTypeOfSymbol is not a function
    at Object.convertProperty (.../node_modules/typedoc/dist/lib/converter/symbols.js:362:25)

Apparently I need to make the warning about running with unsupported versions of TypeDoc louder. TypeScript 4.5 is not supported. If you upgrade TypeScript, this error will go away.

When entryPointsStrategy is set to packages I get the error:

The option is entryPointStrategy, not entryPointsStrategy. For packages mode, you should also specify package directories containing package.json as your entry points, not files.

1reaction
Cardueliscommented, Oct 15, 2022

Can confirm inability to work with monorepo with nx and lerna

When entryPointsStrategy is set to packages I get the error:

error Tried to set an option (entryPointsStrategy) that was not declared.

But it is declared like this:

{
  "tsconfig": "./tsconfig.base.json",
  "entryPoints": [
    "packages/time/src/index.ts",
    "packages/ui/src/index.ts",
    "packages/utils/src/index.ts"
  ],
  "entryPointsStrategy": "packages",
  "exclude": [],
  "out": "docs",
  "name": "Insided Packages",
  "pretty": true
}

By any configuration it does not use child (leaf) package.jsons typedoc property. For example, I would like to use tsconfig.json files per package (some packages are react-based, some not).

And I would like to use a custom .md (in my case Changelog by Conventional Commits) on page of each package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug when creating a single documentation for an ... - GitHub
For the monorepo I'm using Lerna + NX, without workspaces (I'm ... able to set up a PR for https://github.com/TypeStrong/typedoc-repros ...
Read more >
Installation - TypeDoc
Installing TypeDoc is available as a node package. Using npm ensures that all relevant dependencies are setup correctly. You can choose to either...
Read more >
Nx Community and Plugin Listing
typedoc is a transparent wrapper plugin for Nx workspaces to quickly setup documentation automation on your projects using typedoc.
Read more >
@nx-plus/docusaurus - npm
This will fetch the specified version of @nx-plus/docusaurus , analyze the dependencies and fetch all the dependent packages. The process will ...
Read more >
Unable to resolve dependency tree error when installing npm ...
This is not related to an HTTP proxy. You have dependency conflict (incorrect and potentially broken dependency) as it says, so try to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found