Skip to content

Discussion: Reduce dependency footprint #83

@outslept

Description

@outslept
  1. gunshi

Note

I wasn't around when the "core" deps were chosen. So I might be missing something on this.

gunshi is effectively only used to route 2 subcommands and call renderUsage; a whole framework looks like an overkill. if we want to change this there are 2 options:

  • Option A: Replace with mri + a tiny manual dispatcher with lazy imports - smallest footprint and full control, but help/usage must be maintained manually
  • Option B: Replace with a lightweight CLI library (e.g. sade) - keeps auto help and per‑command option parsing with only a small increase in dependency size (in the sade example, it weighs ~2.3 times less than gunshi)
  1. module-replacements

I might be crazy, but.. We can host those three JSON manifests on "a registry" (like shadcn’s /r/.json concept, for example - https://ui.shadcn.com/r) and have the CLI fetch and cache them, so we avoid installing the whole package into node_modules as a result. This should be a lighter process, than a regular npm installation

  1. module-replacements-codemods

Probably should open an issue upstream to track this. This is the biggest size eater rn. module-replacements-codemods currently pulls @ast-grep/napi, which brings prebuilt native bindings and adds a large install footprint (~80MB observed). Given that the repository only uses the ast-grep API in fewer than 10 places and a lot of the existing codemod base is jscodeshift-based, shipping those binaries by default feels disproportionate. Can we settle on one option or find a workaround there?

  1. package-manager-detector

Check around process.env.npm_config_user_agent should be sufficient for our use case. It's not a lot of code to implement: https://github.com/antfu-collective/package-manager-detector/blob/main/src/detect.ts

  1. premove

Since this is a dev dependency, it has the lowest priority. However, given that the test script already uses FORCE_COLOR=1 (which doesn't work properly on Windows without the tweaks), we could consider replacing premove with native rm -rf to eliminate this dependency entirely.

Branch - https://github.com/e18e/cli/compare/main...outslept:cli:replace-premove?expand=1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions