Skip to content

Is this library trimmable #104

Closed
Closed

Description

@albertwoo

I am using this library in blazor application, but the size of this library is 1713kb after published. Is it possible to make it trimmable?

Activity

  1. krauthaufen commented on May 1, 2022

    @krauthaufen
    Collaborator

    Hey, what do you mean by trimmable? I'm not familiar with the term but I assume some sort of dead-code removal?

  2. albertwoo commented on May 1, 2022

    @albertwoo
    Author

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

    Simply speaking, if this library is not using reflection then is should be ok to add:

    <TrimMode>link</TrimMode>
    <IsTrimmable>true</IsTrimmable>

    But need to verify that.

  3. krauthaufen commented on May 1, 2022

    @krauthaufen
    Collaborator

    It is actually using some reflection bits for building cheap(conservarive) equality comparisons

  4. albertwoo commented on May 1, 2022

    @albertwoo
    Author

    It may need extra work to annotate that.

  5. krauthaufen commented on May 1, 2022

    @krauthaufen
    Collaborator

    Basically reflection usage quite limited and iirc only used ror generating these equality-comparers, so it should be fairly easy to get that running, for some datastructures there's a specialized cheap equals method afair which is then used by the reflection code. If you want to look for these things yourself ShallowEquality is the thing to look for. When I have a little time I can investigate this myself but it might take a few days
    Cheers

  6. krauthaufen commented on May 1, 2022

    @krauthaufen
    Collaborator

    I quickly took a look and it basically boils down to one helper function that is only called via reflection, all the other things should be fine as long as the trimming process doesn't remove fields from types, sadly I also can't offer any guarantees that this will work. Maybe publishing the test-project trimmed could be sufficient to show that nothing crucial gets removed...

  7. krauthaufen commented on May 1, 2022

    @krauthaufen
    Collaborator

    Just to be clear here we need to build the core library with net6.0 for that to work right?

  8. krauthaufen commented on May 1, 2022

    @krauthaufen
    Collaborator

    I have it running in a branch trimmed-publish and a very simple test works

    > ls -lh FSharp.Data.Adaptive.dll 
    -rw-r--r--  1 schorsch  staff    35K  1 May 19:39 FSharp.Data.Adaptive.dll
    > ./PublishTrimmedTest   
    20
    200
    

    I'll test some more things but it looks good so far

  9. krauthaufen commented on May 1, 2022

    @krauthaufen
    Collaborator

    After some local tests I think this works. I'm getting properly trimmed binaries and everything I tested still works as intended.

    I'll just get a new version out now so you can test your project with it and I expect nothing to break in absence of trimming.
    The new version is 1.2.13 and should be on nuget any minute.

    Please let me know if your tests are successful.
    Cheers

  10. albertwoo commented on May 2, 2022

    @albertwoo
    Author

    @krauthaufen it works so great. Currently no errors. And the bundle size is 55KB in compressed in br format for my app.

    So great!!! Thanks for your great and quick job!!! 👍🚀

  11. krauthaufen commented on May 2, 2022

    @krauthaufen
    Collaborator

    Nice, out of curiosity: what are you using it for?

  12. albertwoo commented on May 2, 2022

    @albertwoo
    Author

    I am building a nuget library for F# developers to write blazor application. Similar to bolero but in my own optionated way.
    https://github.com/slaveOftime/Fun.Blazor

  13. krauthaufen commented on May 2, 2022

    @krauthaufen
    Collaborator

    Cool, nice to see the library in use 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions