clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2021-04-24T02:54:03.388100Z

I would think that the generated JavaScript is not considered the source code of ClojureScript, so you can use whatever license you want for the output of the ClojureScript compiler.

2021-04-24T02:55:25.389300Z

If you want to create modifications to ClojureScript and distribute them as source, you must do so under the EPL. Analogy on the compiler output: GCC is distributed under some flavor of GPL, but the output of that compiler generated from your source code can be proprietary commercially sold code that you never release the C / C++ source code of.

sova-soars-the-sora 2021-04-24T05:17:52.389800Z

is it possible with clojurescript to generate a .js file that i can pass parameters to ?

Aron 2021-04-24T07:05:34.391300Z

you pass params to the process that runs js

sova-soars-the-sora 2021-04-24T14:06:37.396Z

Hmmm.. could you give me an example?

Aron 2021-04-24T15:19:03.397200Z

Sure, if you tell me what runtime you are using πŸ™‚

sova-soars-the-sora 2021-04-25T01:04:08.399Z

πŸ˜„ I don't know what to say. I'm thinking it looks like: clojurescript compiled to something.js and something.js is loaded on the html page and in the html page there is a <script> call </script that somehow invokes part of something.js like calling a method inside the js file with parameters, or maybe even calling the js file and having it use the default constructor (is there such a thing?) Is that possible with cljs?

Aron 2021-04-25T09:33:54.404900Z

if you are loading it in a html page, then your browser is the runtime

Aron 2021-04-25T09:35:28.405100Z

Browsers are slightly more difficult conceptually - imho - than node.js would be. There you can literally just pass params like any other cli command would take it.

Aron 2021-04-25T09:39:03.405300Z

In the browser people do multiple things, depending on what the real issue is. My own choices might not be fit for your purposes. With that caveat, you can use things like just embedding the information in html into a global variable and reading that variable from js. You can pass GET params to the server and the browser can access it through the DOM. Or you can use something like https://cljs.github.io/api/cljs.core/goog-define

Aron 2021-04-25T09:39:43.405500Z

I suspect this latter might be what you are looking for, but I am not sure.

Prabu Rajan 2021-05-05T22:32:51.156200Z

I haven’t tried this myself, but if you can create a web component in cljs like @thheller shows here - https://clojureverse.org/t/how-to-create-custom-elements-web-components-with-clojurescript/4332/2, you could embed that in your html and pass parameters into it like any other web component and read it in cljs using js interop APIs

ikitommi 2021-04-24T06:57:34.391200Z

is there an equivalent of print-method on ClojureScript that could use the instance :type metadata, e.g. same as in Clojure:

#?(:clj (defmethod print-method ::schema [v ^java.io.Writer w] (.write w (pr-str (-form ^Schema v)))))

thheller 2021-04-24T07:34:08.392300Z

@ikitommi no, in CLJS printing is based on the IPrintWithWriter protocol not a multi-method

ikitommi 2021-04-24T08:25:42.393600Z

thanks! given I have a reified Protocol (not concrete type), is there any way to pretty print it?

ikitommi 2021-04-24T08:26:57.394300Z

(Already have hacks to extend protocols for protocols on the clj side)

thheller 2021-04-24T08:30:48.394700Z

only way I can think of is overriding the default IPrintWithWriter impl

πŸ‘Œ 1
2021-04-24T09:48:10.395700Z

Hi, i've a folder with .cljs files folder-name - a.cljs - b.cljs - c.cljs in an init.cljs file I need to require all ns from folder-name (:require [folder-name.a] [folder-name.b] [folder-name.c]) Is it possible to use cljs.analyzer or something else to do this? So, require every ns/file from a parent-ns/folder? part B) Is there a way to get all the ns/file-names for a parent-ns/folder (not necessary in require)? Thanks in advance.

mfikes 2021-04-24T14:50:52.397Z

@bitkiller.42 https://clojure.atlassian.net/browse/CLJS-3276 just landed. If you are comfortable using unreleased code, it might be an interesting way to do this

πŸ‘ 2
2021-04-25T10:11:25.405700Z

Thanks a lot, I will check. Currently I'm still struggling with an easy solution for just getting the sub-namespaces for a namespace ... and the cljs.analyzer.api throws TypeError and undefined is not an object. I've to go deeper.

teodorlu 2021-04-24T20:51:14.398Z

https://clojurians.slack.com/archives/C03S1L9DN/p1618931187247800 Having seen David Nolen mention UI components in Storybook and everything else in Clojurescript several times here has gotten me really curious. To me, it seems to leverage the best parts of the Javascript ecosystem, while still using Clojure to its potential. Though I'm not comfortable setting up such a project myself. Any recommendations for a starter repo / project template with Clojurescript, Javascript and Storybook?

πŸ‘ 1
Aron 2021-04-24T22:50:52.398800Z

the om next talk is probably the best overview πŸ˜„

πŸ˜„ 1