oclif icon indicating copy to clipboard operation
oclif copied to clipboard

All commands are required, slowing down the CLI

Open mshwery opened this issue 4 years ago • 0 comments

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

I'm seeing all commands being required, both with ts-node and when using OCLIF_TS_NODE=0:

time DEBUG=* OCLIF_TS_NODE=0 npx mycli init --help
  @oclif/config reading core plugin /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli +0ms
  @oclif/config loadJSON /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/package.json +0ms
  @oclif/config loadJSON /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/oclif.manifest.json +3ms
  @oclif/config loadJSON /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/.oclif.manifest.json +0ms
  @oclif/config:@mycli/cli loading IDs from /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/dist/commands +0ms
  @oclif/config:@mycli/cli found commands [ 'init', 'push', 'register', 'generate:action', 'generate:types' ] +10ms
  @oclif/config:@mycli/cli require /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/dist/commands/init.js +2ms
  @oclif/config:@mycli/cli require /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/dist/commands/push.js +317ms
  @oclif/config:@mycli/cli require /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/dist/commands/register.js +225ms
  @oclif/config:@mycli/cli require /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/dist/commands/generate/action.js +1ms
  @oclif/config:@mycli/cli require /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/dist/commands/generate/types.js +186ms
  @oclif/config reading user plugins pjson /Users/matthewshwery/.local/share/@mycli/cli/package.json +0ms
  @oclif/config loadJSON /Users/matthewshwery/.local/share/@mycli/cli/package.json +789ms
  @oclif/config loading plugins [ '@oclif/plugin-help' ] +3ms
  @oclif/config loadJSON /Users/matthewshwery/dev/src/github.com/<repo>/packages/cli/package.json +3ms
  @oclif/config loadJSON /Users/matthewshwery/dev/src/github.com/<repo>/packages/package.json +1ms
  @oclif/config reading core plugin /Users/matthewshwery/dev/src/github.com/<repo>/node_modules/@oclif/plugin-help +0ms
  @oclif/config loadJSON /Users/matthewshwery/dev/src/github.com/<repo>/node_modules/@oclif/plugin-help/package.json +0ms
  @oclif/config loadJSON /Users/matthewshwery/dev/src/github.com/<repo>/node_modules/@oclif/plugin-help/oclif.manifest.json +1ms
  @oclif/config:@oclif/plugin-help using manifest from /Users/matthewshwery/dev/src/github.com/<repo>/node_modules/@oclif/plugin-help/oclif.manifest.json +0ms
  @oclif/config config done +2ms
  @oclif/config start init hook +0ms
  @oclif/config init hook done +1ms
  mycli init version: @oclif/[email protected] argv: [ 'init', '--help' ] +0ms

Note: this happens across multiple commands, with and without --help

What is the expected behavior?

The documentation site claims that only the command to be executed will be required (emphasis mine):

The overhead for running an oclif CLI command is almost nothing. It requires very few dependencies (only 35 dependencies in a minimal setup—including all transitive dependencies). Also, only the command to be executed will be required with node. So large CLIs with many commands will load just as fast as a small one with a single command.

=> Found "@oclif/[email protected]"
=> Found "@oclif/[email protected]"
=> Found "@oclif/[email protected]"
=> Found "@oclif/[email protected]"

On macOS 11.4 (Big Sur), tried on multiple Node versions (12x/14x/16x), Yarn 1.22

mshwery avatar Jun 29 '21 02:06 mshwery