cljs-lambda
cljs-lambda copied to clipboard
Incompatible with current ClojureScript (1.9.562)
The serverless template (and probably the main cljs-lambda template as well) is incompatible with the current (1.9.562) version of ClojureScript. Builds fail because java.lang.AssertionError: Assert failed: :nodejs target with :none optimizations requires a :main entry.
I've tried adding my .core namespace as the :main. Bizarrely, that leads to:
Exception in thread "main" java.lang.ClassNotFoundException:
[…]
Caused
by: java.lang.ClassNotFoundException:<project-name>.core
at
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at
clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at
clojure.lang.DynamicClassLoader.loadClass(DynamicClassLoader.java:77)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at
java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at
clojure.lang.RT.classForName(RT.java:2168)
at clojure.lang.RT.classForName(RT.java:2177)
at
clojure.lang.Compiler.resolveIn(Compiler.java:7145)
at
clojure.lang.Compiler.resolve(Compiler.java:7108)
at
clojure.lang.Compiler.analyzeSymbol(Compiler.java:7069)
at
clojure.lang.Compiler.analyze(Compiler.java:6648)
...
30 more
(where <project-name> is the name of the project)
It looks like Clojure is trying to find the namespace instead of ClojureScript? I have no idea what's going on at this point.
Thanks for reporting - when I update the template to point to a newer cljs I'll add in a default :main (or default to :simple).
As far as your attempt to fix it, I haven't seen this specific issue, though I've previously had issues with the compiler being weird about symbols being used for the namespace passed to :main instead of strings.
I can take a look at the project if that's helpful.
Ah, :simple works great! Thanks.
Adding :main works also for :none in 1.9.854. Weird that we need it though, I guess compiling for lambda was not considered as use case in ClojureScript compiler :smile:
hmm when I added :main :simple, the build worked but then I got:
2017-10-06T11:16:06.611Z be1d2fbc-aa87-11e7-a553-ed5b451ac831 goog.require could not find: _COLON_simple
oh I see... optimizations :simple not :main :simple
@Peeja I found setting the :cljs-lambda/:compiler/:options/:main key to clojure.core/identity made that issue go away - the language in the message gives you a clue, but I also initially assumed it was a top level key.
edit: but that may just push the problem downstream to runtime I think.
Hi, great discussion, thanks. However, when I upgrade to clojurescript 1.10.64 and clojure 1.9.0, but even when I try to change :optimizations to :simple or :main I am getting errors compiling:
Exception in thread "main" java.lang.AssertionError: Assert failed: :source-map true must specify a file in the same directory as :output-to "target/my_proj/my_proj.js" if optimization setting applied
(or (nil? (:output-to opts)) (:modules opts) (string? source-map)), compiling:(/private/var/folders/41/b5ntx4mn2mv9qk3jy
@JimTheMan the semantics of source-map change at different optimization levels: https://clojurescript.org/reference/compiler-options#source-map
Just so it's clearly and explicitly documented, this project.clj solved the issue for me:
(defproject example "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.312"]
[io.nervous/cljs-lambda "0.3.5"]]
:plugins [[lein-npm "0.6.2"]
[io.nervous/lein-cljs-lambda "0.6.6"]]
:npm {:dependencies [[serverless-cljs-plugin "0.1.2"]]}
:cljs-lambda {:compiler
{:inputs ["src"]
:options {:output-to "target/example/example.js"
:output-dir "target/example"
:target :nodejs
:language-in :ecmascript6
:optimizations :simple}}})
Is there somewhere I should issue a PR or something?
I'm happy to accept a pr - the leiningen template would be the place to put the change
On Fri, 22 Jun 2018, 18:53 the-frey, [email protected] wrote:
Is there somewhere I should issue a PR or something?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nervous-systems/cljs-lambda/issues/88#issuecomment-399525433, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYuK4PGqNlIqnwV3nm1vO0vdadXAc5Gks5t_S75gaJpZM4Nvbyb .