Compiling with optimizations none is no doubt quite handy, especially in 
conjunction with source maps, as a traceback will take you to the line of 
code causing the problems, and with the same variable names used in your 
original clojurescript code. But this is not currently possible for .jc 
files used by web workers as the unoptimized .js file contains a reference 
to js/window--and window does not exist in a web worker.


You should still be able to use optimizations none with your main 
javascript code, but you will need to compile your main code and your web 
worker code separately so that you can use different optimizations as 
appropriate. And you can do this so long as your not using shared workers. 
The question then is, how to compile the .js files separately.

The duracell <https://github.com/aatree/aademos/tree/master/duracell> demo 
uses a web worker AND is itself compiled with optimizations none. There are 
two things done to accomplish this:

   1. Duracell itself has no web worker code. Though it uses a library, 
   durable-cells <https://github.com/aatree/durable-cells>, which includes 
   a web worker.
   2. In the duracell build.boot 
   <https://github.com/aatree/aademos/blob/master/duracell/build.boot> file, 
   the dev task uses pandeiro/boot-http 
   <https://github.com/pandeiro/boot-http> rather than the simpler 
   tailrecursion/boot-jetty <https://github.com/tailrecursion/boot-jetty>. 
   The advantage to using boot-http is that it supports the loading of static 
   files from library jar files. In this case, that means the main code in 
   aaworker can create a web worker using durable-cell's dcells.js file.

So how does the durable-cells library create the dcells.js file? Again, 
there are two things done to accomplish this:

   1. In the durable-cells build.boot 
   <https://github.com/aatree/durable-cells/blob/master/build.boot> file, 
   the dev task includes (cljs :optimizations :simple). This invokes the 
   compiler with an appropriate level of optimizations.
   2. But we still need to define the .js file. This is done in the 
   dcells.cljs.edn 
   
<https://github.com/aatree/durable-cells/blob/master/src/worker/dcells.cljs.edn>
 file. 
   See Multiple Builds 
   <https://github.com/adzerk-oss/boot-cljs/wiki/Usage#multiple-builds> for 
   more information on cljs.edn files.

>From https://github.com/aatree/aaworker/wiki/Compiling-with-Optimizations-None

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to