vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.01k stars 2.1k forks source link

chore(deps): replace fast-glob with tinyglobby #4132

Closed Namchee closed 1 month ago

Namchee commented 2 months ago

Description

This pull request replaces fast-glob with tinyglobby to reduce dependency size while keeping the same behavior

Linked Issues

Additional Context

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

Package info for "fast-glob@3.3.2": 512 kB
  Released: 2023-11-06 12:41:11.203 +0000 UTC (40w ago)
  Downloads last week: 26,252,063 (55.53%)
  Estimated traffic last week: 13 TB
  Subdependencies: 17

Removed dependencies:
  - @nodelib/fs.stat@2.0.5: 12 kB (2.39%)
    Downloads last week: 35,212,220 (N/A% from 2.0.5)
    Downloads last week from "fast-glob@3.3.2": 26,252,063 (N/A%)
    Traffic last week: N/A
    Traffic from "fast-glob@3.3.2": 13 TB (N/A%)
    Subdependencies: 0 (0%)
  - @nodelib/fs.walk@1.2.8: 130 kB (25.38%)
    Downloads last week: 34,851,744 (N/A% from 1.2.8)
    Downloads last week from "fast-glob@3.3.2": 26,252,063 (N/A%)
    Traffic last week: N/A
    Traffic from "fast-glob@3.3.2": 13 TB (N/A%)
    Subdependencies: 6 (35.29%)
  - glob-parent@5.1.2: 33 kB (6.47%)
    Downloads last week: 46,878,871 (N/A% from 5.1.2)
    Downloads last week from "fast-glob@3.3.2": 26,252,063 (N/A%)
    Traffic last week: N/A
    Traffic from "fast-glob@3.3.2": 13 TB (N/A%)
    Subdependencies: 2 (11.76%)
  - merge2@1.4.1: 9.3 kB (1.81%)
    Downloads last week: 34,334,669 (N/A% from 1.4.1)
    Downloads last week from "fast-glob@3.3.2": 26,252,063 (N/A%)
    Traffic last week: N/A
    Traffic from "fast-glob@3.3.2": 13 TB (N/A%)
    Subdependencies: 0 (0%)
  - micromatch@4.0.7: 243 kB (47.37%)
    Downloads last week: 19,237,645 (N/A% from 4.0.7)
    Downloads last week from "fast-glob@3.3.2": 26,252,063 (N/A%)
    Traffic last week: N/A
    Traffic from "fast-glob@3.3.2": 13 TB (N/A%)
    Subdependencies: 5 (29.41%)

Added dependencies:
  + tinyglobby@0.2.2: 171 kB (33.44%)
    Downloads last week: 29,150 (N/A% from 0.2.2)
    Estimated traffic last week: N/A
    Subdependencies: 2 (11.76%)

Estimated new statistics:
  Package size: 512 kB → 171 kB (33.44%)
  Subdependencies: 17 → 3 (-14)
  Traffic with last week's downloads:
    For current version: 13 TB → 4.5 TB (8.9 TB saved)
    For all versions: 24 TB → 8.1 TB (16 TB saved)

[!TIP] The author of this PR can publish a preview release by commenting /publish below.

SuperchupuDev commented 2 months ago

for better fast-glob compatibility you can set the expandDirectories option to false btw

brc-dd commented 2 months ago

Few questions -

nit: the "TB saved" thing in description isn't correct. It will only save ~1 GB / wk. (The bundled + gz size difference is 13KB x 80K vitepress downloads / wk.)

pkg-pr-new[bot] commented 2 months ago
pnpm add https://pkg.pr.new/vitepress@4132

commit: 87c4448

benmccann commented 2 months ago

Is there any benchmark of fast-glob vs tinyglobby?

They're pretty comparable. I've generally seen that tinyglobby is a bit faster though it can depend on the file structure being searched, glob pattern, etc.

image

Is vite planning to migrate away from fast-glob too? Is there any attempt in vite's repo to replace the package that passes their tests?

I think that would be nice to do and would be happy to review any PRs in the Vite repo and @bluwy said he'd be supportive of trying it as well. I've filed a couple of feature requests with tinyglobby to make the migration path easier as Vite uses some uncommon functionality of fast-glob. We might be able to just replicate that functionality directly in Vite with a couple of small utility methods, but if tinyglobby can add support that'd be easiest for us