gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.
3.38k stars 57 forks source link

Building with hotscript as dependency #80

Open dkzlv opened 1 year ago

dkzlv commented 1 year ago

Hey there! Thanks for the repo, it's very nice, just as your course (passed it and liked a lot!).

We at Evil Martians have plans to extend our nanostores ecosystem with a form library called nanoform. And for it we wanted to make a map store that will provide typesafe object path interface for the underlying structure. That's where we use Objects.Get and Objects.AllPaths utilities.

It works perfectly from the DX point of view, but we have an issue when building the lib. It's probably not hotscript specific, but I hoped you could give any guidance on how to fix that.

Here's a repro on StackBlitz. You need to run npm run build in terminal there. See the problem is that tsc inlines a lot of hotscript code in the .d.ts file making it unreadable mess.

image

What's extremely odd is that it does that for one function, getPath, but not the other, setPath, even though both use the same set of utility types. Do you have any idea how to get rid of this? Thanks!

ecyrbe commented 1 year ago

It's indeed really weird. Since you are exporting the type it should use the exported type. Can you try to use tsup to generate the build and check if the output is better ?

dkzlv commented 1 year ago

@ecyrbe The output did change a bit, but somehow to the worse: now it also includes direct imports from hotscript's dist/internals folder, but the problem didn't go anywhere.

image

I updated the project to have build:tsup command.

ecyrbe commented 1 year ago

Can you try but making HOTScript a peerdependency ?

GavinMeierSonos commented 1 year ago

TSUP will include a dep sometimes, even if its only a dev dep but is not marked as a peer dep.

Erbenos commented 10 months ago

Similar use case here - have buildable library within NX workspace which I may want to publish for other consumers, the types are mess as well.