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

Avoid error class name mangling in webpack #4768

Merged
merged 4 commits into from
Dec 6, 2022
Merged

Conversation

fregante
Copy link
Collaborator

@fregante fregante commented Dec 6, 2022

What does this PR do?

Discussion

Webpack is mangling the names due to concatenateModules, but we can't expect them to be stable. concatenateModules currently only saves a few KBs (1.09MB -> 1.05MB), so it's not worth keeping it.

Alternative solutions:

  • use both a static and instance name: Err {name = 'Err'; static name = 'Err'}
    • TS complains
    • no way to enforce it
  • extract the name from the constructor by instantiating it
    • some errors require additional arguments, so we can't safely call new on them

Future solution:

Checklist

  • Add tests
  • Run Storybook and manually confirm that all stories are working
  • Designate a primary reviewer

@fregante fregante marked this pull request as ready for review December 6, 2022 09:32
@twschiller twschiller self-requested a review December 6, 2022 13:27
@twschiller
Copy link
Contributor

currently only saves a few KBs (1.09MB -> 1.05MB)

Interesting, I must have done the check locally incorrectly

@twschiller twschiller merged commit bfba703 into main Dec 6, 2022
@twschiller twschiller deleted the F/bug/error#name branch December 6, 2022 13:29
@twschiller twschiller modified the milestones: 1.7.16, 1.7.15 Dec 6, 2022
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.

BusinessError subclasses are being reported to Rollbar
2 participants