day8 / re-com

A ClojureScript library of reusable components for Reagent
https://re-com.day8.com.au
MIT License
796 stars 147 forks source link

Re-com won't build with figwheel-main fig:min #336

Closed BnMcGn closed 4 months ago

BnMcGn commented 5 months ago

From a new figwheel-main project:

lein new figwheel-main retest -- --reagent

The generated project.clj, with re-com dependency added:

(defproject retest "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :min-lein-version "2.7.1"

  :dependencies [[org.clojure/clojure "1.10.0"]
                 [org.clojure/clojurescript "1.11.4"]
                 [cljsjs/react "17.0.2-0"]
                 [cljsjs/react-dom "17.0.2-0"]
                 [re-com "2.17.1"]
                 [reagent "1.1.1" ]]

  :source-paths ["src"]

  :aliases {"fig:build" ["trampoline" "run" "-m" "figwheel.main" "-b" "dev" "-r"]
            "fig:min"   ["run" "-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]
            "fig:test"  ["run" "-m" "figwheel.main" "-co" "test.cljs.edn" "-m" "retest.test-runner"]}

  :profiles {:dev {:dependencies [[com.bhauman/figwheel-main "0.2.17"]
                                  [org.slf4j/slf4j-nop "1.7.30"]
                                  [com.bhauman/rebel-readline-cljs "0.1.4"]]

                   :resource-paths ["target"]
                   ;; need to add the compiled assets to the :clean-targets
                   :clean-targets ^{:protect false} ["target"]}})

Also [re-com.core :as rc] has been added to the require list in src/retest/core.cljs

Attempting an optimized build:

lein fig:min

Results in:

[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build dev to "resources/public/cljs-out/dev-main.js"
Jan. 30, 2024 9:07:52 A.M. com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /home/ben/cljs/retest/resources/public/cljs-out/dev/goog/i18n/numberformat.js:963:8: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2019 mode or better: Optional catch binding.
  963|       } catch {
           ^

Jan. 30, 2024 9:07:52 A.M. com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /home/ben/cljs/retest/resources/public/cljs-out/dev/goog/i18n/numberformat.js:1011:6: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2019 mode or better: Optional catch binding.
  1011|     } catch {
          ^

Jan. 30, 2024 9:07:52 A.M. com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 2 error(s), 0 warning(s)
ERROR: JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2019 mode or better: Optional catch binding. at /home/ben/cljs/retest/resources/public/cljs-out/dev/goog/i18n/numberformat.js line 963 : 8
ERROR: JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2019 mode or better: Optional catch binding. at /home/ben/cljs/retest/resources/public/cljs-out/dev/goog/i18n/numberformat.js line 1011 : 6
[Figwheel] Failed to compile build dev in 15.746 seconds.
[Figwheel:WARNING] Compile Exception: Closure compilation failed  
[Figwheel:SEVERE] 
Exception in thread "main" Syntax error compiling at (/tmp/form-init11083397916225940470.clj:1:74).
null
    at clojure.lang.Compiler.load(Compiler.java:7647)
    at clojure.lang.Compiler.loadFile(Compiler.java:7573)
    at clojure.main$load_script.invokeStatic(main.clj:452)
    at clojure.main$init_opt.invokeStatic(main.clj:454)
    at clojure.main$init_opt.invoke(main.clj:454)
    at clojure.main$initialize.invokeStatic(main.clj:485)
    at clojure.main$null_opt.invokeStatic(main.clj:519)
    at clojure.main$null_opt.invoke(main.clj:516)
    at clojure.main$main.invokeStatic(main.clj:598)
    at clojure.main$main.doInvoke(main.clj:561)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.main.main(main.java:37)
Caused by: clojure.lang.ExceptionInfo: null {:clojure.error/phase :compilation}
    at cljs.util$compilation_error.invokeStatic(util.cljc:23)
    at cljs.util$compilation_error.invoke(util.cljc:22)
    at cljs.closure$report_failure.invokeStatic(closure.clj:421)
    at cljs.closure$report_failure.invoke(closure.clj:412)
    at cljs.closure$optimize.invokeStatic(closure.clj:1531)
    at cljs.closure$optimize.doInvoke(closure.clj:1495)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$apply.invoke(core.clj:660)
    at cljs.closure$build.invokeStatic(closure.clj:3298)
    at cljs.closure$build.invoke(closure.clj:3149)
    at cljs.build.api$build.invokeStatic(api.clj:231)
    at cljs.build.api$build.invoke(api.clj:212)
    at clojure.lang.AFn.applyToHelper(AFn.java:160)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$apply.invoke(core.clj:660)
    at figwheel.main$wrap_with_build_logging$fn__5968$fn__5974.invoke(main.cljc:187)
    at figwheel.main$wrap_with_build_logging$fn__5968.doInvoke(main.cljc:183)
    at clojure.lang.RestFn.applyTo(RestFn.java:146)
    at clojure.core$apply.invokeStatic(core.clj:671)
    at clojure.core$apply.invoke(core.clj:660)
    at figwheel.main$wrap_with_bundling$fn__5964.doInvoke(main.cljc:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:146)
    at clojure.core$apply.invokeStatic(core.clj:665)
    at clojure.core$apply.invoke(core.clj:660)
    at figwheel.main$wrap_with_build_hooks$fn__5987.doInvoke(main.cljc:210)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:665)
    at clojure.core$apply.invoke(core.clj:660)
    at figwheel.main$wrap_with_compiler_passes$fn__5990.doInvoke(main.cljc:219)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at figwheel.main$build.invokeStatic(main.cljc:1772)
    at figwheel.main$build.invoke(main.cljc:1768)
    at figwheel.main$default_compile$fn__8276.invoke(main.cljc:2194)
    at figwheel.main$default_compile.invokeStatic(main.cljc:2193)
    at figwheel.main$default_compile.invoke(main.cljc:2167)
    at figwheel.main$build_once_main_opt.invokeStatic(main.cljc:656)
    at figwheel.main$build_once_main_opt.invoke(main.cljc:655)
    at cljs.cli$main.invokeStatic(cli.clj:703)
    at cljs.cli$main.doInvoke(cli.clj:692)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$apply.invoke(core.clj:660)
    at cljs.main$_main.invokeStatic(main.clj:65)
    at cljs.main$_main.doInvoke(main.clj:56)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:665)
    at clojure.core$apply.invoke(core.clj:660)
    at figwheel.main$_main$fn__8472.invoke(main.cljc:2554)
    at clojure.core$with_redefs_fn.invokeStatic(core.clj:7514)
    at clojure.core$with_redefs_fn.invoke(core.clj:7498)
    at figwheel.main$_main.invokeStatic(main.cljc:2552)
    at figwheel.main$_main.doInvoke(main.cljc:2530)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.Var.invoke(Var.java:399)
    at user$eval140.invokeStatic(form-init11083397916225940470.clj:1)
    at user$eval140.invoke(form-init11083397916225940470.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7176)
    at clojure.lang.Compiler.eval(Compiler.java:7166)
    at clojure.lang.Compiler.load(Compiler.java:7635)
    ... 12 more
Caused by: java.lang.Exception: Closure compilation failed
    ... 71 more

The dev build works fine with lein fig:build

kimo-k commented 5 months ago

Hi, looks complicated. Any guess what the root cause might be? I'd try upgrading clojurescript and figwheel, maybe look over their changelogs.

If it still seems like a re-com issue, maybe try some older versions, see if you can find a particular update that causes this breakage.

kimo-k commented 5 months ago

Also I don't have much experience with figwheel - you might have more luck posting an issue there, or on the figwheel template repo.

BnMcGn commented 5 months ago

I dropped the re-com version back to 2.13.2 but got the same thing. Dropped the clojurescript version to 1.10.773, and the problem went away.

So it looks like some kind of compatibility issue between cljs 1.11 and re-com when advanced optimization is turned on.

Will dig some more...

BnMcGn commented 4 months ago

Works with:

[org.clojure/clojure "1.11.1"]
[org.clojure/clojurescript "1.11.132"]

in project.clj

It's a bug in early cljs 1.11, not a re-com problem.