Json support
I'm trying to add lottie animation in my project and even if I provided the option to resolve json file, compilation process keeps failing saying that I need to enable the option.
Here my tsconfig:
3 Replies
Hi @Flictum. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I understand your issue. However, currently, Wasp doesn't support importing JSON directly. You'll have to parse it or convert the file to a regular JS object and import that.
As for the
tsconfig.json
- Yes, that should work, but Wasp unfortunately doesn't yet take the user's tsconfig.json
into account when processing code. The tsconfig.json
file is only there for the IDE support.
There is an open issue on the Wasp GitHub repository where they are tracking the progress of supporting custom TypeScript configuration. You can follow it here (https://github.com/wasp-lang/wasp/issues/835).
Also, there is another open issue about explaining in the docs how to import JSON files / read static files in Wasp on the server. You can check it out here (https://github.com/wasp-lang/wasp/issues/1564).
Sorry for the inconvenience.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Flictum, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Ah yes you can't cusotmize tsconfig yet, that will be coming soon.
Check this out though, as bot said: https://github.com/wasp-lang/wasp/issues/1564
Basically bot said it all right!
GitHub
Explain in docs how to import JSON files / read static files in Was...
Right now it is a bit tricky because you can directly import .json with node (at least 18), and people get surprised with it because error message is confusing (claims there is no file). I explaine...
Alright so I will follow the provided answer, thanks for your answer