Skip to content
This repository has been archived by the owner on Oct 22, 2022. It is now read-only.

Incompatible with current ClojureScript (1.9.562) #88

Open
Peeja opened this issue Jun 4, 2017 · 11 comments
Open

Incompatible with current ClojureScript (1.9.562) #88

Peeja opened this issue Jun 4, 2017 · 11 comments

Comments

@Peeja
Copy link

Peeja commented Jun 4, 2017

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.

@moea
Copy link
Member

moea commented Jun 4, 2017

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.

@Peeja
Copy link
Author

Peeja commented Jun 4, 2017

Ah, :simple works great! Thanks.

@arichiardi
Copy link

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 😄

@tobowers
Copy link

tobowers commented Oct 6, 2017

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

@tobowers
Copy link

tobowers commented Oct 6, 2017

oh I see... optimizations :simple not :main :simple

@j0ni
Copy link

j0ni commented Dec 21, 2017

@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.

@JimLynchCodes
Copy link

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

@moea
Copy link
Member

moea commented Mar 3, 2018

@JimTheMan the semantics of source-map change at different optimization levels: https://clojurescript.org/reference/compiler-options#source-map

@the-frey
Copy link
Contributor

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}}})

@the-frey
Copy link
Contributor

Is there somewhere I should issue a PR or something?

@moea
Copy link
Member

moea commented Jun 22, 2018 via email

the-frey added a commit to the-frey/cljs-lambda that referenced this issue Jun 22, 2018
moea pushed a commit that referenced this issue Jul 3, 2018
* Address #88 by bumping versions in template project.clj

* Update serverless config to use never node version.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants