clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
wcalderipe 2020-09-19T06:28:48.027500Z

hey folks, how are you running your shadow-cljs project tests locally? are you using command line or the repl or maybe both?

Mark Gerard 2020-09-19T12:40:54.028200Z

I use the command-line. Sometimes, I specify a .dir-locals.el variable to run them when I cider-jack-in

wcalderipe 2020-09-19T12:53:22.028500Z

i was looking for a solution to run test in clojurescript like we do with cider-test-run-test fn in clojure. however, when i tried it i got this user-error: Clojure-only operation requested in a ClojureScript buffer

wcalderipe 2020-09-19T12:53:48.028700Z

so i was wondering how folks with more experience in clojurescript nowadays are running their tests

wcalderipe 2020-09-19T12:54:10.028900Z

thanks for sharing @cattabanks 🙂

1
nickt 2020-09-19T15:33:34.029600Z

Hey all. I'm looking at clojurescript for a project target Duktape, an embedded, es5 compliant javascript engine

nickt 2020-09-19T15:34:01.030200Z

is it possible to get the clojurescript compiler to output a single file, ready to roll with all dependencies bundled?

nickt 2020-09-19T15:34:26.030800Z

(when I try to target node, the output file tries to require a bunch of stuff. When I try to target browser, the output file tries to fetch a bunch of stuff)

2020-09-19T16:04:56.033600Z

It seems there is no clear policy as which optimizations bundle everything in a single file - I would have thought both :simple and :advanced, but only :advanced seems to do that. Is there an established answer? http://Clojurescript.org and Goog.closure sites don’t mention it. I am trying for a single-file bundle with :simple - is this possible? Thx

2020-09-19T16:07:01.035100Z

Also, it seems dependencies in :none optimization are fetched relative to :output-dir. Is this correct? Thx..

Aron 2020-09-19T16:17:07.036Z

I am reading a tutorial here https://github.com/Rovanion/webgl-clojurescript-tutorial/blame/master/README.md#L237 and there is this line (catch js/Error e (recur (next ids))))))] that throws when I try to compile it with Can't recur here

Aron 2020-09-19T16:17:45.036800Z

I am not sure what is happening, is this code that was working before but not anymore? Or what could be the problem?

2020-09-19T16:32:44.038400Z

Is there a compiler setting which writes the goog initialization and deps within a <script> tag, instead of in-line (`document.write(…`)?

p-himik 2020-09-19T16:41:49.038500Z

Are you creating a dev build? Because a release build should produce a single file with everything bundled together.

p-himik 2020-09-19T16:42:01.038700Z

At least, for browsers. No idea about node.

p-himik 2020-09-19T16:43:20.038900Z

How would your compiler change your HTML? Or maybe I misunderstand the question.

nickt 2020-09-19T16:45:18.039100Z

I've tried browser, webworker, and node

nickt 2020-09-19T16:45:27.039300Z

with whitespace, simple, and advanced optimizations

nickt 2020-09-19T16:45:30.039500Z

so far, no dice

nickt 2020-09-19T16:46:48.039700Z

What is shadow-cljs? They seem to support targeting react-native: https://shadow-cljs.github.io/docs/UsersGuide.html#target-react-native

p-himik 2020-09-19T16:46:59.039900Z

Interesting. It's not allowed in Clojure either. I don't know for sure but I think you're right about this working on some older CLJS. Either way, the fix it rather trivial - just wrap try-catch in a let and recur from the let's body.

nickt 2020-09-19T16:47:00.040100Z

(which means running in JavaScriptCore, which is an embedded engine)

p-himik 2020-09-19T16:47:34.040300Z

I use shadow-cljs for browser. When I run production build, only a single file is produced.

p-himik 2020-09-19T16:48:56.040500Z

Also from the documentation: "The :target :node-script produces single-file stand-alone output that can be run using node.js"

nickt 2020-09-19T16:50:33.040700Z

Right, but there's something about the compiled output that fails inside duktape 😕

p-himik 2020-09-19T16:51:46.040900Z

Have you tried setting :output-feature-set to :es5?

p-himik 2020-09-19T16:52:08.041100Z

Although I think that's the default...

nickt 2020-09-19T16:52:19.041300Z

ah, how do I do that?

nickt 2020-09-19T16:52:28.041500Z

(all I have is a deps.edn file)

2020-09-19T16:52:37.041700Z

Thanks @p-himik ..You understood correctly - maybe there is a way to output the fragment to a file? Or to disable it? Way back there used to be an introductory cljs tutorial where this was done manually..

nickt 2020-09-19T16:52:38.041900Z

(and a hello-world file)

p-himik 2020-09-19T16:53:26.042100Z

If you're using shadow-cljs, you should also have a shadow-cljs.edn file. https://shadow-cljs.github.io/docs/UsersGuide.html#_output_language_options

p-himik 2020-09-19T16:56:08.042300Z

The only thing that I've seen where something was done manually is the addition of a single <script src="..."> line that makes the browser fetch the main JS bundle and maybe another <script> line that executes the entry function. In any case - what is the problem that you're trying to solve?

2020-09-19T16:57:30.042500Z

I am writing a browser extension, and would have to muck with security policy (CSP) to make that possible. No inline JS is allowed by default

p-himik 2020-09-19T17:00:21.042700Z

I'm using shadow-cljs. A release build produces a single file that you can add with <script src="...">. It doesn't try to load any other files.

nickt 2020-09-19T17:01:19.042900Z

is it doable just with the deps.edn file and the clj CLI?

2020-09-19T17:01:38.043100Z

Ok…will see if I can use that - thanks!

p-himik 2020-09-19T17:03:16.043300Z

I don't know for sure. You'll have to peruse the documentation or ask in #shadow-cljs

p-himik 2020-09-19T17:03:43.043500Z

If that doesn't help, you can always ask in #shadow-cljs

Felipe Marques 2020-09-19T20:59:33.046Z

Hi all! I've came across a problem with CLJS compilation recently, where my code behaves differently if I compile it with different optimizations options (advanced and simple). I made this small example showing it (https://github.com/felipegmarques/example-cljs-optimizations-affecting-code-behavior). Does anyone have a similar problem?

ozzloy 2020-09-19T22:19:24.046600Z

how do i make it so changes to deps.edn trigger a rebuild?

ozzloy 2020-09-19T22:19:32.046900Z

for example adding a dependency?