<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged clojurescript cljsbuild</title>
<link>https://ask.clojure.org/index.php/tag/clojurescript+cljsbuild</link>
<description></description>
<item>
<title>Why can't clojure find react?</title>
<link>https://ask.clojure.org/index.php/11419/why-cant-clojure-find-react</link>
<description>&lt;p&gt;Attempts to build ClojureScript result in an error.&lt;/p&gt;
&lt;p&gt;Here is the cljs file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns gauss-gun-web-2.core
    (:require [reagent.core :as r]) ;; Error goes away if you comment this line out
)

(-&amp;gt; (.getElementById js/document &quot;content&quot;)
    (.-innerHTML)
(set! &quot;Hello, World! This is my first ClojureScript :) &quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is project.clj:&lt;/p&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defproject my-project-name &quot;0.1.0-SNAPSHOT&quot;

    :description &quot;FIXME: write description&quot;
    :url &quot;http://example.com/FIXME&quot;

    :dependencies [[ch.qos.logback/logback-classic &quot;1.2.7&quot;]
                   [clojure.java-time &quot;0.3.3&quot;]
                   [conman &quot;0.9.3&quot;]
                   [cprop &quot;0.1.19&quot;]
                   [expound &quot;0.8.10&quot;]
                   [funcool/struct &quot;1.4.0&quot;]
                   [json-html &quot;0.4.7&quot;]
                   [luminus-http-kit &quot;0.1.9&quot;]
                   [luminus-migrations &quot;0.7.1&quot;]
                   [luminus-transit &quot;0.1.3&quot;]
                   [luminus/ring-ttl-session &quot;0.3.3&quot;]
                   [markdown-clj &quot;1.10.7&quot;]
                   [metosin/muuntaja &quot;0.6.8&quot;]
                   [metosin/reitit &quot;0.5.15&quot;]
                   [metosin/ring-http-response &quot;0.9.3&quot;]
                   [mount &quot;0.1.16&quot;]
                   [nrepl &quot;0.9.0&quot;]
                   [org.clojure/clojure &quot;1.10.3&quot;]
                   [org.clojure/tools.cli &quot;1.0.206&quot;]
                   [org.clojure/tools.logging &quot;1.1.0&quot;]
                   [org.postgresql/postgresql &quot;42.2.23&quot;]
                   [org.webjars.npm/bulma &quot;0.9.3&quot;]
                   [org.webjars.npm/material-icons &quot;1.0.0&quot;]
                   [org.webjars/webjars-locator &quot;0.42&quot;]
                   [ring-webjars &quot;0.2.0&quot;]
                   [ring/ring-core &quot;1.9.4&quot;]
                   [ring/ring-defaults &quot;0.3.3&quot;]
                   [selmer &quot;1.12.45&quot;]
                   [org.clojure/clojurescript &quot;1.10.914&quot; :scope &quot;provided&quot;]
                   [re-frame &quot;1.3.0-rc2&quot;]
                   [reagent &quot;1.1.0&quot;]
                   ;[fork &quot;2.4.2&quot;]
                   ]

    :min-lein-version &quot;2.0.0&quot;

    :source-paths [&quot;src/clj&quot;]
    :test-paths [&quot;test/clj&quot;]
    :resource-paths [&quot;resources&quot;, &quot;target/cljsbuild&quot;]
    :target-path &quot;target/%s/&quot;
    :cljsbuild {
                :builds {:app {:source-paths [&quot;src/cljs&quot;]
                               :compiler {:output-to &quot;target/cljsbuild/public/js/app.js&quot;
                                          :output-dir &quot;target/cljsbuild/public/js/out&quot;
                                          :main &quot;my-project-name.core&quot;
                                          :asset-path &quot;/js/out&quot;
                                          :optimizations :none
                                          :source-map true
                                          :pretty-print true}}}
                :clean-targets ^{:protect false}
                [:target-path [:cljsbuild :builds :app :compiler :output-dir &quot;resources/public/js/&quot;]
                 [:cljsbuild :builds :app :compiler :output-to &quot;resources/public/js/&quot;]]
                }

    :main ^:skip-aot my-project-name.core

    :plugins [
              [lein-cprop &quot;1.0.1&quot;]
              [migratus-lein &quot;0.2.6&quot;]
              [lein-cljsbuild &quot;1.1.8&quot;]]

    :profiles
    {:uberjar {:omit-source true
               :aot :all
               :uberjar-name &quot;my-project-name.jar&quot;
               :source-paths [&quot;env/prod/clj&quot; ]
               :resource-paths [&quot;env/prod/resources&quot;]}

     :dev           [:project/dev :profiles/dev]
     :test          [:project/dev :project/test :profiles/test]

     :project/dev  {:jvm-opts [&quot;-Dconf=dev-config.edn&quot; ]
                    :dependencies [[org.clojure/tools.namespace &quot;1.1.1&quot;]
                                   [pjstadig/humane-test-output &quot;0.11.0&quot;]
                                   [prone &quot;2021-04-23&quot;]
                                   [ring/ring-devel &quot;1.9.4&quot;]
                                   [ring/ring-mock &quot;0.4.0&quot;]]
                    :plugins      [[com.jakemccrary/lein-test-refresh &quot;0.24.1&quot;]
                                   [jonase/eastwood &quot;0.3.5&quot;]
                                   [cider/cider-nrepl &quot;0.26.0&quot;]]

                    :source-paths [&quot;env/dev/clj&quot; ]
                    :resource-paths [&quot;env/dev/resources&quot;]
                    :repl-options {:init-ns user
                                   :timeout 120000}
                    :injections [(require 'pjstadig.humane-test-output)
                                 (pjstadig.humane-test-output/activate!)]}
     :project/test {:jvm-opts [&quot;-Dconf=test-config.edn&quot; ]
                    :resource-paths [&quot;env/test/resources&quot;] }
     :profiles/dev {}
     :profiles/test {}})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;br&gt;
When I run:&lt;/p&gt;
&lt;p&gt;$ cljsbuild once&lt;/p&gt;
&lt;p&gt;I get this error:&lt;/p&gt;
&lt;p&gt;Warning: implicit hook found: lein-cprop.plugin/hooks Hooks are deprecated and will be removed in a future version. Compiling ClojureScript... Compiling [&quot;target/cljsbuild/public/js/app.js&quot;] from [&quot;src/cljs&quot;]... Compiling [&quot;target/cljsbuild/public/js/app.js&quot;] failed. clojure.lang.ExceptionInfo: failed compiling file:target/cljsbuild/public/js/out/reagent/impl/component.cljs {:file #object[java.io.File 0x6ee5cd06 &quot;target/cljsbuild/public/js/out/reagent/impl/component.cljs&quot;], :clojure.error/phase :compilation} at cljs.compiler$compile_file$fn&lt;strong&gt;4031.invoke(compiler.cljc:1765) at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1725) at cljs.compiler$compile_file.invoke(compiler.cljc:1701) at cljs.closure$compile_file.invokeStatic(closure.clj:660) at cljs.closure$compile_file.invoke(closure.clj:638) at cljs.closure$fn&lt;/strong&gt;5527.invokeStatic(closure.clj:734) at cljs.closure$fn&lt;strong&gt;5527.invoke(closure.clj:728) at cljs.closure$fn&lt;/strong&gt;5440$G&lt;strong&gt;5433&lt;/strong&gt;5447.invoke(closure.clj:556) at cljs.closure$compile_from_jar.invokeStatic(closure.clj:707) at cljs.closure$compile_from_jar.invoke(closure.clj:697) at cljs.closure$fn&lt;strong&gt;5531.invokeStatic(closure.clj:744) at cljs.closure$fn&lt;/strong&gt;5531.invoke(closure.clj:728) at cljs.closure$fn&lt;strong&gt;5440$G&lt;/strong&gt;5433&lt;strong&gt;5447.invoke(closure.clj:556) at cljs.closure$compile_sources$iter&lt;strong&gt;5653&lt;/strong&gt;5657$fn&lt;strong&gt;5658.invoke(closure.clj:1105) at clojure.lang.LazySeq.sval(LazySeq.java:42) at clojure.lang.LazySeq.seq(LazySeq.java:51) at clojure.lang.Cons.next(Cons.java:39) at clojure.lang.RT.next(RT.java:713) at clojure.core$next&lt;/strong&gt;5403.invokeStatic(core.clj:64) at clojure.core$dorun.invokeStatic(core.clj:3130) at clojure.core$doall.invokeStatic(core.clj:3136) at clojure.core$doall.invoke(core.clj:3136) at cljs.closure$compile_sources.invokeStatic(closure.clj:1101) at cljs.closure$compile_sources.invoke(closure.clj:1090) at cljs.closure$build.invokeStatic(closure.clj:3241) at cljs.closure$build.invoke(closure.clj:3145) at cljs.build.api$build.invokeStatic(api.clj:231) at cljs.build.api$build.invoke(api.clj:212) at cljs.build.api$build.invokeStatic(api.clj:218) at cljs.build.api$build.invoke(api.clj:212) at cljsbuild.compiler$compile_cljs$fn&lt;/strong&gt;18710.invoke(compiler.clj:61) at cljsbuild.compiler$compile_cljs.invokeStatic(compiler.clj:60) at cljsbuild.compiler$compile_cljs.invoke(compiler.clj:48) at cljsbuild.compiler$run_compiler.invokeStatic(compiler.clj:168) at cljsbuild.compiler$run_compiler.invoke(compiler.clj:129) at user$eval18939$iter&lt;strong&gt;18987&lt;/strong&gt;18991$fn&lt;strong&gt;18992$fn&lt;/strong&gt;19018.invoke(form-init14466059707374101833.clj:1) at user$eval18939$iter&lt;strong&gt;18987&lt;/strong&gt;18991$fn&lt;strong&gt;18992.invoke(form-init14466059707374101833.clj:1) at clojure.lang.LazySeq.sval(LazySeq.java:42) at clojure.lang.LazySeq.seq(LazySeq.java:51) at clojure.lang.RT.seq(RT.java:535) at clojure.core$seq&lt;/strong&gt;5419.invokeStatic(core.clj:139) at clojure.core$dorun.invokeStatic(core.clj:3121) at clojure.core$doall.invokeStatic(core.clj:3136) at clojure.core$doall.invoke(core.clj:3136) at user$eval18939.invokeStatic(form-init14466059707374101833.clj:1) at user$eval18939.invoke(form-init14466059707374101833.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7181) at clojure.lang.Compiler.eval(Compiler.java:7171) at clojure.lang.Compiler.load(Compiler.java:7640) at clojure.lang.Compiler.loadFile(Compiler.java:7578) at clojure.main$load_script.invokeStatic(main.clj:475) at clojure.main$init_opt.invokeStatic(main.clj:477) at clojure.main$init_opt.invoke(main.clj:477) at clojure.main$initialize.invokeStatic(main.clj:508) at clojure.main$null_opt.invokeStatic(main.clj:542) at clojure.main$null_opt.invoke(main.clj:539) at clojure.main$main.invokeStatic(main.clj:664) at clojure.main$main.doInvoke(main.clj:616) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.main.main(main.java:40) Caused by: clojure.lang.ExceptionInfo: null #:clojure.error{:source nil, :line nil, :column nil, :phase :compilation} at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:4269) at cljs.analyzer$analyze.invoke(analyzer.cljc:4255) at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1581) at cljs.compiler$emit_source.invoke(compiler.cljc:1554) at cljs.compiler$compile_file&lt;em&gt;STAR&lt;/em&gt;$fn__4000.invoke(compiler.cljc:1668) at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1474) at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1463) at cljs.compiler$compile_file&lt;em&gt;STAR&lt;/em&gt;.invokeStatic(compiler.cljc:1652) at cljs.compiler$compile_file&lt;em&gt;STAR&lt;/em&gt;.invoke(compiler.cljc:1645) at cljs.compiler$compile_file$fn&lt;strong&gt;4031.invoke(compiler.cljc:1750) ... 60 more Caused by: clojure.lang.ExceptionInfo: No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing &quot;react&quot; in file target/cljsbuild/public/js/out/reagent/impl/component.cljs {:tag :cljs/analysis-error} at cljs.analyzer$error.invokeStatic(analyzer.cljc:719) at cljs.analyzer$error.invoke(analyzer.cljc:715) at cljs.analyzer$error.invokeStatic(analyzer.cljc:717) at cljs.analyzer$error.invoke(analyzer.cljc:715) at cljs.analyzer$analyze_deps.invokeStatic(analyzer.cljc:2645) at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:2612) at cljs.analyzer$ns_side_effects.invokeStatic(analyzer.cljc:4131) at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:4126) at cljs.analyzer$analyze&lt;em&gt;STAR&lt;/em&gt;$fn&lt;/strong&gt;2886.invoke(analyzer.cljc:4253) at clojure.lang.PersistentVector.reduce(PersistentVector.java:343) at clojure.core$reduce.invokeStatic(core.clj:6829) at clojure.core$reduce.invoke(core.clj:6812) at cljs.analyzer$analyze&lt;em&gt;STAR&lt;/em&gt;.invokeStatic(analyzer.cljc:4253) at cljs.analyzer$analyze&lt;em&gt;STAR&lt;/em&gt;.invoke(analyzer.cljc:4244) at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:4272) ... 69 more&lt;/p&gt;
&lt;p&gt;OS is Ubuntu 20.04&lt;/p&gt;
&lt;p&gt;I have installed node, react, etc. It looks to me like cljsbuild cannot find the cljs bindings to react, although I'm not 100% since I'm new to cljs.&lt;/p&gt;
&lt;p&gt;Am I doing something wrong?&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11419/why-cant-clojure-find-react</guid>
<pubDate>Mon, 27 Dec 2021 07:18:16 +0000</pubDate>
</item>
<item>
<title>How can I analyze my cljs production js output for size?</title>
<link>https://ask.clojure.org/index.php/9283/how-can-i-analyze-my-cljs-production-js-output-for-size</link>
<description>&lt;p&gt;First, thanks to everyone for their efforts on cljs, reagent, and everything else that makes this ecosystem tick. For those efforts, we all suffer less, and I am profoundly grateful.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;We use &lt;code&gt;{:optimizations :advanced}&lt;/code&gt; to produce a single .js file for production deployments of our ClojureScript web front ends.&lt;/p&gt;
&lt;p&gt;The file size of the emitted .js varies a lot, and seems to correlate positively with the complexity of the project, which is good, but is often still a bit bigger than I'd like.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Is there a way, or are there tools, to analyze the contents of the emitted .js (maybe during compilation? or perhaps after the fact?) in order to discover what is using space in the output?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I'm dreaming of something like &lt;code&gt;ncdu&lt;/code&gt;, but for my cljs build output.&lt;/p&gt;
&lt;p&gt;With such tools we could perhaps find paths through the compilation that could produce smaller output. There may be accidental links that defeat the tree-shaker (or whatever).&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Thanks in advance for your time and consideration.&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9283/how-can-i-analyze-my-cljs-production-js-output-for-size</guid>
<pubDate>Sun, 03 May 2020 14:26:58 +0000</pubDate>
</item>
<item>
<title>ClojureScript advanced optimizations overriding externs that overlap with a namespace</title>
<link>https://ask.clojure.org/index.php/8908/clojurescript-advanced-optimizations-overriding-namespace</link>
<description>&lt;p&gt;I just broke our cljsbuild, and I'm curious if it's a bug or expected behavior.&lt;/p&gt;
&lt;p&gt;We have an external JS file that defines a global object with a function: &lt;code&gt;link.myfn()&lt;/code&gt;, and an externs file that describes it. We have a namespace that shares the prefix: &lt;code&gt;link.theme&lt;/code&gt;. This works as expected during development. However, with advanced optimizations it fails, because our cljs output somehow defines an empty &lt;code&gt;link&lt;/code&gt; object that effectively overwrites the one from the external library. If I exclude the externs and the external library, no empty object is created.&lt;/p&gt;
&lt;p&gt;I've put up a repo that reproduces this, and explains the four cases I tried, where only one of them fail: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/cjohansen/cljsns&quot;&gt;https://github.com/cjohansen/cljsns&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This seems like a bug to me, but could possibly be some compiler detail I don't know about. Does anyone know?&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8908/clojurescript-advanced-optimizations-overriding-namespace</guid>
<pubDate>Wed, 27 Nov 2019 08:49:33 +0000</pubDate>
</item>
</channel>
</rss>