Hello,
At my workplace I’ve instigated a ClojureScript project (running on node and browser); to encourage acceptance I’ve promoted the fact that incorporating plain old JS is not a problem. I now find myself with a mix of cljs and js each calling functions from one to the other. It appeared to be working up to 1.9.1032 but the update to the Closure Compiler (72e2ab6e) appears to have broken my build (I used git bisect to pinpoint the breakage). I haven’t been able to exactly reproduce the problem in a minimal reproducible case, but this is my attempt: au-phiware/cljs-in-js-in-cljs. It exhibits some interesting behaviour between 1.9.1032 and 1.9.1033.
First off I’m not even sure my approach is the most sensible or if I’m pushing things in the wrong direction. The majority of the project is written in cljs, some of which calls upon some functionality in a es6 module, e.g.
(ns hello.core
(:require [hello.es-module :refer [greet]]))
(greet "test")
And some of those es6 modules need to call upon some core functionality that is back in the cljs code. To get access to that functionality I have used goog.require
, e.g.
goog.require("hello.say");
export var greet = function(m) {
document.write(hello.say.it(m));
};
Thus that functionality must be exported, e.g.
(ns hello.say)
(defn ^:export it [m]
(str "Hello, " m))
Now, proir to 1.9.1033, the compiler would emit the expected goog.provide
and transform the export statement. With 1.9.1033, the compiler emits goog.require("goog");
and an extra goog.require
for the cljs ns, e.g.
goog.provide("module$usr$src$hello$es_module");
goog.require("goog");
goog.require("hello.say");
goog.require("hello.say");var greet$$module$usr$src$hello$es_module=function(m){document.write(hello.say.it(m))};var module$usr$src$hello$es_module={};module$usr$src$hello$es_module.greet=greet$$module$usr$src$hello$es_module
Compiling with simple optimizations, the goog.require("goog");
appears to confuse the cljs compiler because it adds it itself (src/main/clojure/cljs/closure.clj line 2716) and winds up with two. I notice that there’s already an issue for this: CLJS-1677 but is a low priority.
I guess I’m looking for advice and/or workarounds. Thanks!