This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-16
Channels
- # announcements (19)
- # babashka (13)
- # beginners (7)
- # calva (8)
- # cider (25)
- # clj-kondo (12)
- # cljsrn (7)
- # clojure (60)
- # clojure-australia (5)
- # clojure-europe (59)
- # clojure-france (14)
- # clojure-gamedev (2)
- # clojure-nl (1)
- # clojure-uk (7)
- # clojurescript (43)
- # community-development (8)
- # core-async (2)
- # cursive (15)
- # datomic (75)
- # deps-new (31)
- # depstar (1)
- # fulcro (6)
- # graalvm (53)
- # holy-lambda (1)
- # juxt (3)
- # jvm (13)
- # kaocha (8)
- # lsp (109)
- # malli (14)
- # off-topic (62)
- # pathom (11)
- # pedestal (12)
- # polylith (12)
- # releases (5)
- # sci (5)
- # shadow-cljs (15)
- # sql (16)
- # tools-deps (27)
- # vim (1)
- # xtdb (14)
On the topic of code splitting, I was wondering if there is a way to load chunks dynamically after a component has mounted. Say I have a login page and I know that a large amount of users will go onto the home page, at the moment I would have a sign-in
and home
module, and the home bundle would start downloading as soon as I click login. But it would make a lot more sense to say ‘after sign-in has mounted, start downloading the home
module’. With webpack I could do this
function SignUp() {
useEffect(() => {
import('./home')
}, []);
...
}
Is there a way of doing this with shadow?@alex395 see https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html
Like this creates a single ‘users’ bundle file that includes three pages
:users
{:entries [demo.components.account-overview
demo.components.sign-in
demo.components.sign-up]
:depends-on #{:main}}
But I wanted to know if you can have individual bundles, but pre download future bundles after a page has loaded and the component has mountedI don't know what more to say that what isn't already in the post. the example you picked is a literal example trying to describe how different way of splitting may make sense in your app
sometimes grouping stuff is useful sometimes it may not be. all depends on what exactly your app does so I cannot answer that
I mean (useEffect #(sl/load users-bundle) #js [])
would be the preloading your mentioned
what you don't get is a automatic splitting webpack does. you are required to define :modules
yourself. I believe that to a better way to do stuff but it requires more thought
Ok yeah I’ve just looked at the actual code, I assumed the wrong thing about how lazy-component
worked