Clojurescript code not built properly for production env

I have started a somewhat modified Chestnut-based project called vinculum ([repo][1] – I know some parts of the code are horrible and that nothing is finished – please bear with me, I am learning!). The web ui builds and loads fine in the development environment, but the Clojurescript code is not compiled properly when I enable the production env. When I browse to the server URL, I get a blank page and a console error: “Uncaught ReferenceError: goog is not defined” after following the standard build instructions. Clearly, the ClojureScript code is not compiling as it should.

The output from the uberjar build is also missing some of the outputs from the ClojureScript compilation:

 % lein with-profile -dev,+production uberjar                        
Compiling vinculum.dev
Compiling vinculum.dev
Compiling vinculum.server
Compiling vinculum.core
Compiling vinculum.database
Compiling ClojureScript.
Created /home/albin/projects/vinculum/target/vinculum-0.1.0-SNAPSHOT.jar
Created /home/albin/projects/vinculum/target/vinculum.jar```

These lines are missing compared to what is shown during the same process for a default empty Chestnut project:
```Compiling "resources/public/js/app.js" from ("src/cljs" "env/prod/cljs" "env/prod/cljs")...
Successfully compiled "resources/public/js/app.js" in 27.937 seconds.
Created /var/storage/downloads/test/target/test-0.1.0-SNAPSHOT.jar
Created /var/storage/downloads/test/target/test.jar```

The non-clojurescript code builds and runs fine, from what I can tell, and nothing seems to be missing from my project.clj. Clearly I am missing something trivial, but I cannot figure out what. Any clues? Thanks!


  [1]: https://github.com/albins/vinculum

After much debugging, I finally found the error. It turns out that the cljs compiler doesn’t understand that the *.js files from the developer build are stale when switching profiles, and so uses old, invalid versions. Simply running rm -rf resources/public/js/* fixed the issue.

1 Like