hotscript icon indicating copy to clipboard operation
hotscript copied to clipboard

Building with hotscript as dependency

Open dkzlv opened this issue 1 year ago • 5 comments

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!

dkzlv avatar Mar 16 '23 16:03 dkzlv

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 ?

ecyrbe avatar Mar 16 '23 20:03 ecyrbe

@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.

dkzlv avatar Mar 17 '23 10:03 dkzlv

Can you try but making HOTScript a peerdependency ?

ecyrbe avatar Mar 17 '23 11:03 ecyrbe

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

GavinMeierSonos avatar Mar 21 '23 22:03 GavinMeierSonos

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.

Erbenos avatar Aug 16 '23 13:08 Erbenos