ClojureScript 1.10.X - New Quick Start, Feedback please :)

The paragraph introducing --main refers to the cljs.main namespace as a function. This might cause a slight issue for Clojure devs who may know it is really cljs.main/-main. Perhaps the wording surrounding this aspect could be revised.

2 Likes

I had this happen as well and wrote https://dev.clojure.org/jira/browse/CLJS-2614

1 Like

Now that we have a simple program, let’s build and run some ClojureScript:

clj --main cljs.main --compile hello-world.core --repl

This is now the first terminal command we’re running for our project, so being told to run it at the root of the project folder might help beginners:

Now that we have a simple program, let’s build and run some ClojureScript. At the root of the project folder, run the following command:

clj --main cljs.main --compile hello-world.core --repl

There is a bug in that it still indicates that you should see 5 (which was previously the sum of 2 and 3). Now we are doing

(hello-world.core/average 20 13)

and this evaluates to 16.5.

@SpaceGuy

There is a ticket regarding the InvalidPathException: https://dev.clojure.org/jira/browse/CLJS-2588

The goal is indeed to migrate to using only clj once it has been ported to Windows.

1 Like

Here’s a better link to the Quick Start doc that will update based on David’s changes: https://github.com/clojure/clojurescript-site/blob/quick-start-1.10/content/guides/quick-start.adoc

1 Like

This problem doesn’t appear to happen at this coordinate:

{:git/url "https://github.com/clojure/clojurescript"
 :sha "151edf6fb7984d0d26ce65c12d6f5644c40c1063"}

I think the commands for Windows looks distracting. It would be more consistent if the guide only listing macOS commands. Best solution I can found is to add a tab in each command so people can switch, probably not possible in adoc.

By the way I translated the draft into Chinese, without the Windows part https://segmentfault.com/a/1190000013516267

2 Likes

I link to the install pages for Clojure. It’s one command on OS X and Linux.

I think it’d be better to include the instructions to install clojure so people don’t have to navigate away to another page. It’d give us a chance to tie the guide together more since we could show up front how to get what’s required, and that installing Clojure with brew or apt get gives you the clj command that we use in the rest of the article.

JavaScript developers may not have Java! I really think we need to address this somehow. Any thoughts?

I don’t see the value of duplicating this kind of information. The Clojure installers for OS X and Linux install everything required including Java.

3 Likes

We’re not dropping Windows instructions for the time being. The feedback so far already demonstrates that it’s important. When Windows get the clj tool (in the works) we will have one set of instructions.

1 Like

@dnolen any chance of adding instructions to use npm packages? I mean regular npm packages, not CLJSJS packages. Ideally also showing how to produce a minimized production build. Thanks in advance!

1 Like

Way out of scope for the Quick Start. :npm-deps is still alpha quality and requires more coordination with Google Closure Compiler.

@dnolen Thank you for the quick reply, I appreciate it. Unfortunately, that makes clojurescript a no-go for me.

Then be sure to check back every few months. The progress in that space is pretty exciting.

1 Like

The community has been using NPM based dependencies for years now without any real issues, and tools like shadow-cljs make it even easier.

People need to understand that :npm-deps is a long view project to pass Node dependencies through Google Closure and very little else.

2 Likes

@dnolen:

The community has been using NPM based dependencies for years now without any real issues

Please, could you point me to some docs or examples on how to do that? I would appreciate it. Thanks in advance!

I’d take a look at this project: http://shadow-cljs.org

3 Likes

Hi,
I tried out the sections “Hello, Clojurescript” and “Production Builds”, running on Windows 10.
I noticed two things:

First, before doing a production build, I had to delete the “out” directory. Failing that, compiling would fail with an error.
IMO, a short note after the paragraph before the compile commands would be useful, along the lines of:
"If compilation fails with an error, you may need to delete the ‘out’ directory under the project root directory."
Once I had figured that out, compiling a build worked with all optimization options!

Second, the require :reload - command seems to reload the only symbols from core.cljs, but not their values.

Here is a short example:

core.cljs start out with

(ns hello-world.core)
(println "Hello world!")

(defn my-add [a b]
 (+ a b))

Starting the repl via

java -cp "cljs.jar;src" cljs.main --compile hello-world.core --repl

In the REPL:

(require '[hello-world.core :as  hello])
(hello/my-add 1 2)
;3

Now I add one function to core.cljs:

(defn my-subtract [a b]
  (- a b))

back in the REPL:

(require '[hello-world.core :as hello] :reload)
(ns-publics 'hello-world.core)
;{my-add #'hello-world.core/my-add, foo #'hello-world.core/foo, my-mult #'hello-world.core/my-mult, my-subtract #'hello-world.core/my-subtract}
(hello/my_subtract 1 2)
;TypeError: hello_world.core.my_subtract is undefined

Hope it helps…
Great introduction @dnolen ! :slight_smile:

I suspect what you are describing here are defects that have been fixed in master.

I’m not getting past the compile command:

clj --main cljs.main --compile hello-world.core --repl

It throws an error like this:

clojurescript-site: clj --main cljs.main --compile hello-world.core --repl
Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/main__init.class or cljs/main.clj on classpath.
    at clojure.lang.RT.load(RT.java:456)
    at clojure.lang.RT.load(RT.java:419)
8<....

I’m on OSX with a freshly installed copy of clojure 1.8, installed using port. My project directory looks ok, followed the instructions carefully:

clojurescript-site: tree
.
├── deps.edn
└── src
    └── hello_world
        └── core.cljs

2 directories, 2 files
clojurescript-site:

I’ve never built a project without the help of leiningen or cake before. How should the dependencies in the edn file be fulfilled? Did I miss a step somewhere?