Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow to specify a custom tsconfig in packages mode for monorepos #2061

Closed
avchugaev opened this issue Sep 26, 2022 · 8 comments
Closed

Allow to specify a custom tsconfig in packages mode for monorepos #2061

avchugaev opened this issue Sep 26, 2022 · 8 comments
Labels
enhancement Improved functionality help wanted Contributions are especially encouraged

Comments

@avchugaev
Copy link

avchugaev commented Sep 26, 2022

Search Terms

Monorepo, tsconfig, custom path

Problem

When operating in monorepo mode (multiple packages), each package may contain several tsconfig files.
For instance, Nx generates 3 tsconfig files per TypeScript project:

  • tsconfig.json - base configuration, extends workspace's root tsconfig;
  • tsconfig.lib.json - production code configuration, extends package's tsconfig.json;
  • tsconfig.spec.json - tests configuration, extends package's tsconfig.json.

When one generates documentation for several packages, TypeDoc uses tsconfig.json instead of desired tsconfig.lib.json without ability to override the file name (or location).

Suggested Solution

Allow to override package's tsconfig file name (location) via package.json settings:

{
  "name": "@org/package-a",
  "typedoc": {
    "entryPoint": "./src/index.ts",
    "readmeFile": "./README.md",
    "tsconfig": "./tsconfig.lib.json"
  }
}

So that TypeDoc will be more monorepo-friendly and multi-config-friendly.

@avchugaev avchugaev added the enhancement Improved functionality label Sep 26, 2022
@Gerrit0 Gerrit0 added the help wanted Contributions are especially encouraged label Sep 26, 2022
@ed-jinyoung-park
Copy link

ed-jinyoung-park commented Sep 26, 2022

I have same problem on generating docs with nx projects.
hope this suggestion applies well.

@avchugaev
Copy link
Author

@Zinyon Hi! Just curious, do you publish the resulting API reference to GitHub pages?

@ed-jinyoung-park
Copy link

@avchugaev Hi!, i'm considering it, but haven't tried yet.
have you tried?

@avchugaev
Copy link
Author

@avchugaev Hi!, i'm considering it, but haven't tried yet. have you tried?

Yep, I managed to generate docs for all libraries from Nx workspace and deploy them to GitHub pages.

But to achieve this, I had to rename tsconfig* files in every library so that TypeDoc resolved the right tsconfig.json. So it pushed me to override default configs generated and maintained by Nx.

@avchugaev
Copy link
Author

@Gerrit0 I'd try to implement it, but I need help understanding the codebase and solution design.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Sep 29, 2022

The relevant code starts at https://github.com/TypeStrong/typedoc/blob/master/src/lib/utils/entry-point.ts#L323, seems reasonable to treat this option like the readmeFile is tested today

@avchugaev
Copy link
Author

@Gerrit0 thanks for the feature 🤝 Please check the site build - https://github.com/TypeStrong/typedoc-site/actions/runs/3230626041/jobs/5289289873

There's still a previous version of the docs on the website:
Screenshot from 2022-10-12 15-01-16

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 12, 2022

Huh, surprised that didn't give me an email about a failing build... thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improved functionality help wanted Contributions are especially encouraged
Projects
None yet
Development

No branches or pull requests

3 participants