Skip to content

Drop dependencies replaceable by Node built-ins (−23 MB, −16 packages) #1277

Description

@l2ysho

Measured: installing the full dep tree vs the tree without the deps below = 109 MB → 86 MB (−23 MB, −21%) and 328 → 312 packages. Every npx apify-cli and CI job downloads this fresh.

Droppable now — native replacement on Node 20+

Dep Usage Replace with
axios 2 files native fetch
es-toolkit only cloneDeep, 9 call sites structuredClone()17 MB for one function
rimraf 1 wrapper (rimrafPromised) fs.rm(p, { recursive: true, force: true }) (~5 MB incl. glob/lru-cache chain)
strip-ansi 1 file util.stripVTControlCharacters()
is-ci 1 file ci-info.isCI — already a dependency; is-ci is that one-liner republished
@root/walk 1 file (scrapy wrapper) fs.readdir(dir, { recursive: true })
computer-name 1 file (login device label) os.hostname() — also kills an unmaintained native addon
cors login's localhost auth server ~3 lines of headers on the existing express handler

Duplicates — consolidate

  • adm-zip + archiver are imported in the same file (src/lib/utils.ts) — two full zip implementations; either covers read + write.
  • js-levenshtein + @skyra/jaro-winkler both power the same "did you mean" check in useCommandSuggestions.ts (levenshtein <= 2 || jaroWinkler >= 0.975). One metric is plenty — or inline a 20-line levenshtein and drop both.

Blocked on raising the Node floor

  • escape-string-regexp (2 files) → RegExp.escape() needs Node 24; a one-liner worth inlining meanwhile.
  • tinyglobby (1 file) → fs.glob stable in Node 24.
  • chalk (46 files) → util.styleText on 22+; big mechanical diff, zero user-visible gain — last.

Keepers

semver, ajv, handlebars, express, open, mime, giget, execa, inquirer/apify packages. which is borderline but earns its keep on Windows PATHEXT handling.

Suggested order

  1. Bump engines to >=22 (Node 20 is EOL since 2026-04).
  2. One mechanical PR per dep — all but chalk are single-import.

~10 deps removable today, 23 MB off every install, and ~16 fewer packages to audit next time something like the figlet incident happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-buildersIssues owned by the Builders team.

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions