Effect CommunityEC
Effect Community3y ago
176 replies
fubhy

Limitations of Current Hook & Runtime Factory Pattern in Code Splitting/Chunking Scenarios

@TheStockBroker as discussed (/.cc @Tim Smart):

I think the current hook & runtime factory pattern (https://github.com/datner/react-effect/blob/main/src/RuntimeProvider.ts) falls flat in a code splitting / chunking scenario which is a common requirement these days.

If we have a single global R, it means that apps with heterogenous service requirements will have one possibly super sized Layer that poisons code splitting for the entire app.

E.g. imagine a landing page that uses useResult with an Effect with very slim set of requirements. With the current setup, unless I'm missing something, the landing page bundle would have to load all the code of all the unused Layers too. That seems wasteful and is probably not what we want.

Is there a way with which we could allow for more surgical approach to Layer composition e.g. at useResult call time?
Was this page helpful?