-
Notifications
You must be signed in to change notification settings - Fork 13
Reduce size impact of populateExchange #122
Conversation
Refactor some parts to avoid unnecessary immutability for micro-perf optimisations, and reduce size where possible by reusing helpers and swapping out immutability for mutability. Total minzipped size: 8.24kB -> 8.19kB
This isn't supported in IE11 and hence breaks compatibility if it isn't user polyfilled. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
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.
Looking good, a few savings/perf boosts found
Removes additional closures that aren't needed. Addresses PR comments
a1e8efe
to
abfd97a
Compare
533ddaa
to
b76cce9
Compare
userFragments, | ||
}: AddFragmentsToQuery) => { | ||
export const addFragmentsToQuery = ( | ||
schema: GraphQLSchema, |
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.
Is there an advantage to changing these to indexed parameters? It's less transparent as to what the arguments should be.
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 gets rid of the property names in the output JS (although I'd love if Terser would do that automatically)
I personally think it's still transparent since TS typehints (of the TS language server for instance) still give you the signature with names and types.
809e7a3
to
cc633a0
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.
Great work!
populateExchange
by reusing more helpers we already hadArray.from
for IE11 compatTests are still passing. 💯
5.73kB
6.62kB
6.6kB