Fork me on GitHub
#figwheel-main
<
2022-05-03
>
cheewah03:05:51

thanks https://app.slack.com/team/U6GNVEWQG , i tried restarting, waiting longer, refreshing the page and also using different browsers, but none work once i have :target :bundle. lsof also shows similar connections with/without using :target :bundle

cheewah03:05:17

think i will just try out other tool chain for now

athomasoriginal18:05:59

Are there any other properties in your build file?

cheewah02:05:00

dev.cljs.edn 's content

^{:watch-dirs ["test" "src"]
  :css-dirs ["resources/public/css"]
  :auto-testing true
  :log-file "figwheel-main.log"
  :log-level :trace
  :client-log-level :finest}
{:main learn-cljs.weather
 :clean-outputs true
 :target :bundle
 :bundle-cmd {:none ["npx" "webpack" "--mode=development"
                     "--entry" :output-to
                     "--output-path" :final-output-dir
                     "--output-filename" :final-output-filename]
              :default ["npx" "webpack" "--mode=production"
                        "--entry" :output-to
                        "--output-path" :final-output-dir
                        "--output-filename" :final-output-filename]}}
nothing in figwheel-main.edn

cheewah02:05:06

the project is basically created from example provided by https://www.learn-clojurescript.com/ mainly just, saved the following to ~/.clojure/deps.edn

{:aliases
 {:new {:extra-deps {seancorfield/clj-new
                     {:mvn/version "1.1.243"}}
        :exec-fn clj-new/create
        :exec-args {}}}}
and run
clj -X:new :template figwheel-main :name learn-cljs/weather :args '["+deps" "--reagent"]'
then i just changed :target to :bundle and added :bundle-cmd . problem disappears if i comment out :target

athomasoriginal12:05:23

Could you try to update your figwheel build to this instead?

^{:auto-bundle      :webpack
  :css-dirs         ["resources/public"]
  :watch-dirs       ["src" "test"]}
{:main learn-cljs.weather}
And see if your able to 1. still run the app (I don’t know what the src looks like) and 2. that you can connect via the REPL. (ensure you have webpack and webpack-cli installed as well)

cheewah16:05:01

thanks. i changed dev.cljs.edn to above and still face the same issue deps.edn

{:deps {org.clojure/clojure {:mvn/version "1.10.0"}
        org.clojure/clojurescript {:mvn/version "1.11.4"}}
 :paths ["src" "resources"]
 :aliases {:fig {:extra-deps
                 {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
                  org.slf4j/slf4j-nop {:mvn/version "1.7.30"}
                  com.bhauman/figwheel-main {:mvn/version "0.2.17"}}
                 :extra-paths ["target" "test"]}
           :build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]}
           :min   {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]}
           :test  {:main-opts ["-m" "figwheel.main" "-co" "test.cljs.edn" "-m" "learn-cljs.test-runner"]}}}
src/learn-cljs/weather.cljs
(ns ^:figwheel-hooks learn-cljs.weather)

(println "This text is printed from src/learn_cljs/weather.cljs. Go     ahead and edit it and see reloading in action.")

(defn mount-app-element []
  (println "mount called"))

;; conditionally start your application based on the presence of an "app" element
;; this is particularly helpful for testing this ns without launching the app
(mount-app-element)

;; specify reload hook with ^:after-load metadata
(defn ^:after-load on-reload []
  (mount-app-element))

cheewah16:05:07

package.json

{
  "devDependencies": {
    "webpack": "^5.72.0",
    "webpack-cli": "^4.9.2"
  }
}

cheewah16:05:37

i do notice the following though Figwheel says compiled output is dev/main.js and after bundling is dev/main_bundle.js:

[Figwheel] Compiling build dev to "target/public/cljs-out/dev/main.js"                                                                                                                                                                        
[Figwheel] Successfully compiled build dev to "target/public/cljs-out/dev/main.js" in 9.747 seconds.                                                                                                                                          
[Figwheel] Bundling: npx webpack --mode=development --entry ./target/public/cljs-out/dev/main.js --output-path ./target/public/cljs-out/dev --output-filename main_bundle.js
but in html i see it is still using the output dev-main.js (which is without using bundle).
<script src="cljs-out/dev-main.js" type="text/javascript"></script>
could this be the problem?

athomasoriginal20:05:02

Do you see an error in your browser console saying it can’t find dev-main.js ? If yes, update your index.html script reference to dev/main.js

cheewah01:05:59

i changed to <script src="cljs-out/dev/main_bundle.js" and it is working now. thanks athomasoriginal for all your helps 👍 ps: there was no error message in the browser console, probably because dev-main.js was still around due to previous build. i have :clean-outputs true but it seems to only clean up either based on current :target or the folder dev.

🎉 1