File tree 4 files changed +14
-26
lines changed
4 files changed +14
-26
lines changed Original file line number Diff line number Diff line change 848
848
(emitln " if(!COMPILED) " loaded-libs " = cljs.core.set();" ))
849
849
(doseq [lib (remove (set (vals seen)) (distinct (vals libs)))]
850
850
(cond
851
- (ana/foreign-dep? lib)
851
+ (and (= :nodejs (get-in @env/*compiler* [:options :target ]))
852
+ (ana/foreign-dep? lib))
852
853
; ; under node.js we load foreign libs globally
853
- (if (= :nodejs (get-in @env/*compiler* [:options :target ]))
854
- (let [js-index (:js-dependency-index @env/*compiler*)
855
- ijs-url (get-in js-index [(name lib) :url ])]
856
- (emitln " cljs.core.load_file(\" " (util/get-name ijs-url) " \" );" ))
857
- ; ; otherwise only include if set in the options to do so,
858
- ; ; in the browser unnecessary due to the fact that goog.require
859
- ; ; there works by writing all deps as script tags, this doesn't
860
- ; ; work in Rhino-like environment where we do a proper goog.require
861
- ; ; on demand
862
- (when (get-in @env/*compiler* [:options :require-foreign ])
863
- (emitln " goog.require('" (munge lib) " ');" )))
854
+ (let [{:keys [js-dependency-index options]} @env/*compiler*
855
+ ijs-url (get-in js-dependency-index [(name lib) :url ])]
856
+ (emitln " cljs.core.load_file(\" "
857
+ (str (io/file (util/output-directory options) (util/get-name ijs-url)))
858
+ " \" );" ))
864
859
865
860
(-> libs meta :reload )
866
861
(emitln " goog.require('" (munge lib) " ', 'reload');" )
Original file line number Diff line number Diff line change 317
317
(defmacro false? [x]
318
318
(bool-expr (core/list 'js* " ~{} === false" x)))
319
319
320
- (defmacro array? [x]
321
- (if (= :nodejs (-> @env/*compiler* :options :target ))
322
- (bool-expr `(.isArray js/Array ~x))
323
- (bool-expr (core/list 'js* " ~{} instanceof Array" x))))
324
-
325
320
(defmacro string? [x]
326
321
(bool-expr (core/list 'js* " typeof ~{} === 'string'" x)))
327
322
1974
1969
[vol f & args]
1975
1970
`(-vreset! ~vol (~f (-deref ~vol) ~@args)))
1976
1971
1972
+ ; ; INTERNAL - do not use, only for Node.js
1977
1973
(defmacro load-file* [f]
1978
- (core/let [{:keys [target output-dir]} (:options @env/*compiler*)]
1979
- (core/condp = target
1980
- ; ; under Node.js, always relative to JVM working directory
1981
- :nodejs `(. js/goog (~'nodeGlobalRequire (str ~output-dir ~File/separator ~f)))
1982
- `(. js/goog (~'importScript_ ~f)))))
1974
+ `(. js/goog (~'nodeGlobalRequire ~f)))
Original file line number Diff line number Diff line change 169
169
(defrecord RhinoEnv []
170
170
repl /IReplEnvOptions
171
171
(-repl-options [this]
172
- {:require-foreign true
173
- :output-dir " .cljs_rhino_repl"
172
+ {:output-dir " .cljs_rhino_repl"
174
173
:wrap wrap-fn})
175
174
repl /IParseStacktrace
176
175
(-parse-stacktrace [this frames-str ret {output-dir :output-dir }]
Original file line number Diff line number Diff line change 153
153
(defn ^boolean array?
154
154
" Returns true if x is a JavaScript array."
155
155
[x]
156
- (cljs.core/array? x))
156
+ (if (identical? *target* " nodejs" )
157
+ (.isArray js/Array x)
158
+ (instance? js/Array x)))
157
159
158
160
(defn ^boolean number?
159
161
" Returns true if x is a JavaScript number."
221
223
s
222
224
(str ty)))
223
225
224
- ; ; INTERNAL - do not use
226
+ ; ; INTERNAL - do not use, only for Node.js
225
227
(defn load-file [file]
226
228
(when-not js/COMPILED
227
229
(cljs.core/load-file* file)))
You can’t perform that action at this time.
0 commit comments