ghcjs / jsaddle

JavaScript interface that works with GHCJS or GHC
116 stars 62 forks source link

Made the lens dependency optional #124

Closed ilyakooo0 closed 2 years ago

ilyakooo0 commented 3 years ago

When using the library to develop frontends (compiled with GHCJS) some might want to speed up the page loading time by reducing the size of the generated js.

lens had a pretty big dependency footprint which might otherwise not be needed in a frontend application.

The only thing the lens library is really needed for is for generating IndexPreservingGetters. IMO a large portion of the uses of the IndexPreservingGetters is just as plain Getters.


This PR adds a flag that disables the lens dependency, regressing all IndexPreservingGetters to Getters.

This is not a breaking change since the default is to preserve the previous behavior.

hamishmack commented 2 years ago

ghcjs should do function level tree shaking to remove all the unused parts of lens. Does this really make the final code size smaller? If so it may be that ghcjs tree shaking is broken. Can you please provide an example that demonstrates code size savings?

ilyakooo0 commented 2 years ago

Turns out it doesn’t make much of a difference.

Feel free to close this