twittwer / nx-tools

Workspace for Nx Plugins.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Nx + Angular (v13): tsconfig path error

Nxtivision opened this issue · comments

Nx 13 has a new way to design Angular projects. If we leave tsConfig option as-is (<projectRoot>/tsconfig.lib.json), the command will fail because path to tsconfig is not set correctly. Here is what I have when I set debug option to true:

> nx run formly-one:compodoc:json 
Prepare Compodoc...
 {
  tsConfig: 'libs/formly-one/tsconfig.lib.json',
  outputPath: 'dist/compodoc/formly-one',
  disableRoutesGraph: true,
  disableSourceCode: false,
  disableDomTree: false,
  disableTemplateTab: false,
  disableStyleTab: false,
  disableGraph: true,
  disableProtected: false,
  disableSearch: false,
  disableDependencies: false,
  debug: true,
  exportFormat: 'json',
  workspaceDocs: false,
  disableCoverage: true,
  disablePrivate: true,
  disableInternal: true,
  disableLifeCycleHooks: true,
  language: 'en-US',
  theme: 'gitbook',
  hideGenerator: false,
  port: 8080,
  watch: false
}
Spawn Compodoc... {
  command: 'npx compodoc',
  arguments: [
    '--tsconfig="C:\\Users\\freel\\IdeaProjects\\design-system\\libs\\formly-one\\tsconfig.lib.json"',
    '--output="C:\\Users\\freel\\IdeaProjects\\design-system\\dist\\compodoc\\formly-one"',
    '--exportFormat="json"',
    '--minimal',
    '--name="formly-one"',
    '--disableCoverage',
    '--disableGraph',
    '--disablePrivate',
    '--disableInternal',
    '--disableLifeCycleHooks',
    '--disableRoutesGraph',
    '--language="en-US"',
    '--theme="gitbook"',
    '--silent'
  ],
  options: { cwd: 'libs/formly-one', shell: true }
}

Compodoc v1.1.16

C:\Users\freel\IdeaProjects\design-system\node_modules\@compodoc\compodoc\dist\index-cli-298ea115.js:953
        throw new Error(message);
        ^

Error: error TS5083: Cannot read file 'C:\Users\freel\IdeaProjects\design-system\libs\formly-one\C:\Users\freel\IdeaProjects\design-system\libs\formly-one\tsconfig.lib.json'

As we can see, root project path is set twice. Any idea of a workaround, or if this is related to compodoc itself?
Thanks in advance

I have trouble reproducing this behaviour, can you provide a reproduction repo?

In my test case it works on windows & osx:

osx
> nx run lib:compodoc:json 
Prepare Compodoc...
 {
  tsConfig: 'libs/lib/tsconfig.lib.json',
  outputPath: 'dist/compodoc/lib',
  debug: true,
  silent: true,
  exportFormat: 'json',
  workspaceDocs: false,
  disableCoverage: true,
  disableSourceCode: false,
  disableDomTree: false,
  disableTemplateTab: false,
  disableStyleTab: false,
  disableGraph: false,
  disablePrivate: true,
  disableProtected: false,
  disableInternal: true,
  disableLifeCycleHooks: true,
  disableRoutesGraph: false,
  disableSearch: false,
  disableDependencies: false,
  language: 'en-US',
  theme: 'gitbook',
  hideGenerator: false,
  port: 8080,
  watch: false
}
Spawn Compodoc... {
  command: 'npx compodoc',
  arguments: [
    '--tsconfig="/Users/twittwer/git/compodoc-test/libs/lib/tsconfig.lib.json"',
    '--output="/Users/twittwer/git/compodoc-test/dist/compodoc/lib"',
    '--exportFormat="json"',
    '--minimal',
    '--name="lib"',
    '--disableCoverage',
    '--disablePrivate',
    '--disableInternal',
    '--disableLifeCycleHooks',
    '--language="en-US"',
    '--theme="gitbook"',
    '--silent'
  ],
  options: { cwd: 'libs/lib', shell: true }
}
Compodoc v1.1.16
windows
> nx run lib:compodoc:json 
Prepare Compodoc...
 {
  tsConfig: 'libs/lib/tsconfig.lib.json',
  outputPath: 'dist/compodoc/lib',
  debug: true,
  silent: true,
  exportFormat: 'json',
  workspaceDocs: false,
  disableCoverage: true,
  disableSourceCode: false,
  disableDomTree: false,
  disableTemplateTab: false,
  disableStyleTab: false,
  disableGraph: false,
  disablePrivate: true,
  disableProtected: false,
  disableInternal: true,
  disableLifeCycleHooks: true,
  disableRoutesGraph: false,
  disableSearch: false,
  disableDependencies: false,
  language: 'en-US',
  theme: 'gitbook',
  hideGenerator: false,
  port: 8080,
  watch: false
}
Spawn Compodoc... {
  command: 'npx compodoc',
  arguments: [
    '--tsconfig="C:\\Users\\tw\\git\\compodoc-test\\libs\\lib\\tsconfig.lib.json"',
    '--output="C:\\Users\\tw\\git\\compodoc-test\\dist\\compodoc\\lib"',
    '--exportFormat="json"',
    '--minimal',
    '--name="lib"',
    '--disableCoverage',
    '--disablePrivate',
    '--disableInternal',
    '--disableLifeCycleHooks',
    '--language="en-US"',
    '--theme="gitbook"',
    '--silent'
  ],
  options: { cwd: 'libs/lib', shell: true }
}
Compodoc v1.1.16

Weel, this is quite embarassing: I just retested today to provide you a reproduction, but everything is working now. Maybe updating some versions in the meantime fixed the above error ¯_(ツ)_/¯

Have a nice day!

Ok, nice to hear the problem is solved 👍