ai / size-limit

Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
MIT License
6.48k stars 1.82k forks source link

Unable to run on windows 10 #336

Closed CGarces closed 8 months ago

CGarces commented 10 months ago

Hi

I'm using size-limit 9 with NodeJs 18 and windows 10

Using powershell I have de following error.

C:\desarrollos\ActiveDirectory>npm run size --why
npm ERR! No workspaces found:
npm ERR!   --workspace=--usage

The second option y run at WSL but I have one annoying bug that I can solve

⠋ Running JS in headless ChromeError: Failed to launch the browser process! spawn C:\Program Files\Google\Chrome\Application\chrome.exe ENOENT

It's possible to run npm run size --why and saving the result, without open the browser?

ai commented 10 months ago

It is Size Limit issue? Looks like it is more npm and workspaces issue in your environment.

CGarces commented 10 months ago

Maybe, not directly a size-limit issue. I'm not using workspaces as I only have one package.json, and it only happends on windows not wsl.

I'm trying to understand if there is a way to generate the esbuild-why.html file before the error. Also maybe is a good feature generate the esbuild-why.html file without open a browser to use it as result of a CI/CD script, or as workaround for this issue.

JounQin commented 8 months ago

https://github.com/un-ts/size-limit/actions/runs/6822135697/job/18553660760#step:6:33

+1 for this, it is caused by

https://github.com/ai/size-limit/blob/f2493379fefc00559af2a8c54fc52cedbbc9b0bd/packages/size-limit/load-plugins.js#L30-L34

which resolves an absolute path like D: for import on Windows which is not supported. The fix is to use pathToFileURL.

And considering #344, I think we should simply use import(i) here. cc @ai

ai commented 8 months ago

The fix by @JounQin was released in 10.0.3.