Skip to content

Instantly share code, notes, and snippets.

@swannodette
Forked from hsestupin/project.clj
Last active December 15, 2015 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/8775213 to your computer and use it in GitHub Desktop.
Save swannodette/8775213 to your computer and use it in GitHub Desktop.
(defproject cljs-gwt "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/clojurescript "0.0-2138"]
[compojure "1.0.4"]
[hiccup "1.0.0"]]
:plugins [[lein-cljsbuild "1.0.1"]
[lein-ring "0.7.0"]]
:ring {:handler cljs-gwt.core/app}
:source-paths ["src/clj"]
:cljsbuild {
:builds [{:id "dev"
:source-paths ["src/cljs"]
:compiler {
:output-dir "resources/public/js/out/"
:output-to "resources/public/js/cljs_gwt.js"
:source-map true
:optimizations :none}}
{:id "prod"
:source-paths ["src/cljs"]
:compiler {
:output-to "resources/public/js/cljs_gwt.js"
:optimizations :advanced}}]})
@hsestupin
Copy link

It's not working also with the same browser error "Uncaught ReferenceError: goog is not defined".
It raises because lein-cljsbuild generates the following file structure:

resources/public/js/goog/ ...
resources/public/js/cljs_gwt/ ...
resources/public/js/cljs/ ...
resources/public/js/cljs_gwt.js

and cljs_gwt.js contains the only following strings:

goog.addDependency("base.js", ['goog'], []);
goog.addDependency("../cljs/core.js", ['cljs.core'], ['goog.string', 'goog.array', 'goog.object', 'goog.string.StringBuffer']);
goog.addDependency("../cljs_gwt/core.js", ['cljs_gwt.core'], ['cljs.core']);

So in fact "goog" object is really undefined within such generated file structure. Hope my explanation is clear.

@swannodette
Copy link
Author

@hsestupin, I've tweaked :output-dir. Also worth taking a look at https://github.com/magomimmo/cljs-start, I'm pretty sure they've solved the configuration problem.

@hsestupin
Copy link

And of course before trying your option I made "lein cljsbuild clean"

@swannodette
Copy link
Author

@hsestupin, actually you don't need to set :source-map-path since source maps are produced for every single file.

@hsestupin
Copy link

; The optimization level. May be :whitespace, :simple, or :advanced.
; Defaults to :whitespace.
:optimizations :whitespace

It's from "lein cljsbuild sample". And there is nothing said about :none option. Don't know why, but {:optimization :whitespace} generates working file-structure and sorce maps works well with that

@twashing
Copy link

I'm finding the same thing happening to me. :optimizations :whitespace generates the correct file and file structure. But :optimizations :none was giving me this error.

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