Synchronous operation #18
Replies: 4 comments 3 replies
-
Hi, For the parse/find it is possible to add sync equivalents, the main async operations are fs that have sync equivalents. For parseNative/findNative it is not so easy as it would require finding a workaround for the dynamic typescript import that allows this functionality to be offered without an explicit dependency on typescript. If you have ideas how to make that happen, i'd be happy to collaborate on a feature request PR. While i myself prefer async operations all the way i understand that there is a need for sync sometimes and it's a feature worth having in a low level tool like tsconfck. Thanks for bringing this up. |
Beta Was this translation helpful? Give feedback.
-
here's a quick version with sync: https://github.com/dominikg/tsconfck/tree/feat/sync uses sync fs functions and createRequire instead of dynamic import. This would need some cleanup before it could be released though, far too much code duplication. But it works, so if you need/want this, please chime in and we can see what can be done. Another option would be to use something like deasync to wrap the async calls with a sync wrapper. |
Beta Was this translation helpful? Give feedback.
-
Hey there, Thanks for getting back to me! Our PR moved pretty quickly and it looks like we're using the native TS utils now. But, as you said, it's pretty likely that other CLI tools would want synchronous operation. I'd seen a similar de-async function out there which used a timeout and I did a 😬 face! Anyway, thanks for the input, and I hope it's useful for future travellers! Cheers, |
Beta Was this translation helpful? Give feedback.
-
assume you mean this PR? davestewart/alias-hq#37 You are adding typescript as a dependency there and eager require it. Plus typescript itself is slower in big projects as it looks for matching files by default. tsconfck, esp without using parseNative means a lot less weight and faster results. But if that PR works for you, i'm fine :) thanks for mentioning this anyways |
Beta Was this translation helpful? Give feedback.
-
Hi there.
Considering using this lib to solve a couple of issues in my Alias HQ lib:
tsconfig.json
that extends anothertsconfig.base.json
with the alias paths davestewart/alias-hq#30However, the async nature of this library looks like it may be incompatible.
Is there a way to make this lib synchronous, or some other workaround without having to start
await
ing all follow-on functionality?Beta Was this translation helpful? Give feedback.
All reactions