This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-22
Channels
- # announcements (2)
- # architecture (33)
- # babashka (4)
- # beginners (445)
- # bristol-clojurians (10)
- # calva (23)
- # cider (43)
- # clj-kondo (36)
- # cljs-dev (13)
- # cljsrn (20)
- # clojure (136)
- # clojure-argentina (8)
- # clojure-dev (1)
- # clojure-europe (18)
- # clojure-germany (1)
- # clojure-italy (5)
- # clojure-nl (45)
- # clojure-spec (66)
- # clojure-uk (29)
- # clojurescript (69)
- # conjure (157)
- # cursive (2)
- # datomic (216)
- # emacs (10)
- # exercism (4)
- # figwheel-main (8)
- # fulcro (30)
- # graphql (21)
- # hoplon (5)
- # kaocha (7)
- # leiningen (3)
- # luminus (4)
- # music (1)
- # off-topic (24)
- # pathom (10)
- # re-frame (19)
- # reagent (11)
- # reitit (16)
- # remote-jobs (1)
- # ring-swagger (5)
- # rum (7)
- # shadow-cljs (125)
- # spacemacs (8)
- # sql (9)
- # tools-deps (12)
random comment to say how happy I am with shadow’s caching/invalidation approach. I had forgotten how often I used to encounter bugs related to partially compiled code, macros not recompiling properly, waiting to recompile everything after ‘clean’, etc, which had faded in my memory (until working again on some old code).
anyone tried using shadow in nixos? does it need a nixpkg like leiningen or is it just usable as a dep in the package.json of your project?
it loads the shadow-cljs-jar
npm dependency which contains an uberjar to download maven dependencies yes
Hello. I have a macro, which I would like to output different code, when in release build. How do I detect the release vs. development build in my macro code?
@witek you can check the :shadow.build/mode
key in the macro &env
, like this
(core/defmacro defonce
"defs name to have the root value of init iff the named var has no root value,
else init is unevaluated"
[x init]
(if (= :release (:shadow.build/mode &env))
;; release builds will never overwrite a defonce, skip DCE-unfriendly verbose code
`(def ~x ~init)
`(when-not (exists? ~x)
(def ~x ~init))))
Having some trouble loading JS files on my classpath, as per https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js -
The required JS dependency "/js/react-fitted-image/index" is not available, it was required by "nosco/views/ideabox_copy_select_template.cljs".
Dependency Trace:
nosco/views/main.cljs
nosco/views/ideabox_copy_select_template.cljs
However, from the same repl: (io/resource "js/react-fitted-image/index.js")
returns a correct file.
Neither ["/js/react-fitted-image/index.js" :as FittedImage]
nor ["/js/react-fitted-image/index" :as FittedImage]
work.
@orestis it is possible that parsing errors in .js
files aren't reported to the proper place. look at the server output, maybe there is something about a parse error
Nothing there -> I also tried with a trivial file (literally just function foo(){ alert("hi"); }
) and I get the same error.
hmm it might be the filename? the typical -
vs _
as in cljs files? not actually sure.
Background -> I want to use a stupid little react library and run into a flavor of the stupid babel regenerator runtime stuff. So I decided to just copy the thing in, it’s 100 lines of JS.
hmm are you sure your classpath is setup correctly? I mean do you get the proper resource when using shadow-cljs clj-repl
? no other tool, no nrepl, etc?
$ shadow-cljs clj-repl
shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn
shadow-cljs - connected to server
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
> (require '[ :as io])
nil
> (io/resource "js/foo.js")
#object[.URL 0x240a2e93 "file:/Users/orestis/dev/nosco/gamma/dev-resources/js/foo.js"]
shadow.user=>
there are waaaaaaaaaaaaaay to many libraries out there that contains compiled .js code as well as their sources
even uncompiled sources .. so there might be a cljs/core.cljs
file in a .jar
that is not clojurescript
for some reason my shadow repl isn't allowing me to require anything, although I can still require things in the project files.
shadow.user> (require '[tw-cljs.core :refer [tw]]) Execution error (FileNotFoundException) at shadow.user/eval76747 (form-init5445768818949264817.clj:465). Could not locate tw_cljs/core__init.class, tw_cljs/core.clj or tw_cljs/core.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
that is not a CLJS REPL. that is a CLJ REPL. you can switch to the CLJS REPL by calling (shadow/repl :the-build-id)
OK, moving the simple foo
file outside to some non-resources folder seems to work. Good to know in the future.
yeah I should probably lift that restriction somewhat. doesn't really matter if you classpath is clean
should probably just warn about bad .jar
files that contain compiled code in bad places
C-c C-t n doesn't work. I get clojure only operation requested in clojurescript buffer
whenever I run (js/alert "foo") in the shadow repl, it breaks the repl. The repl stops working
btw @thheller that thing I’m working on is recreating next.js’s filesystem routing api, but natively for clojurescript, which has advantages since the source code for a page is data itself so it’s easy to extract a page routes map to configure the router (if you need). I have a basic thing working in our app now, will work on adding more features (what’s missing from next.js)
something you’re aware of https://github.com/thheller/next-cljs/blob/master/src/main/shadow/next_js.clj#L27
@pshar10 if you’re in the browser repl that operation blocks everything until the alert is closed
so say I'm running tests and I want to compare the behavior of a component. e.g. (is (= #(js/alert "something") (:on-click (nth (my-component) 1)))How would I do that?
would you give an example of what you mean by asserting that the passed on-click handler is called?
it seems like you’re trying to simulate user actions, and make assertions about the outcomes based on the new elements displayed
I'm trying to do test driven development, and trying to test the front-end. I'm not sure if test driven development is useful for doing that.
TDD is a little hard for client side code, but something like https://github.com/bhauman/devcards
my workflow is get my editor connected to the browser repl, and then just start writing code
Running into this error on Cordova: WebSocket network error: WebSocket connection failed because it violates HTTP Strict Transport Security.
I’m looking into it now, but just posting it here to see if anyone has run into this issue before? It’s preventing the hot reloading.
just relax your CSP? it is configured in your index.html by default and rather strict. just remove it for development?
this is about as far as I have ever used cordova and it had a CSP meta in the default html https://github.com/thheller/cordova-cljs
I'm trying out shadow-cljs for the first time with a new project based on Luminus. When I try to jack-in-cljs I get "Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). missing instance". Is this an easy fix?
I do not support the way luminus has integrated shadow-cljs via lein-shadow
. so you are going to have to ask the authors how this is meant to work.
How can I add a js file in my shadow build process? It's a postcss.config.js file in my root directory and I want to build my shadow app with the postcss
neither lein nor shadow-cljs need to know where your .css
files come from. they just need to be somewhere.
I use this for my tailwind stuff https://github.com/postcss/postcss#npm-run--cli
Hello, I've got a js file that I want to import into my app. The file starts like this:
var CodeMirror = require('codemirror/lib/codemirror')
require('codemirror/mode/javascript/javascript')
require('codemirror/addon/hint/javascript-hint')
require('codemirror/addon/hint/show-hint')
require('codemirror/addon/selection/mark-selection')
require('codemirror/addon/comment/comment')
console.log("cm",CodeMirror)
The problem is that CodeMirror
is undefined. How can I import it?I took it from another repo, I don't want to rewrite all the files
My calling code looks a bit like this:
I'm assuming that you mean this console.log("cm",CodeMirror)
logs CodeMirror
as being undefined?
yes, and also the code that follows throws an error because of that
(ns algoradio.core
(:require
[algoradio.state :refer [app-state]]
[cljs.user :refer [spy]]
[algoradio.archive :as archive]
[reagent.core :as reagent]
[algoradio.freesound :as freesound]
[algoradio.player :as player]
["/hydra_editor/dist/index" :as h]))
;; more code
(comment (h/init (clj->js {:editorContainerId "editor-container"})))
yes, and also the code that follows throws an error because of that
I just found a quick and painless solution, that was building a bundle with parcel
, but I wonder I am doing something wrong
there's a bundle builder for js called parcel
(kind of like webpack)
yeah, it's not good
Could you please try this @thheller
const CodeMirror = require('codemirror/lib/codemirror')
console.log("cm2", CodeMirror)
export default {}
I found that adding the export default
caused the failure on my side
in fact any use of export
seems to provoke it
How do I use reframe in the repl? In my project files subscribe and dispatch works, but in the connected shadow-cljs repl, the dispatches and the subscribes are all returning nil
@diego.vid.eco do not mix require
with export
. either use require
with exports.foo
or import
and export foo
. don't use commons and ESM in one file.
This doesn't work for me either
import CodeMirror from 'codemirror/lib/codemirror'
//const CodeMirror = require ('codemirror/lib/codemirror')
console.log("cm2", CodeMirror)
should it?
cool, thanks
BTW I am really enjoying working with shadow. Awesome work!