Last active
April 11, 2016 19:38
-
-
Save vincent-dm/30701e1dbd5d13beb30b8e5e856e6fda to your computer and use it in GitHub Desktop.
Closure compiler does not eliminate dead branches based on branching the goog.LOCALE setting. (File paths are converted to underscores in the file names)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cljs.build.api) | |
(cljs.build.api/build "src" | |
{:output-to "out/main.js" | |
:optimizations :advanced | |
:pretty-print true | |
:closure-defines { | |
'goog.DEBUG false | |
'goog.LOCALE "nl"}}) | |
(System/exit 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 20471 lines of javascript omitted | |
var i18n = {fr:{}}; | |
i18n.fr.message = "French"; | |
i18n.nl = {}; | |
i18n.nl.message = "Dutch"; | |
i18n.translate = {}; | |
cljs.core.enable_console_print_BANG_.call(null); | |
i18n.translate.translation = function() { | |
var a = cljs.core.identical_QMARK_, b = goog.LOCALE; | |
return cljs.core.truth_(a.call(null, "nl", b)) ? i18n.nl.message : cljs.core.truth_(a.call(null, "fr", b)) ? i18n.fr.message : "unknown"; | |
}(); | |
cljs.core.println.call(null, "goog.LOCALE ", goog.LOCALE, " leads to translated text: ", i18n.translate.translation); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I only included line 5364 of the 5406-line output | |
}(), Ee = x(za.a ? za.a("nl", "nl") : za.call(null, "nl", "nl")) ? "Dutch" : x(za.a ? za.a("fr", "nl") : za.call(null, "fr", "nl")) ? "French" : "unknown", Ge = fc(["goog.LOCALE ", "nl", " leads to translated text: ", Ee], 0), He = kc.g(qa(), ua, !1), Ie, Je; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns i18n.fr) | |
(def message "French") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns i18n.nl) | |
(def message "Dutch") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns i18n.translate | |
(:require [i18n.nl] | |
[i18n.fr])) | |
(enable-console-print!) | |
(def translation (condp identical? js/goog.LOCALE | |
"nl" i18n.nl/message | |
"fr" i18n.fr/message | |
"unknown")) | |
(println "goog.LOCALE " js/goog.LOCALE " leads to translated text: " translation) | |
;; both the word "Dutch" from "src/i18n/nl.cljs" and the word | |
;; "French" from "src/i18n/fr.cljs" are present in the output. | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output is different when I use a
case
in thetranslate.cljs
file, but the issue of having all the branches in the output remains: