Fork me on GitHub
#shadow-cljs
<
2018-05-16
>
jjttjj00:05:31

Cool, yeah something like that. Search definitely needs improvement. Also was thinking some backup mechanisms

jjttjj00:05:35

Basically just want a playground where I can mess with files+UI :)

bupkis05:05:47

what would be the best way, in a shadow-cljs build to include CSS that's bundled with an NPM module? For the javascript itself, i'm using the shadow-cljs Guide's recommendation of "some-lib" :default SomeExport in the ns :require, etc., but not sure how to include the CSS. In JS I could use a similar import statement for the CSS, but here I've resorted to copying the file out of the npm_modules subdir and into my :http-root

thheller06:05:27

@samuel.wagen yeah CSS "includes" are not yet supported. didn't have time to work on it yet.

bupkis06:05:06

@thheller thanks, that's fine, I'll use my bandaid for now 🙂

bupkis06:05:43

if you point me in the right direction, I might try to implement it myself

thheller06:05:48

Nothing to point to really. I have a basic idea for a concept but nothing implemented yet.

thheller06:05:04

I also won't do it via ns require. I think that is a bad idea.

thheller06:05:17

It will probably be some kind of macro

thheller06:05:31

(assets/include "./some.scss")

bupkis06:05:33

yeah I agree, overloading ns require to do too much feels hacky

thheller06:05:57

(assets/resource-uri "./some.png" :size "300x200")

bupkis06:05:11

that would be lovely 🙂

thheller06:05:11

thats the current concept

thheller06:05:28

just need a way to do it that doesn't break the compiler cache

thheller06:05:54

and is sort of flexible/extendable enough to support sass/less/imagemagick/...

bupkis06:05:33

maybe sass/less could stay like the current include of own js files - the processor runs externally and shadow-cljs only deals with the produced artifacts (https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects)

thheller06:05:25

problem is you can't process them one by one. you need to collect all and then process them together

thheller06:05:37

I will probably do a "simple" version first that doesn't do anything and just records which resources were "included"

thheller06:05:52

and then export that info so another tool can do the actual work

thheller06:05:39

I have some custom tooling built on top of node-sass in my work project

thheller06:05:56

might just extract it from there

kurt-o-sys09:05:39

If I get it well, cljsjs packages don't work pretty well with shadow-cljs? At least, I can't make it work with [cljsjs/auth0-lock "11.5.2-0"]

kurt-o-sys09:05:06

So I tried to add the auth0-lock to package.json

kurt-o-sys09:05:15

"dependencies": {
    "auth0-lock": "^11.6.1",
   ...
}

kurt-o-sys09:05:34

but than, I get this:

The required JS dependency "auth-lock" is not available, it was required by "ui_app/components/navbar.cljs".

You probably need to run:
  npm install auth-lock

kurt-o-sys09:05:50

(and I ran npm install auth-lock already a few times, but it's still the same...)

kurt-o-sys09:05:01

I guess I must be missing something 😛

thheller09:05:08

auth0-lock or auth-lock? which one is it? 😛

kurt-o-sys09:05:27

thx a lot for solving this extremely hard bug 😉

denik17:05:26

this also prevents me from getting back into the parent clj process

denik17:05:07

and it seems to have killed cljs compilation

denik17:05:36

finding myself restarting the repl more than in comfy in clojure 😕

thheller17:05:10

what did you send before the timeout?

thheller17:05:20

quitting the REPL should never be necessary

thheller17:05:07

if all else fails you can do (shadow.cljs.devtools.server/reload!)

thheller17:05:43

but no without more info I have no idea what could be happening

denik17:05:59

I deleted a function which caused the recompile. afterwards I got the time out ¯\(ツ)

denik17:05:14

(shadow.cljs.devtools.server/reload!) from the timed out repl?

thheller17:05:29

> I deleted a function which caused the recompile.

thheller17:05:32

what does that mean?

thheller17:05:58

the :cljs/quit didn't timeout? I can't see what you sent before the first :cljs/quit and :cljs/quit technically cannot timeout since it is never sent to the client

thheller17:05:06

I suspect that you are in a CLJ REPL already? I cannot tell which client you are using. are you running standalone or embedded? too many moving parts, need to narrow it down

denik17:05:18

I was in a CLJS repl, sorry should’ve made that clear

denik17:05:28

using shadow-cljs embedded

thheller17:05:04

yes I recognize that error but I need to know what triggered it. so you must have sent something but I can't see what was sent

denik17:05:06

now hitting this:

[:app] Compiling ...
[:app] Build failure:
The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/util/dom.cljs".

denik17:05:18

it previously worked

denik17:05:51

I didn’t send anything. The message before this was a recompile log.

thheller17:05:41

anything in the log? should get a warning why it is not available

thheller17:05:39

since you are running the embedded version: what else are you doing in the VM? use tools.namespace or anything like that?

thheller17:05:49

that can seriously mess with things

denik17:05:14

I’m using mount which uses tools.namespace I believe

denik17:05:38

not getting more warnings

[:app] Compiling ...
[:app] Build completed. (928 files, 2 compiled, 0 warnings, 0.78s)
[:app] Compiling ...
[:app] Build failure:
The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/core.cljs".

thheller17:05:18

yeah sorry. not a clue. is that after a fresh restart or still in this broken state?

thheller17:05:19

tools.namespace can critically mess with the internal state of the shadow-cljs server runtime

thheller17:05:45

so you might need to reload! that at some point

thheller17:05:49

embedded you are pretty much on your own which is why I don't recommend doing that

thheller17:05:18

you gain nothing but these kinds of headaches from it

denik17:05:01

Fresh restart

thheller17:05:58

in the clojure REPL try ( "net/cgrand/xforms.cljc") after it fails

thheller17:05:13

no idea why it would disappear

thheller17:05:30

you can turn on debug logging

thheller17:05:46

but that depends on which logging framework you are using in embedded

thheller18:05:46

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

log4j.logger.shadow=DEBUG

thheller18:05:55

this is my log4j.properties

denik18:05:06

AFK will try in a second.

denik18:05:12

Should I turn verbose on?

thheller18:05:30

probably wont be much help

thheller18:05:53

the classpath indexer is not part of the build so its errors go to the log instead

denik18:05:30

I use the repl because I want to get rid of the command line. There are to many build commands that need to be run in a certain order etc to get a project going. My current setup I run one Clojure function in the repl and it takes care of shadow-cljs and the backend. Is there a way to manage multiple Clojure repls each with their own jvm from one (master-)repl?

thheller18:05:41

which client are you using?

thheller18:05:46

I do understand the desire to have all of this running with one click

🙏 4
denik18:05:02

what do you mean by client?

thheller18:05:08

REPL client

denik18:05:17

intellij cursive

denik18:05:23

lein repl local

thheller18:05:21

unfortunately it is not so easy to completely isolate shadow-cljs due to clojure being hard to isolate

thheller18:05:43

but first we should get your logging setup done

thheller18:05:54

so we can at least get a clue about what is going on

thheller18:05:19

are you using any kind of logging currently? log4j, logback or anything like those?

denik18:05:33

@thheller what would I need to do?

thheller18:05:00

add these deps to your dev profile

thheller18:05:10

[org.slf4j/slf4j-log4j12 "1.7.25"]
     [log4j "1.2.17"]

thheller18:05:32

if you have a src/dev or dev source path already configured

thheller18:05:54

create a log4j.properties there with the content I pasted above

thheller18:05:05

the config only logs to the console since that is what I'm using for shadow-cljs but it should be printing more info

thheller18:05:24

[10:59:38,136] classpath updates total:2
[10:59:38,137] classpath update [:mod] C:\Users\thheller\code\shadow-cljs\src\ui-release\shadow\cljs\ui\dist\js\ui.js
[10:59:38,205] classpath update [:mod] C:\Users\thheller\code\shadow-cljs\src\ui-release\shadow\cljs\ui\dist\js\ui.js
[10:59:38,271] :shadow.cljs.devtools.server.system-msg/resource-update {:namespaces #{module$shadow$cljs$ui$dist$js$ui}, :deleted #{}, :updated #{module$shadow$cljs$ui$dist$js$ui}, :added #{}}

thheller18:05:30

should see messages like those

denik19:05:02

@thheller followed your instructions but it doesn’t seem to work, only getting warnings

[15:29:41,605] XNIO version 3.3.8.Final
[15:29:41,639] XNIO NIO Implementation Version 3.3.8.Final
15:29:42.237 WARN  [shadow.build.classpath] (nREPL-worker-1) failed to inspect resource "/Users/den/Dropbox/dev/code/vimsical/web-stack/resources/templates/frontend/core.cljs", it will not be available.
15:29:49.381 WARN  [shadow.build.classpath] (nREPL-worker-1) failed to inspect resource "jar:file:/Users/den/.m2/repository/vimsical/web-stack/0.1.01/web-stack-0.1.01.jar!/templates/frontend/core.cljs", it will not be available.
15:29:49.610 WARN  [shadow.build.babel] (nREPL-worker-1) can't find node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.transform.js, please install npm install --save-dev shadow-cljs.
shadow-cljs - HTTP server for :app available at 
shadow-cljs - server running at 
shadow-cljs - socket repl running at localhost:61783
shadow-cljs - nREPL server started on port 61785
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (928 files, 3 compiled, 0 warnings, 7.10s)

[:app] Compiling ...
[:app] Build failure:
The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/util/dom.cljs".

thheller19:05:46

hmm might be a conflict with some other logging library

thheller19:05:46

what exactly are you doing to trigger the second compile?

denik19:05:09

uncommenting [net.cgrand.xforms :as x]

denik19:05:23

just got it to work. restarted intellij!

thheller19:05:43

uhm ... I assumed the problem was that is compiled once fine and then failed

thheller19:05:55

that probably just meant that the lib wasn't on the classpath?

denik19:05:05

It worked initially through a several compilation, then the repl timeout caused me to restart the repl, then it didn’t work, the I deleted the compiled js, restarted intellij. now it works

denik19:05:37

yeah I think so too, sth todo with the classpath

lilactown20:05:24

I'm running into a problem with a particular npm package, graphql

lilactown20:05:38

when using it in Node.js, it works just fine as expected

lilactown20:05:43

however, when using it on the client-side (it's a peer dependency of another npm package, graphql-tag, which translates GraphQL strings to an AST), I get this error:

source.js:15 Uncaught TypeError: Cannot call a class as a function
    at new C.Source (source.js:15)
    at C.parse (parser.js:34)
    at c (graphql-tag.umd.js:136)
 ...

lilactown20:05:15

it seems to not be passing this check:

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**

lilactown20:05:35

the offending line:

var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;