Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing to baseline file seems to fail the first time due to missing directory #4832

Closed
philwolstenholme opened this issue Nov 12, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@philwolstenholme
Copy link

philwolstenholme commented Nov 12, 2024

I am getting ENOENT the first time I try to create a baseline file:

npx bundle-stats --baseline generated/bundle-size/webpack-stats.json
✔ Read Webpack stats files
↓ Baseline stats file is missing, see "baseline" option. [SKIPPED]
✖ ENOENT: no such file or directory, open '/Users/wolsph/Projects…
◼ Process data
◼ Generate reports
◼ Save reports
ENOENT: no such file or directory, open '/Users/wolsph/Projects/shop-next/node_modules/.cache/bundle-stats/baseline.json'

However, if I create an empty directory first then things are happier:

❯ mkdir -p node_modules/.cache/bundle-stats
❯ npx bundle-stats --baseline generated/bundle-size/webpack-stats.json
✔ Read Webpack stats files
↓ Baseline stats file is missing, see "baseline" option. [SKIPPED]
✔ Write baseline data (node_modules/.cache/bundle-stats/baseline.…
✔ Process data
✔ Generate reports
✔ Save reports

┌─────────────────────────────────────┐
│                                     │
│   Bundle Size — 18.39MiB (+100%).   │
│                                     │
└─────────────────────────────────────┘

Artifacts:
- dist/bundle-stats.html
@philwolstenholme philwolstenholme changed the title Writing to baseline file seems to fail the first time due to missing file (because it's not been created yet) Writing to baseline file seems to fail the first time due to missing directory Nov 12, 2024
@philwolstenholme
Copy link
Author

There's a chance this directory was actually created at some point but then I did a rm -rf node_modules/.cache/bundle-stats while experimenting, unfortunately I can't remember. I'd suggest creating the directory if it's empty though?

@vio
Copy link
Member

vio commented Nov 12, 2024

@philwolstenholme thank you for opening the issue!

This is a regression caused by swapping fs-extra with fs. fs-extra handled the missing directory creation by default.

A fix is available for testing on v4.17.0-beta.7. Let me know how it goes if you get the chance to try it.

@vio vio closed this as completed Nov 13, 2024
@vio vio self-assigned this Nov 13, 2024
@vio
Copy link
Member

vio commented Nov 18, 2024

Released on v4.17.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants