Fork me on GitHub
#shadow-cljs
<
2019-01-17
>
thosmos01:01:39

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}}

caleb.macdonaldblack06:01:29

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

lilactown07:01:01

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

caleb.macdonaldblack08:01:00

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.

lilactown16:01:00

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

lilactown16:01:28

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

caleb.macdonaldblack23:01:21

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

thheller10:01:39

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

thheller10:01:55

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

thheller10:01:39

or use :cache-blockers to prohibit caching of files that use side-effecting macros https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache

caleb.macdonaldblack10:01:13

What do you mean by passing data from html?

thheller10:01:42

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

thheller10:01:52

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

thheller10:01:28

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

thheller10:01:14

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

thheller10:01:35

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

caleb.macdonaldblack10:01:33

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?

thheller10:01:49

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

caleb.macdonaldblack10:01:52

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.

aisamu16:01:20

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 https://github.com/matthieu-beteille/cljs-css-modules, 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=$CLJS.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?

thheller16:01:49

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

aisamu16:01:42

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

aisamu16:01:19

Will do, thanks!

aisamu16:01:40

It works beautifully! Thanks again!

aisamu16:01:40
replied to a thread:try 2.7.15

It works beautifully! Thanks again!