Fork me on GitHub
#shadow-cljs
<
2020-04-20
>
knubie01:04:48

Are you still optimistic about the worker stuff?

wilkerlucio02:04:35

hello, I've a project that I'm getting a lot of debug logs like

19:40:50.929 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
19:40:51.646 [main] INFO  io.undertow - starting server: Undertow - 2.0.30.Final
19:40:51.655 [main] INFO  org.xnio - XNIO version 3.8.0.Final
19:40:51.664 [main] INFO  org.xnio.nio - XNIO NIO Implementation Version 3.8.0.Final
19:40:51.728 [main] INFO  org.jboss.threads - JBoss Threads version 3.1.0.Final
19:40:51.737 [XNIO-1 I/O-2] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-2', selector [email protected]
19:40:51.737 [XNIO-1 I/O-3] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-3', selector [email protected]
19:40:51.737 [XNIO-1 I/O-4] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-4', selector [email protected]
19:40:51.737 [XNIO-1 I/O-6] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-6', selector [email protected]
19:40:51.737 [XNIO-1 I/O-1] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-1', selector [email protected]
19:40:51.737 [XNIO-1 I/O-7] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-7', selector [email protected]
19:40:51.737 [XNIO-1 I/O-5] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-5', selector [email protected]
19:40:51.738 [XNIO-1 I/O-8] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-8', selector [email protected]

wilkerlucio02:04:54

is there a way for me to debug why I'm getting the verbose, and how to tune it down?

steveb8n05:04:25

Q: I like the “hacking libraries” capability. Should this also work for hacking npm dep sources?

thheller06:04:28

@wilkerlucio if you are running the embedded version logging is subject to your logging config. so you configure it and can just disable it if you want.

steveb8n06:04:47

Good to know. Thanks. I can still do the local clone/patch with my npm deps. that’s working well.

wilkerlucio06:04:24

@thheller do you have an example of that config?

thheller06:04:40

I don't. You do.

thheller06:04:48

What do you use for logging in your app?

thheller06:04:01

logback.xml, log4j.properties, etc?

wilkerlucio06:04:03

nothing, I'm guessing some dependency is doing it

thheller06:04:24

check via shadow-cljs clj-repl ( "logback.xml") or so

thheller06:04:34

something must be configuring the logging somewhere

thheller06:04:37

I'm a bit rusty when it comes to jvm logging setups

wilkerlucio06:04:09

it seems to happen on my deps projects, on lein ones it seems normal

wilkerlucio06:04:36

not just on shadow really, I see the same issue in other projects with just deeps

wilkerlucio06:04:42

gonna dig down

thheller06:04:28

check your dependencies for a logging lib

thheller06:04:34

log4j, logback etc

thheller06:04:58

some libs have direct deps on them when they shouldn't

thheller06:04:30

need to find which lib is doing the actual logging to disable it 😛

thheller06:04:37

@wilkerlucio log4j.properties in one classpath root with

log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{HH:mm:ss,SSS}] %m%n

thheller06:04:48

should make it shutup .. but only if your logger is log4j

thheller06:04:53

I don't have a config for logback

Andrea Russo08:04:34

I have an hybrid project, where I use some JSX files. I’m able to convert them with babel in standard JS and consume them from ClojureScript in a re-frame app.

Andrea Russo08:04:01

my problem arises when I try to import a local Js file in another JS file

Andrea Russo08:04:56

import { ProTip } from ‘./ProTip’;

Andrea Russo08:04:27

the closure compiler says that it can’t understand import from directories

thheller08:04:54

please post actual code with actual messages. makes it much harder to follow if you shorten things.

Andrea Russo08:04:42

yes sorry I’m trying to replicate the problem, now I have other errors that happens before the one I described

thheller08:04:44

I don't really recommend including too many .js files. the system isn't really tuned for that and has a lot of issues I haven't had time to work on.

Mark Bailey08:04:52

Hey everyone! Setting up a new template for projects and shadow keeps alerting me "Stale Client". Not sure why it keeps doing so, even on a page refresh

thheller08:04:25

means you are loading outdated .js code

thheller08:04:48

common cause is changing the output directory or names but not adjusting your html accordingly

Mark Bailey08:04:52

checking over my html, everything seems to be in place

Mark Bailey08:04:11

output dir is set correctly as well it seems

thheller08:04:21

if you are using a different http server it might be caching related

thheller09:04:22

could also be that you have 2 separate shadow-cljs instances running competing with each other

Mark Bailey09:04:00

what if they are running on different ports?

Mark Bailey09:04:22

i have two dev instances running on different tmux boxes but on separate ports

thheller09:04:30

I mean in the same project

thheller09:04:43

you can have as many different projects as you like

thheller09:04:49

just don't run shadow-cljs twice in the same project

Mark Bailey09:04:20

okay, that makes sense but that doesn't seem to be whats going on. mind if i throw you a github link?

Mark Bailey09:04:14

committing now, one sec. sorry for the delay

Mark Bailey09:04:29

in the meantime, @thheller you did an absolutely stellar job with shadow, my guy. CLJS has been an incredible journey and shadow has drastically improved my ux!

thheller09:04:38

looks fine. a bit dated maybe but fine.

Mark Bailey09:04:19

did a clean and im running npm install again. i'll go through the whole set up and if it works

thheller09:04:21

{init-fn app.core/init} is incorrect though

Mark Bailey09:04:04

okay! that was my initial guess as to why it wasn't giving me a non-stale build

thheller09:04:41

{:source-paths ["src"]

 :dependencies [[nrepl "0.7.0"]
                [cider/cider-nrepl "0.25.0-alpha1"]
                [proto-repl "0.3.1"]
                [binaryage/devtools "1.0.0"]
                [reagent "0.10.0"]
                [re-frame "0.12.0"]
                [day8.re-frame/re-frame-10x "0.6.2"]
                [bidi "2.1.6"]
                [kibu/pushy "0.3.8"]]
 :nrepl {:port 3334}

 :dev-http {8080 "public"}

 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"

   :modules
   {:main
    {:init-fn app.core/init
     :preloads [day8.re-frame-10x.preload]}}

   :dev
   {:compiler-options
    {:closure-defines {re-frame.trace/trace-enabled? true
                       day8.re-frame.tracing/trace-enabled? true}}}}}}

thheller09:04:12

shadow-cljs watch app should complain about the bad {init-fn ...}?

thheller09:04:32

so yeah it would be stale after that since it never finishes the compile

Mark Bailey09:04:31

no complaint, and says build completed

thheller09:04:35

fixed in master 😉

Mark Bailey09:04:27

i'm sorry i don't understand, i've never had someone else edit my code with git

thheller09:04:10

no I mean I fixed it in shadow-cljs. with the next release {init-fn ...} will fail properly and show an error

Mark Bailey09:04:33

wow. my level of tiredness is showing

Mark Bailey10:04:09

@thheller I've gone through every setting I can think of to no avail. It's still giving me a stale client warning

Mark Bailey10:04:03

I am going through Jacek Schae's tutorial on re-frame, this is basically his template, just with updated deps. everything is fine running his template, but as soon as i update deps, things get wonky with the stale client warning

thheller11:04:58

@mbbailey96 verify that you are actually loading what you are think you are loading

thheller11:04:26

you get a stale client warning when the .js you are loading was not produced by the running watch

thheller11:04:00

there aren't that many places that can cause this

Mark Bailey11:04:15

main.js is supplied by watch afaik, which is being compiled. it is stored in my js/ folder, which is definitely linked in my index.html.

Mark Bailey11:04:05

I haven't been getting any build errors, main is compiled and in the right directory, i just don't know what I am missing

Mark Bailey11:04:23

when I try to run (js/alert) it's giving me an error "No such namespace: js". Can't interact with the site at all through repl. Might this be a cause or a help determining what is going wrong?

thheller11:04:58

that means you are in a CLJ REPL not a CLJS REPL

thheller11:04:12

but not that doesn't mean anything

thheller11:04:19

lets go step by step

thheller11:04:21

shut down shadow-cljs

thheller11:04:44

open the webpage? do you get something? if yes something else is running somewhere

thheller11:04:52

delete public/js

thheller11:04:58

open the webpage? does it 404 properly?

thheller11:04:39

you are looking all over the place if all you need to check if file you think you are loading are the actual files you are looking at

Mark Bailey11:04:25

@thheller i was still getting connection from elsewhere.

Mark Bailey11:04:33

thank you for all the help!!

Andrea Russo13:04:16

I can’t believe that yesterday this import (and others) worked:

Andrea Russo13:04:31

(ns dias-web.common-ui (:require [re-frame.core :as re-frame] [dias-web.subs :as subs] [“@material-ui/core/styles/MuiThemeProvider” :default ThemeProvider] [“@material-ui/core/styles” :refer [createMuiTheme withStyles]] [“@material-ui/core/colors” :as mui-colors] [“@material-ui/core/CssBaseline” :default CssBaseline] [“@material-ui/core/Typography” :default Typography] ; [“@material-ui/core/Avatar” :default mui-avatar] ; [“@material-ui/icons/Android” :default AndroidIcon] [“@material-ui/core/AppBar” :default AppBar] [“@material-ui/core/Toolbar” :default ToolBar] [“@material-ui/core/IconButton” :default IconButton] [“@material-ui/icons/Menu” :default MenuIcon] [“@material-ui/core/Button” :default Button]))

Andrea Russo13:04:46

and today everything compiles but at runtime it says:

Andrea Russo13:04:55

Failed to load dias_web/common_ui.cljs Module not provided: module$node_modules$$material_ui$core$styles$index

Andrea Russo13:04:16

It’s very strange, everything the same as yesterday

Aron13:04:45

I would like to ask for some orientation (I am already reading the docs but I have some questions that are more basic than what the docs assumes). Basically, I am not even sure if it's possible, or rather I assume it's possible but I am not sure if I should do what I want to do : ) I would like to have specs added next to my devcards build that would complain during development if I mess up some argument to functions (or let bindings in components) or the output of some functions. Is there some guide regarding this that I could read to get up to speed?

thheller14:04:25

@andrea.russo looks fine as far as I can tell. "Failed to load" sort of creates a chain reaction. One thing fails to load and then a whole bunch of others that depend on that also fail so you gotta fine the actual failing thing

thheller14:04:46

@ashnur clarify "specs added"? shadow-cljs only compiles stuff for you. you are responsible for adding stuff to the build and requiring it. I typically recommend adding specs to extra namespaces. so for (ns app.foo) you also have (ns app.foo-spec) and then load that ns via :preloads or some other means

Aron14:04:35

adding the files and writing in the namespace and the tests is what is the most clear thing in this process

Aron14:04:24

the preloads stuff, I have no idea why it is preload, compared to what, I am guessing there is a lot of history here where these names and approaches are coming from. I only know javascript, if I want something like this, I have to bundle in with the rest of the app

thheller14:04:41

:preloads is badly named yes but it is what it is. It is for namespaces that should only be added to the build in development.

Aron14:04:09

sorry, I didn't mean to criticize, I just don't understand 😐

thheller14:04:10

they are added "before" the other code so they are sometimes loaded before the other code

thheller14:04:31

but they can depend on other code in which they that code will be loaded before them

Aron14:04:35

ok, so it is similar as the namespace that I write in my file?

thheller14:04:04

it IS just a regular namespace yes

thheller14:04:16

you just don't require them from any other namespaces

Aron14:04:57

I hate when I am stupid, I added the file, wrote in the namespaces, specified the file/namespace in the vector of preloads for the build that I am running, if I change the file I can see shadowcljs picking the change up and rebuilding, but a simple (prn 'foo) has no output

Aron14:04:19

the relationship between namespaces/filenames is as obscure as ever for me

Aron14:04:34

so I use the same for both, hopefully that should work

thheller14:04:09

@ashnur you are not stupid. you are learning, it is ok to make mistakes. it is ok to ask questions ... that is how we learn.

👏 16
thheller14:04:36

namespace and filename are really the same thing. there are just a few basic rules for namespaces and which filename they should have

thheller14:04:44

(ns foo.bar) should be foo/bar.cljs

thheller14:04:03

(ns foo.with-a-dash) should be foo/with_a_dash.cljs

thheller14:04:23

the names go onto the classpath, meaning you pick one of your source-paths and put them there

thheller14:04:25

thats it really

thheller14:04:50

and yes the name of the namespace MUST match the filename

thheller14:04:54

otherwise it won't be found

thheller14:04:48

prn not showing up I don't know. if you do everything correctly it should.

Aron16:04:35

it works, for some reason I forgot to put the :preloads under :devtools facepalm

lilactown16:04:29

hey thheller, I am getting a bunch of $jscomp errors when using dependencies that ship es6+ code, unless I bump :output-feature-set to match the level required not to compile them

lilactown16:04:05

a not-completely-minimal-example is this project: https://github.com/geraldodev/react-form-hook-test when i boot this up, I see a couple errors about $jscomp.makeIterator changing the :output-feature-set to :es6 makes these go away. then I try and type something in a field, which throws an error about $jscomp with the stacktrace pointing at an async function. bumping the :output-feature-set to :es8 makes this go away.

Andrea Russo16:04:26

@thheller I’ve found that if I delete the .shadow-cljs/ and rebuild everything works. As soon as I stop the build and the start another without deleting the .shadow-cljs directory, I have the module loading problem

lilactown16:04:07

i'll open a github issue

Andrea Russo16:04:51

I can share with you the repo I’m working on, if you are interested seeing this behaviour

Andrea Russo16:04:28

by deleting everytime the .shadow-cljs I’m able to work, which means I’m stuck again with another problem, maybe this one is something related to the closure compiler, which does not accept directory paths in javascript files when importing other files:

Andrea Russo16:04:34

losure compilation failed with 1 errors
--- App.js:6
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)

Andrea Russo16:04:05

These are imports from the App.js file:

Andrea Russo16:04:12

import * as React from ‘react’; import Container from ‘@material-ui/core/Container’; import Typography from ‘@material-ui/core/Typography’; import Box from ‘@material-ui/core/Box’; import Link from ‘@material-ui/core/Link’; import * as ProTip from ‘./ProTip’;

Andrea Russo16:04:31

and the problem is importing a local file called ProTip.js

Andrea Russo16:04:52

which is in the same directory of App.js

Andrea Russo16:04:40

oh sorry, and this is my shadow-cljs.edn

Andrea Russo16:04:40

{:lein true :nrepl {:port 8777} :builds {:app {:target :browser :output-dir “resources/public/js/compiled” :asset-path “/js/compiled” :modules {:app {:init-fn dias-web.core/init :preloads [devtools.preload day8.re-frame-10x.preload]}} :dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true day8.re-frame.tracing.trace-enabled? true}}} :devtools {:http-root “resources/public” :http-port 8280 }}}}

Andrea Russo16:04:31

oh now I read that you are discouraging having more than a bunch of js files in a shadow-cljs project

Andrea Russo16:04:15

any suggestion on how to coordinate me, using cljs, and my other cooworkers, using js? Maybe a magic live changing local node module in node_modules?

Ivan Fedorov18:04:20

Seeing those sometimes now after a version upgrade I think.

[:dev] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/spacegangster/clj/lightpad/client/src/flow/views/tasks/microtasks.cljs:6:1
--------------------------------------------------------------------------------
   3 |             [space-ui.style.constants :as sc]
   4 |             [space-ui.style.constants :as sc]))
   5 |
   6 | (def ^:const dim-item-side-px (sc/px sc/dim-step))
-------^------------------------------------------------------------------------
Error in phase :compilation
Can't redefine a constant at line 6 flow/views/tasks/microtasks.cljs
--------------------------------------------------------------------------------
   7 | (def ^:const dim-fs ".9rem")
   8 |
   9 | (def rules1
  10 |   [:.microtasks
Version output
=== Version                                                                        
jar:            2.8.97            
cli:            2.8.97               
deps:           1.3.2                   
config-version: 2.8.97  
Previously was on: ^2.8.91

Ivan Fedorov18:04:54

Will add an issue on demand

thheller20:04:20

@ognivo just don't use ^:const. it doesn't do what you think it does. do not use it. there is no point. also why is [space-ui.style.constants :as sc] imported twice? line 3/4?

👍 4
Ivan Fedorov19:04:06

ok, thanks! I think I saw it somewhere in Mike Fikes twits

thheller20:04:44

@andrea.russo I can't help much with this. I need something reproducible to figure out what is happening. deleting the cache shouldn't be necessary so that sounds like a bug.

thheller20:04:21

I always thought bash was bad but the syntax of powershell is ridiculous .. who comes up with this shit ...

🙂 4
isak20:04:54

yea they messed up pretty bad

Andrea Russo22:04:38

@thheller I can give you access to the repo if you want to reproduce the behaviour. I’m really sorry, I’m in a hurry with a project at work and I don’t have time to contribute with a minimal project that exposes this behaviour.

Aron22:04:03

i thought powershell syntax was intuitive 😄