Skip to content

Commit c72e9c5

Browse files
pupenodnolen
authored andcommitted
When targeting nodejs with no optimizations, add headers the same way as with optimizations.
This is to fix bug http://dev.clojure.org/jira/browse/CLJS-1454. The counterpart for optimized builds can be found here: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L1723
1 parent 3847961 commit c72e9c5

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,32 +1129,33 @@
11291129
(defn output-deps-file [opts sources]
11301130
(output-one-file opts (deps-file opts sources)))
11311131

1132+
(declare foreign-deps-str add-header add-source-map-link)
1133+
11321134
(defn output-main-file [opts]
11331135
(let [asset-path (or (:asset-path opts)
11341136
(util/output-directory opts))
11351137
closure-defines (json/write-str (:closure-defines opts))]
11361138
(case (:target opts)
11371139
:nodejs
11381140
(output-one-file opts
1139-
(str "var path = require(\"path\");\n"
1140-
"try {\n"
1141-
" require(\"source-map-support\").install();\n"
1142-
"} catch(err) {\n"
1143-
"}\n"
1144-
"require(path.join(path.resolve(\".\"),\"" asset-path "\",\"goog\",\"bootstrap\",\"nodejs.js\"));\n"
1145-
"require(path.join(path.resolve(\".\"),\"" asset-path "\",\"cljs_deps.js\"));\n"
1146-
"goog.global.CLOSURE_UNCOMPILED_DEFINES = " closure-defines ";\n"
1147-
"goog.require(\"" (comp/munge (:main opts)) "\");\n"
1148-
"goog.require(\"cljs.nodejscli\");\n"))
1141+
(add-header opts
1142+
(str "var path = require(\"path\");\n"
1143+
"try {\n"
1144+
" require(\"source-map-support\").install();\n"
1145+
"} catch(err) {\n"
1146+
"}\n"
1147+
"require(path.join(path.resolve(\".\"),\"" asset-path "\",\"goog\",\"bootstrap\",\"nodejs.js\"));\n"
1148+
"require(path.join(path.resolve(\".\"),\"" asset-path "\",\"cljs_deps.js\"));\n"
1149+
"goog.global.CLOSURE_UNCOMPILED_DEFINES = " closure-defines ";\n"
1150+
"goog.require(\"" (comp/munge (:main opts)) "\");\n"
1151+
"goog.require(\"cljs.nodejscli\");\n")))
11491152
(output-one-file opts
11501153
(str "var CLOSURE_UNCOMPILED_DEFINES = " closure-defines ";\n"
11511154
"if(typeof goog == \"undefined\") document.write('<script src=\"" asset-path "/goog/base.js\"></script>');\n"
11521155
"document.write('<script src=\"" asset-path "/cljs_deps.js\"></script>');\n"
11531156
"document.write('<script>if (typeof goog != \"undefined\") { goog.require(\"" (comp/munge (:main opts))
11541157
"\"); } else { console.warn(\"ClojureScript could not load :main, did you forget to specify :asset-path?\"); };</script>');\n")))))
11551158

1156-
(declare foreign-deps-str add-header add-source-map-link)
1157-
11581159
(defn output-modules
11591160
"Given compiler options, original IJavaScript sources and a sequence of
11601161
module name and module description tuples output module sources to disk.

0 commit comments

Comments
 (0)