question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`--entrypointStrategy Packages` problem with project references

See original GitHub issue

Search terms

project reference, entrypointStrategy, monorepo, packages

Expected Behavior

If I use --entrypointStrategy Packages and if my sub-project has a slightly complicated setup (see how in pkg1, the tsconfig file refers to tsconfig.package.json, typedoc won’t be able to handle it. Strangely, with the same TS setup, if I use Resolve mode, things went fine.

Actual Behavior

Typescript fails with the following log

Using TypeScript 4.7.4 from ./node_modules/typescript/lib
Converting with 2 programs 2 entry points
packages/pkg1/src/index.ts:1:25 - error TS6059: File '/Users/sample/Developer/js/issue-repo/packages/pkg1/package.json' is not under 'rootDir' '/Users/sample/Developer/js/issue-repo/packages/pkg1/src'. 'rootDir' is expected to contain all source files.

1 import packageJson from "../package.json";
                          ~~~~~~~~~~~~~~~~~

packages/pkg1/src/index.ts:1:25 - error TS6307: File '/Users/sample/Developer/js/issue-repo/packages/pkg1/package.json' is not listed within the file list of project '/Users/sample/Developer/js/issue-repo/packages/pkg1/tsconfig.json'. Projects must list all files or use an 'include' pattern.

1 import packageJson from "../package.json";
                          ~~~~~~~~~~~~~~~~~

Steps to reproduce the bug

Please checkout

https://github.com/akphi/issue-repo/tree/typedoc

To reproduce:

yarn && yarn repro

Additional Context

However, I could totally be okay with using --entrypointStrategy Resolve strategy, but I don’t like the way modules are being shown as folders, I wonder if we could do something about that (like being able to specify module name), otherwise if it’s intended, I would like to use --entrypointStrategy Packages instead

yarn && yarn repro:resolve
Screen Shot 2022-07-01 at 8 18 30 PM

Environment

  • Typedoc version: 0.23.3
  • TypeScript version: 4.7.4
  • Node.js version: 16.15.0
  • OS: Mac 12.4

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Gerrit0commented, Jul 2, 2022

Have you run a npm install? That’s a pretty new dev dependency, might not be installed if you installed a while ago.

I bet this is the fix:

diff --git a/src/lib/utils/entry-point.ts b/src/lib/utils/entry-point.ts
index e5bbb300..3e331a8c 100644
--- a/src/lib/utils/entry-point.ts
+++ b/src/lib/utils/entry-point.ts
@@ -367,6 +367,7 @@ function getEntryPointsForPackages(
         const program = ts.createProgram({
             rootNames: parsedCommandLine.fileNames,
             options: options.fixCompilerOptions(parsedCommandLine.options),
+            projectReferences: parsedCommandLine.projectReferences,
         });
         const sourceFile = program.getSourceFile(packageEntryPoint);
         if (sourceFile === undefined) {
0reactions
akphicommented, Jul 2, 2022

I’ll find time to try it with my main project https://github.com/finos/legend-studio later. Due to https://github.com/TypeStrong/typedoc/issues/1959 I need to put a dummy typedocMain in all of my packages 😆

Thanks for such a quick turnaround!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options - TypeDoc
TypeDoc assumes that if a symbol was referenced from a package, it was exported from that package. This will be true for most...
Read more >
Typedoc does not generate doc for imported modules
The entrypoint file is entrypoint of koa server and it import all other files like routers, controllers, services, ORM models (through other ...
Read more >
Documentation - Project References - TypeScript
tsc -w can't run on multiple config files at once. Project references can solve all of these problems and more. What is a...
Read more >
typedoc - npm
js and is available as a NPM package. npm install typedoc --save-dev. Usage. To generate documentation TypeDoc needs to know your project entry ......
Read more >
Typedoc: Documentation Generator for TypeScript Projects - Morioh
typedoc --entryPointStrategy packages . ... project ideas are simple suggestions to help you deal with the difficulty of choosing the correct projects.
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