Closed FunctionDJ closed 3 years ago
Thanks for the report!
I will try to incoperate a jsonc-parser
, that should fix the issue..
@FunctionDJ So ive managed to get a jsonc-parser working and fixed your other mentioned config issues!
Unfortunately it comes with a catch, JSON itself doesnt support natively comments and i couldnt find a decent and fast jsonc-parser
that retains the comments at their exact position. The most common one from microsoft, hasnt been updated on that case since 2019.. so basically it will read a file with comments, but it wont keep them on rewriting the File.
If you got a simple & quick solution for it, feel free to create a PR.
Thanks for taking a look at this. I already thought this might be impossible to properly pull off.
I suggest that you check the json file for comments, and when found, error out and let the user know to extract the contents to a base.json file in order to not touch the comments and just write to a config.json that extends from the base one, which is what i've done.
Overall i would love to support this, so its quite sad that there is no proper Library that already does this, not even one from Microsoft.. I will look into this further and try to contact them via their git, maybe it pins out somehow!
The newest Version v0.8.4. Will currently remove any Comment on the jsonc/json File.
I will leave this Issue here open, so if anyone has a Solution, please feel free to comment or create a PR!
If not (so giving it some time), i will create a 0.8.5
with an opt-out Error if any Comment is found.
I am also considering to maybe save the comments in a seperate file, so they are atleast not lost..
I would really suggest to just detect the comments and abort if they are found. Then maybe log a link to this issue or something. That's the easiest and least destructive solution right now in my opinion.
So ive been trying to fit quick Solutions but there doesnt seems to be an easy way to achieve is without basically writing another Library for this ^^
I will move forward with 0.8.5
and include an Error Notification and a Config Option.
When attempting to run this plugin with a
tsconfig.json
that has//
comments,JSON.parse()
breaks.