preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Preact-cli works very slow

Open DenizBasgoren opened this issue 5 years ago • 7 comments

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

What is the current behaviour? Cli tool runs unacceptably slow. even --help responds in 10-20 seconds. on subsequent runs cli works faster, but still very slow. (--help takes 3 seconds, watch prints its first message in 3 seconds)

If the current behaviour is a bug, please provide the steps to reproduce. I downloaded preact-cli latest version yesterday, using npm i -g preact-cli. I'm using node, which I got using nvm. node version is 14.7.0. node -v responds immediately.

What is the expected behaviour? At least the help msg should run immediately. Since all inputs take 3 seconds to respond, I think it's a general bug.

If this is a feature request, what is motivation or use case for changing the behaviour?

Please mention other relevant information.

Please paste the results of preact info here.

System:
    OS: Linux 5.9 Manjaro Linux
    CPU: (4) x64 Intel(R) Core(TM) i3-2370M CPU @ 2.40GHz
  Binaries:
    Node: 14.7.0 - ~/.nvm/versions/node/v14.7.0/bin/node
    npm: 6.14.7 - ~/.nvm/versions/node/v14.7.0/bin/npm
  Browsers:
    Firefox: 83.0
  npmPackages:
    preact: ^10.1.0 => 10.5.7 
    preact-cli: ^3.0.0 => 3.0.3 
    preact-render-to-string: ^5.1.2 => 5.1.12 
  npmGlobalPackages:
    preact-cli: 3.0.3

DenizBasgoren avatar Dec 08 '20 14:12 DenizBasgoren

Any reason you need it globally installed? Generally would recommend against that. Easy for it to get out dated.

Is it also slow using the local (to a project) install?

Edit: Can you also try disabling NVM? There's a lot of search results around nvm killing terminal performance. Some of that is years old, some is newer, but that could be the culprit.

rschristian avatar Dec 08 '20 17:12 rschristian

It turns out it was not preact-cli's fault, but rather npm's. I solved it using npm cache verify. Also, if I run npx preact-cli, npx will download the whole cli just for a single command. I'd suggest you to warn your users that npx preact-cli is wrong and npx preact is right. Regaring local vs global installation, both perform the same. edit: Preact still takes a long time to respond (-h responds in 3 seconds), but that's nowhere near 30 sec - 1 min. So, I'll open another issue for that

DenizBasgoren avatar Dec 09 '20 04:12 DenizBasgoren

npx preact-cli is absolutely correct. That's the name of the package. preact gets you the Preact library, not Preact-CLI.

If you have the CLI globally installed, as you do, then preact can be used to run the Preact-CLI commands. However that is NPX using your locally installed package before falling back to get the package directly from the NPM repository.

rschristian avatar Dec 09 '20 05:12 rschristian

npx preact-cli will go to $PWD/node_modules/.bin and see if there is a file called preact-cli, which there isn't. There is a symlink called preact, and that's the file we need to access. If we write npx preact-cli, npx won't find preact-cli in said folder, so it will automatically download the package, just to run a single command, and it's definitely not the expected behavior. npx preact would do the job. What could be done about this, is to create another symlink called preact-cli pointing the same script file. This would be less surprising for users.

DenizBasgoren avatar Dec 09 '20 20:12 DenizBasgoren

npx preact-cli will go to $PWD/node_modules/.bin and see if there is a file called preact-cli, which there isn't.

Sure, but if you're using it to create a project then there won't be a local install. It will then fall back to the NPM repository where this package is named preact-cli.

so it will automatically download the package, just to run a single command, and it's definitely not the expected behavior.

Sorry, but this is the behavior we expect. It keeps it up to date. You shouldn't need to use npx along with the CLI to do anything other than to create a new project.

npx preact would do the job.

Only if you have it installed, which we'd rather you didn't. Many issues arise from this, hence why we switched to suggesting NPX over an install.

rschristian avatar Dec 09 '20 20:12 rschristian

If automatic installation is the expected behavior, I'd suggest you to point it out, with just a sentence on the front page that it will download the package every time npx preact-cli is run. Thanks for your time

DenizBasgoren avatar Dec 09 '20 21:12 DenizBasgoren

There is no automatic installation.

The entire purpose of npx is to run packages, like a CLI app, without actually globally installing them. Other popular situations include running DB migrations or updating config files.

rschristian avatar Dec 09 '20 21:12 rschristian