-
Notifications
You must be signed in to change notification settings - Fork 948
Tree-Shakeable Serialization #3231
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
Conversation
Binary Size ReportAffected SDKs
Test Logs
|
c449195
to
458cdf8
Compare
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.
Haven't really reviewed this PR, but a high-level comment.
@@ -93,10 +93,14 @@ export class Firestore implements firestore.FirebaseFirestore { | |||
this._datastorePromise = PlatformSupport.getPlatform() | |||
.loadConnection(databaseInfo) | |||
.then(connection => { | |||
const serializer = PlatformSupport.getPlatform().newSerializer( | |||
const serializationOptions = PlatformSupport.getPlatform().newSerializationOptions( |
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.
In tree-shakeable style, the structure containing the data we pass through that used to be a class is now just a dumb struct, but it still has the same identity. All that's changed is that it's a dumb struct with accompanying functions instead of a class with member functions.
For parity with the other platforms I think it still makes sense to call that thing a Serializer
.
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.
The parity argument makes sense. I updated the PR accordingly.
458cdf8
to
9c4663a
Compare
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.
There is one place where serializer is not used but in the parameters. Otherwise LGTM.
* Returns a number (or null) from a google.protobuf.Int32Value proto. | ||
*/ | ||
function fromInt32Proto( | ||
serializer: JsonProtoSerializer, |
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.
serializer
is not needed here.
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.
Fixed (also in a couple other places)
This PR replaces the class methods in JSONSerializer with free standing functions, which allows for a lot of tree shaking (see binary size report).
This PR is split in three parts:
005abb3
is a manual change that uses an options interface in lieu of the empty serializer class.This PR is a bit easier to review by appending "?w=1" to the URL.