Skip to content

Commit ade19ed

Browse files
committed
deprecate cljs.closure/add-dependencies, remove misleading
cljs.closure ns docstring, remove comments referring to cljs.closure/add-dependencies
1 parent c2461b8 commit ade19ed

2 files changed

Lines changed: 2 additions & 77 deletions

File tree

src/main/clojure/cljs/build/api.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
(closure/source-for-namespace ns compiler-env)))
133133

134134
(defn add-dependencies
135-
"Given one or more IJavaScript objects in dependency order, produce
135+
"DEPRECATED: Given one or more IJavaScript objects in dependency order, produce
136136
a new sequence of IJavaScript objects which includes the input list
137137
plus all dependencies in dependency order."
138138
[opts & ijss]

src/main/clojure/cljs/closure.clj

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,6 @@
77
; You must not remove this notice, or any other, from this software.
88

99
(ns cljs.closure
10-
"Compile ClojureScript to JavaScript with optimizations from Google
11-
Closure Compiler producing runnable JavaScript.
12-
13-
The Closure Compiler (compiler.jar) must be on the classpath.
14-
15-
Use the 'build' function for end-to-end compilation.
16-
17-
build = find-sources -> add-dependencies -> compile -> optimize -> output
18-
19-
Two protocols are defined: IJavaScript and Compilable. The
20-
Compilable protocol is satisfied by something which can return one
21-
or more IJavaScripts.
22-
23-
With IJavaScript objects in hand, calling add-dependencies will
24-
produce a sequence of IJavaScript objects which includes all
25-
required dependencies from the Closure library and ClojureScript,
26-
in dependency order. This function replaces the closurebuilder
27-
tool.
28-
29-
The optimize function converts one or more IJavaScripts into a
30-
single string of JavaScript source code using the Closure Compiler
31-
API.
32-
33-
The produced output is either a single string of optimized
34-
JavaScript or a deps file for use during development.
35-
"
3610
(:refer-clojure :exclude [compile])
3711
(:require [cljs.util :as util :refer [distinct-by]]
3812
[cljs.core :as cljsm]
@@ -861,10 +835,8 @@
861835
(let [url (deps/to-url (constants-filename opts))]
862836
(javascript-file nil url [(str ana/constants-ns-sym)] ["cljs.core"])))
863837

864-
;; Internally only REPLs use this. We do expose it in cljs.build.api - David
865-
866838
(defn add-dependencies
867-
"Given one or more IJavaScript objects in dependency order, produce
839+
"DEPRECATED: Given one or more IJavaScript objects in dependency order, produce
868840
a new sequence of IJavaScript objects which includes the input list
869841
plus all dependencies in dependency order."
870842
[opts & inputs]
@@ -1070,30 +1042,6 @@
10701042
(str "#!" (or hashbang "/usr/bin/env node") "\n"))
10711043
(when preamble (preamble-from-paths preamble))))
10721044

1073-
(comment
1074-
;; add dependencies to literal js
1075-
(add-dependencies {} "goog.provide('test.app');\ngoog.require('cljs.core');")
1076-
(add-dependencies {} "goog.provide('test.app');\ngoog.require('goog.array');")
1077-
(add-dependencies {} (str "goog.provide('test.app');\n"
1078-
"goog.require('goog.array');\n"
1079-
"goog.require('clojure.set');"))
1080-
;; add dependencies with external lib
1081-
(add-dependencies {:libs ["closure/library/third_party/closure"]}
1082-
(str "goog.provide('test.app');\n"
1083-
"goog.require('goog.array');\n"
1084-
"goog.require('goog.dom.query');"))
1085-
;; add dependencies with foreign lib
1086-
(add-dependencies {:foreign-libs [{:file "samples/hello/src/hello/core.cljs"
1087-
:provides ["example.lib"]}]}
1088-
(str "goog.provide('test.app');\n"
1089-
"goog.require('example.lib');\n"))
1090-
;; add dependencies to a JavaScriptFile record
1091-
(add-dependencies {} (javascript-file false
1092-
(deps/to-url "samples/hello/src/hello/core.cljs")
1093-
["hello.core"]
1094-
["goog.array"]))
1095-
)
1096-
10971045
;; Optimize
10981046
;; ========
10991047

@@ -1443,11 +1391,6 @@
14431391

14441392
;; optimize a ClojureScript form
14451393
(optimize {:optimizations :simple} (-compile '(def x 3) {}))
1446-
1447-
;; optimize a project
1448-
(println (->> (-compile "samples/hello/src" {})
1449-
(apply add-dependencies {})
1450-
(apply optimize {:optimizations :simple :pretty-print true})))
14511394
)
14521395

14531396
;; Output
@@ -1977,24 +1920,6 @@
19771920

19781921
:else (output-deps-file opts disk-sources))))
19791922

1980-
(comment
1981-
1982-
;; output unoptimized alone
1983-
(output-unoptimized {} "goog.provide('test');\ngoog.require('cljs.core');\nalert('hello');\n")
1984-
;; output unoptimized with all dependencies
1985-
(apply output-unoptimized {}
1986-
(add-dependencies {}
1987-
"goog.provide('test');\ngoog.require('cljs.core');\nalert('hello');\n"))
1988-
;; output unoptimized with external library
1989-
(apply output-unoptimized {}
1990-
(add-dependencies {:libs ["closure/library/third_party/closure"]}
1991-
"goog.provide('test');\ngoog.require('cljs.core');\ngoog.require('goog.dom.query');\n"))
1992-
;; output unoptimized and write deps file to 'out/test.js'
1993-
(output-unoptimized {:output-to "out/test.js"}
1994-
"goog.provide('test');\ngoog.require('cljs.core');\nalert('hello');\n")
1995-
)
1996-
1997-
19981923
(defn get-upstream-deps*
19991924
"returns a merged map containing all upstream dependencies defined
20001925
by libraries on the classpath."

0 commit comments

Comments
 (0)