fsprojects / FSharp.Data

F# Data: Library for Data Access
https://fsprojects.github.io/FSharp.Data
Other
816 stars 288 forks source link

Is it possible to make this library trimmable by default #1436

Open albertwoo opened 2 years ago

albertwoo commented 2 years ago

Description

I am using this library in blazor wasm application, but this library's bundle size is 1008kb which is a lot for a web application. I also created similar ticket for FSharp.Data.Adaptive, which they already made it hanppen. https://github.com/fsprojects/FSharp.Data.Adaptive/issues/104 And the result is pretty good.

Known workarounds

People can add below stuff to their own application to make it work. But it is better to have it support by default.

<Target Name="ConfigureTrimming" BeforeTargets="PrepareForILLink">
<ItemGroup>
    <ManagedAssemblyToLink Condition="'%(Filename)' == 'FSharp.Data'">
        <TrimMode>link</TrimMode>
        <IsTrimmable>true</IsTrimmable>
    </ManagedAssemblyToLink>
</ItemGroup>
</Target>
cartermp commented 2 years ago

This library does make a bit of use of reflection. I'm not sure what that means for trimmability.

albertwoo commented 2 years ago

Then below stuff should be able to add to the project file, so other people do not need to use the workaround.

<TrimMode>link</TrimMode>
<IsTrimmable>true</IsTrimmable>
albertwoo commented 2 years ago

Here is the docs: https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming