Fork me on GitHub

is there a way to turn off devtools for just one module in a dev build that has devtools enabled? my webworker is failing because it's loading the devtools stuff and turning it off in the module section doesn't seem to do anything:

:devtools   {:http-root  "admin/public"
                               :http-port  1337
                               :after-load threshold.admin.core/reload
                               :preloads   [fulcro.inspect.preload  threshold.admin.development-preload]}
                  :modules    {:main   {:init-fn threshold.admin.core/main
                                        :entries [threshold.admin.core]}
                               :worker {:devtools {:enabled false}
                                        :entries [threshold.admin.worker.core]
                                        :depends-on #{:main}
                                        :web-worker true}}


What are some good ways to bring in variables from system environment variables? I'm currently using a macro with direnv, however I think I'm having some caching issues


system environment variables is usually a code smell. why are you using env vars in a browser app?


I have multiple environments develop, staging & production each with it's own backend infrastructure. I compile on CircleCI where I use the git branch to decide what environment variables to use. My application is compiled with those environment variables.


we do similar, but we have other ways of discerning which env we’re in. e.g. by host name, or by a global var on the page inserted by the back end


that way our builds are portable. it seems weird to have to compile your app for each environment


I'm hosting static html files so I can't insert them dynamically with a web server.


@caleb.macdonaldblack I generally recommend avoiding environment variables for browser builds and instead passing data to the build from HTML


but you can use #shadow/env "FOO" in the build config to access environment variables


or use :cache-blockers to prohibit caching of files that use side-effecting macros


What do you mean by passing data from html?


@thosmos how is it failing? devtools should be disabled for webworkers?


@caleb.macdonaldblack I generally recommend using an init function. (defn ^:export init [some-config] ...) <script>your.ns.init({"url":"http://..."});</script>


alternatively <script>var MY_CONFIG = {...};</script> and then accessing js/MY_CONFIG


that pattern makes most sense if you have a dynamic webserver and not just static html files though


but you could just use an index.html + index-ci.html or so


Yea Im using static html files but I can see how incredibly useful that method would be for dynamic stuff. Im not sure what you meant by index-ci.html though. Are you suggesting multiple index-*.html files with different configs for my environments and the copying that file to index.html when I deploy?


if you are not using a dynamic web server yes. you can either copy or generate different html files depending on the environment


Okay. From your suggestions I think I prefer the #shadow/env method for static hosting plus it works well with my current setup. However I really like the other method for dynamic web servers. Thanks a lot for the help.


Hi! I'm getting a ReferenceError: garden is not defined, but I can't figure out why. It happens while using cljs code as a regular module on webpack. The CLJS code targets :npm-module and is generated with the compile task. The component in question uses, and adding garden.core on the ns that uses it "solves" the problem. The compiled webpack bundle contains modules for cljs-css-modules, garden and my component, as expected. cljs-css-modules contains a __webpack_require__ pointing to garden's module. Without garden.core explicitly required, my component's module contains a __webpack_require__ to cljs-css-modules but it fails. With garden.core require outside the ns (via a macro that outputs a require), the module gains a goog.require('garden.core') but it still fails. With garden.core explicitly imported on the component, the webpack module gains a __webpack_require__ to the garden module, a garden=$ and a goog.require('garden.core'). Everything works. What is confusing me is that cljs-css-modules imports garden.core, and my code both requires and webpack_requires cljs-css-modules. Is it expected to have to require garden again?


@aisamu which shadow-cljs version are you on? (should be fixed in latest)


Oh, forgot! version: 2.7.8 node: v9.11.2


Will do, thanks!


It works beautifully! Thanks again!

replied to a thread:try 2.7.15

It works beautifully! Thanks again!