-
Notifications
You must be signed in to change notification settings - Fork 536
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
Remove usages of assert in all code that ends up bundled in the browser #4144
Conversation
…to chrisgo/assert # Conflicts: # lerna-package-lock.json
…to chrisgo/assert # Conflicts: # lerna-package-lock.json # package-lock.json
…to chrisgo/assert
@@ -0,0 +1,64 @@ | |||
/*! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this file need to be here? I.e. should it be separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It keeps it from regressing, I can move it to another PR if that helps review this one.
@@ -346,7 +346,7 @@ export class PermutationVector extends Client { | |||
} | |||
|
|||
default: | |||
assert.fail(); | |||
throw new Error(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having at least some text here would be nice :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions for what it should say?
@@ -327,7 +327,9 @@ export class ConsensusOrderedCollection<T = any> | |||
} | |||
if (local) { | |||
assert( | |||
localOpMetadata, `localOpMetadata is missing from the local client's ${op.opName} operation`); | |||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change cast below to include undefined and move this assert after it, testing resolve for not being undefined.
That said, maybe even better - just remove assert, it does not add much value - we will crash one way or another if things go wrong
@@ -255,7 +254,10 @@ export class ConsensusRegisterCollection<T> | |||
message.sequenceNumber, | |||
local); | |||
if (local) { | |||
assert(localOpMetadata, "localOpMetadata is missing from the client's write operation"); | |||
assert( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, I'd just remove it
Resolves #4070
With this change we remove all client side usages of assert to dramatically reduce bundle sizes. Also adds a custom webpack plugin to the bundle size tests to cause PRs that add new instances of assert will fail to build.
This reduces the container from 240KB (62.5KB compressed) to 180KB (45.5KB compressed)