Fork me on GitHub
#shadow-cljs
<
2018-07-15
>
Yehonathan Sharvit11:07:10

Shadow-cljs really rocks!!!!

parrot 16
Yehonathan Sharvit11:07:57

I was able to compile a 16k lines of clojurescript code and make it an npm module, easilly consumable by a react web app

Yehonathan Sharvit11:07:39

A question about publishing the npm package: is it advised to include the generated js.map files?

thheller12:07:57

@viebel you can but most tools do not read them although I do think that webpack supports it somehow

Yehonathan Sharvit12:07:26

Thanks @thheller. Does somebody know how webpack makes use of the js.map files?

denis_krivosheev18:07:10

Hi guys. I have a big react app written on TypeScript. I wanna migrate it to clojurescript using shadow cljs. So basically I’m interested in interop between clojurescript and JavaScript (and vice versa). Is there some examples how to do so?

Yehonathan Sharvit18:07:42

@denis_krivosheev what kind of interop examples do you need? 1. accessing javascript code from clojurescript 2. accessing npm modules from clojurescript

denis_krivosheev18:07:48

The main issue here is using cljs from js files

denis_krivosheev18:07:47

I read the docs and it suggests to use goog: prefix... and compiler is going to understand that

denis_krivosheev18:07:58

But I don’t understand how

denis_krivosheev18:07:49

For now the root of my app is going to be in typescript and I want to use clojurescript from there

denis_krivosheev18:07:12

And also use some ts from cljs

Yehonathan Sharvit18:07:18

do you want to integrate clojurescript into your code base?

Yehonathan Sharvit18:07:41

There is a video demo that @thheller did

denis_krivosheev18:07:14

Sounds awesome. Where can I find it?

Yehonathan Sharvit18:07:52

It is a bit old so some of the shadow-cljs commands have changed

Yehonathan Sharvit18:07:11

I think you need to run shadow-cljs compile npm

Yehonathan Sharvit18:07:05

My turn to ask for support

Yehonathan Sharvit18:07:32

I am seeing the following error when running npm watch test

Yehonathan Sharvit18:07:55

Jul 15, 2018 6:13:41 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :test available at 
shadow-cljs - server version: 2.4.5
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 57924
shadow-cljs - nREPL server running on port 57926
shadow-cljs - watching build :test
[:test] Configuring build.
[:test] Compiling ...
[:test] Build failure:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/viebel/.m2/repository/thheller/shadow-cljs/2.4.5/shadow-cljs-2.4.5.jar!/shadow/cljs/devtool
s/client/hud.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow.cljs.devtools.client.hud
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.core.async/go does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |     [shadow.dom :as dom]
   4 |     [shadow.xhr :as xhr]
   5 |     [shadow.animate :as anim]
--------------------------------------------------------------------------------

Yehonathan Sharvit18:07:04

npm compile test works fine

Yehonathan Sharvit18:07:33

here is my shadow-cljs.edn

Yehonathan Sharvit18:07:50

{:lein true
 :builds {:npm 
            {:target :npm-module
             :output-dir "."}
          :test
            {:target :browser-test
             :test-dir "resources/public/js/test"
             :devtools  {:http-port 8021
                         :http-root "resources/public/js/test"}}}}

Yehonathan Sharvit18:07:05

anybody can help solving this issue?

Hukka19:07:45

Figwheel has an option to start a ring server to serve the frontend. Does shadow have something similar? Couldn't find anything in the guide

grav19:07:36

When I start shadow-cljs server from cmd-line, it says:

shadow-cljs - Using IP "192.168.1.43" from Interface "en0"
Can I get it to listen on 0.0.0.0 or localhost instead? Currently I have to restart the server every time my ip changes.

Hukka19:07:49

@oscar Precisely, there seems to be support only for static file serving, not running a full ring api

oscar19:07:59

:http-handler

urbanslug19:07:10

Hey guys so I'm trying to use this tool https://github.com/sass/node-sass However this

(:require ["node-sass" :as sass])

(sass/render {:file 'path-to-file'})
errors with Invalid symbol: 'path-to-file'

urbanslug19:07:52

is that not how to call these js functions?

thheller19:07:15

@viebel thats an outdated core.async version

Yehonathan Sharvit05:07:53

thanks @thheller That solved the issue

thheller19:07:54

@grav its always listening on 0.0.0.0 unless otherwise specified. the fixed IP is also gone for a couple of releases now.

thheller19:07:35

@urbanslug 'path-to-file' thats a symbol in CLJS, must use "path-to-file". ie. double quotes

thheller19:07:34

and you probably need to either use clj->js or #js {:file ...} as node-sass expects a JS object not a CLJS map

urbanslug19:07:57

@thheller Ah I see. I thought that error was weird. Aren't symbols things that resolve to something?

urbanslug19:07:30

so strings are double quotes and single quotes are symbols like vars are symbols?

urbanslug19:07:35

I'm clearly missing something

urbanslug19:07:52

Yeah I thought it being a cljs map would be an issue

thheller19:07:55

' is quote in CLJS

urbanslug19:07:47

the syntax highlighting also hinted to that facepalm

urbanslug20:07:40

has anyone used node-sass? I get an interesting error that dirname is not defined basically from https://github.com/sass/node-sass/blob/master/lib/extensions.js#L10 defaultBinaryDir = path.join(__dirname, '..', 'vendor')

thheller20:07:03

are you trying to use node-sass in a :browser build?

thheller20:07:26

thats not going to work. it relies on libsass which is a native c extension

urbanslug20:07:45

Yeah it pointed to this in the readme https://github.com/sass/libsass

urbanslug20:07:33

@thheller you know a way to get this done?

thheller20:07:42

it is not possible

urbanslug20:07:33

I was calling node-sass via the binary but it ddidn't have code-reload

urbanslug20:07:43

guess I'll go back to css then

thheller20:07:29

what are you trying to do?

thheller20:07:46

you can use node-sass in node builds just fine. just not in the browser.

urbanslug20:07:08

I am making a reagent app using shadow cljs

urbanslug20:07:28

and I wanted to use scss for easily managing css

thheller20:07:39

thats fine. just have to compile the scss on the server and load the compile css

urbanslug20:07:13

Ok so this is how I'm doing it rn. I have a project cljs file along the following lines:

{...
 scripts: {
  sass: "node-sass ...",
  dev: "shadow-cljs watch app;",
  repl: "shadow-cljs cljs-repl app;"
}}
so for dev I run all 3 in different split screens

urbanslug20:07:51

is this kinda what you mean or are you saying there's a way to configure shadow-cljs in the .edn file?

thheller20:07:22

yes something like that. shadow-cljs has nothing built-in for sass (yet)

urbanslug20:07:26

also this doesn't reload css after node-sass updates the file

urbanslug20:07:36

so I have to manually reload and lose state

thheller20:07:46

css reloading should work. assuming you have an absolute path

thheller20:07:13

check if you have a <link rel="stylesheet" href="/absolute/path.css">

thheller20:07:23

if thats not using an absolute path it will not be live reloaded

urbanslug20:07:57

Ah I have "./css/style.css"

urbanslug20:07:27

but an absolute path makes it brittle like it means I have to change that for prod

thheller20:07:34

relative paths are currently not supported as stated in the docs. no idea how you setup looks like so can't comment on that.

urbanslug20:07:08

thanks I haven't gone through the docs very well