sveltejs / svelte-preprocess

A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
MIT License
1.73k stars 147 forks source link

Support typia #576

Closed dirk-bester closed 1 year ago

dirk-bester commented 1 year ago

Is your feature request related to a problem? Please describe. I am unable to get typia to work with svelte. https://github.com/samchon/typia

Describe the solution you'd like I am a few days into modern javascript and having suffered under Typescript I do not want to also hand roll custom JSON to import and export data like me 10 years ago. Typia strikes me as best practice in that regard. Directly use Typescript to do I/O, validation etc.

Describe alternatives you've considered I looked at Zod and it currently seems like an anti pattern of ignoring the fact of TS and creating some parallel type system. Which is also slow and unsuitable for me. The benchmarks here are illuminating.

How important is this feature to you? Best practices are important to me. I chose svelte and sveltestrap to learn the current state of the art in a small project. This is based solely on svelte bothering to not be a massive 1mb burden for even the simplest page using it.

My last web outing was 10 years ago with a 10m line C++ machine learning server and pure JS frontend with some jquery. I really do value quality in tools. Obviously a workaround is again handcrafting the JSON, sorting the keys etc so a SHA256 can determine equality/identity etc. But so much better if it just works automagically based on the Typescript class info.

If I am right, this integration would be a valuable step in making svelte industrial strength and even more better than it is.

Additional context I opened https://github.com/samchon/typia/issues/500 but based on other issues there typia may be blocked by a lack of typescript preprocessor support. Something like this: https://github.com/sveltejs/svelte-preprocess/issues/537

Test project: https://github.com/dirk-bester/bare breaks on Act I Scene I. I need to get typia plugged into the Typescript compiler chain.

*I am still functionally stupid at all this so I don't even know what the right questions are to ask or where to ask them.

dirk-bester commented 1 year ago

OK, https://github.com/samchon/typia/issues/509 is making its way to release on the typia side. I will check back in after to see if a svelte-preprocess plugin is required for smooth operation.

dirk-bester commented 1 year ago

OK success! Integration done via ts-patch which directly patches the problem child: typescript. npx typia setup npm install --save-dev @rollup/plugin-typescript and it's off to the races. This can be closed.