Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
272 stars 54 forks source link

Make MsgPack treeshakable to reduce bundle size when MsgPack isn't used #256

Closed bklop closed 3 years ago

bklop commented 3 years ago

This small change moves the MsgPack.Read reference to Remoting.withBinarySerialization. As long as you don't call that function, bundlers are free to treeshake the MsgPack stuff out. Previously the hard reference to MsgPack.Read in Proxy.executeRequest prevented this.

I've tested it on an application using Fable 3.2.2 and Webpack 5.38.1. The production bundle size decreased with 15KB (post-minification, but before compression). Enough to make it worthwhile IMHO 😄.

This shouldn't be a breaking change either, unless someone uses the RemoteBuilderOptions record directly...

Zaid-Ajaj commented 3 years ago

Published as of Fable.Remoting.Client v7.15 🚀 keep 'em coming 😄