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.52k stars 1.82k forks source link

Feature request: support monorepos by logging the package name #283

Closed Offirmo closed 2 years ago

Offirmo commented 2 years ago

Thanks a lot for this tool!

I'm using a monorepo. When launching a size-limit check on my whole monorepo, I get something like that:

✔ Adding to empty esbuild project

  dist/src.es2021/index.js
  Size limit: 250 B
  Size:       184 B with all dependencies, minified and gzipped

  dist/src.es2021.cjs/index.js
  Package size limit has exceeded by 31 B
  Size limit: 250 B
  Size:       281 B with all dependencies, minified and gzipped

  Try to reduce size or increase limit in "size-limit" section of package.json

and then the command stop.

The problem is... I have no idea which package of my monorepo caused this error 😅 it's not named anywhere in the output. Could we add an extra line such as: Checking size limit for package "@foo/bar"...

Checking size limit for package "@foo/bar"...
✔ Adding to empty esbuild project

  dist/src.es2021/index.js
...

Thanks a lot!

ai commented 2 years ago

Will it be a better way to add printing the package name in script?

  "scripts": {
    "size": "echo '@foo/bar' && size-limit"
  }
Offirmo commented 2 years ago

@ai yes it could work. It doesn't scale very well, though. Need dozens of package.json altered.

Another solution would be for the monorepo tooling to prefix the lines with the repo name.

I understand that the responsibility is unclear.

ai commented 2 years ago

It doesn't scale very well, though.

You can write a small wrapper on top of Size Limit CLI.

I think that it is rare case when we have to change output for all Size Limit users and increase CLI code complixity :(.