generate mode passthrough
Opened this issue · 7 comments
I'm not sure if this is practical, but I think it'd be nice to be able to filter the scope of files that tyipa generate
will process, and doing a simple file copy on any that don't match.
We're unable to patch our ts compiler.
The typia generate
step is now the slowest part of our build.
Esbuild processes the output from typia generate
.
All of our typia functionality is imported from a single file, ts/guards.ts
I'm thinking the generate
task could be a lot faster if we could tell typia that it only need to process that one file, and everything else it can just copy.
What do you think? Would it make a difference to build times?
How about using unplugin-typia
of @ryoppippi
I've experimented with unplugin-typia
. With bun it works great. With esbuild I couldn't figure out how to get it to do anything without patching typescript. Is it supposed to work without the patch?
Yes unplugin-typia
also needs ts-patch
patching.
@jff1625 Hi!
Actually we don't need to configure ts-patch
when you use unplugin-typia
, because unpuigin-typia
doesn't use transform plugin for tsc.
However, I got some issue with esbuild before. ryoppippi/unplugin-typia#163
I guess this is because of transformation ordering(maybe sometimes esbuild removes type information before executing plugin, but we cannot enforce the order).
To make it works fine, I recommend to use unplugin-typia
with vite/rollup/rolldown/bun. I like rolldown these days because it runs fast and the plugins also work fine. Also, the output of rollwodn is cleaner than that of Bun.build
.
https://github.com/ryoppippi/pkg-to-jsr/blob/b759fede3cc4395a9bcc8448f9e05671b61f0ed0/tsdown.config.ts
Also, we can implement glob
feature for generate
command.
I guess this is because of transformation ordering(maybe sometimes esbuild removes type information before executing plugin, but we cannot enforce the order).
This aligns with my observation.
I recommend to use unplugin-typia with vite/rollup/rolldown/bun
I prefer not to migrate the project to a different build tool at this time because (1) esbuild is otherwise a good fit, and (2) I tried quickly migrating it to bun but it was not so trivial.
Also, we can implement
glob
feature forgenerate
command.
I saw the similarly named issue Support glob patterns in typia generate #1251 but I'm not sure it's the same use-case.
I want it to behave something like this:
src
├─ index.ts
└─ ts
└─ guards.ts
typia generate --input src/ --output typia-generated --match guards
...generates to:
typia-generated
├─ index.ts // typia didn't spend time thinking about this file, only copied
└─ ts
└─ guards.ts // typia generated code for this file
The question is - would that actually be any faster?
thanks!
So I added some cache feature to unplugin-typia
before. Maybe typia cli should have this