how can we change the source of clojurescript?

You need to define the path in the file deps.edn, which needs to be located in the top level folder of your project, like this:

.
├── deps.edn
└── src
    └── main
        └── cljs
            └── hello
                └── core.cljs

The contents of deps.edn are like this:

{:deps {org.clojure/clojurescript {:mvn/version "1.10.758"}}
 :paths [:cljs-paths]
 :aliases {:cljs-paths ["src/main/cljs"]}}

The example file:

(ns hello.core)

(println "Hello CLJS from hello.core")

I’ll compile and run the example from NodeJS, so I pass a flag (--target node) to set NodeJS as the runtime target:

$ clj -m cljs.main --target node --output-to core.js -c hello.core
WARNING: When invoking clojure.main, use -M

$ node core.js 
Hello CLJS from hello.core

The complete reference for the contents of the file deps.edn can be found on: https://clojure.org/reference/deps_and_cli and there’s a section on how to configure paths for source, resource and test folders.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top