Fork me on GitHub
#clojurescript
<
2020-11-14
>
blmstrm05:11:13

Hello! I wonder how I would go about rewriting the following (.decorate obj (fn [sel] (. (. sel enter) classed "ma" true))) with ..notation? I realise it should be something along the lines of (.decorate obj (fn [sel] (.. sel enter classed "ma" true))))but I can’t figure out how I will get the ..notation to understand that "ma"and true are arguments to the classedfunction? I’m new to javascript so please excuse me if I mangle any terminology.

thheller09:11:13

@blmstrm you "group" everything via () so (.. sel enter (classed "ma" true))

blmstrm10:11:26

Ah, I didn't think about that! Thank you so much!

victorb11:11:09

Hello folks! Trying to wrangle self hosted clojurescript into doing what I want, and it kind of works but no macros seems to be available. Not sure if this is expected or not, any input? Current code in attached screenshot. For example, neither fn nor -> (and probably other) macros are not available and can't figure out how to get them in there, if even possible

borkdude12:11:20

fwiw, I've got a self-hosted CLJS project here, maybe it's useful for debugging your problem: https://github.com/borkdude/re-find.web

thheller12:11:17

@UEJ5FMR6K in case you are trying this while compiling with shadow-cljs you kinda have to use the :bootstrap support described here https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html

thheller12:11:54

otherwise self-hosted I believe relies on :dump-core true which isn't available in shadow-cljs

thheller12:11:29

if you do this manually you must also properly load the macro code

thheller12:11:47

not exactly sure how that would look when done the way you are doing it

victorb12:11:14

Oh, I see, yeah I'm using shadow-cljs, I'll check out your link. Thanks @U05224H0W and thanks for the example @borkdude, I'll check that out as well

victorb13:11:25

Yup, the "bootstrap support" stuff did the trick, thanks again Thomas

borkdude13:11:09

I have a .cljc file wherein I define a top level defn for CLJS only:

#(:cljs
  (defn buf [reader]
    (prn :frames (.-frames reader))
    (str (:buffer @(.-frames reader)))))
However, when I try to find/call this function, it is nil. Both in CLJS and self-hosted.
cljs.user=> edamame.impl.parser.parse_next
#object[edamame$impl$parser$parse_next]
cljs.user=> edamame.impl.parser.buf
nil
cljs.user=> (require '[edamame.impl.parser :as p] :reload-all)
nil
cljs.user=> (p/buf 1)
WARNING: Use of undeclared Var edamame.core/buf at line 1 <cljs repl>
wat?

borkdude13:11:07

is this because defn is a macro? self-hosted should be able to handle this I think?

thheller14:11:36

@borkdude when that is the actual code you are missing a #?( instead of #( 😉

borkdude14:11:24

yikes :) thanks

Erkan19:11:48

Seems that I'm unable to run inline tests in a .cljs file. In a figwheel REPL I do

(cljs.test/run-tests 'my-namespace)
but it returns
Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
is there any configuration that needs to be done in my project.clj file?

Erkan20:11:36

Yes it was, add

:test-paths    ["src"]
:)

jaime20:11:38

Hi, is there a way for cljs to read a json file config? I'm trying to integrate this tool https://github.com/vadimdemedes/tailwind-rn But its generated config is in json file

import {create} from 'tailwind-rn';
import styles from './styles.json'; <----- importing json config

const {tailwind, getColor} = create(styles);

tailwind('text-blue-500 text-opacity-50');
Right now, I'm just thinking to copy the content of styles.json and declare a cljs map instead of importing the json file.

Dan Maltbie21:11:02

I'm running into a problem when importing a javascript library that has a dependency on streaming_iterables.js. shadow-cljs compile reports successful compile but when I run my app I get the error below. I've simplified the the test to a simple app that works fine and then add the import of streaming_iterables.js where it fails. This may be related to Babel and support for async/await. I tried installing the regeneratorRuntime package with NPM but still fails. Any ideas why this is happening? Thanks for your help,Dan ========================= > web console output ReferenceError: regeneratorRuntime is not defined at Object.shadow$provide.module$node_modules$streaming_iterables$dist$index_mjs (index.mjs:44) at Object.shadow.js.jsRequire (js.js:66) at Object.shadow.js.require (js.js:113) at eval (./cljs-runtime/ttncore.main.js:2) at eval (<anonymous>) at Object.goog.globalEval (main.js:566) at Object.env.evalLoad (main.js:1659) at main.js:1966 env.evalLoad @ main.js:1662 (anonymous) @ main.js:1966

thheller21:11:56

@dmaltbie should work if you add (:require ["regenerator-runtime/runtime"]) anytime before requiring the JS lib in question

Dan Maltbie21:11:13

Thank you!!! That works. Thomas I am very impressed with the support you provide. A+

👍 3
Kent Bull19:07:30

This worked for me as well.

thheller21:11:32

@jaime.sangcap I'm guessing this is for react-native in which case you can just import the .json file as you would in JS as metro will be providing it anyways

thheller21:11:57

well I guess it depends on the tool you are using but (js/require "../path/to/styles.json") should do it

jaime21:11:46

I'm using krell and following this tutorial https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial I'm trying to log the import styles.json but it returns nil

(ns awesome-project.core
  (:require [reagent.core :as r]
            [reagent.react-native :as rn]))

(defn hello []
  [rn/view {:style {:flex 1 :align-items "center" :justify-content "center"}}
   [rn/text {:style {:font-size 50}} "Hello Krell!"]])

(defn ^:export -main [& args]
  (r/as-element [hello]))


(comment
  (js/console.log (js/require "../../styles.json")))
Directory is
awesome-project/
--src/
----awesome-project/
------core.cljs
--styles.json

thheller21:11:01

looks like you are trying to do this in the REPL which does not work

thheller21:11:14

it needs to be in the code actually processed by metro

thheller21:11:54

and it might need to be in the assets path. the js/require path needs to be relative to the path of the .js file you are loading. not relative to the .cljs file