4 ms·
I have had many discussions with the author and we ultimately decided not to support those kinds of usecases until we have a very solid set of guarantees. Suppo
by trgwii 1y ago
I have had many discussions with the author and we ultimately decided not to support those kinds of usecases until we have a very solid set of guarantees. Supporting closures can quickly become very tricky when you need to preserve a function across JS processes.
- shortrounddev2 1y agoI just want to be able to select dependencies at bundle time depending on the build environment. If its in dev, use `MockService`. If its in prod, use `ProdService`. Right now I just have `index.prod.ts` and `index.dev.ts` that choose the dependencies, which is not a bad solution, I just wish I could keep my initialization code in one file and have functions return the dependencies based on the environment. I can do this at runtime obviously but it doesnt seem to eliminate unused dependencies well I know its a cursed idea but I often find myself wishing typescript had a C++ style preprocessor
- MKRhere 1y agoAuthor here. To be clear, what you're asking for is basically: const X = comptime(condition ? A : B); and have it compile down to const X = A; without attempting to serialise the functions themselves. Is this correct? The way comptime.ts currently works is that it runs the expression in a constructed block. But perhaps a new primitive, like import { conditional } from "comptime.ts" with { type: "comptime" }; const X = conditional(condition, X, Y); Might work though! I'm also interested in conditional comptime code removal, but not sure about the API design there. I know bundlers already do it, but I'd like for it to be possible in source->source transformations too, for example shipping a version of a library with debugs/traces. Feel free to open an issue if you'd like to discuss ideas.