Skip to content

Commit f9b1939

Browse files
authored
Merge pull request #128 from sayjeyhi/fix/sayjeyhi/huge-bundle-size
Fix: reduce huge bundle size by adding ADVANCED_OPTIMIZATIONS when compiling protobuf JS
2 parents b545ac8 + 7aed33b commit f9b1939

13 files changed

+2651
-70
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.idea
2+
/node_modules/
3+
commonjs_out
4+
google/protobuf
5+
bazel-*
6+
/deps.js
7+
/testproto_libs1.js
8+
/testproto_libs2.js
9+
/google-protobuf.js

binary/reader.js

+36
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ jspb.BinaryReader.prototype.getBuffer = function() {
192192
/**
193193
* @return {number} The field number of the next field in the buffer, or
194194
* INVALID_FIELD_NUMBER if there is no next field.
195+
* @export
195196
*/
196197
jspb.BinaryReader.prototype.getFieldNumber = function() {
197198
return this.nextField_;
@@ -210,6 +211,7 @@ jspb.BinaryReader.prototype.getWireType = function() {
210211
/**
211212
* @return {boolean} Whether the current wire type is a delimited field. Used to
212213
* conditionally parse packed repeated fields.
214+
* @export
213215
*/
214216
jspb.BinaryReader.prototype.isDelimited = function() {
215217
return this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED;
@@ -219,6 +221,7 @@ jspb.BinaryReader.prototype.isDelimited = function() {
219221
/**
220222
* @return {boolean} Whether the current wire type is an end-group tag. Used as
221223
* an exit condition in decoder loops in generated code.
224+
* @export
222225
*/
223226
jspb.BinaryReader.prototype.isEndGroup = function() {
224227
return this.nextWireType_ == jspb.BinaryConstants.WireType.END_GROUP;
@@ -272,6 +275,7 @@ jspb.BinaryReader.prototype.advance = function(count) {
272275
* we saw a valid field header or false if we've read the whole stream.
273276
* Throws an error if we encountered a deprecated START_GROUP/END_GROUP field.
274277
* @return {boolean} True if the stream contains more fields.
278+
* @export
275279
*/
276280
jspb.BinaryReader.prototype.nextField = function() {
277281
// If we're at the end of the block, there are no more fields.
@@ -541,6 +545,7 @@ jspb.BinaryReader.prototype.readAny = function(fieldType) {
541545
* @template T
542546
* @param {T} message
543547
* @param {function(T, !jspb.BinaryReader)} reader
548+
* @export
544549
*/
545550
jspb.BinaryReader.prototype.readMessage = function(message, reader) {
546551
goog.asserts.assert(
@@ -570,6 +575,7 @@ jspb.BinaryReader.prototype.readMessage = function(message, reader) {
570575
* @param {number} field
571576
* @param {T} message
572577
* @param {function(T, !jspb.BinaryReader)} reader
578+
* @export
573579
*/
574580
jspb.BinaryReader.prototype.readGroup =
575581
function(field, message, reader) {
@@ -614,6 +620,7 @@ jspb.BinaryReader.prototype.getFieldDecoder = function() {
614620
* error if the next field in the stream is not of the correct wire type.
615621
*
616622
* @return {number} The value of the signed 32-bit integer field.
623+
* @export
617624
*/
618625
jspb.BinaryReader.prototype.readInt32 = function() {
619626
goog.asserts.assert(
@@ -643,6 +650,7 @@ jspb.BinaryReader.prototype.readInt32String = function() {
643650
* error if the next field in the stream is not of the correct wire type.
644651
*
645652
* @return {number} The value of the signed 64-bit integer field.
653+
* @export
646654
*/
647655
jspb.BinaryReader.prototype.readInt64 = function() {
648656
goog.asserts.assert(
@@ -672,6 +680,7 @@ jspb.BinaryReader.prototype.readInt64String = function() {
672680
* error if the next field in the stream is not of the correct wire type.
673681
*
674682
* @return {number} The value of the unsigned 32-bit integer field.
683+
* @export
675684
*/
676685
jspb.BinaryReader.prototype.readUint32 = function() {
677686
goog.asserts.assert(
@@ -701,6 +710,7 @@ jspb.BinaryReader.prototype.readUint32String = function() {
701710
* error if the next field in the stream is not of the correct wire type.
702711
*
703712
* @return {number} The value of the unsigned 64-bit integer field.
713+
* @export
704714
*/
705715
jspb.BinaryReader.prototype.readUint64 = function() {
706716
goog.asserts.assert(
@@ -731,6 +741,7 @@ jspb.BinaryReader.prototype.readUint64String = function() {
731741
* wire type.
732742
*
733743
* @return {number} The value of the signed 32-bit integer field.
744+
* @export
734745
*/
735746
jspb.BinaryReader.prototype.readSint32 = function() {
736747
goog.asserts.assert(
@@ -745,6 +756,7 @@ jspb.BinaryReader.prototype.readSint32 = function() {
745756
* wire type.
746757
*
747758
* @return {number} The value of the signed 64-bit integer field.
759+
* @export
748760
*/
749761
jspb.BinaryReader.prototype.readSint64 = function() {
750762
goog.asserts.assert(
@@ -773,6 +785,7 @@ jspb.BinaryReader.prototype.readSint64String = function() {
773785
* wire type.
774786
*
775787
* @return {number} The value of the double field.
788+
* @export
776789
*/
777790
jspb.BinaryReader.prototype.readFixed32 = function() {
778791
goog.asserts.assert(
@@ -787,6 +800,7 @@ jspb.BinaryReader.prototype.readFixed32 = function() {
787800
* wire type.
788801
*
789802
* @return {number} The value of the float field.
803+
* @export
790804
*/
791805
jspb.BinaryReader.prototype.readFixed64 = function() {
792806
goog.asserts.assert(
@@ -818,6 +832,7 @@ jspb.BinaryReader.prototype.readFixed64String = function() {
818832
* type.
819833
*
820834
* @return {number} The value of the signed 32-bit integer field.
835+
* @export
821836
*/
822837
jspb.BinaryReader.prototype.readSfixed32 = function() {
823838
goog.asserts.assert(
@@ -847,6 +862,7 @@ jspb.BinaryReader.prototype.readSfixed32String = function() {
847862
* type.
848863
*
849864
* @return {number} The value of the sfixed64 field.
865+
* @export
850866
*/
851867
jspb.BinaryReader.prototype.readSfixed64 = function() {
852868
goog.asserts.assert(
@@ -876,6 +892,7 @@ jspb.BinaryReader.prototype.readSfixed64String = function() {
876892
* error if the next field in the stream is not of the correct wire type.
877893
*
878894
* @return {number} The value of the float field.
895+
* @export
879896
*/
880897
jspb.BinaryReader.prototype.readFloat = function() {
881898
goog.asserts.assert(
@@ -889,6 +906,7 @@ jspb.BinaryReader.prototype.readFloat = function() {
889906
* error if the next field in the stream is not of the correct wire type.
890907
*
891908
* @return {number} The value of the double field.
909+
* @export
892910
*/
893911
jspb.BinaryReader.prototype.readDouble = function() {
894912
goog.asserts.assert(
@@ -902,6 +920,7 @@ jspb.BinaryReader.prototype.readDouble = function() {
902920
* field in the stream is not of the correct wire type.
903921
*
904922
* @return {boolean} The value of the boolean field.
923+
* @export
905924
*/
906925
jspb.BinaryReader.prototype.readBool = function() {
907926
goog.asserts.assert(
@@ -915,6 +934,7 @@ jspb.BinaryReader.prototype.readBool = function() {
915934
* field in the stream is not of the correct wire type.
916935
*
917936
* @return {number} The value of the enum field.
937+
* @export
918938
*/
919939
jspb.BinaryReader.prototype.readEnum = function() {
920940
goog.asserts.assert(
@@ -928,6 +948,7 @@ jspb.BinaryReader.prototype.readEnum = function() {
928948
* field in the stream is not of the correct wire type.
929949
*
930950
* @return {string} The value of the string field.
951+
* @export
931952
*/
932953
jspb.BinaryReader.prototype.readString = function() {
933954
goog.asserts.assert(
@@ -942,6 +963,7 @@ jspb.BinaryReader.prototype.readString = function() {
942963
* null if the next field in the stream has an invalid length value.
943964
*
944965
* @return {!Uint8Array} The block of bytes.
966+
* @export
945967
*/
946968
jspb.BinaryReader.prototype.readBytes = function() {
947969
goog.asserts.assert(
@@ -1070,6 +1092,7 @@ jspb.BinaryReader.prototype.readPackedField_ = function(decodeMethod) {
10701092
* Reads a packed int32 field, which consists of a length header and a list of
10711093
* signed varints.
10721094
* @return {!Array<number>}
1095+
* @export
10731096
*/
10741097
jspb.BinaryReader.prototype.readPackedInt32 = function() {
10751098
return this.readPackedField_(this.decoder_.readSignedVarint32);
@@ -1090,6 +1113,7 @@ jspb.BinaryReader.prototype.readPackedInt32String = function() {
10901113
* Reads a packed int64 field, which consists of a length header and a list of
10911114
* signed varints.
10921115
* @return {!Array<number>}
1116+
* @export
10931117
*/
10941118
jspb.BinaryReader.prototype.readPackedInt64 = function() {
10951119
return this.readPackedField_(this.decoder_.readSignedVarint64);
@@ -1110,6 +1134,7 @@ jspb.BinaryReader.prototype.readPackedInt64String = function() {
11101134
* Reads a packed uint32 field, which consists of a length header and a list of
11111135
* unsigned varints.
11121136
* @return {!Array<number>}
1137+
* @export
11131138
*/
11141139
jspb.BinaryReader.prototype.readPackedUint32 = function() {
11151140
return this.readPackedField_(this.decoder_.readUnsignedVarint32);
@@ -1130,6 +1155,7 @@ jspb.BinaryReader.prototype.readPackedUint32String = function() {
11301155
* Reads a packed uint64 field, which consists of a length header and a list of
11311156
* unsigned varints.
11321157
* @return {!Array<number>}
1158+
* @export
11331159
*/
11341160
jspb.BinaryReader.prototype.readPackedUint64 = function() {
11351161
return this.readPackedField_(this.decoder_.readUnsignedVarint64);
@@ -1150,6 +1176,7 @@ jspb.BinaryReader.prototype.readPackedUint64String = function() {
11501176
* Reads a packed sint32 field, which consists of a length header and a list of
11511177
* zigzag varints.
11521178
* @return {!Array<number>}
1179+
* @export
11531180
*/
11541181
jspb.BinaryReader.prototype.readPackedSint32 = function() {
11551182
return this.readPackedField_(this.decoder_.readZigzagVarint32);
@@ -1160,6 +1187,7 @@ jspb.BinaryReader.prototype.readPackedSint32 = function() {
11601187
* Reads a packed sint64 field, which consists of a length header and a list of
11611188
* zigzag varints.
11621189
* @return {!Array<number>}
1190+
* @export
11631191
*/
11641192
jspb.BinaryReader.prototype.readPackedSint64 = function() {
11651193
return this.readPackedField_(this.decoder_.readZigzagVarint64);
@@ -1180,6 +1208,7 @@ jspb.BinaryReader.prototype.readPackedSint64String = function() {
11801208
* Reads a packed fixed32 field, which consists of a length header and a list
11811209
* of unsigned 32-bit ints.
11821210
* @return {!Array<number>}
1211+
* @export
11831212
*/
11841213
jspb.BinaryReader.prototype.readPackedFixed32 = function() {
11851214
return this.readPackedField_(this.decoder_.readUint32);
@@ -1190,6 +1219,7 @@ jspb.BinaryReader.prototype.readPackedFixed32 = function() {
11901219
* Reads a packed fixed64 field, which consists of a length header and a list
11911220
* of unsigned 64-bit ints.
11921221
* @return {!Array<number>}
1222+
* @export
11931223
*/
11941224
jspb.BinaryReader.prototype.readPackedFixed64 = function() {
11951225
return this.readPackedField_(this.decoder_.readUint64);
@@ -1210,6 +1240,7 @@ jspb.BinaryReader.prototype.readPackedFixed64String = function() {
12101240
* Reads a packed sfixed32 field, which consists of a length header and a list
12111241
* of 32-bit ints.
12121242
* @return {!Array<number>}
1243+
* @export
12131244
*/
12141245
jspb.BinaryReader.prototype.readPackedSfixed32 = function() {
12151246
return this.readPackedField_(this.decoder_.readInt32);
@@ -1220,6 +1251,7 @@ jspb.BinaryReader.prototype.readPackedSfixed32 = function() {
12201251
* Reads a packed sfixed64 field, which consists of a length header and a list
12211252
* of 64-bit ints.
12221253
* @return {!Array<number>}
1254+
* @export
12231255
*/
12241256
jspb.BinaryReader.prototype.readPackedSfixed64 = function() {
12251257
return this.readPackedField_(this.decoder_.readInt64);
@@ -1240,6 +1272,7 @@ jspb.BinaryReader.prototype.readPackedSfixed64String = function() {
12401272
* Reads a packed float field, which consists of a length header and a list of
12411273
* floats.
12421274
* @return {!Array<number>}
1275+
* @export
12431276
*/
12441277
jspb.BinaryReader.prototype.readPackedFloat = function() {
12451278
return this.readPackedField_(this.decoder_.readFloat);
@@ -1250,6 +1283,7 @@ jspb.BinaryReader.prototype.readPackedFloat = function() {
12501283
* Reads a packed double field, which consists of a length header and a list of
12511284
* doubles.
12521285
* @return {!Array<number>}
1286+
* @export
12531287
*/
12541288
jspb.BinaryReader.prototype.readPackedDouble = function() {
12551289
return this.readPackedField_(this.decoder_.readDouble);
@@ -1260,6 +1294,7 @@ jspb.BinaryReader.prototype.readPackedDouble = function() {
12601294
* Reads a packed bool field, which consists of a length header and a list of
12611295
* unsigned varints.
12621296
* @return {!Array<boolean>}
1297+
* @export
12631298
*/
12641299
jspb.BinaryReader.prototype.readPackedBool = function() {
12651300
return this.readPackedField_(this.decoder_.readBool);
@@ -1270,6 +1305,7 @@ jspb.BinaryReader.prototype.readPackedBool = function() {
12701305
* Reads a packed enum field, which consists of a length header and a list of
12711306
* unsigned varints.
12721307
* @return {!Array<number>}
1308+
* @export
12731309
*/
12741310
jspb.BinaryReader.prototype.readPackedEnum = function() {
12751311
return this.readPackedField_(this.decoder_.readEnum);

0 commit comments

Comments
 (0)