josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
826 stars 109 forks source link

Import failing in sveltekit #204

Closed ghost closed 1 year ago

ghost commented 1 year ago

https://github.com/josdejong/svelte-jsoneditor/blob/99df4b302d9d60479a2dcfffa669af9f9619e358/src/lib/components/modes/tablemode/ColumnHeader.svelte#L3

Hey! it looks like you are importing ts files by name, and in this example, it's causing failures on import after transpilation.

I'm not a typescript expert by any means, but I think in these examples you usually need to leave the .ts off prior to transpilation for TS files, and I think its resolves all that for you with the new .js name after transpilation.

I'm happy to submit a PR to fix this, just don't want to step on any toes

ghost commented 1 year ago

https://github.com/josdejong/svelte-jsoneditor/blob/99df4b302d9d60479a2dcfffa669af9f9619e358/src/lib/components/modes/tablemode/ColumnHeader.svelte#L9

looks like the same issue here actually

josdejong commented 1 year ago

Ah, you're right. Unfortunately the build tools do not complain about this 🤔 . Ideally, they should be automatically changed to .js, or at least we should get a compile or lint error or so.

A PR fixing the wrong imports would be very welcome, thanks for your offer.

ghost commented 1 year ago

image I get linting errors, do you know if there are more files like that?

josdejong commented 1 year ago

Yes I get these linting errors too, using a different IDE though. In my case I get the suggestion to shorten the import by replacing it with "$lib", but that is not a good idea, since that is the index file for the library, and results in circular dependencies. (I do not yet know if I can turn off that suggestion somehow).

ghost commented 1 year ago

Alright, I made a pass and found a couple other small issues, I'm aiming to use this instead of monaco in a production application for making and receiving manual API calls, so I just want to help button everything up

ghost commented 1 year ago

Please let me know if you have any questions or issues, I look forward to using this tool in my app :)

josdejong commented 1 year ago

Fixed in v0.11.2