This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-29
Channels
- # announcements (2)
- # babashka (18)
- # beginners (42)
- # calva (56)
- # chlorine-clover (35)
- # clara (9)
- # clj-http (1)
- # clj-kondo (19)
- # cljs-dev (8)
- # clojure (14)
- # clojure-europe (23)
- # clojure-france (7)
- # clojure-norway (6)
- # clojure-uk (3)
- # clojurescript (37)
- # community-development (3)
- # cursive (29)
- # datomic (3)
- # emacs (10)
- # events (2)
- # fulcro (77)
- # hyperfiddle (2)
- # introduce-yourself (4)
- # joker (1)
- # lsp (40)
- # malli (52)
- # meander (7)
- # missionary (16)
- # off-topic (3)
- # pedestal (1)
- # re-frame (5)
- # reitit (38)
- # releases (1)
- # shadow-cljs (4)
- # tools-build (18)
- # tools-deps (1)
- # xtdb (8)
where do I put this on my .edn file
{:npm-deps {"@material-ui/core" "4.9.13"
"@material-ui/icons" "4.9.1"}
...}
shadow-cljs.edn file :
{:source-paths
["src"]
:dependencies
[
[reagent "1.1.0"]
[re-frame "1.2.0"]
]
:dev-http {8280 "resources/public"}
:builds
{:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "js/compiled"
:modules
{:app {:init-fn toy-project1.core/init}}
}}}
I assume that :npm-deps
is coming from a library. When you start shadow-cljs it should download those from npm for you.
npm libraries aren't added to you shadow-cljs.edn file. you should add those to your package.json instead. i'd recommend reading shadow's user guide
With a skeleton project in hand, let's wire up the views. Dipping our toes into Material UI requires adding it as a dependency to src/cljs/deps.edn:
{:npm-deps {"@material-ui/core" "4.9.13"
"@material-ui/icons" "4.9.1"}
...}
It happens I guess. Just add these deps to your package.json and you should be good to go
Instead of square brackets around :use you need to use parentheses. (ns main (:use [com.company.utils])) ps: general advice to prefer :require with alias instead of :use in ns form. it should help you further maintain your codebase
Which tool you use to prepare classpath for your project? leiningen, clojure cli or something different?
You don’t have a project file that tells clojure where to look for files. In your example, using clojure tools, adding a file deps.edn
at root with the followig:
{:paths ["." "com"]}
makes it work> may I ask, how to use `require` in this file ? (ns main (:require [com.company.utils :as utils])) (utils/hello "world")
@U7S5E44DB what is deps.edn
is this new feature ?
https://www.clojure.org/guides/deps_and_cli it is the part of clojure cli (replit is using it in the background)
replit uses clojure cli, or lein? They’re asking me to signup to run clojure and I don’t want to
Hi, I am reading the book Programming Clojure and trying the examples in repl as I read.
While trying examples from the chapter on Specifications
this works
(s/def :bowling/roll #{0 1 2 3 4 5 6 7 8 9 10})
while this fails
(s/def ::bowling/roll #{0 1 2 3 4 5 6 7 8 9 10})
I tried googling, but nothing concrete came up. What am I doing wrong?
λ ~/src/code/ clj
Clojure 1.9.0
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (s/def :bowling/roll #{0 1 2 3 4 5 6 7 8 9 10})
:bowling/roll
user=> (s/def ::bowling/roll #{0 1 2 3 4 5 6 7 8 9 10})
RuntimeException Invalid token: ::bowling/roll clojure.lang.Util.runtimeException (Util.java:221)
#{0 7 1 4 6 3 2 9 5 10 8}
RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:221)
::bowling/roll
will try to resolve bowling
as an alias to a namespace -- but it isn't, which is why it fails.

(! 653)-> clj
Clojure 1.10.3
user=> (ns example)
nil
example=> (in-ns 'user)
#object[clojure.lang.Namespace 0xa10c1b5 "user"]
user=> (require '[example :as ex])
nil
user=> :ex/foo
:ex/foo
user=> ::ex/foo
:example/foo
user=>
Does that help explain it @rathi.k.nitin?Hey team, noob q: Is there a “multiline” (read-line)
?
I want a user to be able to type in multiline input, and only receive the string once they press enter.
I don’t think so, but if you line-seq
the input, you can take-while
until you get your chosen marker
Thanks tschady! This oculd work. One issue I’m having though: It doesn’t seem to detect “enter” as a marker
You can just use the java.io.Reader interface of *in*
directly
I tried to use the grammar from here https://github.com/antlr/grammars-v4/tree/master/sql/tsql But when I try:
(def sql (antlr/parser "grammar/tsql.g4" {:case-sensitive? false}))
I just get pages and pages of errors in the terminal, that look like clj-antlr
doesnt like the grammar file 😞 Errors like
error(50): /mnt/c/Users/stuarts/Source/___TESTREPOS/__Clojure/messing/grammar/tsql.g4:140:13: syntax error: '"' came as a complete surprise to me
error(50): /mnt/c/Users/stuarts/Source/___TESTREPOS/__Clojure/messing/grammar/tsql.g4:140:20: syntax error: '-' came as a complete surprise to me
error(50): /mnt/c/Users/stuarts/Source/___TESTREPOS/__Clojure/messing/grammar/tsql.g4:140:25: syntax error: '-' came as a complete surprise to me
error(50): /mnt/c/Users/stuarts/Source/___TESTREPOS/__Clojure/messing/grammar/tsql.g4:140:38: syntax error: '"' came as a complete surprise to me
error(50): /mnt/c/Users/stuarts/Source/___TESTREPOS/__Clojure/messing/grammar/tsql.g4:140:48: syntax error: '"' came as a complete surprise to me
error(50): /mnt/c/Users/stuarts/Source/___TESTREPOS/__Clojure/messing/grammar/tsql.g4:140:69: syntax error: '-' came as a complete surprise to me
I have a multi module project so I want a top level Makefile that can execute each project individually
What would I do instead @U3JH98J4R?
1. you can make a toplevel deps.edn that will have a build script that uses tools.build to run commands in the context of each project 2. have your script cd into each directory as appropriate
example with babashka tasks of (2):
{:paths ["bin"]
:min-bb-version "0.7.0"
:tasks {:requires ([tasks])
backend:start {:doc "Starts the backend-end application (backend:start-db must be run first)"
:task (shell {:dir "./service"} "clj -M -m your-service.main")}
}
}
example derived from a polylith example of (1)
(ns build
"The build script for the example of the poly documentation.
Targets:
* uberjar :project PROJECT
- creates an uberjar for the given project
For help, run:
clojure -A:deps -T:build help/doc
Create uberjar for command-line:
clojure -T:build uberjar :project command-line"
(:require [ :as io]
[clojure.tools.build.api :as b]
[clojure.tools.deps.alpha :as t]
[clojure.tools.deps.alpha.util.dir :refer [with-dir]]
[org.corfield.build :as bb]))
(defn- get-project-aliases []
(let [edn-fn (juxt :root-edn :project-edn)]
(-> (t/find-edn-maps)
(edn-fn)
(t/merge-edns)
:aliases)))
(defn- ensure-project-root
"Given a task name and a project name, ensure the project
exists and seems valid, and return the absolute path to it."
[task project]
(let [project-root (str (System/getProperty "user.dir") "/projects/" project)]
(when-not (and project
(.exists (io/file project-root))
(.exists (io/file (str project-root "/deps.edn"))))
(throw (ex-info (str task " task requires a valid :project option") {:project project})))
project-root))
(defn uberjar
"Builds an uberjar for the specified project.
Options:
File must contain an :uberjar alias
which must contain at least :main, specifying the main ns
(to compile and to invoke)."
[{:keys [project uber-file] :as opts}]
(let [project-root (ensure-project-root "uberjar" project)
aliases (with-dir (io/file project-root) (get-project-aliases))
main (-> aliases :uberjar :main)]
(when-not main
(throw (ex-info (str "the " project " project's deps.edn file does not specify the :main namespace in its :uberjar alias")
{:aliases aliases})))
(binding [b/*project-root* project-root]
(let [class-dir "target/classes"
uber-file (or uber-file
(-> aliases :uberjar :uber-file)
(str "target/" project ".jar"))
opts (merge opts
{:class-dir class-dir
:compile-opts {:direct-linking false}
:main main
:uber-file uber-file})]
(b/delete {:path class-dir})
(bb/uber opts)
(b/delete {:path class-dir})
(println "Uberjar is built.")
opts))))