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

Plugin does not support tsconfig.json file with multi-line comments #69

Open
ldeluigi opened this issue Nov 20, 2020 · 1 comment
Open

Comments

@ldeluigi
Copy link

ldeluigi commented Nov 20, 2020

Describe the bug
When using "ngd" command inside the root folder of an Angular 10 project an exception is thrown:

[20:30:05] using tsconfig: C:\Users\_\tsconfig.json
internal/modules/cjs/loader.js:1238
    throw err;
    ^

SyntaxError: C:\Users\_\tsconfig.json: Unexpected token / in JSON at position 0
    at parse (<anonymous>)
    at Object.Module._extensions..json (internal/modules/cjs/loader.js:1235:22)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.Application.run (C:\Users\_\AppData\Roaming\npm\node_modules\@compodoc\ngd-cli\dist\cli.js:54:25)    
    at Object.<anonymous> (C:\Users\_\AppData\Roaming\npm\node_modules\@compodoc\ngd-cli\dist\index.js:4:19)       
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)

To Reproduce
Steps to reproduce the behavior:

  1. Create an Angular 10 project
  2. Run "ngd" in the same folder as the tsconfig.json

Expected behavior
It should understand that the text included in /* */ is a comment and parse the file correctly.

Screenshots
If needed, ask me.

Desktop:

  • OS: Windows 10
  • Version 2.1.0

Additional context
Here is my tsconfig.json, generated by Angular CLI:

/*
  This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
  It is not intended to be used to perform a compilation.

  To learn more about this file see: https://angular.io/config/solution-tsconfig.
*/
{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
]
}
@PhiLhoSoft
Copy link

I would say you should avoid loading the solution style file here, even more as the spec files are probably irrelevant to the project's hierarchy.

That say, a tool for Angular should understand "Json with comment" file format, including comments of both style, trailing commas, and so on.
Perhaps the project should use a better library for reading Json config files?

On my project, it fails with:

SyntaxError: C:\___\tsconfig.main.json: Unexpected token ] in JSON at position 252
    at parse (<anonymous>)
    at Object.Module._extensions..json (internal/modules/cjs/loader.js:1128:22)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.Application.run (C:\PrgFiles\nvm\v14.18.2\node_modules\@compodoc\ngd-cli\dist\cli.js:54:25)
    at Object.<anonymous> (C:\PrgFiles\nvm\v14.18.2\node_modules\@compodoc\ngd-cli\dist\index.js:4:19)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

FYI, This file includes a tsconfig.common.js file, which includes another file from node_modules (one of our own libraries), making hard to track where the issue is.
Of course, these config files are perfectly OK for TypeScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants