<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged webpack</title>
<link>https://ask.clojure.org/index.php/tag/webpack</link>
<description></description>
<item>
<title>Using eval from cljs.js with webpack</title>
<link>https://ask.clojure.org/index.php/9995/using-eval-from-cljs-js-with-webpack</link>
<description>&lt;p&gt;In clojurescript 1.10.773 it is impossible to use &lt;code&gt;eval&lt;/code&gt; from cljs.js when I've bundled the project with webpack I think this is because &lt;code&gt;eval&lt;/code&gt; is calling &lt;code&gt;find-ns-obj&lt;/code&gt;, when doesn't work with the &lt;code&gt;:bundle&lt;/code&gt; &lt;code&gt;:target&lt;/code&gt;. That makes sense, but this error still occurs when an &lt;code&gt;:ns&lt;/code&gt; is passed in the options map.&lt;/p&gt;
&lt;p&gt;Using &lt;code&gt;eval&lt;/code&gt; from cljs.js used to work in clojurescript 1.10.741, even when &lt;code&gt;:target&lt;/code&gt; was set to &lt;code&gt;:bundle&lt;/code&gt;. It looks like this is because previous versions of clojurescript never set &lt;code&gt;*target*&lt;/code&gt; when it was set in the compiler options.&lt;/p&gt;
&lt;p&gt;The error I'm getting is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;core.cljs:11642 Uncaught Error: find-ns-obj not supported for target bundle
    at Object.cljs$core$find_ns_obj [as find_ns_obj] (core.cljs:11642)
    at Function.cljs$core$IFn$_invoke$arity$1 (core.cljs:11660)
    at cljs$core$create_ns (core.cljs:11657)
    at Function.cljs$js$compile_str_STAR__$_compile_loop (js.cljs:918)
    at Function.cljs$core$IFn$_invoke$arity$3 (core.cljs:3918)
    at Function.cljs$core$IFn$_invoke$arity$2 (core.cljs:3913)
    at Function.cljs$core$IFn$_invoke$arity$2 (core.cljs:3948)
    at core.cljs:10831
    at Function.cljs$core$IFn$_invoke$arity$1 (core.cljs:10826)
    at Function.cljs$core$IFn$_invoke$arity$variadic (core.cljs:10831)
cljs$core$find_ns_obj @ core.cljs:11642
(anonymous) @ core.cljs:11660
cljs$core$create_ns @ core.cljs:11657
cljs$js$compile_str_STAR__$_compile_loop @ js.cljs:918
(anonymous) @ core.cljs:3918
(anonymous) @ core.cljs:3913
(anonymous) @ core.cljs:3948
(anonymous) @ core.cljs:10831
(anonymous) @ core.cljs:10826
(anonymous) @ core.cljs:10831
cljs$core$trampoline @ core.cljs:10817
cljs$js$compile_str_STAR_ @ js.cljs:910
(anonymous) @ js.cljs:1019
cljs$js$compile_str @ js.cljs:968
interactive_syntax$core$eval_str @ core.cljs:48
run @ core.cljs:351
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306
executeDispatch @ react-dom.development.js:389
executeDispatchesInOrder @ react-dom.development.js:414
executeDispatchesAndRelease @ react-dom.development.js:3278
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3287
forEachAccumulated @ react-dom.development.js:3259
runEventsInBatch @ react-dom.development.js:3304
runExtractedPluginEventsInBatch @ react-dom.development.js:3514
handleTopLevel @ react-dom.development.js:3558
batchedEventUpdates$1 @ react-dom.development.js:21871
batchedEventUpdates @ react-dom.development.js:795
dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3568
attemptToDispatchEvent @ react-dom.development.js:4267
dispatchEvent @ react-dom.development.js:4189
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
discreteUpdates$1 @ react-dom.development.js:21887
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168
Show 8 more frames
react-dom.development.js:327 Uncaught Error: find-ns-obj not supported for target bundle
    at Object.cljs$core$find_ns_obj [as find_ns_obj] (core.cljs:11642)
    at Function.cljs$core$IFn$_invoke$arity$1 (core.cljs:11660)
    at cljs$core$create_ns (core.cljs:11657)
    at Function.cljs$js$compile_str_STAR__$_compile_loop (js.cljs:918)
    at Function.cljs$core$IFn$_invoke$arity$3 (core.cljs:3918)
    at Function.cljs$core$IFn$_invoke$arity$2 (core.cljs:3913)
    at Function.cljs$core$IFn$_invoke$arity$2 (core.cljs:3948)
    at core.cljs:10831
    at Function.cljs$core$IFn$_invoke$arity$1 (core.cljs:10826)
    at Function.cljs$core$IFn$_invoke$arity$variadic (core.cljs:10831)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any use of &lt;code&gt;eval&lt;/code&gt;, or &lt;code&gt;eval-str&lt;/code&gt;, &lt;code&gt;compile-str&lt;/code&gt;, etc. gives it to me. Say:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(eval-str (empty-state) &quot;(+ 1 2)&quot; &quot;UNTITLED&quot; {:eval js-eval} println)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And I get this error even if I provide my own &lt;code&gt;:ns&lt;/code&gt;.&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9995/using-eval-from-cljs-js-with-webpack</guid>
<pubDate>Sun, 03 Jan 2021 02:57:09 +0000</pubDate>
</item>
<item>
<title>Recommended webpack config for clojurescript bundle target</title>
<link>https://ask.clojure.org/index.php/9602/recommended-webpack-config-for-clojurescript-bundle-target</link>
<description>&lt;p&gt;I'm trying to port a re-frame app to use the new :bundle target based on the webpack tutorial.  Prior to this I used the approach from the old webpack tutorial.&lt;/p&gt;
&lt;p&gt;I'm finding webpack takes inpractically long (10 minutes) to perform chunk asset optimisation. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;% webpack --progress resources/public/js/index.js -o resources/public/js/app.js
92% chunk asset optimization TerserPlugin
...&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If I configure the TerserPlugin and set compress: false it improves to a few seconds.&lt;/p&gt;
&lt;p&gt;I suspect the slowness is caused by webpack chewing on the ~2mb advanced build output from my app.&lt;/p&gt;
&lt;p&gt;Are there recommended webpack settings to avoid pointless &quot;compress the compressed file&quot; slowness?&lt;/p&gt;
&lt;p&gt;PS.  I've created a &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/olivergeorge/aa3b7dd8d8826b595bcca293cac6c3bc&quot;&gt;gist with a few of my tests/results&lt;/a&gt;.&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9602/recommended-webpack-config-for-clojurescript-bundle-target</guid>
<pubDate>Sun, 13 Sep 2020 22:59:41 +0000</pubDate>
</item>
</channel>
</rss>