Optimize bin by replacing node_modules/.bin/tsgo with a symlink#4211
Optimize bin by replacing node_modules/.bin/tsgo with a symlink#4211jakebailey wants to merge 5 commits into
Conversation
would the |
|
Theoretically yes, however, it won't work on Windows I don't think (executables cannot be deleted while running), and IIRC package managers don't really expect that packages modify themselves after install for caching reasons? But, it's possible. Maybe since it's Node running the script, it's mutable on Windows. And maybe modifying it after the fact into a symlink is okay? (I am trying to remember if dprint does this...) |
|
dprint modifies at first run, so that may be possible! https://app.unpkg.com/dprint@0.54.0/files/bin.cjs |
|
I don't see sprint doing that there. Perhaps any open file handles can be avoided by spawning another process, then letting the wrapper die. Another pitfall is how this would block the use of |
|
It does: const resolvedExePath = require("./install_api.cjs").runInstall();
runDprintExe(resolvedExePath);That being said, I seem to recall some goofiness here on Windows too where dprint had to do some tmp stuff, but I am not seeing it.
You mean as in users who want to directly exec |
Ah yes, missed that as I'm on mobile and didn't look past the require.
I meant the |
|
Part of this PR is that the But I'm not sure I'm understanding the situation you're describing, since |
|
Seems to work! |
|
I was hoping that the wrapper could first spawn native In situations where the bin optimization fails, there's now always the cost of paying for Perhaps this is moot if the bottleneck is Node startup or if |
Coming back to this, this could be done if the wrapper invokes Probably not worth it. |
Bun uses a trick to replace package manager bin shims with a symlink to the actual binary.
This can greatly improve startup performance, at a terrible cost: a postinstall script.
I tried this for fun and it works, but, I don't 100% know if it's a good idea.
Would close #2836.