ClojureScript

"goog.require could not find: cljs_gwt.css" since compiler generates wrong code

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    [org.clojure/clojure "1.5.1"]
    [org.clojure/clojurescript "0.0-2156"]

    OSX 10.9.1
    Chrome Version 32.0.1700.102

Description

The project for which the problem occurred is here https://github.com/hsestupin/cljs-gwt.
Steps to reproduce the problem:
1) from one console: lein ring server
2) from other console: lein cljsbuild clean & lein cljsbuild auto dev
3) http://localhost:3000/ in Google Chrome with dev-tools console. There will be an error: "goog.require could not find: cljs_gwt.css"

It was happened because of cljs/cljs_gwt/core.cljs is beginning with lines

(ns cljs-gwt.core
  (:require [cljs-gwt.css :as css]))

And then ClojureScript compiler emits the following from previous 2 lines resources/public/js/cljs_gwt.js

goog.require("cljs_gwt.css");
goog.require("cljs_gwt.css");

instead of

goog.provide("cljs_gwt.css");
goog.require("cljs_gwt.css");

therefore an error occurred. That's it.

Activity

Hide
Francis Avila added a comment -

There is no goog.provide("cljs_gwt.css") emitted because there is no file that provides that namespace. Your css.clj file is misnamed--it should be css.cljs, otherwise clojurescript won't see it. (Also it has unbalanced parens and an illegal set!, so it won't compile anyway.)

There are two minor issues that you did hit upon, though:

  • You should have gotten a compiler warning for the missing namespace. I'm not sure why you didn't.
  • The cljs compiler may emit the same goog.require multiple times. This doesn't harm anything and the google closure compiler will remove them all.
Show
Francis Avila added a comment - There is no goog.provide("cljs_gwt.css") emitted because there is no file that provides that namespace. Your css.clj file is misnamed--it should be css.cljs, otherwise clojurescript won't see it. (Also it has unbalanced parens and an illegal set!, so it won't compile anyway.) There are two minor issues that you did hit upon, though:
  • You should have gotten a compiler warning for the missing namespace. I'm not sure why you didn't.
  • The cljs compiler may emit the same goog.require multiple times. This doesn't harm anything and the google closure compiler will remove them all.
Hide
Sergey Stupin added a comment -

Thanks for explanation, it helps a lot.

Show
Sergey Stupin added a comment - Thanks for explanation, it helps a lot.
David Nolen made changes -
Field Original Value New Value
Resolution Declined [ 2 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: