-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
In additional to build client, I'm trying to use esbuild to run our CLI tools (written in TypeScript).
I read in the document saying
First there is the synchronous API. This is the most convenient option because single-threaded JavaScript code has the cleanest syntax. It's also optimal performance-wise if all you need to do is run esbuild and then exit. However, it blocks the main thread so you do not want to use it if you have other work to perform in the meantime. This is also the only option that cannot use plugins (since plugins are asynchronous). It looks like this:
Also somewhere else seems to suggest that every call to transformSync
spawn up a new esbuild process which is highly inefficient. This is especially true for the CLI use case since transformSync will be called on the require path for many many files in the codebase.
After shallow scan of the code, I'm wondering if it's possible to only spawn one process in the background that lives aside the node process, and restructure the API so that only the "communicating" the existing process part is synchronous, but avoid spawnSync-ing a new one every time (kind of like ensureServiceIsRunning
).
Happy to contribute if that's the right direction, figured I might miss something so better to check first.