jarohen / chord

A library designed to bridge the gap between the triad of CLJ/CLJS, web-sockets and core.async.
439 stars 40 forks source link

Strange exception while having :optimizations :none in cljsbuild #43

Closed moxaj closed 9 years ago

moxaj commented 9 years ago

I get the following exception while building with :optimizations :none:

java.lang.IllegalArgumentException: character to be escaped is missing at java.util.regex.Matcher.appendReplacement(Matcher.java:809) at java.util.regex.Matcher.replaceAll(Matcher.java:955) at clojure.string$replace.invoke(string.clj:104) at cljs.closure$lib_rel_path.invoke(closure.clj:1202) at cljs.closure$rel_output_path.invoke(closure.clj:1221) at cljs.closure$write_javascript.invoke(closure.clj:1342) at cljs.closure$source_on_disk.invoke(closure.clj:1375) at cljs.closure$output_unoptimized$fn3879.invoke(closure.clj:1409) at clojure.core$map$fn4553.invoke(core.clj:2624) at clojure.lang.LazySeq.sval(LazySeq.java:40) at clojure.lang.LazySeq.seq(LazySeq.java:49) at clojure.lang.RT.seq(RT.java:507) at clojure.core$seq4128.invoke(core.clj:137) at clojure.core$filter$fn4580.invoke(core.clj:2679) at clojure.lang.LazySeq.sval(LazySeq.java:40) at clojure.lang.LazySeq.seq(LazySeq.java:49) at clojure.lang.RT.seq(RT.java:507) at clojure.core$seq4128.invoke(core.clj:137) at clojure.core$map$fn4553.invoke(core.clj:2616) at clojure.lang.LazySeq.sval(LazySeq.java:40) at clojure.lang.LazySeq.seq(LazySeq.java:49) at clojure.lang.Cons.next(Cons.java:39) at clojure.lang.RT.next(RT.java:674) at clojure.core$next4112.invoke(core.clj:64) at clojure.core$str$fn4188.invoke(core.clj:530) at clojure.core$str.doInvoke(core.clj:528) at clojure.lang.RestFn.applyTo(RestFn.java:139) at clojure.core$apply.invoke(core.clj:630) at cljs.closure$deps_file.invoke(closure.clj:1102) at cljs.closure$output_deps_file.invoke(closure.clj:1122) at cljs.closure$output_unoptimized.doInvoke(closure.clj:1417) at clojure.lang.RestFn.applyTo(RestFn.java:139) at clojure.core$apply.invoke(core.clj:632) at cljs.closure$build.invoke(closure.clj:1714) at cljs.closure$build.invoke(closure.clj:1627) at cljsbuild.compiler$compile_cljs$fn4085.invoke(compiler.clj:81) at cljsbuild.compiler$compile_cljs.invoke(compiler.clj:80) at cljsbuild.compiler$run_compiler.invoke(compiler.clj:187) at user$eval4219$iter42554259$fn4260$fn4278.invoke(form-init2688236187975739560.clj:1) at user$eval4219$iter42554259$fn4260.invoke(form-init2688236187975739560.clj:1) at clojure.lang.LazySeq.sval(LazySeq.java:40) at clojure.lang.LazySeq.seq(LazySeq.java:49) at clojure.lang.RT.seq(RT.java:507) at clojure.core$seq__4128.invoke(core.clj:137) at clojure.core$dorun.invoke(core.clj:3009) at clojure.core$doall.invoke(core.clj:3025) at user$eval4219.invoke(form-init2688236187975739560.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6782) at clojure.lang.Compiler.eval(Compiler.java:6772) at clojure.lang.Compiler.load(Compiler.java:7227) at clojure.lang.Compiler.loadFile(Compiler.java:7165) at clojure.main$load_script.invoke(main.clj:275) at clojure.main$init_opt.invoke(main.clj:280) at clojure.main$initialize.invoke(main.clj:308) at clojure.main$null_opt.invoke(main.clj:343) at clojure.main$main.doInvoke(main.clj:421) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Subprocess failed

Importing only [chord.client :refer [ws-ch]] procs this issue. However, with :optimizations :whitespace it successfully compiles. What am I missing?

jarohen commented 9 years ago

Hi there - this is a strange one - usually CLJS things don't work when you apply a higher optimisation level!

Will take a look - have you got a sample project you could post?

Cheers,

James

moxaj commented 9 years ago

This is my project.clj:

(defproject cat-game "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "1.7.48"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [org.clojure/tools.reader "0.9.2"] [com.stuartsierra/component "0.2.3"] [reloaded.repl "0.1.0"] [quil "2.2.6"] [http-kit "2.1.18"] [overtone/at-at "1.2.0"] [compojure "1.4.0"] [jarohen/chord "0.6.0"] [ring "1.4.0"] [ring/ring-defaults "0.1.5"] [org.clojure/java.jdbc "0.4.1"] [com.h2database/h2 "1.3.170"]] :plugins [[lein-cljsbuild "1.0.6"] [lein-figwheel "0.3.7"]] :cljsbuild {:builds [{:id "fig" :source-paths ["src/client"] :figwheel true :compiler {:asset-path "js/out" :output-to "resources/public/js/app.js" :output-dir "resources/public/js/out" :optimizations :none :main "client.main"}}]})

As for the source files, a simple (ns client.main (:require [chord.client :refer [ws-ch]])) will do. I suspect it's a problem on my end, although I haven't figured it out yet (for now, I'm developing without chord).

Cheers

jarohen commented 9 years ago

Hi,

I've tried this with a minimal project.clj, and it compiles fine:

(defproject cat-game "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.48"]
                 [jarohen/chord "0.6.0"]]
  :exclusions [org.clojure/clojure
               org.clojure/clojurescript]
  :plugins [[lein-cljsbuild "1.0.6"]
            [lein-figwheel "0.3.7"]]
  :cljsbuild {:builds [{:id "fig"
                        :source-paths ["src/client"]
                        :figwheel true
                        :compiler {:asset-path "js/out"
                                   :output-to "resources/public/js/app.js"
                                   :output-dir "resources/public/js/out"
                                   :optimizations :none
                                   :main "client.main"}}]})

src/client/client/main.cljs:

(ns client.main
  (:require [chord.client :refer [ws-ch]]))

(js/console.log "Hello world!")

(note that the source file is under src/client/client/main.cljs, because you've specified the source-path as src/client)

Could you confirm whether this works for you?

James

jarohen commented 9 years ago

(Also worth specifying that I ran this with lein with-profile -user figwheel, to remove any chance that my ~/.lein/profiles.clj :user profile was interfering with the build!)

conan commented 9 years ago

I've also seen this problem in a few different places, including my current project. My first question: are you running on Windows? I think there's a good chance this is a windows-only problem.

conan commented 9 years ago

Incidentally I don't think this has anything to do with chord.

conan commented 9 years ago

I've fixed the problem for me by upgrading my cljs version to the latest (1.7.122). It's a pre-release version, but a downgrade may also help. I experienced the problem with version 1.7.48.

moxaj commented 9 years ago

Thanks for the info! I'm using win10, so it could be the culprit.

conan commented 9 years ago

If you get it fixed with a cljs upgrade, probably best to close this issue. Like I say, I think it's unlikely to be a problem that can be fixed here in chord.