Fork me on GitHub
#shadow-cljs
<
2018-11-13
>
manuel14:11:43

hi everybody. A question concerning shadow-cljs intergration in CIDER. I am working on a mixed CLJ/CLJS project (deps.edn + shadow-cljs). Following shadow-cljs manual, I end up with 3 REPL: - CLJ REPL: where I run the http server and play with CLJ files - CLJ REPL: the one connected to shadow-cljs watch [...] - CLJS REPL: the sibling of the above Is this the expected situation? cider-find-var doesn't seem to be working, but I can interact with the browser from the CLJS REPL.

thheller14:11:03

hey. I don't use emacs myself so I can't really comment. sounds correct though

thheller14:11:16

no idea what cider-find-var is or does though

manuel14:11:43

thanks @thheller. cider-find-var is a jump-to-definition.

thheller15:11:42

yeah sorry no idea how that works. maybe its talking to the wrong REPL?

manuel15:11:33

I'll investigate further, thanks. ๐Ÿ™‚

haywood15:11:36

@manuel you don't have to launch separate cljs repls. I just run the watch command, and connect to the NREPL server that's printed out using cider connect. After that, to get the browser repl working, I run (shadow/nrepl-select :build-name) in that repl buffer window

haywood15:11:11

when you navigate to the project in the browser, you'll see "JS runtime connected"

haywood15:11:23

---- I have a library that uses deps and shadow, I want to use it from another project, but the library has npm dependencies, how do I package those deps so when I use the library I don't get npm install errors?

manuel15:11:12

@haywood fantastic, thanks

thheller15:11:22

@haywood create a deps.cljs and add {:npm-deps {"that-lib" "1.2.3"}}

haywood15:11:54

deps.cljs and not deps.edn?

thheller15:11:16

deps.cljs must be on the classpath and yes deps.cljs

haywood15:11:40

I had tried adding that to deps.edn to no avail, will look into that

thheller15:11:45

must be part of the lib. deps.edn usually isn't

manuel15:11:26

@haywood cider-find-var is not working yet, though

haywood15:11:30

do you have cider in a global deps file?

haywood15:11:46

I have this in my ~/.clojure/deps.edn cider/cider-nrepl {:mvn/version "0.18.0-SNAPSHOT"}

manuel15:11:07

I have that in shadow-cljs.edn

haywood15:11:24

oh, so it's just find var? everything else is working?

manuel15:11:30

yes ๐Ÿ™‚

haywood15:11:49

gotcha, let me see if mine is working

manuel15:11:42

mine now gives: user-error: โ€˜cider-find-varโ€™ requires the nREPL op "info" (provided by cider-nrepl)

haywood15:11:31

thanks @thheller that worked ๐Ÿ™‚

haywood15:11:10

@manuel huh, yea mine works once connected to the browser repl

haywood15:11:26

I don't have any special cider or repl stuff in my shadow project

haywood15:11:12

I do have this in my .clojure/deps.edn refactor-nrepl {:mvn/version "2.4.0"}

haywood15:11:27

not sure if that's necessary

thheller16:11:12

@gleisonsilva I finally had some time to properly trace the re-frame-10x warnings you reported a few days ago https://github.com/Day8/re-frame-10x/issues/219

gleisonsilva16:11:20

this is great, @thheller! Thank you very much

manuel17:11:22

@haywood thanks again. I added refactor-nrepl to my shadow-cljs.edn, and cider-find-var is working now.

haywood17:11:40

great, we did it!

manuel17:11:52

I also removed anything CLJS related from my .dir-locals.el, BTW.

richiardiandrea18:11:44

Question, I am trying to get a node repl for a :node-script but I get:

node bin/migrate-event-store
Error: ENOENT: no such file or directory, open '/home/arichiardi/git/laputa/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at global.SHADOW_IMPORT (/home/arichiardi/git/laputa/event-store/bin/migrate-event-store:47:15)
    at /home/arichiardi/git/laputa/event-store/bin/migrate-event-store:3006:1
    at Object.<anonymous> (/home/arichiardi/git/laputa/event-store/bin/migrate-event-store:3115:3)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
what was the reason for that again?

richiardiandrea18:11:14

(ooops sorry for the ping ๐Ÿ˜ธ)

thheller18:11:12

does it exist? maybe removed .shadow-cljs dir without recompiling?

richiardiandrea18:11:39

it does not exists no

richiardiandrea18:11:43

-rw-rw-r-- 1 arichiardi arichiardi    5671 Nov 13 10:04  goog.debug.console.js
-rw-rw-r-- 1 arichiardi arichiardi   19066 Nov 13 10:04  goog.debug.debug.js
-rw-rw-r-- 1 arichiardi arichiardi    1713 Nov 13 10:04  goog.debug.errorcontext.js
-rw-rw-r-- 1 arichiardi arichiardi    1797 Nov 13 10:04  goog.debug.error.js
-rw-rw-r-- 1 arichiardi arichiardi   13935 Nov 13 10:04  goog.debug.formatter.js
-rw-rw-r-- 1 arichiardi arichiardi    4312 Nov 13 10:04  goog.debug.logbuffer.js
-rw-rw-r-- 1 arichiardi arichiardi   26315 Nov 13 10:04  goog.debug.logger.js
-rw-rw-r-- 1 arichiardi arichiardi    6131 Nov 13 10:04  goog.debug.logrecord.js
-rw-rw-r-- 1 arichiardi arichiardi    2404 Nov 13 10:04  goog.debug.relativetimeprovider.js

richiardiandrea18:11:01

oh sorry yeah it is there

thheller18:11:21

at this full path /home/arichiardi/git/laputa/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js?

richiardiandrea18:11:15

it seems like it expects in the parent of the project folder

richiardiandrea18:11:44

the project path is /home/arichiardi/git/laputa/event-store/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js

richiardiandrea18:11:11

I must have messed something up

thheller18:11:09

check the :output-to file generated by the build

richiardiandrea18:11:33

yeah that ends up correctly in :output-to "./bin/migrate-event-store"

thheller18:11:46

no .. check the content of the actual file

thheller18:11:00

it'll have something like var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/script/dev/out/cljs-runtime'; at the beginning somewhere

richiardiandrea18:11:10

yeah var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/migrate/dev/out/cljs-runtime';

richiardiandrea18:11:26

I am on 2.6.23 in this project

richiardiandrea18:11:43

and if (__dirname == '.') { SHADOW_IMPORT_PATH = "/home/arichiardi/git/laputa/event-store/.shadow-cljs/builds/migrate/dev/out/cljs-runtime"; }

richiardiandrea18:11:58

it seems like it does not go in the if

thheller18:11:11

its not supposed to

thheller18:11:19

but it seems to go up one level too much

richiardiandrea18:11:24

__dirname is HEY /home/arichiardi/git/laputa/event-store/bin

richiardiandrea18:11:29

I put a console.log

thheller18:11:30

try :output-to "bin/migrate-event-store"

richiardiandrea18:11:20

it works with the above

thheller18:11:00

:output-to is always relative to the project root so ./ is pointless

thheller18:11:19

guess I should add a validation for that or properly normalize the path

richiardiandrea18:11:28

so the scripts runs now but it does not connect to any REPL, I am never sure we added support for :node-script REPLs ๐Ÿ˜„

thheller18:11:27

they always had support

richiardiandrea18:11:57

soooo should the script stop with something like

richiardiandrea18:11:01

{:target :node-script
                    :main laputa.event-store.migrate/-main
                    :output-to "bin/migrate-event-store"
                    :release {:compiler-options {:optimizations :advanced
                                                 :source-map true}}}

richiardiandrea18:11:32

it probably does but it might be a problem in my script...which has option validation with failures

richiardiandrea18:11:11

yeah probably that's what happens

richiardiandrea18:11:18

so never mind about the second issue

richiardiandrea18:11:28

and really thanks about debugging and solving the first

richiardiandrea19:11:18

Today is debugging day, so I have this:

$ cat .shadow-cljs/config.edn 
{:node-modules {:install-cmd ["--network-concurrency" "1" :packages]}}

richiardiandrea19:11:31

but I still see running: yarn add ... packages

richiardiandrea19:11:44

is that the right place where to put that conf?

richiardiandrea19:11:47

oh I see it is in $HOME...but I also can put it in shadow-cljs.edn it seems

richiardiandrea19:11:53

seems to work, definitely nice

richiardiandrea19:11:17

shadow-cljs - config: /home/arichiardi/git/laputa/scrutinize-fn/shadow-cljs.edn  cli version: 2.7.3  node: v8.12.0
shadow-cljs - starting via "clojure"
running: yarn add --network-concurrency 1 ....packages....

thheller19:11:28

yeah shadow-cljs.edn or ~/.shadow-cljs/config.edn

thheller19:11:41

don't think .shadow-cljs in the project dir is a useful location

pvillegas1222:11:53

When we do (shadow/release :prod) for the production build, do we need to do compression ourselves?

thheller22:11:15

compression?

thheller22:11:31

gzip? yes, that is done typically by the webserver

pvillegas1222:11:31

as gzip -9 js-file.js

pvillegas1222:11:40

I mean when doing the release of the assets

pvillegas1222:11:54

I am pushing this to s3

pvillegas1222:11:06

and within the bucket I obviously see the uncompressed js

thheller22:11:27

not sure how s3 handles it but I'd expect it to automatically compress

thheller22:11:34

just check the request the browser makes