This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-02
Channels
- # announcements (13)
- # babashka (42)
- # beginners (29)
- # calva (39)
- # cider (15)
- # clerk (10)
- # clojure (67)
- # clojure-europe (18)
- # clojure-hungary (2)
- # clojure-nl (1)
- # clojure-norway (12)
- # clojure-uk (7)
- # clojuredesign-podcast (14)
- # clojurescript (19)
- # datalevin (1)
- # datascript (5)
- # emacs (4)
- # events (2)
- # fulcro (5)
- # graalvm (5)
- # hyperfiddle (23)
- # incanter (3)
- # jobs (2)
- # lsp (8)
- # missionary (15)
- # off-topic (45)
- # portal (41)
- # practicalli (1)
- # re-frame (3)
- # reitit (6)
- # releases (2)
- # remote-jobs (1)
- # sci (1)
- # shadow-cljs (35)
- # solo-full-stack (8)
- # tools-deps (4)
Hi! When I set up Portfolio https://github.com/cjohansen/portfolio#shadow-cljs on an existing projet using shadow.lazy
, I get Could not find module for ns
error:
[:portfolio] Build failure:
------ ERROR -------------------------------------------------------------------
File: /home/xxx/myproject/diffusion/frontend/devcards/myproject/diffusion/frontend/components/recherche/avancee/nomenclature.cljs:24:17
--------------------------------------------------------------------------------
21 | [myproject.diffusion.frontend.components.recherche.common-nomenclature :as nomenclature-front]
22 | [myproject.diffusion.frontend.components.recherche.avancee.dewey :as front-dewey]))
23 |
24 | (def lazy-dewey (lazy/loadable myproject.diffusion.domain.nomenclature.dewey/nomenclature-dewey-notations-geographiques))
-----------------------^--------------------------------------------------------
Encountered error when macroexpanding shadow.lazy/loadable.
Could not find module for ns: myproject.diffusion.domain.nomenclature.dewey at line 24 myproject/diffusion/frontend/components/recherche/avancee/nomenclature.cljs
Any clue how can I debug? I suppose it's a classpath issue, right?More specifically, the error only occurs when I require a namespace from another build using code splitting via :modules
.
Otherwise it works. Is there any solution for this case?
this usually just means that this namespace is just not included in the build at all
Currently I have 2 builds: • The main app • One for portfolio
:dev-http {4005 ["resources/portfolio/public" "classpath:public"]}
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:module-loader true
:modules {:diffusion-frontend-main {:entries [myapp.diffusion.frontend.core]}
:nomenclature {:entries [myapp.diffusion.domain.nomenclature.public
myapp.diffusion.domain.nomenclature.genre
myapp.diffusion.domain.nomenclature.theme
myapp.diffusion.domain.nomenclature.support
myapp.diffusion.domain.nomenclature.source
myapp.diffusion.domain.nomenclature.fiction
myapp.diffusion.domain.nomenclature.scolaire
myapp.diffusion.domain.nomenclature.types-fichiers
myapp.diffusion.domain.nomenclature.type-produit] :depends-on #{:diffusion-frontend-main}}
:app {:entries [myapp.diffusion.frontend.pages.root] :depends-on #{:diffusion-frontend-main :nomenclature}}
:compiler-options {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
"day8.re_frame.tracing.trace_enabled_QMARK_" true}
:strip-type-prefixes #{"cljs.pprint"}}}
:portfolio {:target :browser
:output-dir "resources/portfolio/public/js"
:asset-path "/js"
:modules {:main {:entries [myapp.diffusion.frontend.portfolio]}}
Portfolio live in proper directory in project root :
portfolio/
├── myapp
│ └── diffusion
│ └── frontend
│ └── portfolio.cljs
OK, thanks! it seems obvious to me now 🙂
Last thing, Is there a clean solution to avoid duplicate modules settings between builds?
are you sure you are benefitting from code splitting at all? I mean does the initial app render without triggering a load of the other modules? the setup seems kinda like it would always load everything anways?
Good question. I don't really know if code splitting is currently benefic as this setup is already in place when I started to work on this project. As you say, I think an audit performance will be interesting in future.
May can I ask what about the setup seems always load everything? The different dependencies I suppose.
Is Shadow-cljs report a good start to debug this?
debug what? only you can answer how you use your code. my question was: when the user loads the initial page, does this additional module get loaded anyways?
since there were so many namespaces that kinda seemed like it was essential to your app in some way?
Yes indeed, this is the case. Some modules is loaded only when user clicks to access some pages and/or advanced features.
First of all, thanks for this very informative exchange.
in case you didn't see yet https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html
Already read at some time but thanks I'll refresh my memory.
About the current configuration, here is an loading execution example: 1. Hard reload on the homepage 2. Navigate to cart page load notice.js and panier.js 3. Go to advanced template settings page load gabarit.js
Seems good to me, right?
hmm no clue what notice,panier and gabarit are, they are not defined in the above config
and if the 4 files highlighted in green are all loaded at once, then what is the point is splitting them?
Hey all,
Does anybody know of any tricks to exclude an NPM dependency in a release build (`:target :browser`)?
I’m using a library during development-time only (https://www.npmjs.com/package/pseudolocale – helps catch missing localisations), and it exposes one function that I’m calling within (if ^boolean goog.DEBUG …)
. I never want to use it in a release build (though I guess goog.DEBUG
could be overridden to true
in a release build, so maybe that’s not how I should be thinking about this?)
Not a big deal if not (small library anyway), and it’s the first time I’ve wanted to do something like this in ~6 years of CLJS development, so maybe I’m just being a bit backwards here.
you can add :release {:js-options {:resolve {"pseudolocale" false}}}
to the build config
that will remove the lib from the release build, if its actually unused that should be fine
Perfect, thanks @U05224H0W! (also thanks so much for your work on shadow-cljs!)