[ClojureScript] Weird unexpected error when building a target for the second time.

2015-09-16 Thread J . Pablo Fernández
I turned on verbosity of cljsbuild to try to understand what's going on, the 
first time I run lein cljsbuild once I see this:

$ lein cljsbuild once
Compiling ClojureScript.
Compiling "resources/public/js/app.js" from ("src/cljs" "src/cljc" 
"env/dev/cljs")...
... lots of output 
Successfully compiled "resources/public/js/app.js" in 13.321 seconds.
Compiling "target/js/server-side.js" from ["src/cljs" "src/cljc" "src/node"]...
Analyzing 
jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/core.cljs
Analyzing 
jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/core.cljs
Applying optimizations :simple to 12 sources
Successfully compiled "target/js/server-side.js" in 16.043 seconds.

Note that it said it was optimizing 12 sources. When I run it again, with a 
small change so that target/js/server-side.js needs to be recompiled, this 
happens:

$ lein cljsbuild once
Compiling ClojureScript.
Compiling "target/js/server-side.js" from ["src/cljs" "src/cljc" "src/node"]...
Analyzing 
jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/core.cljs
Analyzing 
jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.122/clojurescript-1.7.122.jar!/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/nodejs.cljs
Compiling target/js/server-side/cljs/core.cljs
Applying optimizations :simple to 13 sources
Sep 16, 2015 11:29:22 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: cljs.nodejs:1: ERROR - namespace "cljs.nodejs" cannot be provided twice
goog.provide('cljs.nodejs');
^

Sep 16, 2015 11:29:22 PM com.google.javascript.jscomp.LoggerErrorManager 
printSummary
WARNING: 1 error(s), 0 warning(s)
ERROR: JSC_DUPLICATE_NAMESPACE_ERROR. namespace "cljs.nodejs" cannot be 
provided twice at cljs.nodejs line 1 : 0
Successfully compiled "target/js/server-side.js" in 11.125 seconds.

So how now it says it's optimizing 13 sources and boom! it fails. Any ideas why?

Going into a bit of details, my project.clj looks like this:

(defproject projectx "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"]
 [ring-server "0.4.0"]
 [cljsjs/react "0.13.3-1"]
 [reagent "0.5.1"]
 [reagent-forms "0.5.9"]
 [reagent-utils "0.1.5"]
 [ring "1.4.0"]
 [ring/ring-defaults "0.1.5"]
 [prone "0.8.2"]
 [compojure "1.4.0"]
 [hiccup "1.0.5"]
 [environ "1.0.1"]
 [org.clojure/clojurescript "1.7.122" :scope "provided"]
 [bidi "1.21.0"]
 [kibu/pushy "0.3.3"]
 [aleph "0.4.0"]]

  :plugins [[lein-environ "1.0.0"]
[lein-asset-minifier "0.2.2"]
[lein-npm "0.6.1"]]

  :ring {:handler  projectx.handler/app
 :uberwar-name "projectx.war"}

  :min-lein-version "2.5.0"

  :uberjar-name "projectx.jar"

  :main projectx.server

  :clean-targets ^{:protect false} [:target-path
[:cljsbuild :builds :app :compiler 
:output-dir]
[:cljsbuild :builds :app :compiler 
:output-to]]

  :source-paths ["src/clj" "src/cljc"]

  :minify-assets {:assets {"resources/public/css/site.min.css" 
"resources/public/css/site.css"}}

  :cljsbuild {:builds {:app {:source-paths ["src/cljs" "src/cljc"]
 :compiler {:output-to  
"resources/public/js/app.js"
:output-dir 
"resources/public/js/app"
:main   "projectx.dev"
:verbosetrue}}
   :server-side {:source-paths ["src/cljs" "src/cljc" 
"src/node"]
 :compiler {:output-to 
"target/js/server-side.js"
:output-dir
"target/js/server-side"
:target:nodejs
:main  
"projectx.node"
:optimizations :simple
:verbose   true
  :npm {:dependencies [[xmlhttprequest "1.7.0"]
   [express "4.13.3"]]}

  :profiles {:dev {:repl-options {:init-ns projectx.repl}

   :dependencies [[ring/ring-mock "0.3.0"]
  [ring/ring-devel "1.4.0

[ClojureScript] Puzzling error: Namespace "com.cognitect.transit.util" already declared.

2015-09-12 Thread J . Pablo Fernández
Hello,

I'm working on loading and running my ClojureScript application on Nashorn, a 
JavaScript implementation that runs inside Java. The purpose is to pre-render 
single page applications. I managed to do it with avery simple application and, 
in case anybody is curious, I'm publishing the results here: 
https://carouselapps.com/2015/09/11/isomorphic-clojurescriptjavascript-for-pre-rendering-single-page-applications-part-1/

When trying to run bigger applications I'm running into lots of little errors 
and issues and solving them one by one. There's one error though that is really 
puzzling. When I require ajax.core, as in:

(ns projectx.handlers
  (:require [ajax.core :as ajax]))

I get this error:

Error: Namespace "com.cognitect.transit.util" already declared.

The traceback is:

Caused by: :19664:6 Error: Namespace "com.cognitect.transit.util" already 
declared.
at 
jdk.nashorn.internal.objects.NativeError.initException(NativeError.java:137)
at jdk.nashorn.internal.objects.NativeError.(NativeError.java:102)
at jdk.nashorn.internal.objects.NativeError.(NativeError.java:106)
at jdk.nashorn.internal.objects.NativeError.(NativeError.java:110)
at 
jdk.nashorn.internal.objects.NativeError.constructor(NativeError.java:129)
at 
jdk.nashorn.internal.scripts.Script$Recompilation$1544$602593A$\^eval\_.provide(:19664)
at 
jdk.nashorn.internal.scripts.Script$Recompilation$1681$\^eval\_.:program$:split-9(:57262)
at jdk.nashorn.internal.scripts.Script$1285$\^eval\_.:program()
at 
jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)
at 
jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
at 
jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
at 
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:437)
... 66 more


line 57262 indeed contains: 

goog.provide("com.cognitect.transit.util");

Trying to figure out how it could be duplicated:

$ grep -R provide.*com\.cognitect\.transit\.util .
./resources/public/js/app/com/cognitect/transit/util.js:goog.provide("com.cognitect.transit.util");
./resources/public/js/server-side/com/cognitect/transit/util.js:goog.provide("com.cognitect.transit.util");
./resources/public/js/server-side.js:goog.provide("com.cognitect.transit.util");

sever-side.js is the only file that is being loaded in Nashorn. Nothing from 
app should ever be loaded as it is a different build target and I don't 
understand how util.js could be loaded, but just in case I commented it out and 
I keep receiving the same error. Which only happens when I'm loading ajax.core.

Any ideas what's going on here? This one left me scratching my head as no 
matter how I poke it, nothing makes sense.

Thanks.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.