Clojurians
#shadow-cljs
<
2018-04-04
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

rgm15:04:03

I'm trying to transition a re-frame/soda-ash (ie. semantic-ui) project to shadow in preparation for trying to do an Electron packaging, and I've hit a bit of an npm head-scratcher:

rgm15:04:53

soda-ash is using cljsjs/semantic-ui-react ... I've followed the cljsjs transitioning steps to replace it with my own little namespace that pulls in the NPM, but the compiler isn't happy that ReactDOM seems to be missing. It's in package.json but the compiler doesn't seem to be picking it up.

thheller17:04:07

@rgm the semantic-ui-react/dist/umd is not a valid package unfortunately. commonjs should be fine. could even try the es version

rgm17:04:32

thanks, yeah... was just trying to mirror what cljsjs.semantic-ui-react pulled down from unpkg (which soda-ash relies on) so I have no idea how lein cljsbuild is making that work. ¯\(ツ)

rgm17:04:13

guess it must just be foreign and tacked onto the front of the bundle in just the right place

thheller17:04:20

CLJSJS just includes things as they are and does not do any further processing. so it relies on the ReactDOM and React globals being available

thheller17:04:19

but quickly looking over the umd bundle you are far better off not using that

thheller17:04:27

since it includes lodash and other stuff

rgm17:04:33

ugh, good times.

thheller17:04:59

so if you any other package also used lodash you'd include it twice. by using the commonjs directly its only included once

rgm17:04:11

thinking downstream towards possible advanced compilation, is there an advantage to using the ES6 versus commonjs versions?

thheller17:04:50

ES6 is better yes, much better actually.

rgm17:04:11

then ES6 it shall be 👍

thheller17:04:46

even better would be only requiring what you need but that seems a bit ugly for this package

thheller17:04:06

using the index always pulls in everything which is a bit annoying if you only use 10% or their stuff

thheller17:04:39

hmm how long do these take? semantic-ui-react has a bajillion files

rgm17:04:44

<- Shadow JS converting 1025 JS sources (18541 ms)

thheller17:04:18

should be fine with caching I hope but I need to optimize that

rgm17:04:31

I'm still shaking off a few years with meteor.js waiting 30-40s every single time the file watcher fired up, so I'm cool with 18s one time.

rgm17:04:01

but far be it for me to stop you from making it faster 😉

gadfly36117:04:54

@rgm @thheller if anyone is willing, would be happy to accept PR to add how to use soda-ash with shadow-cljs to soda-ash's README

rgm17:04:32

And as it happens I would love to contribute that ... just need to find a bit of time

thheller17:04:12

we can add the cljsjs.semantic-ui-react to https://github.com/thheller/shadow-cljsjs so others don't have to do this part

rgm17:04:18

(also I haven't yet got my project back up on its feet so maybe I should wait until I've sorted that out ... don't think there's still a problem with SA since it all looks good but just want to actually see pixels on the screen).

rgm18:04:07

holy dinah ... my project is working again, and so (I think) is advanced compilation for the first time ever

rgm18:04:50

@gadfly361 lmk, but I'm not sure that soda-ash in particular needs anything more than https://github.com/thheller/shadow-cljsjs/pull/5 to exist... seems more of a shadow-specific concern that https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs documents well.

rgm18:04:35

pretty much any use of shadow + cljsjs should lead here; it's not really on soda-ash

thheller18:04:53

merged. will include it in the next release.

gadfly36118:04:24

@rgm sounds good to me! I am unfamiliar with shadow-cljs, so will leave it to you guys :) (Hope to take it for a test ride soon tho!)

rgm18:04:01

ha, I'm only about 10 minutes ahead of you on familiarity. Thx for soda-ash.

gadfly36118:04:58

If only 10 mins, that bodes well for shadow cljs parrot

hmaurer21:04:37

Hi! I have been getting this error and I’ve no idea where it comes from:

NullPointerException: 
	clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:301)
	shadow.build.output/flush-dev-js-modules (output.clj:564)
	shadow.build.output/flush-dev-js-modules (output.clj:560)
	shadow.build.targets.npm-module/process (npm_module.clj:63)
	shadow.build.targets.npm-module/process (npm_module.clj:54)
	clojure.lang.Var.invoke (Var.java:381)
	shadow.build/process-stage/fn--14988 (build.clj:119)
	shadow.build/process-stage (build.clj:116)

thheller21:04:25

@hmaurer what is your build config? and version?

hmaurer21:04:21

@thheller I just started with shadow so sorry if I am doing something silly. I installed it tonight so I assume latest version, and my build config is:

:builds
{:npm {:target :npm-module}}

hmaurer21:04:36

version: 2.2.24

thheller21:04:41

does it work if you just use :builds {}?

thheller21:04:20

or add :output-dir "out" or so. it defaults to :output-dir "node_modules/shadow-cljs"

hmaurer21:04:01

hum yes, with :builds {} it works

thheller21:04:21

:target :npm-module requires at least :output-dir, which is set if using the built-in :npm config

thheller21:04:36

but by you setting it manually that gets overridden. I'll add a validation for this

hmaurer21:04:27

Oh I see. In the doc it’s mentioned as optional

thheller21:04:53

oh that is incorrect

hmaurer21:04:02

Ah well, quick fix 🙂 Beyond that I am excited about shadow; I am working on a ClojureScript project which I would like to use as a library in a webpack project

hmaurer21:04:05

it seems like a good fit

hmaurer21:04:37

Oh also, while I am at it: when running the watch command I get a bunch of warnings @thheller :

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/hmaurer/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

thheller22:04:31

yeah those are Java9 warnings. can't really do anything about them until that lib gets updated.

thheller22:04:41

don't worry about those though. not a problem.

hmaurer22:04:47

Ok; just wanted to make sure something wasn’t off about my setup

hmaurer22:04:09

@thosmos is it possible to load some namespace automatically when clj-repl starts?

hmaurer22:04:15

(to set up some functions, etc)

hmaurer22:04:30

e.g. I would like to load the my-app.tinker namespace, or similar

hmaurer22:04:03

oh also, is it normal that arrow keys don’t work in the clj-repl ? Am I required to use rlwrap?

thheller22:04:19

clj-repl no. I still need to add an option for that.

thheller22:04:52

I never use the REPL from the command line. always from my editor (Cursive) so I really have no idea what people want for the command line

thheller22:04:08

feel free to open a ticket though. I'm happy to add this.

hmaurer22:04:47

Ok, thank you! I should probably get used to an editor with good clojure repl integration

thheller22:04:09

it helps a lot if people actually just report what they expected to work. Can't fix anything if I'm not aware there is a problem in the first place.

thheller22:04:49

only because I don't like working at the command line doesn't mean it shouldn't be supported properly