This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-23
Channels
- # announcements (2)
- # beginners (246)
- # boot-dev (1)
- # braveandtrue (3)
- # calva (13)
- # cider (26)
- # cljs-dev (6)
- # clojure (75)
- # clojure-finland (4)
- # clojure-germany (39)
- # clojure-italy (1)
- # clojure-mexico (1)
- # clojure-nl (14)
- # clojure-spec (61)
- # clojure-uk (104)
- # clojurescript (125)
- # cursive (20)
- # datomic (1)
- # emacs (2)
- # figwheel-main (91)
- # fulcro (29)
- # graphql (9)
- # jobs (3)
- # jobs-discuss (9)
- # juxt (13)
- # liberator (2)
- # luminus (1)
- # off-topic (15)
- # parinfer (8)
- # re-frame (70)
- # reagent (35)
- # reitit (24)
- # remote-jobs (5)
- # ring-swagger (3)
- # shadow-cljs (127)
- # spacemacs (34)
- # yada (6)
is it possible to call (shadow/nrepl-select :app)
from a different nrepl that’s running from the same app? or do you have to use the shadow nrepl to call that? can the shadow nrepl replace clojure.tools.nrepl
?
you'll need to add the middelware to that server https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server
okay, and then do i still call nrepl-select
?
okay thank you
you can use something like this https://github.com/juxt/pack.alpha
you’d need a deps.edn file though
thanks @biscuitpants
i haven’t used it in prod yet though 🙂
btw, a proof that audioworklet and wasm can be compiled with shadow-cljs https://jsfiddle.net/4o3q5tu7/1/ (just showoff)

but https://github.com/jacekschae/conduit/blob/master/shadow-cljs.edn#L12 I can see both bundled together
@urbanslug no that is not supported currently. you can do it via :lein
or :deps
if you need to
Is it possible, or has it been thought trough and considered not worth it. To publish jar with cljs resources and bundle with it the shadow-cljs.edn file, which when consumed by other shadow-cljs app. Will inherit the npm dependencies, :resolve and :hooks (or make it configureable which to inherit and what not)?
This seems to part of another endless discussion of npm deps in cljs. But yeh, totally annoying. tools.deps supporting :npm-deps would be nice. It almost doesn't happen anymore that someone makes a library in clojurescript.
@hlolli I had a look at pack
as well for the same reason and I am thinking of adding an Azure pack
target for my use case: https://github.com/juxt/pack.alpha/issues/18
but it would definetly convenient to have everything in one tool...
@richiardiandrea yes looks like this is very special usecase. Maybe it's not such a big problem of packageing the stuff we need, generate .pom etc. But what the build tools do with it. I'd like more radical integration with javascript. As for the hooks, js already has install, preinstall and postinstall. We have 4 tools to build clj/s (lein/boot/shadow-cljs/clj), and none can do it. If you ask me, the minification that webpack does is pretty radical and has gotten way better. Clojurescript isn't an island, but almost.
Don't know why I added the webpack comment there 🙂 but it's easy not to use any optimization, at least in shadow-cljs, which I love.
Anyway, to end my rant, which only in a good tone and with great love of cljs. Then imagine, publishing a cljs library running on nodejs "by the book". Then the recommended way is bundling all the dependencies in a consumeable form, makeing a jar, stuffing in the js, and declare foreign libs. With that, generate extern. Now imagine 100 modules in the node_modules for like 5 npm deps. Wiriting extern for each and one of them. Then ok, if successful, upload them to cljsjs, create PR and wait, so that at the end of it you can tell your friend, "hey check out my new library with this oneliner". End of rant 🙂
yeah not ideal
@hlolli it has been considered but ruled "not desirable". a library should never be specific to one tool, its one of the worst aspects of some npm
deps and not something I want to introduce to CLJS. its already kind of bad that CLJS can't easily consume most npm
deps like shadow-cljs but I do hope that they'll catch up eventually.
custom :resolve
hooks are really a last resort option and should be used very rarely
:npm-deps
you can declare in deps.cljs
which shadow-cljs
supports and will install on startup. CLJS will to when configured to do so.
there is also the fundamental difference in how cljs and closure view the world vs webpack. closure wants to optimize your whole program, webpack optimizes file by file and only recently gained some cross-file stuff
webpack minification is laughable compared to what closure does. it is getting better but is nowhere near closure :advanced
I can start ranting about all the bad things in npm
for hours but I'd rather not 😉

you seem to have deleted another related message. at least I got an email notification but can't find the message here 😉
hehe yup, I deleted it, it was about being stuck between :es5 and :es6 when I using cljsbuild. If I uesed :es5 then I got errors about const and whole lots of features not being supported. When I used :es6, I started to get require calls adding .default and some of the node modules. Basically I'm working on packaging cljs app so that, hopefully, everyone can consume it on any build tool.
But :npm-deps
in deps.cljs
, I had no idea that was possible. That may actually be exactly what I need. Thanks for pointing that out!
yeah the .default
issue is a bit annoying. its the closure compiler doing that and unfortunately breaks many npm packages. and its a wontfix 😞 https://github.com/google/closure-compiler/issues/2971
Chad Killingsworth seem to have encountered this himself and made some changes. Maybe I try them out.
It's funny you are mentioning this because when vscode was open sourced, the very first thing i did is i tried to compile it, then i tried to see how can i hook in to the rendering and the file buffer, to see if i can implement elastic tabstops. But then I got lost in the forrest of typescript classes and gave up on it...
the problem was with .default, is that it was a module that I wasn't event require-ing directly, but a nested require
it was in lein, but yup, I am leaving it behind for now and concentrating on tools.dep.
But I guess that they need to run in lein too... so I won't leave it behind. My brain is bit drained.
if this is a nofix, then I just publish this stuff I have and write big red letters, use shadow-cljs. This is happening in the module "safe-buffer", which some module I'm requireing, is requireing, is requireing a built-in module "buffer"
var buffer = require('buffer')
this becomes
module$buffer.default
and I get ReferenceError: module$buffer is not definedbuffer
is also usually a built-in node package so it requires the node-libs-browser
shims that webpack also uses
I'm in this case only targeting node, I have seperate namespace for the browser, which I don't think this package will get required
I would assume that, built-in modules would just get hard-coded into the closure compiler.
hmm if you are only building for node that closure shouldn't rewrite any code at all?
in shadow-cljs when compiling for node the (:require ["whatever" :as x])
just generates a require("whatever")
call
the code rewriting stuff only applies for browser builds since they can't use require
so it should never get to the situation where require("buffer")
is turned into module$buffer
at all
ah ok I get it! now what's happening it that I just add the npm modules to foreign-libs, which is good, because I can set :module-type
for each and every dependency.
for example, when compiling, I get
Caused by: clojure.lang.ExceptionInfo: No such namespace: web-audio-api, could not locate web_audio_api.cljs, web_audio_api.cljc, or JavaScript source providing "web-audio-api"
yes and if I add
{:file "node_modules/web-audio-api/index.js"
:provides ["web-audio-api"]
:module-type :commonjs}
it will go awayyou want the CLJS compiler to emit require("web-audio-api")
. that is all. nothing else.
ask someone that does before continuing. you are on the completely wrong path when trying to use :foreign-libs to solve this.
ok just commented :npm-deps false
then it compiles, just again ReferenceError: module$buffer is not defined
they are not suitable for this at all. :foreign-libs
are prepended to the compiled code as-is!
hehe I maybe ask at another channel. And want to add that this is no "problem" for me, it's only an extra cool point that more people could use my code. Most likely, 1-2 peeps max will 🙂
Hello, I've just started using shadow-cljs for my ClojureScript development. My configuration file looks so:
{ :source-paths ["src/clj" "src/cljc" "src/cljs"]
:dependencies [[reagent "0.8.1"]]
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:entries [my-ns.main]}}}}}
In one of the file I'm requiring reagent like so:
(ns my-ns.main
(:require [reagent.core :as r]))
when I try to build this I got such message:
The required namespace "reagent.core" is not available, it was required by
Should I invoke some command to install it? Or maybe I should install it by lein project?
Thanks in advance!@raf use three quotes for multi line code. your config looks fine and should work. are you sure you started shadow-cljs after adding the dependency?
@thheller I use such command in the shell:
lein run -m shadow.cljs.devtools.cli compile app
well if you use lein
to run the command you need to add the dependency to project.clj
@thheller clear - I thought that only puting :lein option in the shadow-cljs.edn
makes that lein deps are used
generally yes but only if you actually use the shadow-cljs
command itself and not lein
now everything is clear. Thank you very much for help! I appreciate this! You've saved me a lot of time 🙂
@thheller just wanted to let you know, that now everything works, I was able to compile and run code
I get Error: Cannot find module '@cljs-oss/module-deps'
don't know who's asking for this
then Error: Could not locate the bindings file. Tried:...
for node-speaker
What is the best way to develop “lein” library and include it to shadow-cljs as dependency? My goal is to develop module and during this development test it in separated project as lein and shadow dependency.
I was even thinking about use the same project with project.clj
and shadow-cljs.edn
and run the same code using both to test it