File tree Expand file tree Collapse file tree 4 files changed +52
-17
lines changed Expand file tree Collapse file tree 4 files changed +52
-17
lines changed Original file line number Diff line number Diff line change 2408
2408
; ; Select Node files that are required by Cljs code,
2409
2409
; ; and create list of all their dependencies
2410
2410
node-required (set/intersection (set (keys top-level)) requires)]
2411
- (if-not (= target :nodejs )
2412
- (let [opts (-> opts
2413
- (update :foreign-libs
2414
- (fn [libs]
2415
- (into (index-node-modules node-required)
2416
- (expand-libs libs))))
2417
- process-js-modules)]
2418
- (swap! compiler-env merge
2419
- ; ; we need to also track the whole top level - this is to support
2420
- ; ; cljs.analyze/analyze-deps, particularly in REPL contexts - David
2421
- {:js-dependency-index (deps/js-dependency-index opts)
2422
- :node-module-index (into #{} (map str (keys top-level)))})
2423
- opts)
2424
- (do
2425
- (swap! compiler-env update-in [:node-module-index ]
2426
- (fnil into #{}) (map str node-required))
2427
- opts))))
2411
+ (let [opts (-> opts
2412
+ (update :foreign-libs
2413
+ (fn [libs]
2414
+ (into (if (= target :nodejs )
2415
+ []
2416
+ (index-node-modules node-required))
2417
+ (expand-libs libs))))
2418
+ process-js-modules)]
2419
+ (swap! compiler-env (fn [cenv]
2420
+ (-> cenv
2421
+ ; ; we need to also track the whole top level - this is to support
2422
+ ; ; cljs.analyze/analyze-deps, particularly in REPL contexts - David
2423
+ (merge {:js-dependency-index (deps/js-dependency-index opts)})
2424
+ (update-in [:node-module-index ] (fnil into #{})
2425
+ (if (= target :nodejs )
2426
+ (map str node-required)
2427
+ (map str (keys top-level)))))))
2428
+ opts)))
2428
2429
2429
2430
(defn build
2430
2431
" Given a source which can be compiled, produce runnable JavaScript."
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ foo : 'bar' ,
3
+ }
Original file line number Diff line number Diff line change
1
+ ; ; Copyright (c) Rich Hickey. All rights reserved.
2
+ ; ; The use and distribution terms for this software are covered by the
3
+ ; ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4
+ ; ; which can be found in the file epl-v10.html at the root of this distribution.
5
+ ; ; By using this software in any fashion, you are agreeing to be bound by
6
+ ; ; the terms of this license.
7
+ ; ; You must not remove this notice, or any other, from this software.
8
+
9
+ (ns foreign-libs-dir-test.core
10
+ (:require [vendor.lib :as lib]))
11
+
12
+ (enable-console-print! )
13
+
14
+ (defn main []
15
+ (println lib))
Original file line number Diff line number Diff line change 462
462
(test/delete-out-files out)
463
463
(test/delete-node-modules )
464
464
(.delete (io/file " package.json" ))))
465
+
466
+ (deftest test-cljs-2296
467
+ (let [out (.getPath (io/file (test/tmp-dir ) " cljs-2296-test-out" ))
468
+ {:keys [inputs opts]} {:inputs (str (io/file " src" " test" " cljs_build" ))
469
+ :opts {:main 'foreign_libs_dir_test.core
470
+ :output-dir out
471
+ :optimizations :none
472
+ :target :nodejs
473
+ ; ; :file is a directory
474
+ :foreign-libs [{:file " src/test/cljs_build/foreign-libs-dir"
475
+ :module-type :commonjs }]}}]
476
+ (test/delete-out-files out)
477
+ (build/build (build/inputs (io/file inputs " foreign_libs_dir_test/core.cljs" )) opts)
478
+ (is (.exists (io/file out " src/test/cljs_build/foreign-libs-dir/vendor/lib.js" )))
479
+ (is (true ? (boolean (re-find #"goog\. provide\(\" module\$ src\$ test\$ cljs_build\$ foreign_libs_dir\$ vendor\$ lib\"\) "
480
+ (slurp (io/file out " src/test/cljs_build/foreign-libs-dir/vendor/lib.js" ))))))))
You can’t perform that action at this time.
0 commit comments