shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Aron 2020-09-07T09:12:30.139300Z

What is the easiest way to take the output of the report and create a pie chart or something visual? So far I only tried to see if I can copy paste from the terminal or from html.

thheller 2020-09-07T10:09:43.140300Z

not all of the data is exported in pure data form. you can check the .shadow-cljs/release-snapshots/<build-id>/latest/bundle-info.edn file, maybe it contains what you need?

thheller 2020-09-07T10:17:07.140900Z

the HTML file also has the data in EDN format so you could get it from there

Aron 2020-09-07T10:51:00.141100Z

that's going to be perfect, thanks

robert-stuttaford 2020-09-07T16:45:46.146500Z

any js pros able to guide me on how to do this with cljs only, perhaps? (from the code inside the first example on https://react-select.com/advanced):

const SortableMultiValue = SortableElement(props => {
  const onMouseDown = e => {
    e.preventDefault();
    e.stopPropagation();
  };
  const innerProps = { onMouseDown };
  return <components.MultiValue {...props} innerProps={innerProps} />;
});
<SortableSelect
      components={{
        MultiValue: SortableMultiValue,
      }}
    />
one of the downfalls of working on cljs so long is i've long since forgotten all the javascript arcana!

thheller 2020-09-07T16:54:53.147Z

isn't JSX fun? 😛 you are using reagent I presume?

thheller 2020-09-07T17:02:04.150900Z

(def SortableMultiValue
  (SortableElement
    (fn [props]
      (let [mouse-down
            (fn [e]
              ...)]
        
        (react/createElement
          components/MultiValue
          (js/Object.assign
            #js {:innerProps
                 #js {:mouseDown mouse-down}}
            props))))))

[:> SortableSelect {:components #js { :MultiValue SortableMultiValue}}]

Aron 2020-09-07T17:02:11.151100Z

@robert-stuttaford what have you tried so far? This does not appear to be exceedingly difficult to translate, it's a function getting a lambda and returning a dynamically created element with an injected eventhandler. (I would probably ask the person who wrote the original code to either document why this convolution or to rewrite it though)

Aron 2020-09-07T17:02:42.151400Z

why the object assign?

thheller 2020-09-07T17:03:40.152300Z

I'm assuming those are React props which shouldn't be mutated (or even might be frozen)

Aron 2020-09-07T17:03:44.152500Z

oh, that's the merge because they are spreading the original props, got it

Aron 2020-09-07T17:04:17.153Z

this kind of state management is very fragile 😞

robert-stuttaford 2020-09-07T17:08:23.154300Z

@ashnur i have noooo experience translating any js using const - that's after my time. been cljsing since 2012 😅 it's super occasional that i need something like this. thank you @thheller! using rum actually, but yeah, this gets me there!

thheller 2020-09-07T17:09:57.155Z

just replace const with var, if that makes it more readable 😉

robert-stuttaford 2020-09-07T17:10:26.155700Z

it would have been rad for the react-select folks to support multi-select as a first class feature, but this is the only method they offer. don't care to learn the whole thing's internals, just need the feature in. complexity budget reserved for the domain!

thheller 2020-09-07T17:11:03.156900Z

yeah the react world likes to go crazy with HoCs 😛

robert-stuttaford 2020-09-07T17:11:03.157Z

yeah, i mean the whole es 2015 and onwards flavour of js. the last major js i wrote was raw gclosure in 2011/2012 😂

robert-stuttaford 2020-09-07T17:12:12.157400Z

i appreciate the quick response and help, @thheller, thank you sir o7

robert-stuttaford 2020-09-07T17:12:44.157900Z

old news to you, but shadow is fucking rad 👏

❤️ 2
Aron 2020-09-07T17:20:34.158700Z

react-select is the issue here, i gathered several hundreds of downvotes speaking my mind in its issue pages

Aron 2020-09-07T17:21:12.159200Z

and I can just agree with @thheller 🙂

robert-stuttaford 2020-09-07T17:57:37.159800Z

it may not do it well, but man, it's such an upgrade to anything we were doing before

thheller 2020-09-07T18:03:28.160500Z

but does it really justify adding 90kb to a release build? for a select thingy? feels like a little overkill

thheller 2020-09-07T18:04:27.161Z

but I guess as far as react components are concerned thats still pretty reasonable 😛

alpox 2020-09-07T20:53:19.161200Z

It seems that they lessen again since Hooks came into play. Now there are just tons of those ^^

neilyio 2020-09-07T22:08:20.164Z

I'm not sure that my namespace dev.preload is being loaded from the :devtools {:preloads [dev.preload]} slot in my shadow-cljs.edn. I have (js/console.log "We are preloading.") right at the top of my dev.preload namespace and nothing is being printed in the browser. What should I try next?

neilyio 2020-09-07T22:14:03.166500Z

I can confirm that the following, from my main application namespace, does indeed print "We are preloading" when the app loads, so I know that dev.preload is the correct namespace.

(ns app.core
  (:require [dev.preload]))

neilyio 2020-09-07T22:16:44.168800Z

I thought that having :devtools {:preloads [dev.preload]} in my build config would have the same effect, please let me know if there's an extra step or if there's something that I missed. If it helps, my :source-paths is just ["src"], and the file is src/dev/preload.cljs.

thheller 2020-09-07T23:00:34.169300Z

@neil.hansen.31 you need to be more specific WHERE you put the preloads. it is supposed to be in your build config. can't tell where you have it if you just paste a part, the part looks correct though.

neilyio 2020-09-07T23:04:04.170900Z

Hey @thheller, thanks for the reply. I can confirm it's in the the build config, as in

:builds
  {:app
    {:target :npm-module
     ...
     :devtools {:preloads [dev.preload]}}}

thheller 2020-09-07T23:04:26.171300Z

that is the correct position

thheller 2020-09-07T23:04:38.171700Z

ah ..

neilyio 2020-09-07T23:04:38.171900Z

Sorry just made an edit above

thheller 2020-09-07T23:04:43.172Z

:npm-module does not support preloads

thheller 2020-09-07T23:05:28.173200Z

you are kinda responsible to loading it yourself since there is no clearly defined way which namespace is loaded first

thheller 2020-09-07T23:05:40.173700Z

ie. the JS loading the code controls that

neilyio 2020-09-07T23:06:50.175Z

Got it, thanks for clarifying. I really dug through the shadow-cljs user guide on this one, but sorry if I missed a mention of this anywhere.

thheller 2020-09-07T23:07:24.175500Z

well technically preloads is supported .. but they are only compiled and not loaded

neilyio 2020-09-07T23:07:52.176100Z

Is that true for all the npm/node targets?

thheller 2020-09-07T23:08:00.176300Z

what are you doing? :npm-module is sort of deprecated and kinda dead

thheller 2020-09-07T23:08:10.176600Z

nope only :npm-module

neilyio 2020-09-07T23:10:02.178100Z

I'm (still) working on a CLJS + StorybookJS integration. I'm using the npm-module target, and having the Storybook process load all the compiled .js files that are prefixed with my stories namespace.

neilyio 2020-09-07T23:11:13.179600Z

Storybook asks for a glob path to the .js files that have your "stories" in them, so this was my solution. It feels kind of hacky (and is slow), but it's working right now. I'd love a tip if you have a suggestion!

thheller 2020-09-07T23:11:57.180Z

hmm yeah no clue about storybook. either way its going to be hacky 😛

neilyio 2020-09-07T23:13:13.180300Z

What's the best alternative to :npm-module?

thheller 2020-09-07T23:13:28.180500Z

in case of storybook none

thheller 2020-09-07T23:13:43.180700Z

since that really wants multiple files

neilyio 2020-09-07T23:16:19.181700Z

I think I can also just point it to a single file. Would :node-script be worth trying?

thheller 2020-09-07T23:16:41.182100Z

unlikely since you are not running in node

thheller 2020-09-07T23:19:29.183700Z

https://clojureverse.org/t/generating-es-modules-browser-deno/6116 :esm is the more modern :npm-module but its probably not an option for storybook

thheller 2020-09-07T23:20:05.184400Z

mostly because storybook probably won't accept the already provided react version

neilyio 2020-09-07T23:59:32.185400Z

The :esm target is coming pretty close... But I'm getting these two warnings:

Warning: unmountComponentAtNode(): The node you're attempting to unmount was rendered by another copy of React.

neilyio 2020-09-07T23:59:42.185600Z

Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.
    in Transition (created by CSSTransition)
    in CSSTransition (created by app.sidebar.modal_left)
    in app.sidebar.modal_left (created by stories.core.sidebar_modal)
    in stories.core.sidebar_modal (created by reagent3)
    in reagent3 (created by storyFn)
    in div (created by storyFn)
    in storyFn
    in ErrorBoundary