Fork me on GitHub
#shadow-cljs
<
2020-09-18
>
benny04:09:58

any places to look when running with a release build, I get undefined is not an object (evaluating 'Z4.$l') but it works just fine when running dev builds?

p-himik04:09:34

Issues with externs. Likely whatever Z4 was before, it shouldn't have been renamed. Or you have something different happening in the release build so that Z4 is a genuine variable that has a value of undefined.

thheller07:09:15

@benny turn on externs inference if it isn't on (wasn't the default as of very recently) https://shadow-cljs.github.io/docs/UsersGuide.html#externs

thheller07:09:19

looks like an externs renaming issue

Karol Wójcik10:09:08

Is it possible to not start nrepl server when using shadow.cljs.devtools.server/start?

sogaiu10:09:20

in shadow-cljs.edn: > The nREPL server can be disabled by setting :nrepl false.

❤️ 3
sogaiu10:09:33

may be that works?

yenda14:09:03

Is there some gotchas when hot-reloading a namespace that uses macros? Trying to use clara-rules defrule macro and every time I save the namespace shadow complains about undeclared vars, which are functions defined in the namespace and originally compiled fine

yenda14:09:19

additionally when moving these functions to another namespace it also works fine

thheller14:09:04

not enough information to comment

yenda14:09:29

(ns notifications.notifications
  (:require [clara.rules :as clara])
  (:require-macros [clara.macros :refer [defrule defsession]]))

(defsession session 'notifications.notifications
  :fact-type-fn :type)

(defn testz [user-id]
  {[:user/id user-id] [:user/id]})

(defrule follow
  "A rule which isd fired on every follow"
  [:context [env] (= ?env env)]
  [:follow [{followed-id :followed/id user-id :user/id}]
   (= ?followed-id followed-id)
   (= ?user-id user-id)]

  =>
  (testz ?user-id))

(defn handle-event [env event]
  (-> session
      (clara/insert (merge env {:type :context})
                    event)
      (clara/fire-rules)))

thheller14:09:49

I don't know much about clara-rules so no clue what that code does

thheller14:09:15

I know that is uses a clojure side atom and does not play well with caching

thheller14:09:29

so could be likely that it also doesn't play well with incremental compilation at all

yenda14:09:00

yeah it looks like it's something like that because rules that are deleted keep throwing undeclared-var compilation errors

yenda14:09:12

so disabling caching could help?

thheller14:09:36

if you want to completely obliterate recompile performance 😉

thheller14:09:13

no clue to be honest. maybe there is something you can call to "reset" its state

thheller14:09:45

cache is off by default for clara already

frozar15:09:55

Hi, I'm wondering how to manage subproject through shadow-cljs. My situation is the following: I want to create a main project on a private repository and this project should use an "embedded" subproject which is public and should remain public. Both on them will use shadow-cljs.edn as build configuration file. Is there a convenient way to embed a subproject with shadow-cljs?

thheller15:09:11

you can use deps.edn or project.clj to do this

thheller15:09:16

shadow-cljs.edn itself does not support this

thheller15:09:54

well you can just add :sources-paths ["src/main" "../that-subproject/src/main"] if its just about source paths

yenda15:09:17

interesting even after completely disable the cache the initial compilation works then I get undeclared variables 😕

thheller15:09:16

@yenda diid you restart the shadow-cljs process? as I said the library keeps some CLJ side state that isn't part of any shadow-cljs cache or so you could reset

yenda15:09:05

yes I restarted it

thheller15:09:46

sorry don't know enough about the lib to even guess

yenda15:09:22

looks like there is a clear-ns-productions! function

yenda15:09:20

so I should use it in

:before-load  

thheller15:09:18

for macros that access the analyzer state directly

thheller15:09:42

can't remember if that was necessary or not

yenda15:09:36

(clara/clear-ns-productions!) needs to be put in the ns

yenda15:09:40

nothing else required

frozar15:09:36

OK, thank you @thheller, always reactive, always amazing ! Yes, I can manage this with the classpath, but I don't want to duplicate the dependencies of the subproject in the main project. I'll try the deps.edn approach, thank again

frozar16:09:02

As I use many npm package, it's finally easier to keep using shadow-cljs ^^

Stephen15:09:03

Hi, I am just getting into clj/cljs dev. Is there a way to only use the shadow-cljs commandline tool for managing all deps (clj and cljs)? Or are deps.edn and/or lein always needed for the backend(clj) side?

Stephen15:09:24

All this clj (deps.edn), lein, and shadow-cljs configs confuse me

frozar15:09:35

@slack1781 as far as I know, shadow-cljs is dedicated to clojurescript project, or javascript aspect of a project.

wombawomba15:09:06

So I have a shadow-cljs project, and I want to disable CORS (i.e. inject permissive CORS headers) for the shadow-cljs watch command. How can I make this happen?

wombawomba15:09:18

FWIW I thought the :push-state/headers key as described in the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http) seems promising for this, but adding it doesn’t seem to have any effect

wombawomba15:09:20

Maybe I’m putting it in the wrong place?

wombawomba16:09:04

Nevermind, I figured it out 🙂

diego.videco16:09:43

how can I set environment vars for development vs prod. I am reading this section of the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env), but I am used to starting shadow with Cider, so I am not even sure how I set the env vars there.

diego.videco16:09:22

I just want to point the api endpoint to somewhere else, so it's something quite trivial

dpsutton16:09:16

{...
 :builds
 {:app
  {:target :browser
   ...
   :modules {:app {:entries []}}
   ;; to enable in development only
   :dev {:closure-defines { true}}
   ;; to enable always
   :closure-defines { true}
   ;; you may also enable it for release as well
   :release {:closure-defines { true}}
   }}
you could use :dev and :release to use hardcoded versions. or start shadow from the command line and then cider-connect-cljs to the already running instance with easily set env vars

dpsutton16:09:42

you could also call (setenv VARIABLE VALUE). make a function that does this and then calls cider-jack-in-cljs and you might be good if you really wan to stay in emacs

diego.videco18:09:34

Awesome, thanks

dpsutton16:09:58

for work i use

(cider-connect-cljs (list :host "localhost"
                          :port 7888
                          :cljs-repl-type 'figwheel-connected
                          'project-dir "~/projects/aclaimant/acl"))
in a function. you could adjust that as needed with a call to set-env

zhuxun218:09:44

Has anyone seen npx shadow-cljs watch :main running forever? Like so:

[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.49s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.49s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.39s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.35s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.34s)
... (forever) ...

zhuxun218:09:16

I did not touch any code during this time..

zhuxun218:09:55

What triggers a re-compilation in watch mode?

zhuxun218:09:23

And if I delete the compiled folder, and restart the watch, the problem resolves ... weird

thheller18:09:15

@zhuxun2 this can happen if your :output-dir is also on any of the :source-paths

zhuxun218:09:43

@thheller But isn't that usually the case? for example, I usually use "resources/public/js" as the output directory, but "resources" is usually one of the source-paths

thheller18:09:05

yes, but that is filtered. the filter is very basic so it may not properly filter all the stuff

thheller18:09:29

I thought I fixed most cases but maybe I didn't. not saying that this is the cause of your problem. just a guess.

thheller18:09:46

if you have non-standard paths then it is more likely

zhuxun218:09:24

Yes I do, I used a separate resources folder called "resources_dev" for the development compiles

zhuxun218:09:33

Is there any workaround in that case?

thheller18:09:18

call it dev-resources 😛

thheller18:09:32

paths ending in resources are filtered

thheller18:09:09

which version is this? I though I fixed this in general but maybe I didn't

zhuxun218:09:32

LOL, okay. I am using 2.9.10

zhuxun218:09:06

Oh actually 2.8.58

thheller18:09:38

hmm yeah maybe try upgrading. or just renaming that should definitely work

zhuxun218:09:14

Okay I'll try. Why not make the filter an explicit setting?

thheller18:09:01

it shouldn't be required at all anymore but that was definitely after 2.8.58

zhuxun218:09:08

I see, yeah maybe I was just using an out-dated version .. thanks!