├── samples ├── dom │ ├── .gitignore │ ├── test.html │ └── src │ │ └── dom │ │ └── test.cljs ├── hello │ ├── .gitignore │ ├── src │ │ └── hello │ │ │ ├── foo │ │ │ └── bar.cljs │ │ │ └── core.cljs │ ├── hello.html │ ├── hello-dev.html │ └── README.md ├── repl │ ├── .gitignore │ ├── src │ │ └── repl │ │ │ └── foo.cljs │ ├── repl.clj │ └── index.html ├── hello-js │ ├── .gitignore │ ├── externs.js │ ├── my-external-lib.js │ ├── externed-lib.js │ ├── src │ │ └── hello-js │ │ │ ├── extern-example.cljs │ │ │ └── core.cljs │ ├── hello-extern.html │ ├── hello-js.html │ ├── hello-js-dev.html │ └── README.md ├── string-requires-npm-deps │ ├── .gitignore │ ├── package.json │ ├── src │ │ └── foo │ │ │ └── core.cljs │ ├── build.clj │ └── README.md ├── twitterbuzz │ ├── .gitignore │ ├── reset.css │ ├── README.md │ └── src │ │ └── twitterbuzz │ │ ├── timeline.cljs │ │ └── leaderboard.cljs ├── nodehello.cljs └── nodels.cljs ├── src ├── test │ ├── cljs_build │ │ ├── json_modules_test │ │ │ ├── b.json │ │ │ └── a.js │ │ ├── analyzer_test │ │ │ └── no_defs.cljs │ │ ├── trivial │ │ │ ├── core5.cljs │ │ │ ├── core3.cljs │ │ │ ├── core4.cljs │ │ │ ├── core.cljs │ │ │ ├── core2.cljs │ │ │ └── core6.cljs │ │ ├── foreign-libs-dir │ │ │ └── vendor │ │ │ │ └── lib.js │ │ ├── firebase │ │ │ └── core.cljs │ │ ├── adv_src_map │ │ │ └── core.cljs │ │ ├── loader_test │ │ │ ├── foreignA.js │ │ │ ├── foreignB.js │ │ │ ├── bar.cljs │ │ │ └── foo.cljs │ │ ├── code-split │ │ │ ├── src │ │ │ │ └── code │ │ │ │ │ └── split │ │ │ │ │ ├── d.cljs │ │ │ │ │ ├── b.cljs │ │ │ │ │ ├── c.cljs │ │ │ │ │ └── a.cljs │ │ │ ├── index.html │ │ │ └── repl.clj │ │ ├── libs_test │ │ │ └── core.cljs │ │ ├── cljs_3284 │ │ │ ├── bean.cljs │ │ │ └── core.cljs │ │ ├── foreign_libs_cljs_2334 │ │ │ ├── lib.js │ │ │ └── core.cljs │ │ ├── cljs_3311_regress │ │ │ ├── tests.cljs │ │ │ └── core.cljs │ │ ├── npm_deps_test │ │ │ ├── core.cljs │ │ │ ├── invoke.cljs │ │ │ └── string_requires.cljs │ │ ├── node_modules_opt_test │ │ │ └── core.cljs │ │ ├── cljs_3235 │ │ │ ├── foreign.js │ │ │ └── core.cljs │ │ ├── cljs_3346_as_alias │ │ │ └── core.cljs │ │ ├── emit_node_requires_test │ │ │ ├── native_modules.cljs │ │ │ └── core.cljs │ │ ├── cljs_3452_str_optimizations │ │ │ └── core.cljs │ │ ├── hello-modules │ │ │ ├── src │ │ │ │ ├── bar │ │ │ │ │ └── core.cljs │ │ │ │ └── foo │ │ │ │ │ └── core.cljs │ │ │ ├── index.html │ │ │ ├── release.clj │ │ │ └── repl.clj │ │ ├── package_json_resolution_test │ │ │ └── core.cljs │ │ ├── thirdparty │ │ │ └── add.js │ │ ├── emit_global_requires_test │ │ │ └── core.cljs │ │ ├── circular_deps │ │ │ ├── a.cljs │ │ │ └── b.cljs │ │ ├── foreign_libs │ │ │ └── core.cljs │ │ ├── foreign_libs_cljs_2249 │ │ │ └── core.cljs │ │ └── foreign_libs_dir_test │ │ │ └── core.cljs │ ├── node │ │ └── test.js │ ├── clojure │ │ └── cljs │ │ │ ├── preamble1.js │ │ │ ├── preamble2.js │ │ │ ├── source_map │ │ │ └── base64_tests.clj │ │ │ ├── profile.clj │ │ │ ├── js_deps_tests.clj │ │ │ ├── transpile_tests.clj │ │ │ ├── instant_tests.clj │ │ │ ├── compiler │ │ │ └── glib_module_test.clj │ │ │ ├── test_runner.clj │ │ │ └── repl_tests.clj │ ├── cljs │ │ ├── hello.cljs │ │ ├── es6_default_hello.js │ │ ├── es6_dep.js │ │ ├── es6_hello.js │ │ ├── single_seg_macros.clj │ │ ├── externs.js │ │ ├── js_libs │ │ │ └── tabby.js │ │ ├── deps.cljs │ │ ├── calculator_global.js │ │ ├── calculator.js │ │ ├── Circle.js │ │ ├── Circle-min.js │ │ ├── baz.cljs │ │ ├── cljs │ │ │ ├── baz.cljs │ │ │ ├── ns_test │ │ │ │ ├── bar.cljs │ │ │ │ └── foo.cljs │ │ │ ├── spec │ │ │ │ └── test │ │ │ │ │ ├── test_ns2.cljs │ │ │ │ │ ├── test_ns1.cljs │ │ │ │ │ └── test_macros.cljc │ │ │ ├── keyword_other.cljs │ │ │ ├── macro_test │ │ │ │ ├── cljs2261.cljs │ │ │ │ ├── cljs2261.clj │ │ │ │ ├── macros.clj │ │ │ │ └── cljs2852.clj │ │ │ ├── keyword_macros.clj │ │ │ ├── binding_test_other_ns.cljs │ │ │ ├── array_access │ │ │ │ ├── beta.cljs │ │ │ │ ├── helper.clj │ │ │ │ └── alpha.cljs │ │ │ ├── array_access_test.cljc │ │ │ ├── top_level.cljs │ │ │ ├── syntax_quote_test.cljs │ │ │ ├── keyword_test.cljs │ │ │ ├── qualified_method_test.cljs │ │ │ ├── repl_test.cljs │ │ │ ├── foo │ │ │ │ └── ns_shadow_test.cljs │ │ │ ├── tagged_literals_test.cljs │ │ │ ├── var_test.cljs │ │ │ ├── import_test.cljs │ │ │ ├── letfn_test.cljs │ │ │ ├── specials_test.cljs │ │ │ ├── hash_set_test.cljs │ │ │ ├── clojure_alias_test.cljs │ │ │ ├── proxy_test.cljs │ │ │ ├── inference_util.clj │ │ │ ├── chunked_seq.cljs │ │ │ ├── set_equiv_test.cljs │ │ │ ├── invoke_test.cljs │ │ │ ├── pprint_test.clj │ │ │ ├── macro_test.cljs │ │ │ ├── npm_deps_test.cljs │ │ │ ├── eval_test.cljs │ │ │ ├── test_test.cljs │ │ │ ├── reducers_test.cljs │ │ │ ├── lite_collections_test.cljs │ │ │ ├── binding_test.cljs │ │ │ ├── iterator_test.cljs │ │ │ ├── ns_test.cljs │ │ │ └── recur_test.cljs │ │ ├── preloads_test │ │ │ ├── core.cljs │ │ │ └── preload.cljs │ │ ├── module_test │ │ │ ├── main.cljs │ │ │ └── modules │ │ │ │ ├── a.cljs │ │ │ │ └── b.cljs │ │ ├── data_readers.cljc │ │ ├── static │ │ │ └── core_test.cljs │ │ ├── foo │ │ │ └── ns_shadow_test.cljs │ │ ├── data_readers_test │ │ │ ├── core.cljc │ │ │ └── records.cljc │ │ ├── reactJS.js │ │ ├── react-min.js │ │ └── clojure │ │ │ ├── edn_test.cljs │ │ │ ├── walk_test.cljs │ │ │ ├── data_test.cljs │ │ │ └── datafy_test.cljs │ ├── cljs_cp │ │ └── npm_deps_test │ │ │ └── string_requires_in_classpath.cljs │ ├── cljs_cli │ │ └── cljs_cli │ │ │ └── test_runner.clj │ ├── externs │ │ └── test.js │ └── self │ │ ├── bootstrap_test │ │ ├── core.cljs │ │ ├── helper.clj │ │ └── macros.clj │ │ └── self_parity │ │ └── setup.clj ├── main │ ├── cljs │ │ ├── cljs │ │ │ ├── nodejs_externs.js │ │ │ ├── imul.js │ │ │ ├── core │ │ │ │ └── specs │ │ │ │ │ └── alpha.cljs │ │ │ ├── externs.js │ │ │ ├── reader.clj │ │ │ ├── js.clj │ │ │ ├── source_map │ │ │ │ └── base64.cljs │ │ │ ├── nodejscli.cljs │ │ │ ├── proxy │ │ │ │ └── impl.cljs │ │ │ ├── analyzer │ │ │ │ ├── passes.cljc │ │ │ │ └── passes │ │ │ │ │ └── lite.cljc │ │ │ ├── nodejs.cljs │ │ │ └── spec │ │ │ │ └── gen │ │ │ │ └── alpha.cljc │ │ ├── process │ │ │ └── env.cljs │ │ └── clojure │ │ │ ├── browser │ │ │ └── repl │ │ │ │ └── preload.cljs │ │ │ ├── core │ │ │ └── protocols.cljs │ │ │ ├── datafy.cljs │ │ │ └── reflect.cljs │ └── clojure │ │ └── cljs │ │ ├── compiler │ │ └── macros.clj │ │ ├── support.cljc │ │ ├── analyzer │ │ ├── utils.clj │ │ ├── impl.cljc │ │ └── macros.clj │ │ ├── source_map │ │ └── base64.clj │ │ ├── env │ │ └── macros.clj │ │ ├── vendor │ │ └── bridge.clj │ │ ├── server │ │ ├── node.clj │ │ └── browser.clj │ │ ├── core │ │ └── macros.clj │ │ └── instant.clj └── assembly │ ├── slim.xml │ └── aot.xml ├── script ├── aot.clj ├── browser_repl.clj ├── repl.clj ├── self-compile ├── test-cli ├── clean ├── repl ├── repl.bat ├── browser-repl ├── noderepljs ├── test-self-host ├── test-compile ├── revision ├── test-self-parity ├── aot_core ├── benchmark ├── compile ├── vendorize_deps ├── test.ps1 └── uberjar ├── resources ├── cljs-logo-icon-32.png ├── self_parity_test.edn ├── self_host_test.edn ├── test.edn └── lite_test.edn ├── ci └── install_jsc.sh ├── devnotes ├── testing ├── bcrepl.org ├── day2.org └── README.org ├── ast-ref └── buildref.sh ├── bin ├── cljsc.bat ├── cljsc └── cljsc.clj ├── .gitignore ├── .github └── workflows │ └── release.yml ├── project.clj └── appveyor.yml /samples/dom/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | dom.js -------------------------------------------------------------------------------- /samples/hello/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | hello.js 3 | -------------------------------------------------------------------------------- /samples/repl/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | main.js 3 | -------------------------------------------------------------------------------- /samples/hello-js/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | hello*.js 3 | -------------------------------------------------------------------------------- /samples/string-requires-npm-deps/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | -------------------------------------------------------------------------------- /samples/twitterbuzz/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | twitterbuzz.js 3 | -------------------------------------------------------------------------------- /src/test/cljs_build/json_modules_test/b.json: -------------------------------------------------------------------------------- 1 | {"foo": 42} 2 | -------------------------------------------------------------------------------- /src/test/node/test.js: -------------------------------------------------------------------------------- 1 | var objectAssign = require("object-assign"); -------------------------------------------------------------------------------- /src/test/clojure/cljs/preamble1.js: -------------------------------------------------------------------------------- 1 | var preamble1 = require("preamble1"); -------------------------------------------------------------------------------- /src/test/clojure/cljs/preamble2.js: -------------------------------------------------------------------------------- 1 | var preamble2 = require("preamble2"); -------------------------------------------------------------------------------- /src/test/cljs_build/analyzer_test/no_defs.cljs: -------------------------------------------------------------------------------- 1 | (ns analyzer-test.no-defs) 2 | -------------------------------------------------------------------------------- /samples/repl/src/repl/foo.cljs: -------------------------------------------------------------------------------- 1 | (ns repl.foo) 2 | 3 | (defn bar [a b] 4 | (+ a b)) -------------------------------------------------------------------------------- /script/aot.clj: -------------------------------------------------------------------------------- 1 | (require '[cljs.closure :as cljsc]) 2 | (cljsc/aot-cache-core) 3 | -------------------------------------------------------------------------------- /src/test/cljs_build/trivial/core5.cljs: -------------------------------------------------------------------------------- 1 | (ns trivial.core5) 2 | 3 | (.log js/console {}) -------------------------------------------------------------------------------- /src/test/cljs/hello.cljs: -------------------------------------------------------------------------------- 1 | (ns hello) 2 | (defn ^:export greet [n] 3 | (str "Hello " n)) 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/trivial/core3.cljs: -------------------------------------------------------------------------------- 1 | (ns trivial.core3) 2 | 3 | (.log js/console :foo) 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/trivial/core4.cljs: -------------------------------------------------------------------------------- 1 | (ns trivial.core4) 2 | 3 | (.log js/console []) 4 | -------------------------------------------------------------------------------- /samples/string-requires-npm-deps/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "string-requires-npm-deps" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/foreign-libs-dir/vendor/lib.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | foo: 'bar', 3 | } 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/trivial/core.cljs: -------------------------------------------------------------------------------- 1 | (ns trivial.core) 2 | 3 | (. js/console (log "Hello!")) 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/json_modules_test/a.js: -------------------------------------------------------------------------------- 1 | // b is a .json module 2 | var theJSON = require('./b'); 3 | -------------------------------------------------------------------------------- /src/test/cljs_build/trivial/core2.cljs: -------------------------------------------------------------------------------- 1 | (ns trivial.core2) 2 | 3 | (.log js/console (-lookup 1 2)) 4 | -------------------------------------------------------------------------------- /samples/hello/src/hello/foo/bar.cljs: -------------------------------------------------------------------------------- 1 | (ns hello.foo.bar) 2 | 3 | (defn sum [xs] 4 | (reduce + 0 xs)) 5 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/nodejs_externs.js: -------------------------------------------------------------------------------- 1 | var global = {}; 2 | function require(){}; 3 | function process(){}; 4 | -------------------------------------------------------------------------------- /src/test/cljs/es6_default_hello.js: -------------------------------------------------------------------------------- 1 | export default function sayHello () { 2 | return "Hello, world!"; 3 | }; 4 | -------------------------------------------------------------------------------- /src/test/cljs/es6_dep.js: -------------------------------------------------------------------------------- 1 | import {default as calc} from './calculator'; 2 | 3 | export var calculator = calc; 4 | -------------------------------------------------------------------------------- /src/test/cljs/es6_hello.js: -------------------------------------------------------------------------------- 1 | export var sayHello = function() { 2 | console.log("Hello, world!"); 3 | }; 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/firebase/core.cljs: -------------------------------------------------------------------------------- 1 | (ns firebase.core 2 | (:require ["firebase/auth" :as auth])) 3 | 4 | -------------------------------------------------------------------------------- /samples/hello-js/externs.js: -------------------------------------------------------------------------------- 1 | var external = {}; 2 | external.lib = {}; 3 | external.lib.send_alert = function() {}; 4 | -------------------------------------------------------------------------------- /src/test/cljs/single_seg_macros.clj: -------------------------------------------------------------------------------- 1 | (ns single-seg-macros) 2 | 3 | (defmacro test-macro [a b] 4 | `(+ ~a ~b)) 5 | -------------------------------------------------------------------------------- /src/test/cljs_build/adv_src_map/core.cljs: -------------------------------------------------------------------------------- 1 | (ns adv-src-map.core) 2 | 3 | (.log js/console "Hello!" (first [1 2 3])) -------------------------------------------------------------------------------- /resources/cljs-logo-icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojurescript/HEAD/resources/cljs-logo-icon-32.png -------------------------------------------------------------------------------- /samples/hello-js/my-external-lib.js: -------------------------------------------------------------------------------- 1 | function send_alert(msg) { 2 | alert("Sending Alert via " + msg + "!"); 3 | }; 4 | -------------------------------------------------------------------------------- /src/test/cljs/externs.js: -------------------------------------------------------------------------------- 1 | var nth = function(array, n){}; 2 | var Calculator = { 3 | add: function(a, b) {} 4 | }; 5 | -------------------------------------------------------------------------------- /src/test/cljs_build/loader_test/foreignA.js: -------------------------------------------------------------------------------- 1 | global.foreignA = function() { 2 | console.log("I'm foreign!") 3 | }; 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/loader_test/foreignB.js: -------------------------------------------------------------------------------- 1 | global.foreignB = function() { 2 | console.log("I'm foreign too!"); 3 | }; 4 | -------------------------------------------------------------------------------- /script/browser_repl.clj: -------------------------------------------------------------------------------- 1 | (require '[cljs.repl :as repl]) 2 | (require '[cljs.repl.browser :as browser]) 3 | (repl/repl (browser/repl-env)) -------------------------------------------------------------------------------- /script/repl.clj: -------------------------------------------------------------------------------- 1 | (require '[cljs.repl :as repl]) 2 | (require '[cljs.repl.node :as node]) 3 | (repl/repl (node/repl-env :debug-port 5002)) -------------------------------------------------------------------------------- /src/test/cljs/js_libs/tabby.js: -------------------------------------------------------------------------------- 1 | goog.provide("tabby"); 2 | 3 | tabby.hello = function() { 4 | return "hello there from tabby"; 5 | }; 6 | -------------------------------------------------------------------------------- /src/test/cljs_build/code-split/src/code/split/d.cljs: -------------------------------------------------------------------------------- 1 | (ns code.split.d) 2 | 3 | (defn hello [] 4 | (println "Hello from code.split.d.")) 5 | -------------------------------------------------------------------------------- /src/test/cljs_build/libs_test/core.cljs: -------------------------------------------------------------------------------- 1 | (ns libs-test.core 2 | (:require [tabby])) 3 | 4 | (enable-console-print!) 5 | 6 | (println (tabby/hello)) 7 | -------------------------------------------------------------------------------- /src/test/cljs/deps.cljs: -------------------------------------------------------------------------------- 1 | {:externs ["externs.js"] 2 | :foreign-libs [{:file "calculator_global.js" 3 | :provides ["thirdparty.calculator"]}]} 4 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3284/bean.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs-3284.bean) 2 | 3 | (deftype ^:private SomeType [a]) 4 | 5 | (defn some-type 6 | [a] 7 | (SomeType. a)) 8 | -------------------------------------------------------------------------------- /src/test/cljs_build/foreign_libs_cljs_2334/lib.js: -------------------------------------------------------------------------------- 1 | import leftPad from 'left-pad'; 2 | 3 | export var lp = function() { 4 | return leftPad(42, 5, 0); 5 | } 6 | -------------------------------------------------------------------------------- /samples/hello-js/externed-lib.js: -------------------------------------------------------------------------------- 1 | external = {}; 2 | 3 | external.lib = { 4 | send_alert : function (msg) { 5 | alert("Sending Alert via " + msg + "!"); 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3311_regress/tests.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs-3311-regress.tests 2 | (:require [cljs.test :refer [deftest is]])) 3 | 4 | (deftest some-test 5 | (is (= 1 1))) 6 | -------------------------------------------------------------------------------- /src/test/cljs_build/npm_deps_test/core.cljs: -------------------------------------------------------------------------------- 1 | (ns npm-deps-test.core 2 | (:require left-pad)) 3 | 4 | (enable-console-print!) 5 | 6 | (println "Padded:" (left-pad 42 5 0)) 7 | -------------------------------------------------------------------------------- /src/test/cljs_build/foreign_libs_cljs_2334/core.cljs: -------------------------------------------------------------------------------- 1 | (ns foreign-libs-cljs-2334.core 2 | (:require [mylib])) 3 | 4 | (enable-console-print!) 5 | 6 | (println "mylib:" mylib) 7 | -------------------------------------------------------------------------------- /src/test/cljs_build/trivial/core6.cljs: -------------------------------------------------------------------------------- 1 | (ns trivial.core6) 2 | 3 | (.log js/console (->> (map inc (range 10)) (filter even?) (partition 2) (drop 1) (mapcat identity) into-array)) 4 | -------------------------------------------------------------------------------- /script/self-compile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | rm -rf classes 4 | mkdir classes 5 | ./script/repl -e "(compile 'cljs.repl.node) (compile 'cljs.repl.browser) (compile 'cljs.core)" 6 | -------------------------------------------------------------------------------- /src/test/cljs_build/node_modules_opt_test/core.cljs: -------------------------------------------------------------------------------- 1 | (ns node-modules-opt-test.core 2 | (:require left-pad)) 3 | 4 | (enable-console-print!) 5 | 6 | (println "Padded:" (left-pad 42 5 0)) 7 | -------------------------------------------------------------------------------- /src/test/cljs/calculator_global.js: -------------------------------------------------------------------------------- 1 | Calculator = { 2 | add: function (a, b) { 3 | return a + b; 4 | }, 5 | subtract: function (a, b) { 6 | return a - b; 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3235/foreign.js: -------------------------------------------------------------------------------- 1 | window.globalLib = { 2 | woz: function() { 3 | 4 | }, 5 | foz: { 6 | boz: function() { 7 | 8 | } 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3346_as_alias/core.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs-3346-as-alias.core 2 | (:require [clojure.set :as-alias set] 3 | [made.up.lib :as-alias lib])) 4 | 5 | (println ::set/foo ::lib/bar) 6 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3284/core.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs-3284.core 2 | (:require 3 | cljs-3284.bean)) 4 | 5 | (defn maybe-bean 6 | [x] 7 | (if (object? x) 8 | (cljs-3284.bean/some-type x) 9 | x)) 10 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3311_regress/core.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs-3311-regress.core 2 | (:require [cljs.test :refer-macros [run-tests]] 3 | [cljs-3311-regress.tests])) 4 | 5 | (run-tests 'cljs-3311-regress.tests) 6 | -------------------------------------------------------------------------------- /samples/hello-js/src/hello-js/extern-example.cljs: -------------------------------------------------------------------------------- 1 | (ns hello.extern-example) 2 | 3 | (defn ^:export foo [] 42) 4 | 5 | (external.lib/send_alert "ClojureScript calling a function defined in an externed JavaScript library") 6 | -------------------------------------------------------------------------------- /script/test-cli: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f target/cljs.jar ]; then 4 | echo "Run script/uberjar first" 5 | exit 1 6 | fi 7 | 8 | java -cp target/cljs.jar:src/test/cljs_cli clojure.main -m cljs-cli.test-runner "$@" 9 | -------------------------------------------------------------------------------- /src/test/cljs_build/loader_test/bar.cljs: -------------------------------------------------------------------------------- 1 | (ns loader-test.bar 2 | (:require [cljs.loader :as loader])) 3 | 4 | (enable-console-print!) 5 | 6 | (println "Hello from bar!") 7 | 8 | (defn woz [] 9 | (println "Woz!")) 10 | -------------------------------------------------------------------------------- /ci/install_jsc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | if [ ! -d WebKit ] 3 | then 4 | git clone -b Safari-611.1.5.1 --depth=1 https://github.com/WebKit/WebKit.git WebKit; 5 | cd WebKit; 6 | Tools/Scripts/build-jsc --jsc-only; 7 | cd .. 8 | fi 9 | -------------------------------------------------------------------------------- /script/clean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf closure 4 | rm -rf compilation 5 | rm -rf lib 6 | rm -rf target 7 | rm -rf builds 8 | rm -rf clojure 9 | rm -rf out 10 | rm -rf node_modules 11 | rm -rf package.json 12 | rm -rf package-lock.json 13 | -------------------------------------------------------------------------------- /src/test/cljs/calculator.js: -------------------------------------------------------------------------------- 1 | var calculator = { 2 | add: function (a, b) { 3 | return a + b; 4 | }, 5 | subtract: function (a, b) { 6 | return a - b; 7 | } 8 | }; 9 | 10 | module.exports = calculator; 11 | -------------------------------------------------------------------------------- /src/test/cljs_build/emit_node_requires_test/native_modules.cljs: -------------------------------------------------------------------------------- 1 | (ns emit-node-requires-test.native-modules 2 | (:require [path :refer [isAbsolute]])) 3 | 4 | (enable-console-print!) 5 | 6 | (println (isAbsolute (path/resolve js/__filename))) 7 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3452_str_optimizations/core.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs-3452-str-optimizations.core) 2 | 3 | (defn my-str-fn [x y] 4 | (str x y nil ::foobar "my 5 | 6 | multiline 7 | 8 | string with `backticks`" 9 | true false 3.14)) 10 | -------------------------------------------------------------------------------- /src/test/cljs_build/hello-modules/src/bar/core.cljs: -------------------------------------------------------------------------------- 1 | (ns bar.core 2 | (:require [cljs.loader :as loader])) 3 | 4 | (enable-console-print!) 5 | 6 | (println "I'm bar!") 7 | 8 | (defn woz [] 9 | (println "WOZ!")) 10 | 11 | (loader/set-loaded! :bar) 12 | -------------------------------------------------------------------------------- /resources/self_parity_test.edn: -------------------------------------------------------------------------------- 1 | {:optimizations :none 2 | :main self-parity.test 3 | :language-out :es6 4 | :verbose true 5 | :output-to "builds/out-self-parity/main.js" 6 | :output-dir "builds/out-self-parity" 7 | :cache-analysis-format :edn 8 | :target :nodejs} 9 | -------------------------------------------------------------------------------- /src/test/cljs_build/code-split/src/code/split/b.cljs: -------------------------------------------------------------------------------- 1 | (ns code.split.b 2 | (:require [cljs.loader :as loader] 3 | [code.split.d :as d])) 4 | 5 | (defn hello [] 6 | (println "Hello from code.split.b.") 7 | (d/hello)) 8 | 9 | (loader/set-loaded! :b) 10 | -------------------------------------------------------------------------------- /src/test/cljs_build/hello-modules/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/repl/repl.clj: -------------------------------------------------------------------------------- 1 | (require '[cljs.closure :as cljsc]) 2 | (require '[cljs.repl :as repl]) 3 | (require '[cljs.repl.browser :as brepl]) 4 | 5 | (cljsc/build "src" 6 | {:output-to "main.js" 7 | :verbose true}) 8 | 9 | (repl/repl (brepl/repl-env) 10 | :repl-verbose true) -------------------------------------------------------------------------------- /src/test/cljs_build/package_json_resolution_test/core.cljs: -------------------------------------------------------------------------------- 1 | (ns package-json-resolution-test.core 2 | (:require [iterall] 3 | [graphql])) 4 | 5 | (enable-console-print!) 6 | 7 | (println "Is collection:" (iterall/isCollection #js [1 2])) 8 | (println "GraphQL:" graphql) 9 | -------------------------------------------------------------------------------- /src/test/cljs_build/code-split/src/code/split/c.cljs: -------------------------------------------------------------------------------- 1 | (ns code.split.c 2 | (:require [cljs.loader :as loader] 3 | [code.split.d :as d])) 4 | 5 | (enable-console-print!) 6 | 7 | (defn hello [] 8 | (println "Hello from code.split.c.") 9 | (d/hello)) 10 | 11 | (loader/set-loaded! :c) 12 | -------------------------------------------------------------------------------- /resources/self_host_test.edn: -------------------------------------------------------------------------------- 1 | {:optimizations :simple 2 | :main self-host.test 3 | :static-fns true 4 | :output-to "builds/out-self/core-self-test.js" 5 | :output-dir "builds/out-self" 6 | :optimize-constants true 7 | :verbose true 8 | :compiler-stats true 9 | :parallel-build true 10 | :target :nodejs} -------------------------------------------------------------------------------- /samples/hello-js/src/hello-js/core.cljs: -------------------------------------------------------------------------------- 1 | (ns hello-js.core) 2 | 3 | (defn ^:export popup-msg 4 | [msg] 5 | (js/send_alert msg)) 6 | 7 | (popup-msg "ClojureScript calling a global function defined in an external JavaScript library") 8 | 9 | (popup-msg (str "ClojureScript: the time is now " (js/Date.))) 10 | -------------------------------------------------------------------------------- /devnotes/testing: -------------------------------------------------------------------------------- 1 | Definitely a work-in-progress. 2 | 3 | To run tests before you commit: 4 | 5 | script/test 6 | 7 | To add tests: 8 | 9 | * Create test fiels in the test/cljs directory. 10 | * Write fns that throw an exception on failure. 11 | * Call those fns from test/cljs/cljs/test_runner.cljs 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/cljs_cp/npm_deps_test/string_requires_in_classpath.cljs: -------------------------------------------------------------------------------- 1 | (ns npm-deps-test.string-requires-in-classpath 2 | "This tests string require of a lib that is not loaded 3 | by project local files from a classpath file." 4 | (:require ["lodash/array" :as array])) 5 | 6 | (println "lodash/array is loaded:" (array/nth #js [true] 1)) 7 | -------------------------------------------------------------------------------- /src/test/cljs_build/npm_deps_test/invoke.cljs: -------------------------------------------------------------------------------- 1 | (ns npm-deps-test.invoke 2 | (:require [react :refer [createElement]] 3 | ["react-dom/server" :as ReactDOMServer] 4 | ["lodash-es/array" :as array])) 5 | 6 | (createElement "div") 7 | 8 | (ReactDOMServer/renderToString nil) 9 | 10 | (array/findIndex #js [1 2] 2) 11 | -------------------------------------------------------------------------------- /script/repl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$CLOJURESCRIPT_HOME" = "" ]; then 4 | CLOJURESCRIPT_HOME="`dirname $0`/.." 5 | fi 6 | 7 | CLJSC_CP='' 8 | for next in classes: lib/*: src/main/clojure: src/main/cljs: test/cljs; do 9 | CLJSC_CP="${CLJSC_CP}${CLOJURESCRIPT_HOME}/${next}" 10 | done 11 | 12 | java -server -cp "$CLJSC_CP" clojure.main "$@" 13 | 14 | -------------------------------------------------------------------------------- /src/test/cljs_build/cljs_3235/core.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs-3235.core 2 | (:require [some-foreign :refer [woz]] 3 | [some-foreign$woz :as sf-woz] 4 | [some-foreign$foz.boz :as sf-foz-boz] 5 | [react-select :refer [foo bar]] 6 | [react-select$default :as select] 7 | [react-select$default.baz :as select-baz])) 8 | -------------------------------------------------------------------------------- /src/test/cljs_build/code-split/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Module A

4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /ast-ref/buildref.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | java -cp .:`lein cp` clojure.main < 7 | 8 | 9 | 10 | ); 11 | } 12 | }); 13 | 14 | module.exports = Circle; 15 | -------------------------------------------------------------------------------- /samples/string-requires-npm-deps/src/foo/core.cljs: -------------------------------------------------------------------------------- 1 | (ns foo.core 2 | (:require [react :refer [createElement]] 3 | ["react-dom/server" :as rds :refer [renderToString]] 4 | "create-react-class")) 5 | 6 | (enable-console-print!) 7 | 8 | (println "resolves single exports" create-react-class) 9 | 10 | (println (renderToString (createElement "div" nil "Hello World!"))) 11 | -------------------------------------------------------------------------------- /src/test/cljs/Circle-min.js: -------------------------------------------------------------------------------- 1 | var React = require('./react-min'); 2 | 3 | var Circle = React.createClass({ 4 | render: function() { 5 | return( 6 | 7 | 8 | 9 | 10 | ); 11 | } 12 | }); 13 | 14 | module.exports = Circle; 15 | -------------------------------------------------------------------------------- /src/test/cljs_cli/cljs_cli/test_runner.clj: -------------------------------------------------------------------------------- 1 | (ns cljs-cli.test-runner 2 | (:require 3 | [cljs-cli.test] 4 | [cljs-cli.util])) 5 | 6 | (defn -main [& args] 7 | (try 8 | (binding [cljs-cli.util/*repl-env* (or (first args) "node") 9 | cljs-cli.util/*repl-opts* (second args)] 10 | (clojure.test/run-tests 'cljs-cli.test)) 11 | (finally 12 | (shutdown-agents)))) 13 | -------------------------------------------------------------------------------- /samples/string-requires-npm-deps/build.clj: -------------------------------------------------------------------------------- 1 | (require '[cljs.build.api :as b]) 2 | 3 | (b/build "src" 4 | {:output-dir "out" 5 | :output-to "out/main.js" 6 | :optimizations :none 7 | :verbose true 8 | :target :nodejs 9 | :compiler-stats true 10 | :main 'foo.core 11 | :npm-deps {:react "15.6.1" 12 | :react-dom "15.6.1"} 13 | :closure-warnings {:non-standard-jsdoc :off}}) 14 | -------------------------------------------------------------------------------- /samples/hello/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello ClojureScript 4 | 5 | 6 |

Hello ClojureScript!

7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /script/repl.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setLocal EnableDelayedExpansion 3 | 4 | if "%CLOJURESCRIPT_HOME%" == "" set CLOJURESCRIPT_HOME=%~dp0..\ 5 | 6 | set CLASSPATH=%CLOJURESCRIPT_HOME%src\clj;%CLOJURESCRIPT_HOME%src\cljs" 7 | for /R "%CLOJURESCRIPT_HOME%\lib" %%a in (*.jar) do ( 8 | set CLASSPATH=!CLASSPATH!;%%a 9 | ) 10 | set CLASSPATH=!CLASSPATH!" 11 | 12 | java -server -cp "%CLASSPATH%" clojure.main 13 | 14 | -------------------------------------------------------------------------------- /src/test/cljs_build/emit_node_requires_test/core.cljs: -------------------------------------------------------------------------------- 1 | (ns emit-node-requires-test.core 2 | (:require [react :refer [createElement]] 3 | ["react-dom/server" :as ReactDOMServer])) 4 | 5 | (enable-console-print!) 6 | 7 | (println "ReactDOMServer exists:" ReactDOMServer 8 | (.-renderToString ReactDOMServer)) 9 | 10 | (println "hi" (ReactDOMServer/renderToString (createElement "div" nil "Hello World!"))) 11 | -------------------------------------------------------------------------------- /src/test/cljs_build/hello-modules/release.clj: -------------------------------------------------------------------------------- 1 | (require '[cljs.build.api :as b]) 2 | 3 | (b/build "src" 4 | {:output-dir "out" 5 | :asset-path "/out" 6 | :optimizations :advanced 7 | :verbose true 8 | :modules {:foo {:entries '#{foo.core} 9 | :output-to "out/foo.js"} 10 | :bar {:entries '#{bar.core} 11 | :output-to "out/bar.js"}}}) 12 | 13 | (System/exit 0) 14 | -------------------------------------------------------------------------------- /script/browser-repl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$CLOJURESCRIPT_HOME" = "" ]; then 4 | CLOJURESCRIPT_HOME="`dirname $0`/.." 5 | fi 6 | 7 | CLJSC_CP='' 8 | for next in lib/*: src/main/clojure: src/main/cljs: test/cljs; do 9 | CLJSC_CP=$CLJSC_CP$CLOJURESCRIPT_HOME'/'$next 10 | done 11 | 12 | java -server -cp $CLJSC_CP clojure.main -e " 13 | (require '[cljs.repl :as r]) 14 | (require '[cljs.repl.browser :as b]) 15 | (r/repl (b/repl-env)) 16 | " 17 | -------------------------------------------------------------------------------- /script/noderepljs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$CLOJURESCRIPT_HOME" = "" ]; then 4 | CLOJURESCRIPT_HOME="`dirname $0`/.." 5 | fi 6 | 7 | CLJSC_CP='' 8 | for next in lib/*: src/main/clojure: src/main/cljs: src/test/cljs; do 9 | CLJSC_CP=$CLJSC_CP$CLOJURESCRIPT_HOME'/'$next 10 | done 11 | 12 | java -server -cp $CLJSC_CP clojure.main -e \ 13 | "(require '[cljs.repl :as repl]) 14 | (require '[cljs.repl.node :as node]) 15 | (repl/repl (node/repl-env $1))" 16 | -------------------------------------------------------------------------------- /src/test/externs/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | */ 4 | var Foo = function() {}; 5 | Foo.prototype.wozMethod = function() { 6 | }; 7 | /** 8 | * @return {Foo} 9 | */ 10 | var baz = function() {}; 11 | /** 12 | * @constructor 13 | */ 14 | Foo.Bar = function() {}; 15 | /** 16 | * @return {Foo.Boo} 17 | */ 18 | Foo.Bar.prototype.baz = function() {}; 19 | /** 20 | * @constructor 21 | */ 22 | Foo.Boo = function() {}; 23 | Foo.Boo.prototype.woz = function() {}; -------------------------------------------------------------------------------- /samples/string-requires-npm-deps/README.md: -------------------------------------------------------------------------------- 1 | # ClojureScript string-based requires demo 2 | 3 | Running: 4 | 5 | 1. At the root of the ClojureScript repo, run `./script/bootstrap` 6 | 2. Switch into this directory: `cd samples/string-requires-npm-deps` 7 | 3. Build the project: 8 | 9 | ``` shell 10 | $ java -cp `ls ../../lib/*.jar | paste -sd ":" -`:../../src/main/cljs:../../src/main/clojure:src clojure.main build.clj 11 | ``` 12 | 13 | 4. run the generated JavaScript with `node out/main.js` 14 | -------------------------------------------------------------------------------- /src/test/cljs_build/hello-modules/src/foo/core.cljs: -------------------------------------------------------------------------------- 1 | (ns foo.core 2 | (:require [goog.dom :as gdom] 3 | [goog.events :as events] 4 | [cljs.loader :as loader]) 5 | (:import [goog.events EventType])) 6 | 7 | (enable-console-print!) 8 | 9 | (println "I'm foo!") 10 | 11 | (events/listen (gdom/getElement "button") EventType.CLICK 12 | (fn [e] 13 | (loader/load :bar 14 | (fn [] 15 | ((resolve 'bar.core/woz)))))) 16 | 17 | (loader/set-loaded! :foo) 18 | -------------------------------------------------------------------------------- /samples/hello-js/hello-extern.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello Externed JavaScript Library 4 | 5 | 6 |

Hello Externed JavaScript Library!

7 | 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/imul.js: -------------------------------------------------------------------------------- 1 | if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) { 2 | Math.imul = function (a, b) { 3 | var ah = (a >>> 16) & 0xffff; 4 | var al = a & 0xffff; 5 | var bh = (b >>> 16) & 0xffff; 6 | var bl = b & 0xffff; 7 | // the shift by 0 fixes the sign on the high part 8 | // the final |0 converts the unsigned value into a signed value 9 | return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/nodehello.cljs: -------------------------------------------------------------------------------- 1 | (ns nodehello 2 | (:require [cljs.nodejs :as nodejs])) 3 | 4 | (defn -main [& args] 5 | (println (apply str (map [\space "world" "hello"] [2 0 1])))) 6 | 7 | (nodejs/enable-util-print!) 8 | (set! *main-cli-fn* -main) 9 | 10 | (comment 11 | ; Compile this using a command line like: 12 | 13 | CLOJURESCRIPT_HOME=".../clojurescript/" \ 14 | bin/cljsc samples/nodehello.cljs {:target :nodejs} \ 15 | > out/nodehello.js 16 | 17 | ; Then run using: 18 | nodejs out/nodehello.js 19 | 20 | ) 21 | -------------------------------------------------------------------------------- /src/test/cljs_build/loader_test/foo.cljs: -------------------------------------------------------------------------------- 1 | (ns loader-test.foo 2 | (:require [goog.dom :as gdom] 3 | [goog.events :as events] 4 | [cljs.loader :as loader] 5 | [foreign.a] 6 | [foreign.b]) 7 | (:import [goog.events EventType])) 8 | 9 | (enable-console-print!) 10 | 11 | (println "Hello from foo!") 12 | 13 | (events/listen (gdom/getElement "button") EventType.CLICK 14 | (fn [e] 15 | (loader/load :bar 16 | (fn [] 17 | ((resolve 'loader-test.bar/woz)))))) 18 | -------------------------------------------------------------------------------- /script/test-self-host: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # stop blowing compiled stuff 4 | rm -rf builds/out-self 5 | mkdir -p builds/out-self 6 | 7 | if ! bin/cljsc src/test/self/self_host "{:optimizations :simple :static-fns true :output-dir \"builds/out-self\" :optimize-constants true :verbose true :compiler-stats true :parallel-build true :target :nodejs}" > builds/out-self/core-self-test.js; then 8 | >&2 echo ClojureScript compilation failed 9 | exit 1 10 | fi; 11 | 12 | echo "Testing with Node" 13 | node builds/out-self/core-self-test.js 14 | -------------------------------------------------------------------------------- /samples/nodels.cljs: -------------------------------------------------------------------------------- 1 | ; This one doesn't yet work with :optimizations :advanced 2 | (ns nodels 3 | (:require [cljs.nodejs :as nodejs])) 4 | 5 | (def fs (nodejs/require "fs")) 6 | (def path (nodejs/require "path")) 7 | 8 | (defn file-seq [dir] 9 | (tree-seq 10 | (fn [f] (.isDirectory (.statSync fs f) ())) 11 | (fn [d] (map #(.join path d %) (.readdirSync fs d))) 12 | dir)) 13 | 14 | (defn -main [& paths] 15 | (dorun (map println (mapcat file-seq paths)))) 16 | 17 | (nodejs/enable-util-print!) 18 | (set! *main-cli-fn* -main) 19 | -------------------------------------------------------------------------------- /src/test/cljs/baz.cljs: -------------------------------------------------------------------------------- 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 baz) 10 | 11 | (defn f [x] x) 12 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/baz.cljs: -------------------------------------------------------------------------------- 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 baz) 10 | 11 | (defn f [x] x) 12 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/ns_test/bar.cljs: -------------------------------------------------------------------------------- 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 cljs.ns-test.bar) 10 | 11 | (defn quux [] 123) 12 | -------------------------------------------------------------------------------- /src/test/cljs/preloads_test/core.cljs: -------------------------------------------------------------------------------- 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 preloads-test.core) 10 | 11 | (def foo :foo) 12 | -------------------------------------------------------------------------------- /src/test/cljs_build/hello-modules/repl.clj: -------------------------------------------------------------------------------- 1 | (require '[cljs.repl :as r]) 2 | (require '[cljs.build.api :as b]) 3 | (require '[cljs.repl.browser :as rb]) 4 | 5 | (def opts 6 | {:watch "src" 7 | :output-dir "out" 8 | :asset-path "/out" 9 | :optimizations :none 10 | :modules {:foo {:entries '#{foo.core} 11 | :output-to "out/foo.js"} 12 | :bar {:entries '#{bar.core} 13 | :output-to "out/bar.js"}} 14 | :browser-repl true 15 | :verbose true}) 16 | 17 | (b/build "src" opts) 18 | (r/repl* (rb/repl-env) opts) 19 | -------------------------------------------------------------------------------- /src/test/cljs_build/thirdparty/add.js: -------------------------------------------------------------------------------- 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 | function add(a, b) { 10 | return a + b; 11 | } 12 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/spec/test/test_ns2.cljs: -------------------------------------------------------------------------------- 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 cljs.spec.test.test-ns2) 10 | 11 | (def z 3) 12 | -------------------------------------------------------------------------------- /src/test/self/bootstrap_test/core.cljs: -------------------------------------------------------------------------------- 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 bootstrap-test.core) 10 | 11 | (defn foo [a b] 12 | (+ a b)) -------------------------------------------------------------------------------- /src/test/cljs/cljs/keyword_other.cljs: -------------------------------------------------------------------------------- 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 cljs.keyword-other) 10 | 11 | (defn foo [a b] 12 | (+ a b)) 13 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/macro_test/cljs2261.cljs: -------------------------------------------------------------------------------- 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 cljs.macro-test.cljs2261) 10 | 11 | (defrecord X []) 12 | -------------------------------------------------------------------------------- /src/test/cljs/preloads_test/preload.cljs: -------------------------------------------------------------------------------- 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 preloads-test.preload) 10 | 11 | (def preload-var :foo) 12 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/macro_test/cljs2261.clj: -------------------------------------------------------------------------------- 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 cljs.macro-test.cljs2261) 10 | 11 | (defmacro cake [] 12 | `(X.)) 13 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/spec/test/test_ns1.cljs: -------------------------------------------------------------------------------- 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 cljs.spec.test.test-ns1) 10 | 11 | (def x 1) 12 | 13 | (def y 2) 14 | -------------------------------------------------------------------------------- /src/test/self/bootstrap_test/helper.clj: -------------------------------------------------------------------------------- 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 bootstrap-test.helper) 10 | 11 | (defn bar [a b] 12 | `(* ~a ~b)) 13 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/keyword_macros.clj: -------------------------------------------------------------------------------- 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 cljs.keyword-macros) 10 | 11 | (defmacro add 12 | [a b] 13 | `(+ ~a ~b)) 14 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/core/specs/alpha.cljs: -------------------------------------------------------------------------------- 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 cljs.core.specs.alpha 10 | (:require-macros [cljs.core.specs.alpha])) 11 | -------------------------------------------------------------------------------- /src/test/cljs_build/emit_global_requires_test/core.cljs: -------------------------------------------------------------------------------- 1 | (ns emit-global-requires-test.core 2 | (:require [react :refer [createElement]] 3 | ["react-dom/server" :as ReactDOMServer] 4 | ["@material-ui/core/styles" :as mui-styles] 5 | ["@material-ui/core/styles/a" :as mui-styles-a])) 6 | 7 | (enable-console-print!) 8 | 9 | (println "ReactDOMServer exists:" ReactDOMServer 10 | (.-renderToString ReactDOMServer)) 11 | 12 | (println "hi" (ReactDOMServer/renderToString (createElement "div" nil "Hello World!"))) 13 | 14 | (mui-styles/createMuiTheme #js {}) 15 | (mui-styles-a/foo) 16 | -------------------------------------------------------------------------------- /samples/hello-js/hello-js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello External JavaScript Library 4 | 5 | 6 |

Hello External JavaScript Library!

7 | 8 | 9 | 10 | 13 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/binding_test_other_ns.cljs: -------------------------------------------------------------------------------- 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 cljs.binding-test-other-ns) 10 | 11 | (def ^:dynamic *foo* 1) 12 | 13 | (def bar 10) 14 | -------------------------------------------------------------------------------- /src/test/cljs/module_test/main.cljs: -------------------------------------------------------------------------------- 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 module-test.main) 10 | 11 | (defn ^:export main [] 12 | (println "Loading modules A and B ...")) 13 | -------------------------------------------------------------------------------- /src/test/cljs/module_test/modules/a.cljs: -------------------------------------------------------------------------------- 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 module-test.modules.a) 10 | 11 | (defn ^:export main [] 12 | (println "Module A loaded.")) 13 | -------------------------------------------------------------------------------- /src/test/cljs/module_test/modules/b.cljs: -------------------------------------------------------------------------------- 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 module-test.modules.b) 10 | 11 | (defn ^:export main [] 12 | (println "Module B loaded.")) 13 | -------------------------------------------------------------------------------- /src/test/cljs_build/circular_deps/a.cljs: -------------------------------------------------------------------------------- 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 circular-deps.a 10 | (:require [circular-deps.b])) 11 | 12 | (defn foo [a b] 13 | (+ a b)) 14 | -------------------------------------------------------------------------------- /src/test/cljs_build/circular_deps/b.cljs: -------------------------------------------------------------------------------- 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 circular-deps.b 10 | (:require [circular-deps.a])) 11 | 12 | (defn bar [c d] 13 | (* c d)) 14 | -------------------------------------------------------------------------------- /samples/hello/hello-dev.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello ClojureScript 4 | 5 | 6 |

Hello ClojureScript!

7 | 8 | 9 | 10 | 13 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/cljs/process/env.cljs: -------------------------------------------------------------------------------- 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 process.env 10 | "A shim namespace for the Node.js process library") 11 | 12 | (goog-define NODE_ENV "development") 13 | -------------------------------------------------------------------------------- /src/test/cljs_build/foreign_libs/core.cljs: -------------------------------------------------------------------------------- 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.core 10 | (:require [thirdparty.add])) 11 | 12 | (defn main [] 13 | (println (js/add 1 2))) 14 | -------------------------------------------------------------------------------- /src/test/self/bootstrap_test/macros.clj: -------------------------------------------------------------------------------- 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 bootstrap-test.macros 10 | (:require [bootstrap-test.helper :refer [bar]])) 11 | 12 | (defmacro foo [a b] 13 | (bar a b)) -------------------------------------------------------------------------------- /script/test-compile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Generating sample javascript" 4 | mkdir compilation 5 | 6 | cat >compilation/test.js < > out.js" 14 | echo "cljsc {:optimiztions :advanced} > out.js" 15 | ) else ( 16 | java -server -cp "%CLASSPATH%" clojure.main "%CLOJURESCRIPT_HOME%\bin\cljsc.clj" %* 17 | ) 18 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/array_access/helper.clj: -------------------------------------------------------------------------------- 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 cljs.array-access.helper 10 | (:require [cljs.analyzer :as ana])) 11 | 12 | (defmacro unchecked-arrays? [] 13 | (ana/unchecked-arrays?)) 14 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/array_access_test.cljc: -------------------------------------------------------------------------------- 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 cljs.array-access-test) 10 | 11 | (defmacro suppress-errs [& forms] 12 | `(cljs.core/with-redefs [cljs.core/*print-err-fn* nil] 13 | ~@forms)) -------------------------------------------------------------------------------- /src/test/cljs_build/foreign_libs_cljs_2249/core.cljs: -------------------------------------------------------------------------------- 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-cljs-2249.core 10 | (:require [thirdparty.calculator])) 11 | 12 | (defn main [] 13 | (println (js/Calculator.add 1 2))) 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .idea 3 | /.DS_Store 4 | .DS_Store 5 | /classes 6 | /lib 7 | /target 8 | closure 9 | /core.js 10 | /coreadvanced.js 11 | /coresimple.js 12 | /out 13 | *out 14 | .lein* 15 | *.iml 16 | .repl* 17 | *.swp 18 | *.zip 19 | clojurescript_release_* 20 | closure-release-* 21 | .lein-repl-history 22 | .nrepl-port 23 | .nrepl-repl-history 24 | builds 25 | .cljs* 26 | node_modules 27 | nashorn_code_cache 28 | src/main/cljs/cljs/core.aot.js 29 | src/main/cljs/cljs/core.aot.js.map 30 | src/main/cljs/cljs/core.cljs.cache.aot.edn 31 | src/main/cljs/cljs/core.cljs.cache.aot.json 32 | .node_repl 33 | package.json 34 | package-lock.json 35 | .cpcache 36 | resources/brepl_client.js 37 | -------------------------------------------------------------------------------- /src/test/cljs_build/foreign_libs_dir_test/core.cljs: -------------------------------------------------------------------------------- 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)) 16 | -------------------------------------------------------------------------------- /samples/hello-js/hello-js-dev.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello External JavaScript Library 4 | 5 | 6 |

Hello External JavaScript Library!

7 | 8 | 9 | 10 | 11 | 14 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/hello/src/hello/core.cljs: -------------------------------------------------------------------------------- 1 | (ns hello.core 2 | (:require [hello.foo.bar :as bar] 3 | [cljs.reader :as reader])) 4 | 5 | (defn ^{:export greet} greet [n] 6 | (str "Hello " n)) 7 | 8 | (defn ^:export sum [xs] 9 | (bar/sum xs)) 10 | 11 | (defn ^:export let-works? [day month year] 12 | (let [hour (first day) 13 | minutes (first hour) 14 | seconds (last hour)] 15 | (.log js/console "Date: " year month day) 16 | (str year month day hour minutes seconds))) 17 | 18 | (defn bailey [proton neutron electron & comedies] 19 | (apply + proton neutron electron) 20 | (map identity comedies)) 21 | 22 | (defn videotape [& rainbows] 23 | (map :params rainbows)) 24 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/macro_test/macros.clj: -------------------------------------------------------------------------------- 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 cljs.macro-test.macros 10 | (:refer-clojure :exclude [==])) 11 | 12 | (defmacro == [a b] 13 | `(+ ~a ~b)) 14 | 15 | (defmacro sm-cljs-3027 [] 16 | (sorted-map "a" "b")) 17 | -------------------------------------------------------------------------------- /src/main/cljs/clojure/browser/repl/preload.cljs: -------------------------------------------------------------------------------- 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 clojure.browser.repl.preload 10 | (:require [clojure.browser.repl :as repl])) 11 | 12 | (defonce conn 13 | (repl/connect (str "http://" repl/HOST ":" repl/PORT "/repl"))) 14 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/array_access/alpha.cljs: -------------------------------------------------------------------------------- 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 cljs.array-access.alpha 10 | (:require-macros [cljs.array-access.helper :as helper]) 11 | (:require [cljs.array-access.beta])) 12 | 13 | (defn unchecked-arrays? [] 14 | (helper/unchecked-arrays?)) 15 | -------------------------------------------------------------------------------- /script/revision: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | # The command `git describe --match v0.0` will return a string like 6 | # 7 | # v0.0-856-g329708b 8 | # 9 | # where 856 is the number of commits since the v0.0 tag. It will always 10 | # find the v0.0 tag and will always return the total number of commits (even 11 | # if the tag is v0.0.1). 12 | MAJOR="1" 13 | MINOR="11" 14 | REVISION=`git --no-replace-objects describe --match v$MAJOR.$MINOR` 15 | 16 | # Extract the version number from the string. Do this in two steps so 17 | # it is a little easier to understand. 18 | REVISION=${REVISION:5} # drop the first 5 characters 19 | REVISION=${REVISION:0:${#REVISION}-9} # drop the last 9 characters 20 | REVISION=${REVISION/\-/} 21 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/spec/test/test_macros.cljc: -------------------------------------------------------------------------------- 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 cljs.spec.test.test-macros 10 | #?(:cljs (:require [cljs.spec.alpha :as s]))) 11 | 12 | (defmacro add 13 | [a b] 14 | `(+ ~a ~b)) 15 | 16 | #?(:cljs 17 | (s/fdef add 18 | :args (s/cat :a number? :b number?))) 19 | -------------------------------------------------------------------------------- /src/test/cljs_build/npm_deps_test/string_requires.cljs: -------------------------------------------------------------------------------- 1 | (ns npm-deps-test.string-requires 2 | (:require [react :refer [createElement]] 3 | ["react-dom/server" :as ReactDOMServer] 4 | ["lodash-es/toArray" :refer [default] :rename {default toArray}] 5 | ["lodash-es/toFinite" :as toFinite] 6 | ["lodash-es/array" :as array] 7 | [npm-deps-test.string-requires-in-classpath])) 8 | 9 | (enable-console-print!) 10 | 11 | ;; CJS namespace access 12 | (println ReactDOMServer) 13 | 14 | ;; CJS method call 15 | (ReactDOMServer/renderToString nil) 16 | 17 | ;; es6 default with refer rename 18 | (toArray nil) 19 | 20 | ;; es6 :as and default 21 | (toFinite/default nil) 22 | 23 | ;; es6 24 | (array/findIndex #js [1 2] 2) 25 | -------------------------------------------------------------------------------- /src/test/cljs/data_readers.cljc: -------------------------------------------------------------------------------- 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 | {cljs/tag clojure.core/identity 10 | cljs/inc clojure.core/inc 11 | cljs/union clojure.set/union 12 | test/custom-identity data-readers-test.core/custom-identity 13 | test/custom-form #?(:cljs data-readers-test.core/custom-form-cljs :clj clojure.core/identity)} 14 | -------------------------------------------------------------------------------- /src/test/cljs/static/core_test.cljs: -------------------------------------------------------------------------------- 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 static.core-test 10 | (:require [cljs.test :refer-macros [deftest is]])) 11 | 12 | ; The purpose of this test namespace is to ensure 13 | ; that the use of a reserved JavaScript keyword 14 | ; (`static`) in the namespace is handled properly. 15 | 16 | (deftest foo-test 17 | (is (= 1 1))) 18 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/top_level.cljs: -------------------------------------------------------------------------------- 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 cljs.top-level 10 | (:refer-clojure :exclude [test]) 11 | (:require [cljs.test :refer-macros [deftest is]])) 12 | 13 | (let [foo 1] 14 | (defn bar [] 15 | foo)) 16 | 17 | (let [foo 2] 18 | (defn baz [] 19 | foo)) 20 | 21 | (deftest test 22 | (is (= (bar) 1)) 23 | (is (= (baz) 2))) 24 | -------------------------------------------------------------------------------- /devnotes/bcrepl.org: -------------------------------------------------------------------------------- 1 | * ClojureScript browser connected REPL 2 | ** send cljs compiler output to the browser to be evaluated 3 | ** send results back to the command line process to be printed 4 | ** side effects happen in the browser 5 | ** abstract communication away using goog library 6 | *** Goog abstraction for websockets? Ideal! 7 | *** Polling? It will work everywhere. 8 | *** Ideally an abstraction over both that prefers websockets but doesn't fail and doesn't complain loudly. 9 | ** evaluation daemon for the browser 10 | ** launch browser 11 | ** transparent update of bound symbols? We should test. 12 | ** brepl has its own solution for deps, we'd like to tie into the ClojureScript dependency story 13 | ** require mechanisms are out; the source that forms the repl's environment will need to be updated and the page reloaded 14 | -------------------------------------------------------------------------------- /bin/cljsc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Compile a single cljs file or a directory of cljs files into a 4 | # single JavaScript file. 5 | 6 | if [ "$CLOJURESCRIPT_HOME" = "" ]; then 7 | CLOJURESCRIPT_HOME="`dirname $0`/.." 8 | fi 9 | 10 | if ! test "$(ls -A "$CLOJURESCRIPT_HOME/lib" 2>/dev/null)"; then 11 | >&2 echo lib/ folder is empty, have you run \`script/bootstrap\`? 12 | exit 1 13 | fi 14 | 15 | CLJSC_CP='' 16 | for next in lib/*: src/main/clojure: src/main/cljs: src/test/cljs: src/test/self; do 17 | CLJSC_CP="${CLJSC_CP}${CLOJURESCRIPT_HOME}/${next}" 18 | done 19 | 20 | if test "$#" -eq 0 21 | then 22 | echo 'Usage: cljsc ' 23 | echo ' cljsc "{:optimizations :advanced}"' 24 | else 25 | java -server -Xms2g -Xmx4g -cp "$CLJSC_CP" clojure.main "$CLOJURESCRIPT_HOME/bin/cljsc.clj" "$@" 26 | fi 27 | -------------------------------------------------------------------------------- /src/main/clojure/cljs/compiler/macros.clj: -------------------------------------------------------------------------------- 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 cljs.compiler.macros 10 | (:refer-clojure :exclude [let])) 11 | 12 | (defmacro emit-wrap [env & body] 13 | `(cljs.core/let [env# ~env] 14 | (when (= :return (:context env#)) (cljs.compiler/emits "return ")) 15 | ~@body 16 | (when-not (= :expr (:context env#)) (cljs.compiler/emitln ";")))) 17 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/syntax_quote_test.cljs: -------------------------------------------------------------------------------- 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 cljs.syntax-quote-test 10 | (:require [cljs.test :as test :refer-macros [deftest is]])) 11 | 12 | (deftest test-syntax-quote 13 | (is (= 'cljs.syntax-quote-test/foo `foo)) 14 | (is (= 'cljs.test/test-vars `test/test-vars)) 15 | (is (= 'cljs.test/deftest `test/deftest)) 16 | (is (= 'cljs.test/foo `test/foo))) 17 | -------------------------------------------------------------------------------- /src/test/cljs_build/code-split/repl.clj: -------------------------------------------------------------------------------- 1 | ;; Instructions: 2 | 3 | ;; ./script/uberjar 4 | ;; cd src/test/cljs_build/code-split 5 | ;; java -cp ../../../../target/cljs.jar:src clojure.main repl.clj 6 | ;; chromium http://localhost:9000/index.html 7 | 8 | (require '[cljs.repl :as r]) 9 | (require '[cljs.build.api :as b]) 10 | (require '[cljs.repl.browser :as rb]) 11 | 12 | (def opts 13 | {:output-dir "out" 14 | :asset-path "/out" 15 | :optimizations :none 16 | :modules {:a {:entries '#{code.split.a} 17 | :output-to "out/a.js"} 18 | :b {:entries '#{code.split.b} 19 | :output-to "out/b.js"} 20 | :c {:entries '#{code.split.c} 21 | :output-to "out/c.js"}} 22 | :browser-repl true 23 | :verbose true}) 24 | 25 | (b/build "src" opts) 26 | (r/repl* (rb/repl-env) (dissoc opts :modules)) 27 | -------------------------------------------------------------------------------- /resources/test.edn: -------------------------------------------------------------------------------- 1 | {:optimizations :advanced 2 | :main test-runner 3 | :output-to "builds/out-adv/core-advanced-test.js" 4 | :output-dir "builds/out-adv" 5 | :output-wrapper true 6 | :verbose true 7 | :compiler-stats true 8 | :parallel-build true 9 | :npm-deps {:lodash "4.17.4"} 10 | :closure-warnings {:non-standard-jsdoc :off :global-this :off} 11 | :install-deps true 12 | :language-out :es5 13 | :foreign-libs 14 | [{:file "src/test/cljs/calculator_global.js" 15 | :provides ["calculator"] 16 | :global-exports {calculator Calculator}} 17 | {:file "src/test/cljs/es6_dep.js" 18 | :module-type :es6 19 | :provides ["es6_calc"]} 20 | {:file "src/test/cljs/calculator.js" 21 | :module-type :commonjs 22 | :provides ["calculator"]} 23 | {:file "src/test/cljs/es6_default_hello.js" 24 | :provides ["es6_default_hello"] 25 | :module-type :es6}]} 26 | -------------------------------------------------------------------------------- /src/test/clojure/cljs/source_map/base64_tests.clj: -------------------------------------------------------------------------------- 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 cljs.source-map.base64-tests 10 | (:require 11 | [clojure.test :refer [deftest is]] 12 | [cljs.source-map.base64 :as base64])) 13 | 14 | (deftest encode-test 15 | (doseq [n (range 64)] 16 | (is (= (get base64/int->char n) (base64/encode n)))) 17 | (is (thrown-with-msg? Error #"Must be between 0 and 63: 64" (base64/encode 64)))) 18 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | */ 10 | 11 | Math.imul = function(a, b) {}; 12 | 13 | Object.prototype.done; 14 | Object.prototype.value; 15 | Object.prototype.next = function() {}; 16 | 17 | /** 18 | * @constructor; 19 | */ 20 | function IEquiv() {}; 21 | IEquiv.prototype.equiv = function() {}; 22 | 23 | /** 24 | * @constructor 25 | */ 26 | function Java() {}; 27 | Java.prototype.type = function() {}; -------------------------------------------------------------------------------- /src/main/clojure/cljs/support.cljc: -------------------------------------------------------------------------------- 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 cljs.support) 10 | 11 | (defmacro assert-args 12 | "Internal - do not use!" 13 | [fnname & pairs] 14 | `(do (when-not ~(first pairs) 15 | (throw (ex-info ~(str fnname " requires " (second pairs)) {:clojure.error/phase :macro-syntax-check}))) 16 | ~(let [more (nnext pairs)] 17 | (when more 18 | (list* `assert-args fnname more))))) 19 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/macro_test/cljs2852.clj: -------------------------------------------------------------------------------- 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 cljs.macro-test.cljs2852) 10 | 11 | (defmacro alpha 12 | ([x])) 13 | 14 | (defmacro beta [] 15 | `'~(:arglists (meta #'alpha))) 16 | 17 | (defmacro gamma 18 | ([x]) 19 | ([x y])) 20 | 21 | (defmacro delta [] 22 | `'~(:arglists (meta #'gamma))) 23 | 24 | (defmacro epsilon 25 | ([x]) 26 | ([x & xs])) 27 | 28 | (defmacro zeta [] 29 | `'~(:arglists (meta #'epsilon))) 30 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/keyword_test.cljs: -------------------------------------------------------------------------------- 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 cljs.keyword-test 10 | (:require-macros [cljs.keyword-macros :as macros] 11 | [cljs.test :refer [deftest is]]) 12 | (:require [cljs.keyword-other :as other] 13 | [cljs.test])) 14 | 15 | (deftest test-keyword 16 | (is (= ::bar :cljs.keyword-test/bar)) 17 | (is (= ::other/foo :cljs.keyword-other/foo)) 18 | (is (= ::macros/foo :cljs.keyword-macros/foo))) 19 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/qualified_method_test.cljs: -------------------------------------------------------------------------------- 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 cljs.qualified-method-test 10 | (:refer-global :only [String]) 11 | (:require [cljs.test :as test :refer-macros [deftest testing is]])) 12 | 13 | (deftest qualified-method-return-position-test 14 | (testing "qualified method returned from function to force it in return position" 15 | (let [f (fn [] String/.toUpperCase) 16 | m (f)] 17 | (is (= "FOO" (m "foo")))))) 18 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/repl_test.cljs: -------------------------------------------------------------------------------- 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 cljs.repl-test 10 | (:require 11 | [cljs.repl] 12 | [cljs.test :refer [deftest is]])) 13 | 14 | (deftest test-cljs-3017 15 | (let [m (cljs.repl/Error->map (js/TypeError.))] 16 | (is (= 'js/TypeError (get-in m [:via 0 :type]))))) 17 | 18 | (deftest test-cljs-3019 19 | (let [m (cljs.repl/Error->map (ex-info "" {}))] 20 | (is (= 'cljs.core/ExceptionInfo (get-in m [:via 0 :type]))))) 21 | -------------------------------------------------------------------------------- /script/test-self-parity: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # stop blowing compiled stuff 4 | rm -rf builds/out-self-parity 5 | mkdir -p builds/out-self-parity 6 | 7 | # extract needed files from clojure.jar 8 | if [ ! -f lib/clojure.jar ]; then 9 | echo "Run script/bootstrap first" 10 | exit 1 11 | fi 12 | jar xvf lib/clojure.jar clojure/template.clj > /dev/null 13 | unzip lib/test.check.jar 'clojure/*' > /dev/null 14 | mkdir -p builds/out-self-parity/clojure/test 15 | mv clojure/template.clj builds/out-self-parity/clojure 16 | mv clojure/test builds/out-self-parity/clojure 17 | 18 | if ! bin/cljsc src/test/self/self_parity "{:optimizations :simple :language-out :es5 :output-to \"builds/out-self-parity/main.js\" :output-dir \"builds/out-self-parity\" :main self-parity.test :target :nodejs}"; then 19 | >&2 echo ClojureScript compilation failed 20 | exit 1 21 | fi; 22 | 23 | echo "Testing with Node" 24 | node builds/out-self-parity/main.js 25 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/reader.clj: -------------------------------------------------------------------------------- 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 cljs.reader 10 | (:require [cljs.env :as env])) 11 | 12 | (defmacro add-data-readers [default-readers] 13 | (let [data-readers 14 | (->> (get @env/*compiler* :cljs.analyzer/data-readers) 15 | (map (fn [[k v]] 16 | `['~k (fn [x#] (~(vary-meta (-> v meta :sym) assoc :cljs.analyzer/no-resolve true) x#))])) 17 | (into {}))] 18 | `(do (merge ~default-readers ~data-readers)))) 19 | -------------------------------------------------------------------------------- /src/test/cljs/foo/ns_shadow_test.cljs: -------------------------------------------------------------------------------- 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 foo.ns-shadow-test 10 | (:require [cljs.test :refer-macros [deftest is]] 11 | baz)) 12 | 13 | (defn bar [] 1) 14 | 15 | (defn quux [foo] 16 | (+ (foo.ns-shadow-test/bar) foo)) 17 | 18 | (defn id [x] x) 19 | 20 | (defn foo [] (id 42)) 21 | 22 | (defn baz 23 | ([] (baz 2)) 24 | ([x] (quux 2))) 25 | 26 | (deftest test-shadow 27 | (is (= (quux 2) 3)) 28 | (is (= (foo) 42)) 29 | (is (= (baz) 3))) 30 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/foo/ns_shadow_test.cljs: -------------------------------------------------------------------------------- 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 foo.ns-shadow-test 10 | (:require [cljs.test :refer-macros [deftest is]] 11 | baz)) 12 | 13 | (defn bar [] 1) 14 | 15 | (defn quux [foo] 16 | (+ (foo.ns-shadow-test/bar) foo)) 17 | 18 | (defn id [x] x) 19 | 20 | (defn foo [] (id 42)) 21 | 22 | (defn baz 23 | ([] (baz 2)) 24 | ([x] (quux 2))) 25 | 26 | (deftest test-shadow 27 | (is (= (quux 2) 3)) 28 | (is (= (foo) 42)) 29 | (is (= (baz) 3))) 30 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/ns_test/foo.cljs: -------------------------------------------------------------------------------- 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 cljs.ns-test.foo 10 | (:require [cljs.test :refer-macros [deftest is]] 11 | [made.up.lib :as-alias lib])) 12 | 13 | (defn baz [] 123) 14 | 15 | (def kw ::foo) 16 | (def qkw '::foo) 17 | 18 | (deftest test-namespaced-keywords 19 | (is (= (str kw) ":cljs.ns-test.foo/foo")) 20 | (is (= (str qkw) ":cljs.ns-test.foo/foo"))) 21 | 22 | (deftest test-as-alias-keywords 23 | (is (keyword-identical? ::lib/foo :made.up.lib/foo))) 24 | -------------------------------------------------------------------------------- /src/assembly/slim.xml: -------------------------------------------------------------------------------- 1 | 2 | slim 3 | 4 | jar 5 | 6 | false 7 | 8 | 9 | src/main/cljs 10 | / 11 | 12 | 13 | src/main/clojure 14 | / 15 | 16 | 17 | resources 18 | / 19 | 20 | 21 | 22 | 23 | pom.xml 24 | META-INF/maven/org.clojure/clojurescript 25 | 26 | 27 | target/maven-archiver/pom.properties 28 | META-INF/maven/org.clojure/clojurescript 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/tagged_literals_test.cljs: -------------------------------------------------------------------------------- 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 cljs.tagged-literals-test 10 | (:require [cljs.test :refer-macros [deftest is]] 11 | [cljs.reader :as reader])) 12 | 13 | (deftest test-identity-custom-literal 14 | (is (= #cljs/tag [1 2 3] [1 2 3]))) 15 | 16 | (deftest test-runtime-reader 17 | (is (object? (reader/read-string "#js {}"))) 18 | (is (= {} (reader/read-string "#cljs/tag {}"))) 19 | (is (= (reader/read-string "#cljs/inc 0") 1)) 20 | (is (= (reader/read-string "#cljs/union #{1}") #{1}))) 21 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/var_test.cljs: -------------------------------------------------------------------------------- 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 cljs.var-test 10 | (:require [cljs.test :refer-macros [deftest is testing]])) 11 | 12 | (defn cljs-3411-function 13 | "this function adds two numbers" 14 | {:test #(do 15 | (assert (= (cljs-3411-function 2 3) 5)) 16 | (assert (= (cljs-3411-function 4 4) 8)))} 17 | ([x y] (+ x y))) 18 | 19 | (deftest cljs-3411 20 | (testing "cljs.core/test respects docstring" 21 | (is (= :ok (test cljs-3411-function))) 22 | (is (= :ok (test #'cljs-3411-function))))) 23 | -------------------------------------------------------------------------------- /resources/lite_test.edn: -------------------------------------------------------------------------------- 1 | {:optimizations :advanced 2 | :main lite-test-runner 3 | :output-to "builds/out-lite/lite-test.js" 4 | :output-dir "builds/out-lite" 5 | :output-wrapper true 6 | :verbose true 7 | :compiler-stats true 8 | :parallel-build true 9 | :npm-deps {:lodash "4.17.4"} 10 | :closure-warnings {:non-standard-jsdoc :off :global-this :off} 11 | :install-deps true 12 | :language-out :es5 13 | :foreign-libs 14 | [{:file "src/test/cljs/calculator_global.js" 15 | :provides ["calculator"] 16 | :global-exports {calculator Calculator}} 17 | {:file "src/test/cljs/es6_dep.js" 18 | :module-type :es6 19 | :provides ["es6_calc"]} 20 | {:file "src/test/cljs/calculator.js" 21 | :module-type :commonjs 22 | :provides ["calculator"]} 23 | {:file "src/test/cljs/es6_default_hello.js" 24 | :provides ["es6_default_hello"] 25 | :module-type :es6}] 26 | :pseudo-names true 27 | :pretty-print true 28 | :lite-mode true} 29 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/js.clj: -------------------------------------------------------------------------------- 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 cljs.js 10 | (:require [cljs.env :as env] 11 | [cljs.env.macros :as menv] 12 | [cljs.analyzer :as ana] 13 | [clojure.java.io :as io])) 14 | 15 | (defmacro with-state 16 | [state & body] 17 | `(menv/with-compiler-env ~state 18 | ~@body)) 19 | 20 | (defmacro dump-core [] 21 | (let [state @env/*compiler*] 22 | (if-not (false? (get-in state [:options :dump-core])) 23 | `(quote ~(get-in state [::ana/namespaces 'cljs.core])) 24 | `(hash-map)))) 25 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/import_test.cljs: -------------------------------------------------------------------------------- 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 cljs.import-test 10 | (:require [cljs.test :refer-macros [deftest is]]) 11 | (:import goog.math.Long 12 | [goog.math Vec2 Vec3] 13 | [goog.math Integer])) 14 | 15 | (deftest test-import 16 | (is (fn? Long)) 17 | (is (.equals (Long. 4 6) (.add (Long. 1 2) (Long. 3 4)))) 18 | (is (= "12" (str (Long.fromInt 12)))) 19 | (is (not (nil? (Vec2. 1 2)))) 20 | (is (not (nil? (Vec3. 1 2 3)))) 21 | (is (.equals (Integer.fromString "10") (goog.math.Integer.fromString "10")))) 22 | -------------------------------------------------------------------------------- /src/test/cljs/data_readers_test/core.cljc: -------------------------------------------------------------------------------- 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 data-readers-test.core) 10 | 11 | (def custom-identity identity) 12 | 13 | (assert (= 1 #test/custom-identity 1)) 14 | 15 | (defn custom-form-cljs 16 | "a clojure and clojurescript function - in both cases targeting only cljs. 17 | 18 | returns a clojurescript form (from :clj branch, when compiling) 19 | and executes js from :cljs branch when using cljs.reader/read" 20 | [x] 21 | #?(:clj `(js/Array.of ~x) 22 | :cljs (js/Array.of x))) 23 | 24 | #?(:cljs 25 | (def result #test/custom-form"foo")) 26 | -------------------------------------------------------------------------------- /src/test/cljs_build/code-split/src/code/split/a.cljs: -------------------------------------------------------------------------------- 1 | (ns code.split.a 2 | (:require [cljs.loader :as loader] 3 | [clojure.pprint :refer [pprint]] 4 | [goog.dom :as gdom] 5 | [goog.events :as events]) 6 | (:import [goog.debug Console] 7 | [goog.events EventType])) 8 | 9 | (def loader 10 | "The module loader." 11 | (.getLoader loader/*module-manager*)) 12 | 13 | ;; Enable logging, to see debug messages. 14 | (.setCapturing (Console.) true) 15 | 16 | (defn print-modules [] 17 | (println "Module Infos:") 18 | (pprint loader/module-infos) 19 | (println "Module URIs:") 20 | (pprint loader/module-uris)) 21 | 22 | (events/listen (gdom/getElement "button-b") EventType.CLICK 23 | (fn [e] (loader/load :b #((resolve 'code.split.b/hello))))) 24 | 25 | (events/listen (gdom/getElement "button-c") EventType.CLICK 26 | (fn [e] (loader/load :c #((resolve 'code.split.c/hello))))) 27 | 28 | (enable-console-print!) 29 | (print-modules) 30 | 31 | (loader/set-loaded! :a) 32 | -------------------------------------------------------------------------------- /script/aot_core: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [[ -z "$CLJS_SCRIPT_QUIET" ]]; then 6 | set -x 7 | fi 8 | 9 | FILE_SEP='/' 10 | PATH_SEP=':' 11 | OS_ID=`uname | tr [:upper:] [:lower:]` 12 | CLJS_SCRIPT_MVN_OPTS=${CLJS_SCRIPT_MVN_OPTS:-""} 13 | 14 | if [[ $OS_ID == *mingw* ]] 15 | then 16 | echo "MINGW detected" 17 | # Refer to http://www.mingw.org/wiki/Posix_path_conversion 18 | FILE_SEP='//' 19 | PATH_SEP=';' 20 | fi 21 | 22 | CP_FILE=`mktemp /tmp/cljs_cp.txt.XXXXXXXXXXX` 23 | 24 | mvn -B -f pom.template.xml dependency:build-classpath -Dmdep.outputFile=$CP_FILE -Dmdep.fileSeparator=$FILE_SEP -Dmdep.pathSeparator=$PATH_SEP $CLJS_SCRIPT_MVN_OPTS 25 | 26 | CLJS_CP=`cat $CP_FILE` 27 | 28 | # For Hudson server 29 | if [ "$HUDSON" = "true" ]; then 30 | $JAVA_HOME/bin/java -server -cp "$CLJS_CP""$PATH_SEP""src/main/clojure""$PATH_SEP""src/main/cljs" clojure.main script/aot.clj 31 | else 32 | java -server -cp "$CLJS_CP""$PATH_SEP""src/main/clojure""$PATH_SEP""src/main/cljs" clojure.main script/aot.clj 33 | fi 34 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/letfn_test.cljs: -------------------------------------------------------------------------------- 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 cljs.letfn-test 10 | (:require [cljs.test :refer-macros [deftest is]])) 11 | 12 | (deftest test-letfn 13 | (letfn [(ev? [x] 14 | (if (zero? x) 15 | true 16 | (od? (dec x)))) 17 | (od? [x] 18 | (if (zero? x) 19 | false 20 | (ev? (dec x))))] 21 | (is (ev? 0)) 22 | (is (ev? 10)) 23 | (is (not (ev? 1))) 24 | (is (not (ev? 11))) 25 | (is (not (od? 0))) 26 | (is (not (od? 10))) 27 | (is (od? 1)) 28 | (is (od? 11)))) 29 | -------------------------------------------------------------------------------- /src/assembly/aot.xml: -------------------------------------------------------------------------------- 1 | 2 | aot 3 | 4 | jar 5 | 6 | false 7 | 8 | 9 | target/classes 10 | / 11 | 12 | 19 | 20 | 21 | 22 | 23 | pom.xml 24 | META-INF/maven/org.clojure/clojurescript 25 | 26 | 27 | target/maven-archiver/pom.properties 28 | META-INF/maven/org.clojure/clojurescript 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/test/cljs/reactJS.js: -------------------------------------------------------------------------------- 1 | (function(f){ 2 | if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()} 3 | else if(typeof define==="function"&&define.amd){define([],f)} 4 | else{var g;if(typeof window!=="undefined"){g=window} 5 | else if(typeof global!=="undefined"){g=global} 6 | else if(typeof self!=="undefined"){g=self} 7 | else{g=this}g.React = f()} 8 | })(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oFoo3125 5))))) 26 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/source_map/base64.cljs: -------------------------------------------------------------------------------- 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 cljs.source-map.base64) 10 | 11 | (def chars64 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") 12 | (def char->int (zipmap chars64 (range 0 64))) 13 | (def int->char (zipmap (range 0 64) chars64)) 14 | 15 | (defn encode [n] 16 | (let [e (find int->char n)] 17 | (if e 18 | (second e) 19 | (throw (js/Error. (str "Must be between 0 and 63: " n)))))) 20 | 21 | (defn decode [c] 22 | (let [e (find char->int c)] 23 | (if e 24 | (second e) 25 | (throw (js/Error. (str "Not a valid base 64 digit: " c)))))) 26 | -------------------------------------------------------------------------------- /src/main/cljs/clojure/core/protocols.cljs: -------------------------------------------------------------------------------- 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 clojure.core.protocols) 10 | 11 | (defprotocol Datafiable 12 | :extend-via-metadata true 13 | (datafy [o] "return a representation of o as data (default identity)")) 14 | 15 | (extend-protocol Datafiable 16 | nil 17 | (datafy [_] nil) 18 | 19 | default 20 | (datafy [o] o)) 21 | 22 | (defprotocol Navigable 23 | :extend-via-metadata true 24 | (nav [coll k v] "return (possibly transformed) v in the context of coll and k (a key/index or nil), 25 | defaults to returning v.")) 26 | 27 | (extend-protocol Navigable 28 | default 29 | (nav [_ _ x] x)) 30 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/nodejscli.cljs: -------------------------------------------------------------------------------- 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 | ; Projects compiled with :target :nodejs have this file appended. Its 10 | ; job is to make sure cljs.nodejs is loaded and that the *main-cli-fn* 11 | ; is called with the script's command-line arguments. 12 | (ns cljs.nodejscli 13 | (:require [cljs.nodejs :as nodejs] 14 | [goog.object :as gobj])) 15 | 16 | ;; need to set goog.global if COMPILED 17 | (when ^boolean js/COMPILED 18 | (set! goog/global js/global)) 19 | 20 | ;; Call the user's main function 21 | (when (fn? cljs.core/*main-cli-fn*) 22 | (apply cljs.core/*main-cli-fn* (drop 2 (gobj/get js/process "argv")))) 23 | -------------------------------------------------------------------------------- /src/test/cljs/react-min.js: -------------------------------------------------------------------------------- 1 | // React minified. 2 | (function(f){ 3 | if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()} 4 | else if(typeof define==="function"&&define.amd){define([],f)} 5 | else{var g;if(typeof window!=="undefined"){g=window} 6 | else if(typeof global!=="undefined"){g=global} 7 | else if(typeof self!=="undefined"){g=self} 8 | else{g=this}g.React = f()} 9 | })(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Browser-connected REPL 12 | 13 | 14 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/clojure/cljs/profile.clj: -------------------------------------------------------------------------------- 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 cljs.profile 10 | (:require [clojure.java.io :as io] 11 | [cljs.env :as env] 12 | [cljs.analyzer :as ana] 13 | [cljs.compiler :as comp])) 14 | 15 | (comment 16 | 17 | ;; ~900ms 18 | (dotimes [_ 20] 19 | (time 20 | (ana/analyze-file (io/resource "cljs/core.cljs")))) 21 | 22 | ;; ~2700ms 23 | ;; after change ~2500 24 | (dotimes [_ 20] 25 | (time 26 | (env/with-compiler-env (env/default-compiler-env) 27 | (comp/compile-file (.getPath (io/resource "cljs/core.cljs"))) 28 | (.delete (io/file "src/main/cljs/cljs/core.js"))))) 29 | 30 | ) -------------------------------------------------------------------------------- /src/main/cljs/cljs/proxy/impl.cljs: -------------------------------------------------------------------------------- 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 cljs.proxy.impl) 10 | 11 | (deftype SimpleCache [^:mutable obj ^:mutable cnt] 12 | Object 13 | (set [this k v] 14 | (when (== cnt 1024) 15 | (.clear this)) 16 | (unchecked-set obj k v) 17 | (set! cnt (inc cnt)) 18 | v) 19 | (get [this k] 20 | (unchecked-get obj k)) 21 | (clear [this] 22 | (set! obj #js {}) 23 | (set! cnt 0))) 24 | 25 | (deftype MapIterator [^:mutable iter f] 26 | Object 27 | (next [_] 28 | (let [x (.next iter)] 29 | (if-not ^boolean (. x -done) 30 | #js {:value (f (. x -value)) 31 | :done false} 32 | x)))) 33 | -------------------------------------------------------------------------------- /samples/dom/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | DOM testing 12 | 13 | 14 | 17 | 18 | 19 | 20 |
21 |
    22 | 23 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /samples/hello/README.md: -------------------------------------------------------------------------------- 1 | *NOTE: this sample is now out of date. Please refer to the Quick Start* 2 | 3 | Simple ClojureScript Project Example. 4 | 5 | One-time Setup 6 | ============== 7 | 8 | - Create a CLOJURESCRIPT_HOME environment variable which points to the 9 | ClojureScript root directory. 10 | 11 | - If you have not already done so, execute 12 | 13 | $CLOJURESCRIPT_HOME/script/bootstrap 14 | 15 | - Add $CLOJURESCRIPT_HOME/bin to your PATH. 16 | 17 | Run in Development Mode 18 | ======================= 19 | 20 | Development mode allows for each file to be loaded in a separate script tag so 21 | that errors can be easily tracked to the offending file. 22 | 23 | cljsc src > hello.js 24 | 25 | After running the above command, open hello-dev.html. Notice that each required 26 | JavaScript file has been loaded in its most readable form. 27 | 28 | Run Optimized JavaScript 29 | ======================== 30 | 31 | Once an application is ready for production, a single optimized file can be produced. 32 | 33 | cljsc src {:optimizations :advanced} > hello.js 34 | 35 | After running the above command, open hello.html to view the result. 36 | 37 | -------------------------------------------------------------------------------- /devnotes/day2.org: -------------------------------------------------------------------------------- 1 | * ClojureScript Day #2 2 | * Welcome Thortech! 3 | ** Eric, Frank and Tom 4 | *** Long time cohorts 5 | * Tips 6 | ** Don't define things in terms of undefined things 7 | *** someone else will just trip over later 8 | ** Test 9 | *** nil 10 | ** Encapsulate use of -methods in a single place 11 | ** Where's the global namespace? 12 | * Where are we at 13 | * Where are we going 14 | ** [[file:corelib.org][Core lib punchlist]] 15 | ** [[file:~/dev/clojurescript/todo.org][To do]] 16 | ** [[https://github.com/relevance/clojurescript/issues][Tickets]] 17 | * Release 1 18 | ** Make goog-compatible libs work 19 | ** Data structures 20 | *** work but are not optimal for large instances 21 | *** persistent guarantees 22 | ** seq library 23 | ** associative library 24 | ** indexed library 25 | ** atoms 26 | ** binding 27 | ** great tooling 28 | *** push button 29 | ** reader? 30 | *** print-read 31 | ** regex 32 | * Release 2 33 | ** DOM manipulation 34 | ** Can I use jQuery? 35 | ** bitops 36 | ** multimethods 37 | ** hierarchy 38 | ** reader + record support 39 | ** unchecked 40 | ** bitops 41 | ** print 42 | ** eventing value add 43 | ** DOM value add 44 | ** UI value add 45 | -------------------------------------------------------------------------------- /src/test/clojure/cljs/js_deps_tests.clj: -------------------------------------------------------------------------------- 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 cljs.js-deps-tests 10 | (:require [cljs.js-deps :as js-deps] 11 | [clojure.java.io :as io] 12 | [clojure.test :refer [deftest is run-tests]])) 13 | 14 | (deftest test-parse-js-ns-returns-require-types 15 | (let [ns-info (js-deps/parse-js-ns 16 | (line-seq (io/reader (io/resource "goog/events/eventhandler.js"))))] 17 | (is (true? (contains? ns-info :require-types))))) 18 | 19 | (deftest test-js-dependency-index-has-require-types 20 | (let [deps (js-deps/build-index (js-deps/goog-dependencies*)) 21 | ns-info (get deps "goog.events.EventHandler")] 22 | (is (true? (contains? ns-info :require-types))))) 23 | -------------------------------------------------------------------------------- /src/test/clojure/cljs/transpile_tests.clj: -------------------------------------------------------------------------------- 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 cljs.transpile-tests 10 | (:require [cljs.closure :as closure :refer [closure-transpile]] 11 | [clojure.java.io :as io] 12 | [clojure.test :refer [deftest is run-tests]])) 13 | 14 | (deftest test-transpile-lang-in-lang-out 15 | (let [source (closure-transpile 16 | (io/resource "goog/async/throttle.js") 17 | {:language-in :es6 :language-out :es6})] 18 | (is (nil? (re-find #"jscomp" source)))) 19 | (let [source (closure-transpile 20 | (io/resource "goog/async/throttle.js") 21 | {:language-in :es6 :language-out :es5})] 22 | (is (some? (re-find #"jscomp" source))))) 23 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/hash_set_test.cljs: -------------------------------------------------------------------------------- 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 cljs.hash-set-test 10 | (:refer-clojure :exclude [iter]) 11 | (:require [cljs.test :refer-macros [deftest testing is]])) 12 | 13 | (deftest test-hash-set-with-duplicate-keys 14 | (testing "Testing duplicate keys in array maps" 15 | ;; runtime 16 | (is (= [:foo] (keys (apply array-map [:foo :foo])))) 17 | (let [sym-a (with-meta 'foo :first) 18 | sym-b (with-meta 'foo :second)] 19 | (is (= #{sym-a} (apply hash-set [sym-a sym-b])))) 20 | ;; compile-time 21 | (is (= {:foo 2} (hash-set :foo :foo))) 22 | (let [sym-a (with-meta 'foo :first) 23 | sym-b (with-meta 'foo :second)] 24 | (is (= #{sym-a} (hash-set sym-a sym-b)))))) 25 | -------------------------------------------------------------------------------- /samples/twitterbuzz/reset.css: -------------------------------------------------------------------------------- 1 | /* Eric Meyer's Reset Reloaded */ 2 | html, body, div, span, applet, object, iframe, 3 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 4 | a, abbr, acronym, address, big, cite, code, 5 | del, dfn, em, font, img, ins, kbd, q, s, samp, 6 | small, strike, strong, sub, sup, tt, var, 7 | dl, dt, dd, ol, ul, li, 8 | fieldset, form, label, legend, 9 | table, caption, tbody, tfoot, thead, tr, th, td { 10 | margin: 0; 11 | padding: 0; 12 | border: 0; 13 | outline: 0; 14 | font-weight: inherit; 15 | font-style: inherit; 16 | font-size: 100%; 17 | font-family: inherit; 18 | vertical-align: baseline; 19 | } 20 | /* remember to define focus styles! */ 21 | :focus { 22 | outline: 0; 23 | } 24 | body { 25 | line-height: 1; 26 | color: black; 27 | background: white; 28 | } 29 | ol, ul { 30 | list-style: none; 31 | } 32 | /* tables still need 'cellspacing="0"' in the markup */ 33 | table { 34 | border-collapse: separate; 35 | border-spacing: 0; 36 | } 37 | caption, th, td { 38 | text-align: left; 39 | font-weight: normal; 40 | } 41 | blockquote:before, blockquote:after, 42 | q:before, q:after { 43 | content: ""; 44 | } 45 | blockquote, q { 46 | quotes: "" ""; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/analyzer/passes.cljc: -------------------------------------------------------------------------------- 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 cljs.analyzer.passes) 10 | 11 | (defn apply-passes 12 | ([ast passes] 13 | (apply-passes ast passes nil)) 14 | ([ast passes opts] 15 | (reduce 16 | (fn [ast pass] 17 | (pass (:env ast) ast opts)) 18 | ast passes))) 19 | 20 | (defn walk 21 | ([ast passes] 22 | (walk ast passes nil)) 23 | ([ast passes opts] 24 | (reduce 25 | (fn [ast child-k] 26 | (assoc ast 27 | child-k 28 | (let [child (get ast child-k)] 29 | (if (vector? child) 30 | (into [] (map #(walk % passes opts)) child) 31 | (walk child passes opts))))) 32 | (some-> ast (apply-passes passes opts)) (:children ast)))) 33 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/analyzer/passes/lite.cljc: -------------------------------------------------------------------------------- 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 cljs.analyzer.passes.lite 10 | (:refer-clojure :exclude [var?])) 11 | 12 | (defn var? [ast] 13 | (= :var (:op ast))) 14 | 15 | (def ctor->ctor-lite 16 | '{cljs.core/vector cljs.core/vector-lite 17 | cljs.core/vec cljs.core/vec-lite}) 18 | 19 | (defn update-var [{:keys [name] :as ast}] 20 | (let [replacement (get ctor->ctor-lite name)] 21 | (-> ast 22 | (assoc :name replacement) 23 | (assoc-in [:info :name] replacement)))) 24 | 25 | (defn replace-var? [ast] 26 | (and (var? ast) 27 | (contains? ctor->ctor-lite (:name ast)))) 28 | 29 | (defn use-lite-types 30 | [env ast _] 31 | (cond-> ast 32 | (replace-var? ast) update-var)) 33 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/clojure_alias_test.cljs: -------------------------------------------------------------------------------- 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 cljs.clojure-alias-test 10 | "Tests requiring via `clojure.*` instead of `cljs.*`" 11 | (:refer-clojure :exclude [use-macros]) 12 | (:require-macros clojure.spec.gen.alpha) 13 | ;(:use-macros [clojure.analyzer.macros :only [no-warn]]) 14 | (:require [clojure.test :refer [deftest is] :rename {is is?}] 15 | [clojure.spec.alpha :as s :refer [spec? spec] :rename {spec foo}])) 16 | 17 | (deftest normal-test 18 | (is? (= 1 1))) 19 | 20 | (deftest aliases-test 21 | (is? (= spec? clojure.spec.alpha/spec? cljs.spec.alpha/spec?)) 22 | (is? (foo number?))) 23 | 24 | (deftest use-macros 25 | (s/def ::even? (s/and number? even?)) 26 | (is? (s/valid? ::even? 2))) 27 | -------------------------------------------------------------------------------- /bin/cljsc.clj: -------------------------------------------------------------------------------- 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 | (require '[cljs.closure :as closure]) 10 | 11 | (defn transform-cl-args 12 | [args] 13 | (let [source (first args) 14 | opts-string (apply str (interpose " " (rest args))) 15 | options (when (> (count opts-string) 1) 16 | (try (read-string opts-string) 17 | (catch Exception e 18 | (binding [*out* *err*] 19 | (println "Failed to parse command line args:" e)))))] 20 | {:source source :options (merge {:output-to :print} options)})) 21 | 22 | (let [args (transform-cl-args *command-line-args*)] 23 | (closure/build (:source args) (:options args)) 24 | (.flush *out*) 25 | (shutdown-agents) 26 | (System/exit 0)) 27 | -------------------------------------------------------------------------------- /src/main/cljs/cljs/nodejs.cljs: -------------------------------------------------------------------------------- 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 | ; Projects compiled with :target :nodejs can 'require' this namespace 10 | ; to get the nodejs globals loaded into cljs.nodejs and get 11 | ; ClojureScript's 'print' set up correctly. 12 | (ns cljs.nodejs 13 | (:refer-clojure :exclude [require])) 14 | 15 | ; Define namespaced references to Node's externed globals: 16 | (def require (js* "require")) 17 | (def process (js* "process")) 18 | 19 | (defn enable-util-print! [] 20 | (set! *print-newline* false) 21 | (set-print-fn! 22 | (fn [& args] 23 | (.apply (.-log js/console) js/console (into-array args)))) 24 | (set-print-err-fn! 25 | (fn [& args] 26 | (.apply (.-error js/console) js/console (into-array args)))) 27 | nil) 28 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/proxy_test.cljs: -------------------------------------------------------------------------------- 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 cljs.proxy-test 10 | (:refer-global :only [Object]) 11 | (:require [cljs.test :as test :refer-macros [deftest testing is are]] 12 | [cljs.proxy :refer [builder]] 13 | [goog.object :as gobj])) 14 | 15 | (def proxy (builder)) 16 | 17 | (deftest map-proxy 18 | (let [proxied (proxy {:foo 1 :bar 2})] 19 | (is (== 1 (gobj/get proxied "foo"))) 20 | (is (== 2 (gobj/get proxied "bar"))) 21 | (is (= #{"foo" "bar"} (into #{} (Object/keys proxied)))))) 22 | 23 | (deftest vector-proxy 24 | (let [proxied (proxy [1 2 3 4])] 25 | (is (== 4 (alength proxied))) 26 | (is (== 1 (aget proxied 0))) 27 | (is (== 4 (aget proxied 3))))) 28 | 29 | (comment 30 | 31 | (test/run-tests) 32 | 33 | ) 34 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/inference_util.clj: -------------------------------------------------------------------------------- 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 cljs.inference-util) 10 | 11 | (defmacro truth_-called? 12 | "Returns whether cljs.core/truth_ is called when evaluating a form as the 13 | test of an if." 14 | [form] 15 | `(let [called?# (volatile! false)] 16 | (with-redefs [cljs.core/truth_ (fn [x#] 17 | (vreset! called?# true) 18 | (cljs.core/truth_ x#))] 19 | (if ~form 1 2)) 20 | @called?#)) 21 | 22 | (defmacro truth_-not-called? 23 | "Returns whether cljs.core/truth_ is not called when evaluating ecah of 24 | forms as the test of an if." 25 | [& forms] 26 | `(do 27 | ~@(map (fn [form] 28 | `(cljs.test/is (not (truth_-called? ~form)))) 29 | forms))) 30 | -------------------------------------------------------------------------------- /src/test/clojure/cljs/instant_tests.clj: -------------------------------------------------------------------------------- 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 cljs.instant-tests 10 | (:require 11 | [cljs.instant :as inst] 12 | [clojure.test :refer [deftest is]])) 13 | 14 | (deftest read-instant-instant-test 15 | ;; Clojure uses hybrid Julian / Gregorian, while Instant is proleptic Gregorian 16 | (is (not= #inst "1500" (inst/read-instant-instant "1500"))) 17 | (is (not= (inst-ms #inst "1500") (inst-ms (inst/read-instant-instant "1500")))) 18 | (is (= -14831769600000 (inst-ms (inst/read-instant-instant "1500")))) 19 | (is (= "#inst \"1500-01-01T00:00:00.123456789-00:00\"" 20 | (pr-str (inst/read-instant-instant "1500-01-01T00:00:00.123456789-00:00")))) 21 | (is (= "#inst \"2020-01-01T05:00:00.000000000-00:00\"" 22 | (pr-str (inst/read-instant-instant "2020-01-01T00:00:00.000-05:00"))))) 23 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/chunked_seq.cljs: -------------------------------------------------------------------------------- 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 cljs.chunked-seq 10 | (:refer-clojure :exclude [iter]) 11 | (:require [cljs.test :refer-macros [deftest testing is are]])) 12 | 13 | (deftest test-cljs-2693 14 | (is (chunked-seq? (range 5))) 15 | (is (satisfies? IChunk (chunk-first (range 5)))) 16 | (is (nil? (chunk-next (range 32)))) 17 | (is (not (chunked-seq? (range 2 -2 0)))) 18 | (is (chunked-seq? (range))) 19 | (is (= 5 (count (chunk-first (range 5))))) 20 | (is (= 32 (count (chunk-first (range))))) 21 | (is (= 17 (nth (chunk-first (range 100)) 17))) 22 | (is (= 35 (nth (chunk-first (range 100)) 35))) 23 | (is (= 32 (count (chunk-first (range 100))))) 24 | (is (= 0 (first (range 5)))) 25 | (is (= 1 (second (range 5)))) 26 | (is (= (range 1 5) (rest (range 5)))) 27 | (is (= (range 1 5) (next (range 5))))) -------------------------------------------------------------------------------- /src/test/cljs/cljs/set_equiv_test.cljs: -------------------------------------------------------------------------------- 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 cljs.set-equiv-test 10 | (:refer-clojure :exclude [iter]) 11 | (:require [cljs.test :refer-macros [deftest testing is]] 12 | [clojure.string :as s] 13 | [clojure.set :as set])) 14 | 15 | (deftest test-set-equality 16 | (testing "Testing set equality" 17 | (is (= (sorted-set 3 2 1) (sorted-set 1 2 3))) 18 | (is (= (hash-set 3 2 1) (sorted-set 1 2 3))) 19 | (is (= (sorted-set :a :b :c) (hash-set :a :b :c))) 20 | (is (= (hash-set :a :b :c) (hash-set :a :b :c)))) 21 | 22 | (testing "CLJS-2731 uncomparable values" 23 | (is (not= (sorted-set 3 2 1) (sorted-set :a :b :c))) 24 | (is (not= (hash-set 3 2 1) (sorted-set :a :b :c))) 25 | (is (not= (sorted-set 3 2 1) (hash-set :a :b :c))) 26 | (is (not= (hash-set 3 2 1) (hash-set :a :b :c))))) 27 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release on demand 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | deploy: 7 | description: "Deploy to Maven Central" 8 | required: true 9 | default: false 10 | type: boolean 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Check out 17 | uses: actions/checkout@v3 18 | with: 19 | fetch-depth: 0 20 | - name: Set Github identity 21 | run: | 22 | git config --global user.name clojure-build 23 | git config --global user.email "clojure-build@users.noreply.github.com" 24 | - name: Set up Java 25 | uses: actions/setup-java@v3 26 | with: 27 | java-version: 21 28 | distribution: 'temurin' 29 | cache: 'maven' 30 | server-id: central 31 | server-username: MAVEN_USERNAME 32 | server-password: MAVEN_PASSWORD 33 | gpg-private-key: ${{ secrets.CENTRAL_GPG_SECRET_KEY }} 34 | gpg-passphrase: GPG_PASSPHRASE 35 | - name: Release 36 | run: script/build 37 | env: 38 | HUDSON: ${{ github.event.inputs.deploy }} 39 | MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }} 40 | MAVEN_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} 41 | GPG_PASSPHRASE: ${{ secrets.CENTRAL_GPG_SECRET_KEY_PASSWORD }} 42 | -------------------------------------------------------------------------------- /src/main/clojure/cljs/analyzer/utils.clj: -------------------------------------------------------------------------------- 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 cljs.analyzer.utils 10 | (:require [cljs.analyzer :as ana])) 11 | 12 | (defn simplify-env [_ {:keys [op] :as ast}] 13 | (let [env (:env ast) 14 | ast (if (= op :fn) 15 | (assoc ast :methods 16 | (mapv #(simplify-env nil %) (:methods ast))) 17 | ast)] 18 | (assoc (dissoc ast :env) 19 | :env {:context (:context env)}))) 20 | 21 | (defn elide-children [_ ast] 22 | (dissoc ast :children)) 23 | 24 | (defn to-ast 25 | ([form] (to-ast 'cljs.user form)) 26 | ([ns form] 27 | (let [env (assoc-in (ana/empty-env) [:ns :name] ns)] 28 | (binding [ana/*passes* 29 | (or ana/*passes* 30 | [elide-children simplify-env ana/infer-type])] 31 | (ana/analyze env form))))) 32 | 33 | (comment 34 | (require '[clojure.pprint :as pp]) 35 | (pp/pprint (to-ast '(defn foo [a b] (+ a b)))) 36 | ) 37 | -------------------------------------------------------------------------------- /src/main/clojure/cljs/source_map/base64.clj: -------------------------------------------------------------------------------- 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 cljs.source-map.base64) 10 | 11 | (def chars64 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") 12 | (def char->int (zipmap chars64 (range 0 64))) 13 | (def int->char (zipmap (range 0 64) chars64)) 14 | 15 | (defn encode [^long n] 16 | (case n 17 | 0 \A 1 \B 2 \C 3 \D 4 \E 5 \F 6 \G 7 \H 8 \I 9 \J 10 \K 11 \L 12 \M 18 | 13 \N 14 \O 15 \P 16 \Q 17 \R 18 \S 19 \T 20 \U 21 \V 22 \W 23 \X 24 \Y 25 \Z 19 | 26 \a 27 \b 28 \c 29 \d 30 \e 31 \f 32 \g 33 \h 34 \i 35 \j 36 \k 37 \l 38 \m 20 | 39 \n 40 \o 41 \p 42 \q 43 \r 44 \s 45 \t 46 \u 47 \v 48 \w 49 \x 50 \y 51 \z 21 | 52 \0 53 \1 54 \2 55 \3 56 \4 57 \5 58 \6 59 \7 60 \8 61 \9 62 \+ 63 \/ 22 | (throw (Error. (str "Must be between 0 and 63: " n))))) 23 | 24 | (defn ^Character decode [c] 25 | (let [e (find char->int c)] 26 | (if e 27 | (second e) 28 | (throw (Error. (str "Not a valid base 64 digit: " c)))))) -------------------------------------------------------------------------------- /src/test/cljs/data_readers_test/records.cljc: -------------------------------------------------------------------------------- 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 data-readers-test.records 10 | #?(:cljs (:require-macros [data-readers-test.records]))) 11 | 12 | (defrecord Foo [a b]) 13 | 14 | (assert (= (Foo. 1 2) #data_readers_test.records.Foo{:a 1 :b 2})) 15 | (assert (= (Foo. 1 2) 16 | '#data_readers_test.records.Foo{:a 1 :b 2})) 17 | (assert (= (Foo. 1 2) 18 | (second ''#data_readers_test.records.Foo{:a 1 :b 2}))) 19 | (assert (= (Foo. 'a 'b) 20 | (let [a 1 21 | b 2] 22 | #data_readers_test.records.Foo{:a a :b b})) 23 | (pr-str 24 | (let [a 1 25 | b 2] 26 | #data_readers_test.records.Foo{:a a :b b}))) 27 | (assert (= (Foo. 'a 'b) 28 | (let [a 1 29 | b 2] 30 | '#data_readers_test.records.Foo{:a a :b b})) 31 | (pr-str 32 | (let [a 1 33 | b 2] 34 | '#data_readers_test.records.Foo{:a a :b b}))) 35 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/invoke_test.cljs: -------------------------------------------------------------------------------- 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 cljs.invoke-test 10 | (:require [goog.string :as gstr])) 11 | 12 | (defn variadic-fn [& args]) 13 | 14 | (variadic-fn 1 2 3) 15 | 16 | (defn multi-fn 17 | ([a] a) 18 | ([a b] a)) 19 | 20 | (defn hof-fn-expr-should-be-bound 21 | [funexpr0 normal-arg] 22 | ((complement funexpr0) normal-arg)) 23 | 24 | (defn hof-arg-should-be-bound 25 | [hofinvoke inv-arg0] 26 | (hofinvoke (inv-arg0))) 27 | 28 | (defn hof-fn-expr+args-should-be-bound 29 | [funexpr1 inv-arg1] 30 | ((complement funexpr1) (inv-arg1))) 31 | 32 | ;; A keyword should not be bound in a let: 33 | (def foo (delay 34 | (:dont-bind-this js/x))) 35 | 36 | (multi-fn 2) 37 | 38 | (gstr/urlEncode "foo") 39 | 40 | (js/goog.string.urlDecode "bar") 41 | 42 | (declare ^{:arglists '([a b])} declared-fn) 43 | 44 | (declared-fn 1 2) 45 | 46 | (defrecord Foo [foo-field-a foo-field-b]) 47 | 48 | (def foo-record (->Foo 1 2)) 49 | 50 | (:foo-field-a foo-record) 51 | -------------------------------------------------------------------------------- /src/test/cljs/clojure/edn_test.cljs: -------------------------------------------------------------------------------- 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 clojure.edn-test 10 | (:require [cljs.test :refer-macros [deftest is testing]] 11 | [clojure.edn :as edn] 12 | [cljs.reader :as reader] 13 | [cljs.tools.reader.reader-types :as reader-types])) 14 | 15 | (defn- test-reader [] 16 | (reader-types/string-push-back-reader "[1 2 3]")) 17 | 18 | (deftest test-read 19 | (testing "Mirrors cljs.reader/read" 20 | (is (= (edn/read (test-reader)) 21 | (reader/read (test-reader)))) 22 | (is (= (edn/read {} (test-reader)) 23 | (reader/read {} (test-reader)))) 24 | (is (= (edn/read (test-reader) false "EOF" {}) 25 | (reader/read (test-reader) false "EOF" {}))))) 26 | 27 | (deftest test-read-string 28 | (testing "Mirrors cljs.reader/read-string" 29 | (is (= (edn/read-string "(+ 1 2)") 30 | (reader/read-string "(+ 1 2)"))) 31 | (is (= (edn/read-string "{:a #{[1]}}") 32 | (reader/read-string "{:a #{[1]}}"))))) 33 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/pprint_test.clj: -------------------------------------------------------------------------------- 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 cljs.pprint-test 10 | (:require cljs.test)) 11 | 12 | (defmacro simple-tests [name & test-pairs] 13 | `(cljs.test/deftest ~name 14 | ~@(for [[x y] (partition 2 test-pairs)] 15 | `(cond 16 | (cljs.core/regexp? ~y) (cljs.test/is (.exec ~y ~x)) 17 | (cljs.core/string? ~y) (cljs.test/is (= ~x ~y)) 18 | :else (cljs.test/is (= ~x ~y)))))) 19 | 20 | (defmacro code-block 21 | "Read a string then print it with code-dispatch and succeed if it comes out the same" 22 | [test-name & blocks] 23 | `(simple-tests ~test-name 24 | ~@(apply concat 25 | (for [block blocks] 26 | `[(clojure.string/split-lines 27 | (with-out-str 28 | (cljs.pprint/with-pprint-dispatch cljs.pprint/code-dispatch 29 | (cljs.pprint/pprint (cljs.reader/read-string ~block))))) 30 | (clojure.string/split-lines ~block)])))) 31 | -------------------------------------------------------------------------------- /src/main/clojure/cljs/analyzer/impl.cljc: -------------------------------------------------------------------------------- 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 cljs.analyzer.impl) 10 | 11 | (def ANY_SYM 'any) 12 | 13 | (def BOOLEAN_OR_SEQ '#{boolean seq}) 14 | 15 | (def BOOLEAN_SYM 'boolean) 16 | 17 | #?(:cljs 18 | (def CLJ_NIL_SYM 'clj-nil)) 19 | 20 | #?(:cljs 21 | (def CLJS_CORE_MACROS_SYM 'cljs.core$macros)) 22 | 23 | #?(:cljs 24 | (def CLJS_CORE_SYM 'cljs.core)) 25 | 26 | #?(:cljs 27 | (def DOT_SYM '.)) 28 | 29 | (def IGNORE_SYM 'ignore) 30 | 31 | #?(:cljs 32 | (def JS_STAR_SYM 'js*)) 33 | 34 | #?(:cljs 35 | (def NEW_SYM 'new)) 36 | 37 | (def NOT_NATIVE '#{clj not-native}) 38 | 39 | #?(:cljs 40 | (def NUMBER_SYM 'number)) 41 | 42 | #?(:cljs 43 | (def STRING_SYM 'string)) 44 | 45 | #?(:cljs 46 | (defn ^boolean cljs-map? [x] 47 | (implements? IMap x))) 48 | 49 | #?(:cljs 50 | (defn ^boolean cljs-seq? [x] 51 | (implements? ISeq x))) 52 | 53 | #?(:cljs 54 | (defn ^boolean cljs-vector? [x] 55 | (implements? IVector x))) 56 | 57 | #?(:cljs 58 | (defn ^boolean cljs-set? [x] 59 | (implements? ISet x))) 60 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/macro_test.cljs: -------------------------------------------------------------------------------- 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 cljs.macro-test 10 | (:refer-clojure :exclude [==]) 11 | (:require [cljs.test :as test :refer-macros [deftest is]]) 12 | (:use-macros [cljs.macro-test.macros :only [== sm-cljs-3027]]) 13 | (:require-macros [cljs.macro-test.cljs2852] 14 | [single-seg-macros])) 15 | 16 | (deftest test-macros 17 | (is (= (== 1 1) 2))) 18 | 19 | (deftest macroexpansion 20 | (is (= 1 (macroexpand-1 '1))) 21 | (is (= '(if true (do 1)) (macroexpand-1 '(when true 1)))) 22 | (is (= 1 (macroexpand '1))) 23 | (is (= '(if true (do 1)) (macroexpand '(when true 1))))) 24 | 25 | (deftest test-cljs-2283 26 | (is (= ":a" (first (js-keys (js-obj :a 1)))))) 27 | 28 | (deftest test-cljs-2852 29 | (is (= '([x])) (cljs.macro-test.cljs2852/beta)) 30 | (is (= '([x] [x y])) (cljs.macro-test.cljs2852/delta)) 31 | (is (= '([x] [x & xs])) (cljs.macro-test.cljs2852/zeta))) 32 | 33 | (deftest test-cljs-3027 34 | (is (= {"a" "b"} (sm-cljs-3027)))) 35 | 36 | (deftest test-cljs-3413 37 | (is (= 5 (single-seg-macros/test-macro 2 3)))) 38 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/npm_deps_test.cljs: -------------------------------------------------------------------------------- 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 cljs.npm-deps-test 10 | (:refer-clojure :exclude [array vector]) 11 | (:require [cljs.test :refer [deftest is]] 12 | ["lodash/array" :as array :refer [slice] :rename {slice slc}] 13 | [calculator :as vector :refer [add] :rename {add plus}] 14 | [es6_calc] 15 | [es6_default_hello :as es6hello])) 16 | 17 | (def array #js [1 2 3]) 18 | 19 | (def vector [1]) 20 | 21 | (deftest test-module-processing 22 | (is (= (array/nth #js [1 2 3] 1) 2)) 23 | ;; rename works 24 | (is (= (array-seq (slc #js [1 2 3] 1)) [2 3]))) 25 | 26 | (deftest test-global-exports 27 | (is (= (plus 1 2) 3))) 28 | 29 | (deftest test-cljs-2224 30 | ;; array should be correctly resolved in the current NS (shadows module) 31 | (is (= (array-seq array) [1 2 3])) 32 | ;; same should happen with global-exports 33 | (is (= vector [1]))) 34 | 35 | (deftest test-cljs-2286 36 | (is (= 3 (es6_calc/calculator.add 1 2)))) 37 | 38 | (deftest test-cljs-1620 39 | (is (= "Hello, world!" (es6hello/default)))) 40 | -------------------------------------------------------------------------------- /src/main/clojure/cljs/env/macros.clj: -------------------------------------------------------------------------------- 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 cljs.env.macros 10 | (:refer-clojure :exclude [binding ensure])) 11 | 12 | (defmacro with-compiler-env 13 | "Evaluates [body] with [env] bound as the value of the `*compiler*` var in 14 | this namespace." 15 | [env & body] 16 | `(let [env# ~env 17 | env# (cond 18 | (map? env#) (atom env#) 19 | (and (instance? cljs.core/Atom env#) (map? @env#)) env# 20 | :default 21 | (throw 22 | (js/Error. 23 | (str "Compiler environment must be a map or atom containing a map, not " 24 | (type env#)))))] 25 | (cljs.core/binding [cljs.env/*compiler* env#] 26 | ~@body))) 27 | 28 | (defmacro ensure 29 | [& body] 30 | `(let [val# cljs.env/*compiler*] 31 | (when (nil? val#) 32 | (set! cljs.env/*compiler* (cljs.env/default-compiler-env))) 33 | (try 34 | ~@body 35 | (finally 36 | (when (nil? val#) 37 | (set! cljs.env/*compiler* nil)))))) 38 | -------------------------------------------------------------------------------- /src/test/cljs/cljs/eval_test.cljs: -------------------------------------------------------------------------------- 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 cljs.eval-test 10 | (:require [cljs.test :refer [deftest is]])) 11 | 12 | ;;; This test namespace should only be loaded by environments that set up cljs.core/*eval* 13 | 14 | (def addition-list-1 (list + 1 2)) 15 | (def addition-list-2 (list + 1 'a)) 16 | (def addition-list-3 (list (fn [a b] (+ a b)) 1 2)) 17 | (defn square [x] (* x x)) 18 | (defn cube [x] (* x x x)) 19 | 20 | (deftest test-eval 21 | (is (== 1 (eval 1))) 22 | (is (== 3 (eval '(+ 1 2)))) 23 | (is (== 17 (eval '(let [a 10] (+ 3 4 a))))) 24 | (is (= 'a (:name (meta (eval '(def a 3)))))) 25 | (is (== 3 (eval 'a))) 26 | (is (== 3 (eval addition-list-1))) 27 | (is (== 4 (eval addition-list-2))) 28 | (is (== 13 (eval (concat addition-list-1 [10])))) 29 | (is (= 'lucky-number (:name (meta (eval (list 'def 'lucky-number (concat addition-list-1 [20]))))))) 30 | (is (== 23 (eval 'lucky-number))) 31 | (is (== 64 ((eval (list comp square cube)) 2))) 32 | (is (== 5 ((eval (eval +)) 2 3))) 33 | (is (== 3 (eval addition-list-3))) 34 | (is (== 4 (eval (list #'inc 3))))) 35 | -------------------------------------------------------------------------------- /src/test/cljs/clojure/walk_test.cljs: -------------------------------------------------------------------------------- 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 clojure.walk-test 10 | (:require [cljs.test :as test 11 | :refer-macros [deftest is testing]] 12 | [clojure.walk :as w])) 13 | 14 | (defrecord Rec1 [a]) 15 | 16 | (defn inc-leaf [x] 17 | (if (number? x) 18 | (inc x) 19 | x)) 20 | 21 | (deftest test-api 22 | (testing "Test walking" 23 | (is (= [2 {1 "1", :two 2}] (w/postwalk inc-leaf [1 {0 "1", :two 1}]))) 24 | (is (= [(Rec1. 2)] (w/postwalk inc-leaf [(Rec1. 1)]))) 25 | 26 | (is (= (map->Rec1 {:a 1, ":a" 1}) 27 | (w/prewalk #(if (keyword? %) (str %) %) (Rec1. 1))) 28 | "Mirror Clojure behavior"))) 29 | 30 | (deftest test-preserves-meta 31 | (testing "Test preserves meta" 32 | (is (= (-> (w/prewalk identity [1 (with-meta [1 2] {:foo 3})]) 33 | (nth 1) meta) 34 | {:foo 3})) 35 | (is (= (-> (w/postwalk identity [1 (with-meta [1 2] {:foo 3})]) 36 | (nth 1) meta) 37 | {:foo 3})))) 38 | 39 | (deftest test-map-entry 40 | (is (= [:a 2] (clojure.walk/postwalk #(cond-> % (number? %) inc) (->MapEntry :a 1 nil))))) 41 | -------------------------------------------------------------------------------- /samples/dom/src/dom/test.cljs: -------------------------------------------------------------------------------- 1 | (ns dom.test 2 | (:require [clojure.browser.event :as event] 3 | [clojure.browser.dom :as dom])) 4 | 5 | (defn log [& args] 6 | (.log js/console (apply pr-str args))) 7 | 8 | (defn log-obj [obj] 9 | (.log js/console obj)) 10 | 11 | (defn log-listener-count [] 12 | (log "listener count: " (event/total-listener-count))) 13 | 14 | (def source (dom/get-element "source")) 15 | (def destination (dom/get-element "destination")) 16 | 17 | (dom/append source 18 | (dom/element "Testing me ") 19 | (dom/element "out!")) 20 | 21 | (def success-count (atom 0)) 22 | 23 | (log-listener-count) 24 | 25 | (event/listen source 26 | :click 27 | (fn [e] 28 | (let [i (swap! success-count inc) 29 | e (dom/element :li 30 | {:id "testing" 31 | :class "test me out please"} 32 | "It worked!")] 33 | (log-obj e) 34 | (log i) 35 | (dom/append destination 36 | e)))) 37 | 38 | (log-obj (dom/element "Text node")) 39 | (log-obj (dom/element :li)) 40 | (log-obj (dom/element :li {:class "foo"})) 41 | (log-obj (dom/element :li {:class "bar"} "text node")) 42 | (log-obj (dom/element [:ul [:li :li :li]])) 43 | (log-obj (dom/element :ul [:li :li :li])) 44 | (log-obj (dom/element :li {} [:ul {} [:li :li :li]])) 45 | (log-obj (dom/element [:li {:class "baz"} [:li {:class "quux"}]])) 46 | 47 | (log-obj source) 48 | (log-listener-count) -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject org.clojure/clojurescript "0.0-SNAPSHOT" 2 | :description "ClojureScript compiler and core runtime library" 3 | :parent [org.clojure/pom.contrib "1.3.0"] 4 | :url "https://github.com/clojure/clojurescript" 5 | :license {:name "Eclipse Public License" 6 | :url "http://www.eclipse.org/legal/epl-v10.html"} 7 | :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true" "-Xmx512m" "-server"] 8 | :source-paths ["src/main/clojure" "src/main/cljs"] 9 | :resource-paths ["src/main/cljs" "resources"] 10 | :test-paths ["src/test/clojure" "src/test/cljs" "src/test/self" "src/test/cljs_build" "src/test/cljs_cp"] 11 | :dependencies [[org.clojure/clojure "1.10.0"] 12 | [org.clojure/spec.alpha "0.1.143"] 13 | [org.clojure/core.specs.alpha "0.1.24"] 14 | [org.clojure/tools.reader "1.3.6"] 15 | [org.clojure/test.check "1.1.1" :scope "test"] 16 | [com.cognitect/transit-java "1.0.362"] 17 | [org.clojure/google-closure-library "0.0-20250515-f04e4c0e"] 18 | [com.google.javascript/closure-compiler "v20250820"]] 19 | :profiles {:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]} 20 | :uberjar {:aot :all :main cljs.main} 21 | :closure-snapshot {:dependencies [[com.google.javascript/closure-compiler-unshaded "1.0-SNAPSHOT"]]}} 22 | :aliases {"test-all" ["with-profile" "test,1.5:test,1.6" "test"] 23 | "check-all" ["with-profile" "1.5:1.6" "check"]} 24 | :min-lein-version "2.0.0" 25 | :repositories {"sonatype-snapshot" {:url "https://oss.sonatype.org/content/repositories/snapshots"}}) 26 | -------------------------------------------------------------------------------- /src/test/clojure/cljs/compiler/glib_module_test.clj: -------------------------------------------------------------------------------- 1 | (ns cljs.compiler.glib-module-test 2 | (:require [cljs.compiler-tests :as comp-tests] 3 | [cljs.env :as env] 4 | [clojure.test :as test :refer [deftest is testing]])) 5 | 6 | (deftest test-glib-module-compile 7 | (testing "glib modules compiled to Closure Compile expectations" 8 | (let [src (env/with-compiler-env (env/default-compiler-env ) 9 | (comp-tests/compile-form-seq 10 | '[(ns test.foo 11 | (:import [goog.module ModuleLoader])) 12 | (def module-loader (ModuleLoader.))]))] 13 | (is (re-find #"goog\.require\('goog\.module\.ModuleLoader'\)" src)) 14 | (is (re-find #"test\.foo\.goog\$module\$goog\$module\$ModuleLoader = goog\.module\.get\('goog.module.ModuleLoader'\)" src)) 15 | (is (re-find #"test\.foo\.module_loader = \(new test\.foo\.goog\$module\$goog\$module\$ModuleLoader\(\)\)" src))))) 16 | 17 | (deftest cljs-3330-global-goog-object&array 18 | (testing "migration path for goog.module impact on goog.object & goog.array" 19 | (let [src (env/with-compiler-env 20 | (env/default-compiler-env {:global-goog-object&array true}) 21 | (comp-tests/compile-form-seq 22 | '[(ns test.foo 23 | (:require [goog.object :as gobj] 24 | [goog.array :as garray])) 25 | (def module-loader (ModuleLoader.))]))] 26 | (is (re-find #"goog\.require\('goog\.object\'\)" src)) 27 | (is (re-find #"goog\.require\('goog\.array\'\)" src))))) 28 | 29 | (comment 30 | 31 | (test/run-tests) 32 | 33 | ) 34 | -------------------------------------------------------------------------------- /samples/twitterbuzz/README.md: -------------------------------------------------------------------------------- 1 | *NOTE: this sample is now out of date. Please refer to the Quick Start* 2 | 3 | # ClojureScript "TwitterBuzz" Demo 4 | 5 | ## One-time Setup 6 | 7 | See https://github.com/clojure/clojurescript/wiki/Quick-Start 8 | 9 | ## Run in Development Mode 10 | 11 | Compile the demo: 12 | 13 | cljsc src > twitterbuzz.js 14 | 15 | After running the above command, open index.html. 16 | 17 | ## Compile in Development Mode with the REPL (Faster) 18 | 19 | * Run `script/repl` 20 | * To run it from Emacs, `C-x d` and nav to the `clojurescript` directory 21 | * `M-x set-variable inferior-lisp-program` 22 | * Set to `"script/repl"` 23 | * `M-x run-lisp` 24 | 25 | * Once the REPL is running, evaluate: 26 | 27 | (use 'cljs.closure) 28 | (def opts {:output-to "samples/twitterbuzz/twitterbuzz.js" :output-dir "samples/twitterbuzz/out"}) 29 | 30 | (build "samples/twitterbuzz/src" opts) 31 | 32 | The reason we set the `:output-dir` is because the `index.html` script tag is specifically pointing to that directory. 33 | 34 | * See `cljs.closure` source for more compilation examples. 35 | 36 | ## Compile in Advanced Mode 37 | 38 | `cljsc` can be run with a Clojure map of compiler options. To compile using `cljsc` and Closure Compiler's "advanced" optimization setting: 39 | 40 | cljsc src '{:optimizations :advanced}' > twitterbuzz.js 41 | 42 | Because advanced mode results in only one `.js` file, `twitterbuzz.js`, only one `