davestewart / alias-hq

The end-to-end solution for configuring, refactoring, maintaining and using path aliases
https://davestewart.co.uk/projects/open-source/alias-hq/
MIT License
333 stars 12 forks source link

Refactor CLI to a different module? #74

Open mikew opened 12 months ago

mikew commented 12 months ago

Love the idea of the module, but for people who don't want to use the CLI ... quite a lot of modules are installed:

Yeah it's 48 thousand lines, I can't paste it in GitHub, Gist, or Pastebin, but the bulk of them come from jscodeshift, which isn't needed for people not looking to use the CLI.

davestewart commented 12 months ago

Hmmm, interesting!

I hadn't really thought about that.

I found this online tool which visualises the size:

https://arve0.github.io/npm-download-size/#alias-hq

image

From that it looks like jscodeshift is maybe 60% of the 5MB install.

I guess I would have to weigh up the pros and cons of whether it actually matters, vs maintaining two separate repositories, docs, issues, awareness, etc.

FWIW the CLI is also used to let folks configure paths and plugins which is nice as adding TS aliases by hand is a bit cumbersome.

Can you make any cases for why saving ~3MB really matters?

davestewart commented 12 months ago

Having reviewed my own docs again (it's been a while!) the CLI also helps folks debug their setups, as well as develop and publish plugins, so I think I'll close this issue for now; it's just simpler to keep everything together.

Hopefully a bit of the context there has been helpful though!

mikew commented 12 months ago

Doesn't necessarily have to be two repositories, monorepos exist (but are not without complications, admittedly). Also, you only mentioned jscodeshift when I'm guessing these are only to do with the CLI:

Which account for ~87% of the size. And the original 5MB isn't accurate:

$ du -sh node_modules 
520M    node_modules

mike at test-vscode-remote-arch in ~/Work/promoboxx/react-scripts-vite (swap-plugins●) 
$ pnpm install --save alias-hq

   ╭──────────────────────────────────────────────────────────────────╮
   │                                                                  │
   │                Update available! 8.6.11 → 8.11.0.                │
   │   Changelog: https://github.com/pnpm/pnpm/releases/tag/v8.11.0   │
   │                Run "pnpm add -g pnpm" to update.                 │
   │                                                                  │
   │      Follow @pnpmjs for updates: https://twitter.com/pnpmjs      │
   │                                                                  │
   ╰──────────────────────────────────────────────────────────────────╯

 WARN  deprecated @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
 WARN  deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
 WARN  deprecated @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
 WARN  deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
 WARN  deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
 WARN  deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
 WARN  deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
 WARN  deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
 WARN  deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
Packages: +156
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 756, reused 724, downloaded 0, added 143, done

dependencies:
+ alias-hq 6.2.3

Done in 5.8s

mike at test-vscode-remote-arch in ~/Work/promoboxx/react-scripts-vite (swap-plugins●) 
$ du -sh node_modules         
546M    node_modules

Edit: Just found about about this tool which seems more accurate: https://pkg-size.dev/alias-hq

davestewart commented 12 months ago

That's a nice tool! Though I'm not sure I totally understand the output for our use case; we want to know the total installed size of X vs Y dependencies, right?

So I did a quick test (Basic CLI = plugin management, Full CLI = code refactoring):

Alias CLI (Basic) CLI (Full)
Deps 3 4 7
Total Deps 4 95 197
Size 504 KB 30 MB 58 MB

So I think this proves your point very well... I'm just not convinced that it warrants a refactor, publishing to separate NPM packages, etc.

Although thinking about it, a workable option might be for developers who wish to create plugins or refactor code to install from GitHub using an alias:

npm i alias-cli@github:davestewart/alias-hq

I've just attempted this, and it works, as in, the user can run the cli:

dave@ds-m3 aliased % npm i alias-cli@github:davestewart/alias-hq
dave@ds-m3 aliased % alias-hq

  == Alias HQ ==

  -- Main Menu --

? What do you want to do? (Use arrow keys)
❯ - Configure paths 
  - Help 
  - Exit 

I tell you what, let me experiment with a stripped down version published to a personal namespace, then if it works, I think it could be a nice introduction.

I'm not going to get time to do this probably until Christmas though, but if you don't mind waiting (or installing!) until then, I will defo take a look.