Fork me on GitHub
#shadow-cljs
<
2017-10-20
>
mhuebert14:10:49

cljsbuild is deleting stuff from node_modules

mhuebert14:10:10

lein new re-view xyz;
cd xyz;
yarn install;
# node_modules/shadow-cljs is correct
lein figwheel;
# node_modules/shadow-cljs is empty

thheller14:10:48

why would they do that?

mhuebert14:10:57

seems crazy to me.

thheller14:10:40

hmm do they maybe delete everything and then install :npm-deps from deps.cljs only?

thheller14:10:49

while totally ignoring package.json?

mhuebert14:10:50

i think i will post in #cljs-dev

mhuebert14:10:17

if you run those lines above, do you see the same thing? would hope it is not something specific to my machine

thheller14:10:52

its still there

mhuebert14:10:21

shadow-cljs-jar too?

mhuebert14:10:28

for me shadow-cljs directory stays but is emptied

thheller14:10:52

wow yes its empty

thheller14:10:14

what the heck, shadow-cljs-jar is gone too

mhuebert14:10:18

but shadow-cljs-jar is totally removed

thheller14:10:44

I don’t get it

mhuebert14:10:10

i am trying with left-pad

mhuebert14:10:22

deleted left-pad, but did re-order package.json

thheller14:10:30

hmm it seems to be npm not lein

thheller14:10:50

yarn install then npm install react and its gone

thheller14:10:57

yeah its npm

thheller14:10:47

if you start with npm install then everything is fine

thheller14:10:59

so npm install instead of yarn install first

thheller14:10:09

yeah the problem is running npm install react without running npm install first

thheller14:10:27

npm install with package names does not install things from package.json first

mhuebert14:10:18

so npm install with a package name uninstalls things?

mhuebert14:10:35

what on earth

thheller14:10:55

it works if you npm install first since then its in the package-lock.json

thheller14:10:17

seems like an npm bug

mhuebert14:10:36

npm install instead of yarn install

thheller14:10:38

thats why shadow-cljs now detects if there is a yarn.lock and then uses yarn to install npm deps 😉

mhuebert14:10:34

i was hoping to be able to use this re-view template as a nice way to compare things between shadow and cljsbuild

mhuebert14:10:49

because i want it to support both anyway

thheller14:10:58

yeah I was just looking at that 🙂 don’t actually know how those tools work

thheller14:10:18

might not be the best idea to have both in one template though

thheller14:10:34

this stuff tends to stay there

mhuebert14:10:18

npm run Error: missing script: shadow-cljs

mhuebert14:10:29

you had mentioned npx but i really wish another dep wasn’t necessary

thheller14:10:39

npx should come with npm5

mhuebert14:10:06

i see, i can put npx commands into "scripts" in package.json so the user still just runs npm run ... to activate the script

thheller14:10:26

its a bit weird

thheller14:10:28

npm shadow-cljs help

thheller14:10:13

npx shadow-cljs help works

thheller14:10:01

npm run shadow-cljs help doesn’t work though?

mhuebert14:10:22

"scripts": {
    "deps": "npm install; npx shadow-cljs npm-deps;",
    "watch": "npx shadow-cljs watch browser;",
    "release": "npx shadow-cljs release browser;"
  },

thheller14:10:26

didn’t it use to work like that before?

mhuebert14:10:36

i thought so yes

thheller14:10:48

guess they replaced that with npx

mhuebert14:10:49

with the above config i can run npm run deps/watch/release

mhuebert14:10:06

so npm run looks at "scripts" but not other stuff

mhuebert14:10:50

bit of formatting feedback, the website URL when running watch and so is a bit hidden in the stream, and the other urls (server/socket-repl/nrepl) more obvious. for a tutorial context it might be hard to explain where a user should look

thheller14:10:24

yeah all that could be better

thheller14:10:31

the real idea is to have a UI for everything

thheller14:10:44

so you just open the UI and see all the important stuff

thheller14:10:52

just didn’t build that yet

Jon15:10:21

I always use

yarn watch

thheller15:10:24

the whole package.json scripts situation seems rather developer-unfriendly

thheller15:10:58

yarn watch with "watch": "npx shadow-cljs watch browser;" then uses npx right? so only fake yarn 😛

Jon15:10:53

no need npx in yarn. just watch: shadow-cljs watch browser

Jon15:10:38

didn't know there is an npx XD

thheller15:10:10

@mhuebert right, I do think that "watch": "shadow-cljs watch browser;" will use the correct thing as well. shouldn’t need npx

mhuebert15:10:35

even if shadow-cljs is not installed globally?

thheller15:10:54

yarn is smart enough to use the local install, npm should too

Jon15:10:43

as long as shadow-cljs in node_modules/.bin/

mhuebert15:10:03

ah that is simpler

thheller15:10:30

Figwheel Says: Your code didn't compile.

thheller15:10:36

thats neat I should do that

mhuebert15:10:51

having errors pop up into the browser can be nice

mhuebert15:10:25

but would need to think about what to do with warnings that the user is not in control of

thheller15:10:30

Assert failed: cljs.analyzer/foreign-dep? expected symbol got "react"
(symbol? dep)

thheller15:10:56

I thought they support strings

mhuebert15:10:16

they do, that error comes up sometimes. i think you can get around it by deleting the out folder

mhuebert15:10:24

whatever teh out folder is for that build

mhuebert15:10:21

a shadow release is ~25sec vs 38.5sec for lein cljsbuild once prod but not really apples to apples because cljsbuild is running the JS through closure

mhuebert15:10:03

also why the closure build is 229 vs 260 kb

mhuebert15:10:41

:js-provider :closure doesn’t work for me with shadow

mhuebert15:10:35

not that it’s high priority, i think closure still fails on many js libs

thheller15:10:51

yeah I didn’t touch the closure support in a long time

mhuebert15:10:03

maybe not worth touching until it is more reliable itself

thheller15:10:25

229 vs 260 kb is worth fixing it

thheller15:10:36

if it works for that build there is no reason not to use it

thheller15:10:24

what am I doing wrong?

thheller15:10:45

[[email protected] ~/code/tmp/xyz]$ lein cljsbuild once prod
Compiling ClojureScript...
[[email protected] ~/code/tmp/xyz]$

thheller15:10:54

it just doesn’t do anything?

thheller15:10:38

wait I seriously have to delete the files?

mhuebert15:10:40

you have to delete the previous base.js

mhuebert15:10:42

it’s super awful

mhuebert15:10:59

i wasn’t sure if that happened just on my machine but apparently not 🙂

thheller15:10:51

the cljsbuild prod build errors out

thheller15:10:13

EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, Sh`.`

thheller15:10:29

I think the react externs are missing, which are required for react

thheller15:10:58

can’t figure it out .. even adding the externs doesnt fix it

thheller15:10:09

so the 229k is not quite accurate 😉

thheller15:10:13

at least the shadow-cljs release build works as expected. I happily trade 6kb gzip’d for that 🙂

thheller16:10:35

hehe .. yeah the closure support has long ways to go … I fixed the shadow-cljs side but it doesn’t work at all

thheller16:10:51

compiles fine but the the events don’t work (in the html)

thheller16:10:09

closure compiled base.js (387838 bytes) vs shadow JS base.js (259697 bytes)

thheller16:10:44

223K when compiled properly with closure and externs .. but doesn’t work at runtime

thheller16:10:55

@mhuebert btw npm-deps is now automatic, no need to call it anymore

mhuebert18:10:18

@thheller great, that simplifies instructions

mhuebert22:10:22

this is weird, i have never seen that inject-plugins error

mhuebert22:10:27

but now I get the same thing

mhuebert22:10:50

also with cljsbuild I get a JSC_MISSING_PROVIDE_ERROR unless I delete the out folder in-between builds

mhuebert22:10:25

very possible i have outdated externs

mhuebert22:10:30

with pseudo-names, EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, $SimpleEventPlugin$`.`

mhuebert22:10:08

i think that’s it. externs are from React 15. nothing newer that i can find anywhere