WarningImHack3r / intellij-shadcn-plugin

Add, update and delete your shadcn/ui components without leaving your IDE
4 stars 2 forks source link

[crash] Parsing error when processing a tsconfig file with comments #32

Closed shiftcontrol-dan closed 3 months ago

shiftcontrol-dan commented 6 months ago

What is the issue?

I tried using the plugin for the first time and immediately got this error.

What are the steps to reproduce this issue?

  1. Install the plugin
  2. Go to view->tools->shadcn/ui
  3. See WebStorm tell you to submit a bug

What were you expecting to happen?

For the plugin to render.

Paste any relevant logs, error output, etc.

kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 354: Expected quotation mark '"', but had '/' instead at path: $
JSON input: .....    "skipLibCheck": true,
    /* Bundler mode */
    "module.....
    at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
    at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
    at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:598)
    at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:596)
    at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json(AbstractJsonLexer.kt:233)
    at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json$default(AbstractJsonLexer.kt:228)
    at kotlinx.serial

<TRIMMED STACKTRACE>

What OS are you experiencing the problem on?

macOS

Additional platform information

Build version: WebStorm 2023.3.6 Build: #WS-233.15026.13 March 21, 2024 JRE: 17.0.10+1-b1087.23, JetBrains s.r.o. JVM: 17.0.10+1-b1087.23, OpenJDK 64-Bit Server VM, JetBrains s.r.o. Operating System: Mac OS X 14.4.1 (aarch64)

=== Plugins === Custom plugins: [Space (233.15026.16), .ignore (4.5.2), AI Assistant (233.15026.24), GitHub Copilot (1.5.2.5345), shadcn/ui Components Manager (0.7.7)] Disabled plugins:[]

Duplicates

WarningImHack3r commented 6 months ago

Hi there! I'm using a simple JSON decoder to parse the tsconfig.json, however as you used comments in yours (which is not supported by standard JSON files) it introduces a crash during parsing. I'll see if I can easily add support for JSON with comments, sorry for the issue!

WarningImHack3r commented 6 months ago

Update: after some research, the official Kotlinx.serialization I'm using has very recently merged support for JSON comments, which is the last feature they needed to fully support JSON5.

This means that I'm only waiting for a release from them containing this commit to fully support that.

In the meantime, you can bypass the issue by removing any non-standard JSON feature from your tsconfig.json (basically trailing commas, unquoted keys, and comments) to make the plugin work.

Note: I could also use libraries like https://github.com/xn32/json5k but I don't want to add another dependency for a tiny change that will be included within KxS very soon. As your issue is not blocking and doesn't affect everyone, I think it's reasonable.

shiftcontrol-dan commented 6 months ago

Thanks, Yes my file has some comments. Happy to close this or leave it open until the upstream feature is availale.

WarningImHack3r commented 3 months ago

@shiftcontrol-dan @shimizu-izumi I realized that while this new release isn't out, I can try to manually remove comments of the file in-memory before passing it to the JSON parser, it's not optimal but not that hard to do and would fix the issue; the switch to a cleaner solution would later on be transparent for users