Fork me on GitHub
#clojurescript
<
2020-01-23
>
tzzh10:01:50

Hey, how can I import only a library inside a module ? I am trying to use highlight.js and they suggest doing

import hljs from 'highlight.js/lib/highlight';
import javascript from 'highlight.js/lib/languages/javascript';
but I don’t know how to translate these in my :require (I am using shadow-cljs in case that makes a difference)

tzzh10:01:40

yeah I was looking at this but here highlight.js/lib/highlight is not the module name

tzzh10:01:03

ok so I actually initially tried

(:require [highlight.js/lib/highlight :refer [hljs]])
but was getting Invalid symbol: highlight.js/lib/highlight

thheller10:01:18

yeah because you are missing the all important string

thheller10:01:28

and its also not the correct translation

thheller10:01:02

(:require ["highlight.js/lib/highlight" :as hljs])

thheller10:01:15

or maybe :default. depends on how the library is packaged

tzzh10:01:23

ahh yeah get it cheers :thumbsup:

borkdude11:01:27

Does someone have an example of using a react virtualized Table in CLJS / reagent for a recent version? I found @pesterhazy's example here: https://gist.github.com/pesterhazy/10b4a01908e7632825a2321c06130989, but I'm not sure how up to date it?

Hi11:01:12

hi. How to parse .-onerror js/window last argument? if prints like this

#object[Error Error: No protocol method IDeref.-deref defined for type undefined: ]

darwin11:01:27

it looks like default printing of native js/Error object

darwin11:01:22

I would simply log it into javascript console and see its properties there

darwin11:01:40

currently you are printing it via cljs printing machinery

thheller12:01:44

are you asking what that error means? what would you parse it to? you are calling @foo when foo is nil or undefined

Hi12:01:10

how to parse it? how to get stack trace etc

darwin12:01:51

do you mean in general for all js errors or just for this specific case?

thheller12:01:04

last arg to the onerror fn is the error instance

thheller12:01:12

it has a stack property?

thheller12:01:31

parsing that is different between each browser though since its not a standard

darwin12:01:05

this is the general way how to improve printing of js/Errors across your whole app

Hi12:01:38

how to get all fields and functions of that object?

Lu15:01:32

(js/console.log x)

andrewboltachev13:01:52

Hello. In my project (originally figwheel-main one) I've added cljsbuild and am trying to compile CLJS for production. When I'm doing lein cljsbuild once min nothing seems to happen and it just exits silently:

➜  ai-system git:(master) ✗ lein cljsbuild once    
Warning: implicit hook found: lein-environ.plugin/hooks 
Hooks are deprecated and will be removed in a future version.
Compiling ClojureScript...
➜  ai-system git:(master) ✗

andrewboltachev13:01:43

Can I make cljsbuild anyhow be more verbose and provide some debug information?

andrewboltachev13:01:37

Ah sorry, just noticed that actually :min option exists in Figwheel-main as well

Hi14:01:20

how to trigger window.onerror = function(message, source, lineno, colno, error) { ... }? if I throw in console it does nothing...

darwin14:01:47

setTimeout(function() { throw "!"; }, 0)

darwin14:01:52

in console^^

darwin14:01:43

btw. this is not cljs-related at all, this is how javascript and devtools work

ec15:01:25

How is Graphql exp. for cljs? I know there is re-graph which didnt get update for couple of months and a recent apollo integration example repo (which felt like just using js is better). My backend is hasura genrated graphql api so cant utilize Fulcro etc.

Chris O’Donnell22:01:38

@cakir-enes here is an example of using fulcro, pathom, and hasura https://github.com/codonnell/crudless-todomvc

Chris O’Donnell22:01:28

Little bit dated since it uses fulcro 2 instead of 3 but it's perfectly possible to do.

lilactown16:01:40

if you’re already using re-frame, then re-graph can be nice. apollo would be my suggestion as a more a la carte solution

lilactown16:01:07

one thing that is still missing in CLJS land that I see in JS is the ability to auto-generate code based on a graphql backend

lilactown16:01:03

pathom is a library that is specifically building support for GraphQL in a more Clojure-native way of writing queries, but I’m not sure about the value add tbh

lilactown16:01:38

not sure what you’re looking for if the apollo example wasn’t convincing for you, though

mruzekw18:01:24

@cakir-enes You can front the graphql API with Pathom to easily integrate it with Fulcro

denik19:01:58

Have been banging my head against the wall trying to get the CLJS AST for (map inc (range 10)) Anyone know how to go about it?

Roman Liutikov19:01:51

Take a look at analyzer tests in ClojureScript source

denik20:01:20

thanks, I did put couldn't find anything useful. However I found this and it's sufficient for my needs: https://swannodette.github.io/2015/07/29/clojurescript-17

sova-soars-the-sora19:01:22

document.getElementById("myAudio").load(); looks like what in cljs?

sova-soars-the-sora19:01:55

(-.load (. js/document (getElementById "kana-audio")))) is not doing the trick ;x

sova-soars-the-sora19:01:48

oh it was just .load xD

ag22:01:00

I need to traverse hiccup structure. I used https://github.com/cjohansen/hiccup-find before, but I think it has some small limitations (I don’t remember exactly what it was), can anyone suggest anything better?

Drew Verlee22:01:17

Specter? Maybe

Jimmy Miller22:01:26

I've done quite a bit of extracting data from hiccup with meander. Simple example: https://github.com/noprompt/meander/blob/epsilon/doc/cookbook.md#webscrape-html You can go to #meander for help you decide to go that route

aisamu16:01:22

I have coworkers here, stop revealing my secret plans. They won't be able to resist if they don't see it coming

ag22:01:36

Oh, Meander looks promising.

ag22:01:56

it’s Cljs compatible, right?

lilactown23:01:39

using clojure.walk or doing a recursive traversal isn’t too hard either, depending on what you’re trying to do