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

perf: save 0.2kB bundle size by const-ing error message #21

Merged
merged 4 commits into from
Feb 18, 2024

Conversation

bartveneman
Copy link
Contributor

@bartveneman bartveneman commented Nov 20, 2023

Not sure if this is something you'd want to merge, feel free to skip, but I was profiling some perf issues at Wallace's bundle sizes and noticed this error string recurring 3 times.

before

index.cjs 50619
index.js  50478

after

index.cjs 50437 (-182B)
index.js  50296 (-182B)

It now throws a NotAllowedError with the message Manipulating a Specificity instance is not allowed. Instead, create a new Specificity()

@bramus
Copy link
Owner

bramus commented Nov 22, 2023

Thanks for the PR. Nice handy addition.

Looking at the error message itself: I’ve got no clue what went on in my mind when I wrote “Manipulating the port of the specificity directly is not allowed. Instead, directly set a new value”.

  • The port? Maybe I meant part?
  • The “Instead, directly set a new value” part makes no sense at all as it contradicts the first

While at it, it might also be a good idea to change Error to a NotAllowedError.

@bartveneman
Copy link
Contributor Author

I agree on both points, the error message didn't really make sense to me 😆

Btw, I hope the tests are ok, it's a bit repetitive, but at least there's some coverage now.

@bartveneman
Copy link
Contributor Author

Updated:

before

index.cjs 50619
index.js  50478

after

index.cjs 50437 (-182B)
index.js  50296 (-182B)

It now throws a NotAllowedError: Manipulating a Specificity instance is not allowed. Instead, create a new Specificity()

@bramus bramus merged commit 771a237 into bramus:main Feb 18, 2024
3 checks passed
@bartveneman bartveneman deleted the reduce-bundle-size branch February 18, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants