This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-03
Channels
- # announcements (3)
- # babashka (29)
- # beginners (95)
- # calva (109)
- # cider (16)
- # clj-kondo (6)
- # clj-together (1)
- # cljdoc (2)
- # cljsrn (2)
- # clojure (85)
- # clojure-europe (26)
- # clojure-india (1)
- # clojure-seattle (1)
- # clojure-uk (6)
- # clojurescript (14)
- # conjure (4)
- # cursive (8)
- # datomic (6)
- # emacs (21)
- # events (1)
- # figwheel-main (5)
- # fulcro (11)
- # graalvm (32)
- # graphql (1)
- # holy-lambda (7)
- # humbleui (7)
- # jobs (3)
- # membrane (8)
- # nextjournal (31)
- # off-topic (29)
- # pathom (14)
- # polylith (9)
- # portal (16)
- # practicalli (4)
- # reitit (17)
- # releases (1)
- # remote-jobs (2)
- # ring (4)
- # sci (20)
- # shadow-cljs (24)
- # sql (1)
- # vim (12)
- # xtdb (3)
Since yesterday I'm struggling with conversion of my very old lein-figwheel based project (created with luminus almost 5 years ago)
to figwheel-main.
I updated a lot of dependencies and configuration and I think I'm close now.
But when I try to load the page it fails with these errors (see the image)
I struggled quite a bit with figwheel's configuration and was confused by what goes into dev.cljs.edn
vs figwheel-main.edn
After reading the first half of the documentation, it's much clearer and this is what I've got:
figwheel-main.edn
;; overriding default index.html page
;;
{:open-url ""
:css-dirs ["resources/public/css"] ;
:watch-dirs ["src/cljc" "src/cljs" "env/dev/cljs"] ;
;; automatically bundle JS dependencies like react:
:auto-bundle :webpack
}
http://dev.cljs.edn
{:main ***-
:log-level :info
;; re-frame-10x setup:
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
;; also install devtools via preload:
:preloads [devtools.preload day8.re-frame-10x.preload]
}
In package.json I included react and react-dom
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
},
How can I debug this problem?It's backend + frontend app. Backend serves an html page at configured url (http://localhost:5001/app) It looks like this:
<body>
<div id="app">
</div>
<!-- scripts and styles -->
<script type="text/javascript">
var context = "{{servlet-context}}";
var csrfToken = "{{csrf-token}}";
</script>
{% script "/assets/jquery/jquery.min.js" %}
{% script "/assets/popper.js/dist/umd/popper.min.js" %}
{% script "/assets/bootstrap/js/bootstrap.min.js" %}
<!-- original js/app.js script was built by old lein-figwheel -->
<!-- {% script "/js/app.js" %} -->
<!-- Here I include the dev build output produced by figwheel-main-->
{% script "/cljs-out/dev-main.js" %}
</body>
I got further - the first problem was that I was confused by figwheel lein aliases.
I was only running lein fig
while I was supposed to specify the dev
build.
I copied this alias into my :aliases
and trying it now
"fig:build" ["trampoline" "run" "-m" "figwheel.main" "-b" "dev" "-r"]
lein fig:build
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build dev to "target/public/cljs-out/dev/main.js"
...
[Figwheel] Failed to compile build dev in 15.35 seconds.
[Figwheel:WARNING] Compile Exception target/public/cljs-out/dev/day8/re_frame_10x/inlined_deps/reagent/v1v0v0/reagent/dom.cljs line:2 column:14
No such namespace: react-dom, could not locate react_dom.cljs, react_dom.cljc, or JavaScript source providing "react-dom" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file target/public/cljs-out/dev/day8/re_frame_10x/inlined_deps/reagent/v1v0v0/reagent/dom.cljs
1 (ns day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.dom
2 (:require [react-dom :as react-dom]
^---
3 [day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.impl.util :as util]
4 [day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.impl.template :as tmpl]
5 [day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.impl.input :as input]
6 [day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.impl.batching :as batch]
7 [day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.impl.protocols :as p]
[Figwheel:SEVERE] failed compiling file:target/public/cljs-out/dev/day8/re_frame_10x/inlined_deps/reagent/v1v0v0/reagent/dom.cljs
I'm not sure why this doesn't work - react-dom is specified in package.jsonAfter commenting out re-frame-10x I got another error. It seems that figwheel docs are incorrect, because for me the build output is target/public/cljs-out/[build-name]/main.js NOT target/public/cljs-out/[build-name]-main.js However, after fixing this I get another error
Uncaught SyntaxError: Cannot use import statement outside a module main.js:1
# main.js:1
import {npmDeps} from "./npm_deps.js";