Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom tagged literals cause build failure #482

Open
cemerick opened this issue Nov 27, 2017 · 1 comment
Open

Custom tagged literals cause build failure #482

cemerick opened this issue Nov 27, 2017 · 1 comment

Comments

@cemerick
Copy link
Collaborator

In short, usage of custom tagged literals (aka "data readers") works as expected using cljs.build.api, but fails under cljsbuild.

A reproducing project is available here:

https://github.com/cemerick/failing-cljsbuild-data-readers

Using cljs.build.api:

$ lein run -m build
$ node target/out-min/min.js
we made a Bar: #cemerick.foo.Bar{:a 1, :b 2}

Using cljsbuild:

$ lein cljsbuild once min
Compiling ClojureScript...
Compiling ["target/out-min/min.js"] from ["src"]...
Compiling ["target/out-min/min.js"] failed.
clojure.lang.ExceptionInfo: failed compiling file:/mnt/g/dev/clojure/failing-data-readers/src/cemerick/foo.c
ljs {:file #object[java.io.File 0x239678d "/mnt/g/dev/clojure/failing-data-readers/src/cemerick/foo.cljs"]}
        at clojure.core$ex_info.invokeStatic(core.clj:4744)
        at clojure.core$ex_info.invoke(core.clj:4744)
        at cljs.compiler$compile_file$fn__4697.invoke(compiler.cljc:1552)
        at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1513)
        at cljs.compiler$compile_file.invoke(compiler.cljc:1489)
        at cljs.closure$compile_file.invokeStatic(closure.clj:540)
        at cljs.closure$compile_file.invoke(closure.clj:531)
        at cljs.closure$eval6952$fn__6953.invoke(closure.clj:609)
        at cljs.closure$eval6888$fn__6889$G__6877__6896.invoke(closure.clj:493)
        at cljs.closure$compile_sources$iter__7076__7080$fn__7081.invoke(closure.clj:954)
Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'cemerick.foo/read-bar
        at clojure.lang.Var$Unbound.throwArity(Var.java:45)
        at clojure.lang.AFn.invoke(AFn.java:32)
        at clojure.lang.Var.invoke(Var.java:381)
        at clojure.tools.reader$read_tagged.invokeStatic(reader.clj:854)
        at clojure.tools.reader$read_tagged.invoke(reader.clj:846)
        at clojure.tools.reader$read_dispatch.invokeStatic(reader.clj:71)
        at clojure.tools.reader$read_dispatch.invoke(reader.clj:66)
        at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:924)
        ... 78 more
Subprocess failed

I don't know how or why, but the Clojure file that contains the data reader var/fn is not loaded properly, though it is loaded at some point (which you can verify by adding a top-level println expr to cemerick/foo/bar.clj). As seen above, this issue is not present when cljsbuild isn't used.

@cemerick
Copy link
Collaborator Author

Just FWIW, it looks like cljsbuild is passing along a perfectly reasonable-looking map of compiler options:

{:output-wrapper true,
 :externs ["closure-js/externs"],
 :libs ["closure-js/libs"],
 :main cemerick.foo,
 :output-to "target/out-min/min.js",
 :output-dir "target/out-min",
 :optimizations :advanced,
 :pretty-print false,
 :target :nodejs}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants