Fork me on GitHub
#clojurescript
<
2020-09-19
>
wcalderipe06:09:48

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

Mark Gerard12:09:54

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

wcalderipe12:09:22

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

wcalderipe12:09:48

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

wcalderipe12:09:10

thanks for sharing @U017ML3MP98 🙂

sharkdance 3
nickt15:09:34

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

nickt15:09:01

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

nickt15:09:26

(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)

p-himik16:09:49

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

p-himik16:09:01

At least, for browsers. No idea about node.

nickt16:09:18

I've tried browser, webworker, and node

nickt16:09:27

with whitespace, simple, and advanced optimizations

nickt16:09:30

so far, no dice

nickt16:09:48

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

nickt16:09:00

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

p-himik16:09:34

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

p-himik16:09:56

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

nickt16:09:33

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

p-himik16:09:46

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

p-himik16:09:08

Although I think that's the default...

nickt16:09:19

ah, how do I do that?

nickt16:09:28

(all I have is a deps.edn file)

nickt16:09:38

(and a hello-world file)

p-himik16:09:26

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

nickt17:09:19

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

p-himik17:09:16

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

kingcode16:09:56

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

kingcode16:09:01

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

Aron16:09:07

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

Aron16:09:45

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

p-himik16:09:59

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.

kingcode16:09:44

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

p-himik16:09:20

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

kingcode16:09:37

Thanks @U2FRKM4TW ..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..

p-himik16:09:08

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?

kingcode16:09:30

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-himik17:09:21

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.

kingcode17:09:38

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

p-himik17:09:43

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

Felipe Marques20:09:33

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?

ozzloy22:09:24

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

ozzloy22:09:32

for example adding a dependency?