Skip to content

Replace various packages with faster, smaller alternatives #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
beeequeue opened this issue May 12, 2025 · 12 comments
Open

Replace various packages with faster, smaller alternatives #171

beeequeue opened this issue May 12, 2025 · 12 comments

Comments

@beeequeue
Copy link
Contributor

beeequeue commented May 12, 2025

Hi, would you be open to a PR that replaces some of the libraries used in this package with faster, smaller alternatives?

The ones I have my eyes on are:

  • ansi-styles -> ansis
  • read-package-json-fast -> empathic + JSON.parse(readFileSync)
    • allows for finding manifests above the exact current working directory
    • the package doesn't really use any features from read-package-json-fast except opening+parsing the file
    • 22kb -> 18kb
  • minimatch -> picomatch
  • cross-spawn -> tinyexec / nano-spawn
    • would require upping minimum node version to >=20.19
    • more modern
    • 35kb -> 27kb
@bcomnes
Copy link
Owner

bcomnes commented May 13, 2025

I’ll re-review them and see if I want to switch over if it makes sense.

@voxpelli
Copy link
Collaborator

Colors are built into node.js core since v20.12.0: https://nodejs.org/api/util.html#utilstyletextformat-text-options

@voxpelli
Copy link
Collaborator

Regarding picomatch I agree, and when we bump lowest supported version of Node.js to 22, then we can use the built in globbing hopefully: #146 (comment)

@beeequeue
Copy link
Contributor Author

Colors are built into node.js core since v20.12.0

Yes but sadly the API design is quite a bit worse than the current color packages, while also being slower and less tested by the community. 🙁

ansis has a great readme comparing all the different alternatives and showing pros and cons:
https://github.com/webdiscus/ansis#-why-use-ansis

@bcomnes
Copy link
Owner

bcomnes commented May 20, 2025

@beeequeue Looks like the picomatch swap is causing issues:

Any suggestions on how to fix those? If not, we'll probably have to roll that specific change back until we do.

@bcomnes
Copy link
Owner

bcomnes commented May 20, 2025

Seems related to the use of ** globs.

@beeequeue
Copy link
Contributor Author

From my quick testing it seems very inconsistent across libraries
Image

e.g. picomatch and micromatch returning differently despite being maintained by the same people

@beeequeue
Copy link
Contributor Author

I think the problem is that the setting strictSlashes should be enabled, then it should work as before.

image

@bcomnes
Copy link
Owner

bcomnes commented May 20, 2025

I requested those that ran into issues to re-test on 8.0.4-beta.0.

@jdalton
Copy link

jdalton commented May 20, 2025

Curious Q here. Why does file size matter for this non-client side package? This PR saves a total of say 386kb raw, so like 0.15s on 4G LTE. However, packages are downloaded as tarballs so compressed (.tgz) more and then cached locally through pnpm/npm/github-actions etc. Here the cost, compatibility issues and inconsistencies, doesn't seem to be worth the reward on a dev local kind of thing.

@bcomnes
Copy link
Owner

bcomnes commented May 21, 2025

Got confirmation 8.0.4-beta.0 is working for downstream users who had issues. Since we already paid the cost on this one mostly, I'll give it one more go but if we run into more issues with it, I think we're rapidly entering a cost/value tradeoff that isn't worth it.

I would very much rather spend maintenance time on this project on higher value issues like getting type checking set up, modernizing the codebase or speeding up the test suite vs dependency swaps of increasingly little value over the ones we've already landed.

@bcomnes
Copy link
Owner

bcomnes commented May 24, 2025

Not totally unrelated: #181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants