Fork me on GitHub
#shadow-cljs
<
2018-01-22
>
robert-stuttaford07:01:25

@thheller does shadow provide npm-deps to gclosure to be included in dead-code elimination and other whole program optimisations as described here? https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules

thheller08:01:56

it can yes but not by default

thheller08:01:50

has some background on why it doesn’t by default

thheller08:01:03

bascially set :js-options {:js-provider :closure} and see if your build still works

thheller08:01:14

if yes great, it no set it back to :shadow 😉

thheller08:01:48

at this point I’d say the chances are less than 50% .. way too many incompatible packages

robert-stuttaford09:01:38

ok - i’ll give it a spin 🙂 thanks!

mhuebert11:01:24

@thheller picking up on an old thread, I got maria building on circleci w/ shadow-cljs: https://github.com/mhuebert/maria/blob/master/.circleci/config.yml (finally got a docker image with java + node + git working.) I ran into weird issues where my circleci would stop build commands in the middle of what they were doing, and call them “successful”. no idea yet what the cause was. i was able to “get it to work” by breaking things up into smaller commands (hence server/start, then three independent server/release commands) but i am not convinced it will be reliable until i find out what was happening there.

thheller13:01:42

@mhuebert npx shadow-cljs start shouldn’t need the background option. it will exit when the server has finished starting. at least in theory.

thheller13:01:10

I started setting up circleci for shadow-cljs itself too. still need to actually run something though. https://github.com/thheller/shadow-cljs/blob/master/.circleci/config.yml

mhuebert13:01:51

@thheller hmm, i thought the problem was that circleci would somehow cause that process to exit without the background option

mhuebert13:01:14

but i don’t fully understand it

thheller13:01:18

hmm from what I understand from the docs the background will just run the process itself in the background

thheller13:01:35

but the node process that starts the process itself will exit anyways

thheller13:01:43

and only waits until the server is started

thheller13:01:04

so that process does not run in the background, it starts a process that runs in the background by itself

thheller14:01:13

oops, the guide

thheller14:01:48

@mhuebert maybe if you combine background with npx shadow-cljs server that works? (instead of start)

thheller14:01:39

@holyjak to be honest the most recent version is always preferred and I don’t actually know the minimum version. I know some code breaks when using node v5

thheller14:01:57

thats why it has v6 as minimum

mhuebert14:01:24

@thheller maybe what i really need to do is figure out why i can’t just run everything in a single shadow-cljs clj-run maria.build/release.. i don’t see any real reason why i should have to run these commands separately

mhuebert14:01:44

and how they are being abruptly stopped and circleci declaring that a success

thheller14:01:30

maybe the logfile in target/shadow-cljs has some clues?

mhuebert14:01:57

i’ll try that later today

mhuebert14:01:02

do another build and ssh in

thheller14:01:21

but yeah the release fn should work fine

thheller14:01:56

you can just run npx shadow-cljs release live trusted bootstrap

mhuebert14:01:05

yeah, i only created the build script as part of the debugging, to see if it made a difference

mhuebert14:01:11

i was using that command earlier

mhuebert14:01:18

either way, the process exits

mhuebert14:01:34

at unpredictable times and without any message in the circleci logs

hlolli14:01:55

wow, very nice site! I have handful of people I could recommend this to 🙂 @mhuebert

mhuebert14:01:31

@thheller here is the circleci log for an example of the problem: https://circleci.com/gh/mhuebert/maria/322

mhuebert14:01:41

if you click on the pwd; ls; cd editor; npm install; npm run release; command

mhuebert14:01:46

it shows up as green,

mhuebert14:01:20

but it ended itself just after beginning the :bootstrap build. this is the very end of the log:

[:bootstrap] Compiling ...
-> Converting 31 JS sources
<- Converting 31 JS sources (3215 ms)
-> JS Cache write: 31 JS files
<- JS Cache write: 31 JS files (70 ms)
-> Compile CLJS: cljs/core.cljs
<- Compile CLJS: cljs/core.cljs (15735 ms)

thheller14:01:21

now I remember. running the builds in parallel wasn’t great with circleci

thheller14:01:12

but yeah thats not parallel. no idea why it would exit

mhuebert14:01:27

here is an example where I put npx shadow-cljs start into a command (without background: true), then ran subsequent builds - https://circleci.com/gh/mhuebert/maria/325 the build after shadow-cljs start:

#!/bin/bash -eo pipefail
cd editor; npm run release;

> @ release /root/project/editor
> rm -rf public/js/bootstrap; shadow-cljs clj-run maria.build/release;

shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.139
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?

robert-stuttaford14:01:51

circleci’s VMs are pretty constrained. we switched to using our own instances with http://buildkite.com - clojure / cljs builds need lots of cpu

mhuebert14:01:41

that may indeed have sth to do with it

mhuebert14:01:22

looks like buildkite offers free accounts for open source, so may be a good fit for maria

robert-stuttaford14:01:14

well worth a try 🙂

thheller14:01:33

@mhuebert if you use background try server instead of start so circleci can take back of backgrounding the process

thheller14:01:39

instead of letting the node script do that

thheller14:01:43

what happens if you just run npx shadow-cljs release bootstrap and the other 2 builds after each other without the server?

thheller14:01:02

just let it start 3 times?

mhuebert14:01:16

@thheller I can’t remember if i tried that

mhuebert14:01:24

i will try using server instead of start

thheller14:01:20

maybe as the last command just cat target/shadow-cljs/shadow-cljs.log.0 just in case

mhuebert14:01:30

circleci’s docs say: The background attribute allows for executing commands in the background. In this case, job execution will immediately proceed to the next step rather than waiting for the command to return.

thheller14:01:32

yeah probably need to sleep for a bit

mhuebert14:01:55

for the cache key, do you think v1-dependencies-{{ checksum "editor/package.json" }}--{{ checksum "editor/shadow-cljs.edn"}} would be sufficient

mhuebert14:01:18

ie. package.json + shadow-cljs.edn

mhuebert14:01:12

am wondering how long to sleep for, if dependencies have changed it might take longer for the server to start?

thheller14:01:41

hmm true. no idea. start is supposed to solve that

thheller14:01:50

since it exits when the server is started

mhuebert14:01:44

i will try that again

jgdavey14:01:22

I’ve got an interesting issue. We’re using hiccup-like syntax for shared views in .cljc files, and it works with both server- and client-rendered libs. In one particular form field, :phone_number, the input’s name attribute is set to phone_number in development mode (watch), but after doing a shadow-cljs release, that field becomes phone-number. Other underscored field names seem to be unaffected.

mhuebert14:01:08

tried using start again and got the same,

shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.139
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?
deleted pid file, please retry command to start new server
Exited with code 1

mhuebert14:01:16

will try now not using the server at all

thheller14:01:01

@jgdavey no idea? shadow-cljs definitely never rewrites strings/keywords in any way? what does the code do?

jgdavey14:01:17

(I’m using the latest version of shadow-cljs, and have tried dumping caches, etc)

jgdavey14:01:10

It’s hiccup-style view code. I’ll dig further into our libs, but the fact that it acts differently between dev/release seemed odd

thheller14:01:55

yeah .. doh … so in shadow-cljs release keywords are optimized

thheller14:01:03

so they are only allocated once

thheller14:01:57

so it replaces the new cljs.core.Keyword(null, "phone_number", hash, meta) calls with cljs$cst$kw$phone_number variables

jgdavey14:01:19

Ah, interesting. But wouldn’t :phone-number be different than :phone_number?

thheller14:01:27

BUT if you have :phone_number AND :phone-number in your code the normalized JS variable name replace each other

thheller14:01:37

since - is just replaced by _ blindly

jgdavey14:01:46

Interestingl…

thheller14:01:18

let me fix that damn munge function from closure

jgdavey14:01:08

Cool. Everything else’s been working great, in prod. First issue we’ve hit with optimized js

mhuebert14:01:38

@thheller ok, i think i will just abandon the server idea. for deploy I just want something as reliable as possible and a few extra seconds isn’t so important

thheller14:01:45

@mhuebert I’ll try to figure out whats going on. I need it for shadow-cljs CI itself, just first need to figure out the npm side of things since I can’t npm install shadow-cljs there

jgdavey14:01:32

That was quick 🙂

mhuebert14:01:27

@thheller i added that cat log command. are any of these “waiting for…” messages significant? https://circleci.com/gh/mhuebert/maria/335

thheller14:01:49

funny enough I fixed that issue once before in CLJS itself. https://dev.clojure.org/jira/browse/CLJS-1105 😉

thheller14:01:42

@mhuebert not really. its just the parallel compile waiting for other files to compile first

jgdavey14:01:55

@thheller Nice work. 🙂 Thanks again!

thheller14:01:57

they will timeout eventually but it will log the abort

thheller14:01:47

@mhuebert what is odd is the number of logs. there should be more than <number of cpu cores> log messages

mhuebert15:01:17

@thheller weird, i just tried a new deploy after clearing the caches, and after everything ran successfully it said:

#!/bin/bash -eo pipefail
cat target/shadow-cljs/shadow-cljs.log.0
cat: target/shadow-cljs/shadow-cljs.log.0: No such file or directory
Exited with code 1

thheller15:01:12

hmm guess there was nothing to log? the file is created lazily on the first log output

mhuebert15:01:23

now it will try printing the log if the build failed & do nothing if the log doesn’t exist:

- run:
          command: cat target/shadow-cljs/shadow-cljs.log.0 2> /dev/null
          working_directory: ~/project/editor
          when: on_fail

lilactown21:01:31

is there a way to get lein’s “checkouts” functionality working with shadow-cljs?

Jakub Holý (HolyJak)22:01:09

@thheller typo in 7.1.2 of the guide: «Add start/top hook functions.»

Jakub Holý (HolyJak)22:01:18

Also «Adding hooks for hot core reload.»

thheller23:01:37

thx. fixed.

thheller23:01:56

@lilactown just add the :source-paths and keep it in :dependencies. or you use the lein integration