This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-22
Channels
- # aws (1)
- # beginners (102)
- # boot (5)
- # cljs-dev (59)
- # cljsjs (1)
- # clojure (154)
- # clojure-australia (1)
- # clojure-brasil (1)
- # clojure-dusseldorf (4)
- # clojure-greece (36)
- # clojure-italy (10)
- # clojure-poland (5)
- # clojure-romania (1)
- # clojure-russia (7)
- # clojure-spec (32)
- # clojure-uk (113)
- # clojure-ukraine (3)
- # clojurescript (107)
- # cursive (13)
- # data-science (25)
- # datomic (23)
- # emacs (3)
- # events (1)
- # fulcro (72)
- # funcool (10)
- # graphql (1)
- # leiningen (1)
- # luminus (2)
- # lumo (38)
- # off-topic (14)
- # onyx (78)
- # planck (4)
- # re-frame (55)
- # reagent (1)
- # ring (3)
- # ring-swagger (2)
- # rum (19)
- # shadow-cljs (89)
- # spacemacs (101)
- # sql (2)
- # unrepl (88)
I'm trying to compile cljs's out/
directory manually using GCC but can't figure out the magic incantation. I'm using the all-in-one jar:
java -cp cljs-1.9.946.jar com.google.javascript.jscomp.CommandLineRunner --compilation_level ADVANCED --js goog/'**.jar' --js out/'**.js' --manage_closure_dependencies --closure_entry_point bug.core --js_output_file advanced.js
This gives me errors:
out/cljs/core.js:34828: WARNING - Redeclared variable: self__
var self__ = this;
^^^^^^^^^^^^^
out/cljs/core.js:366: ERROR - variable process is undeclared
if((typeof process !== 'undefined') && (!((process.hrtime == null)))){
^^^^^^^
out/cljs/core.js:35941: ERROR - variable global is undeclared
return cljs.core.find_ns_obj_STAR_(global,segs);
^^^^^^
Adding --third_party
gives me
out/goog/base.js:526: ERROR - Malformed goog.forwardDeclaration
goog.forwardDeclare('Document');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I'm trying to repro nikitonsky's issue by the way https://twitter.com/nikitonsky/status/933315653892820993
@dnolen does the CLJS compiler supply the --third_party
flag? Any idea about the goog.forardDeclare
issue?
fixed the global issue by going to that line and doing s/global/goog.global/
the process issue can be fixed by adding --closure_entry_point process.env
@pesterhazy feel free to file a ticket for goog.global
thing
@dnolen will do
@tonsky when invoking adv compilation manually from the CLI, the compiled output works well
B("bug.core.aaa", function () {
console.log("aaa start");
document.querySelector("body").className = "+++aaa+++";
return console.log("aaa end")
});
B("bug.core.bbb", function () {
console.log("bbb\u00a0start");
document.querySelector("body").className = "+++bbb+++";
return console.log("bbb end")
});
B("bug.core.ccc", function () {
console.log("ccc start");
document.querySelector("body").className = "+++ccc+++";
return console.log("ccc end")
});
must be something about the way cljs calls gcc
I'm sure of that
but there could be other enviromental differences
yeah manual java
call
the JS output that CLJS produces seems fine. But those lines do disappear after advanced compilation
another thing to wonder here is whether we somehow have a bad extern for document.querySelector
those lines would be eliminated only if Closure thought mutating the result of that fn was harmless
let me check if it works with a different function call
@rauh, could you link to the ticket?
this is the test script I use : https://github.com/tonsky/closure-elimination-bug/pull/1/files#diff-0b83f9dedf40d7356e5ca147a077acb4
@pesterhazy ah hm, that js/global
is for bootstrapped
tried it now, js/document.querySelector
gets eliminated, js/document.querySelectorXXX
doesn't
@dnolen goog/global
is used in the line just below: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L11115
is there a reason for this difference?
As far as I know, goog/global
works fine in node.js
very strange that enabling warnings causes different code to be omitted
@rauh ok good, then perhaps we just need a patch, bootstrap tests should catch any issues
@pesterhazy I think type checking feeds the compilation phases so Closure can do more
@dnolen attached a patch: https://dev.clojure.org/jira/browse/CLJS-2411