Fork me on GitHub
#shadow-cljs
<
2020-07-19
>
David Pham06:07:12

Can you show us the code that you use? (Maybe clean the .shadow-cljs folder).

thheller07:07:19

@roklenarcic shadow-cljs has no support for serving "assets" from node_modules. it just deals with JS.

Chris McCormick07:07:27

i have symlinked stuff from node_modules/... into public before which worked fine. if you have a build step it has to take this into account.

magra15:07:27

Hi, at the moment, to build production, I have to kill my dev environment and stop the shadow-cljs server to prevent cached dev dependencies (guardrails) to leak into production. Is there a way to tell shadow-cljs to not use the running server?

Drew Verlee16:07:51

I believe you could output your build/release artifacts to another file so they didn't clash.

thheller19:07:52

@magra they don't leak into production unless you builds includes them?

magra08:07:07

maybe I misused the word leaked, I apologize. I think I followed the instructions in the guardrails readme. They work fine if I stop the dev server everytime I want to build release. They throw if I forget to stop the dev server. Since @U05224H0W ansered in another thread a few days ago that maybe someone had inadvertantly a second shadow-cljs server running I thought there maybe is a way to have a second server running on purpose or maybe start shadow-cljs release in a way that it does not reuse the running dev server. If I read the guardrails docs correctly they suggest to always stop the dev server before release and provide a throw if I forgot to stop the dev server.

thheller08:07:07

you are doing something that is absolutely NEVER required but not describing enough WHY you think you have to do it

thheller08:07:32

please first describe what your actual problem is

magra08:07:49

I work on a fulcro project. It works fine and I have emacs and shadow-cljs running 8 hours at a time. When I want to release a main.js to a server I have to kill the shadow-cljs dev server.

thheller08:07:18

what commands are you running?

magra08:07:58

I start dev like: [nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.8.0-alpha3 -d cider/piggieback:0.5.0 -d refactor-nrepl:2.5.0 -d cider/cider-nrepl:0.25.3-SNAPSHOT server -A:dev I start release: npx shadow-cljs release -A:ui prod

thheller08:07:03

ok now you provided some essential info. you are using deps.edn aliases to switch dependencies. that cannot be done with a running server and does require a restart.

thheller08:07:08

now explain WHY you are doing that? like what is the difference in the profiles?

thheller08:07:13

in general it is irrelevant what is on the classpath when building CLJS projects. the code only uses what is actually used, just the presence on the classpath does nothing.

magra08:07:53

ok. The jvm options in the profiles are different since dev includes the fulcro backend.

thheller08:07:30

you don't need the jvm properties when building CLJS. you should configure via the build config as the guardrails doc show

thheller08:07:43

the JVM properties are for CLJ

magra08:07:50

"-Dguardrails.enabled=true"]

thheller08:07:08

...
     :app  {:target            :browser
            :dev               {:compiler-options
                                {:external-config {:guardrails {:throw? false}}
                                 :closure-defines {goog.DEBUG true}}}
...

thheller08:07:16

you don't need the -Dguardrails...

magra08:07:40

I need -Dguardrails for the backend.

thheller08:07:56

then use a different profile for the backend and CLJS?

thheller08:07:04

npx shadow-cljs --force-spawn release -A:ui prod also works but I'd strongly recommend building a setup that doesn't require switching deps.edn aliases

thheller08:07:31

this never uses the running server and always starts a new process

magra08:07:01

Thank you! That is what the question was about. But I still want to follow your guidance about the seperate profiles. What do you mean by different profiles since you seem not to mean different deps.edn aliases. At the moment I use cider to connect both clj and cljs on the conection that I start as shown above. Are you talking about starting a seperate jvm for server and UI and have two seperate connections from emacs without sibling connections?

thheller09:07:13

I do mean deps.edn aliases. just too used to lein which calls them profiles.

thheller09:07:13

I do mean that you create a :backend alias and maybe a :backend-prod or so and then one alias for :cljs which just configures the guardrails via build config without jvm property

magra09:07:07

Ahh thank you!!!! I could not figure out the middle between the extremes. Thank your for your time and your patience!

thheller09:07:12

could also add a :enable-guardrails-clj alias that just sets the jvm property. so you can do clj -A:backend and clj -A:backend:enable-guardrails-clj

magra09:07:57

I think my using cider-jack-in-clj&clj instead of two separate jackins prevented me from doing that. My dev environment used shadow-cljs for UI and Backend at the same time and I am going to change that. Thank you again and thank you for shadow-cljs!

magra16:07:33

For the archive: separate cider-jack-in-clj and cider-jack-in-cljs is completely possible works fine with above suggestions.

thheller20:07:42

the guardrails readme shows how to enable it for dev?

mruzekw20:07:01

I’m working on a node script in IntelliJ/Cursive and I notice all the JS symbols are coming up “cannot be resolved”. Is there a way to fix this?

mruzekw20:07:17

Okay, thanks

thheller20:07:08

well you can fix it by disabling that warning 😛

thheller20:07:28

I think there is an open Cursive issue about this

cfleming20:07:57

Yes, there is, I’m planning to do what I can about this soon-ish.

🎉 6
mruzekw22:07:49

Does shadow-cljs process JS with async/await functions? I’m trying to use a module that exports one and not having much luck

shadow-electron-starter/node_modules/electron-serve/index.js:12
const getPath = async path_ => {
                      ^^^^^
SyntaxError: Unexpected identifier