samchon / typia

Super-fast/easy runtime validators and serializers via transformation
https://typia.io/
MIT License
4.62k stars 159 forks source link

More information on how to configure Typia in a webpack + ts-loader setup #721

Closed abrouaux closed 1 year ago

abrouaux commented 1 year ago

Question

Hi @samchon , I've been closely at Typia, in the last weeks as a candidate to replace zod.

I develop web apps on old browsers (SmartTVs). We need a packager (webpack) and transpiration (babel usually, experimenting with swc at the moment). We can't use vite as some of the browsers we need to support are older than 2015.

I've seen hints here & there in the typia issues that it's possible to get typia to work with ts-loader, except I can't figure exactly why. I've added the typia/lib/transform as a transform plugin in tsconfig.

I've setup a very small repo with web pack, typia, ts-loader and swc as a final ES5 transpiler (I'm aware of the discussion about SWC - it's not used with typia here): https://github.com/abrouaux/typia-webpack.

I've also added the "inspect" web pack plugin to understand what's going on with my builds. What it says about the typia step:

image

At runtime, I'm getting (obviously given the preprocessing seems to have failed) this error:

image

If you could take a look at the repo & tell me what I'm doing wrong, it'd be super helpful! thanks

samchon commented 1 year ago

Run npx typia setup command, then you may be possible.