Skip to content
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

Replace glob with faster alternative #836

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SuperchupuDev
Copy link

@SuperchupuDev SuperchupuDev commented Jul 18, 2024

glob is far from ideal considering its 26 subdependencies and not that fast speed. This PR replaces its use with fdir (the fastest dir crawler out there) and picomatch. They have both a total of zero (0) subdependencies, making this not just a faster approach, but also one that's way lighter.

This PR makes sucrase go from 41 total subdependencies to just 16, reducing its total package size from 5.4 MB to about 1.8 MB :O

Note: since picomatch supports an array of patterns, the loop that went over the patterns is not necessary anymore and was removed. Also refactored the skipping file types logic into picomatch's built-in ignore option

Relevant prior work: https://e18e.dev/guide/cleanup.html, dotenvx/dotenvx#278

Package size report

(tool source)

Package size report
===================

Package info for "[email protected]": 5.4 MB
  Released: 2023-12-22 01:34:43.452 +0000 UTC (30w3d ago)
  Downloads last week: 5,870,223 (68.53%)
  Estimated traffic last week: 32 TB
  Subdependencies: 55

Removed dependencies:
  - [email protected]: 3.6 MB (66.30%)
    Downloads last week: 10,260,938 (N/A% from 10.4.5)
    Downloads last week from "[email protected]": 5,870,223 (N/A%)
    Traffic last week: N/A
    Traffic from "[email protected]": 32 TB (N/A%)
    Subdependencies: 40 (72.72%)

Added dependencies:
  + [email protected]: 59 kB (1.09%)
    Downloads last week: N/A (N/A% from 6.2.0)
    Estimated traffic last week: N/A
    Subdependencies: 0 (0%)
  + [email protected]: 86 kB (1.59%)
    Downloads last week: 1,805,723 (N/A% from 4.0.2)
    Estimated traffic last week: N/A
    Subdependencies: 0 (0%)

Estimated new statistics:
  Package size: 5.4 MB → 817 kB (15.20%)
  Subdependencies: 55 → 16 (-39)
  Traffic with last week's downloads:
    For current version: 32 TB → 4.8 TB (27 TB saved)
    For all versions: 46 TB → 7.0 TB (39 TB saved)

@SuperchupuDev
Copy link
Author

cc @alangpierce let me know if i should change anything 🙏

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

Successfully merging this pull request may close these issues.

1 participant