josdejong / svelte-jsoneditor

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

Separate the svelte component and the js wrapper #372

Open AlexRMU opened 5 months ago

AlexRMU commented 5 months ago

It would be nice to bring all the functionality that is needed for use without svelte into a separate component that will be imported from js. And the pure svelte component will be imported from svelte. You also need to make native events in the svelte component (and pass them above), and use callbacks in the wrapper, etc.

josdejong commented 5 months ago

I'm not entirely sure what you mean, do you mean to move the stuff related to the vanilla-jsoneditor into a separate repo? There is no "js wrapper", it is only a build script that generates a vanilla JS bundle using rollup.

AlexRMU commented 5 months ago

The main component has updateProps and other things that are required for vanilla js. This can be moved to a separate component. In addition, it has a size of 500 lines, it is better to reduce it somehow. Plus, you can add a bunch of slots to be able to replace some components.

AlexRMU commented 5 months ago

Blocked by https://github.com/josdejong/svelte-jsoneditor/issues/373

josdejong commented 5 months ago

Yeah, that can be interesting. It would be neat to separate the stuff related to the vanilla-package from the svelte-version. It should not introduce friction though to implement a feature or fix and then deploy both packages (right now all of that goes in one go).

Is this something you would like to try out?

AlexRMU commented 5 months ago

I think you can just export the svelte component and the wrapper component separately https://github.com/sveltejs/kit/discussions/8825 https://github.com/sveltejs/kit/pull/8922 https://kit.svelte.dev/docs/packaging#anatomy-of-a-package-json-exports