Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
edited by

Hello,

I am trying translate the following cljs.main options with the CLI:

$ clj -m cljs.main          \
      -d public/js/compiled \
      -o public/js/main.js  \
      -O advanced           \
      -c hello-world.core

Into deps.edn:

{:deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
        reagent {:mvn/version "1.0.0-alpha2"}}
 :main "hello-world.core"
 :optimizations :advanced
 :output-dir "public/js/compiled"
 :output-to "public/js/main.js"}

Then execute it with:

clj -m cljs.main -co deps.edn

However, it doesn't seem to work.

I also get the following error using the generated main.js file:

main.js:314 Uncaught TypeError: Cannot read property 'mg' of undefined
    at Mb (main.js:314)
    at Tn (main.js:699)
    at Rn (main.js:698)
    at Nn.h.Me (main.js:718)
    at Function.Wn.A (main.js:710)
    at Nn.h.Le (main.js:718)
    at Function.Wn.j (main.js:710)
    at ep (main.js:761)
    at main.js:761

Some thoughts

  • Am I missing a CLI option? or deps.edn key/value pair?
  • Am I using it wrong; the CLI or deps.edn or both?
  • Or is it not well supported at the moment so I should just stick with the CLI?

2 Answers

0 votes
by
selected by
 
Best answer

You seem to be confusing deps.edn with build.edn (https://clojurescript.org/guides/webpack). All of the keys other than :deps are not valid in a deps.edn file.

by
Thanks Alex,

That's kind of tragic, from Quick Start ( https://clojurescript.org/guides/quick-start ) then a jump to Compiler Options ( https://clojurescript.org/reference/compiler-options ), there was never a mention of build.edn so I assumed the options are suitable for deps.edn.

I think the other factor that I have no intention of using webpack caused me to not even consider going to the webpack guide (where build.edn was actually mentioned).

I'll mark your answer as accepted after I read the tried the examples in that article. :)
by
If there are improvements that could be made, https://github.com/clojure/clojurescript-site/issues is the best place to file an issue.
by
Thanks Alex,
will try to find a way how to contribute in the future (as I really like ClojureScript, it's awesome! :D).

Best,
0 votes
by
edited by

As pointed out by @alexmiller,
build.edn should be used (could be named anything, e.g. lol.edn) instead of deps.edn, since the deps.edn don't recognize the compile options keys mentioned in the example.

So the equivalent of:

$ clj -m cljs.main          \
      -d public/js/compiled \
      -o public/js/main.js  \
      -O advanced           \
      -c hello-world.core

In *.edn (e.g. build.edn) is:

{:main "quick-start.core"
 :optimizations :advanced
 :output-dir "public/js/compiled"
 :output-to "public/js/main.js"}

Then executed with:

$ clj -m cljs.main  \
      -co build.edn \
      -c

Note the -c (--compile) at the end, otherwise, it won't work.

...