This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-10
Channels
- # adventofcode (76)
- # announcements (7)
- # aws (3)
- # babashka (75)
- # beginners (25)
- # calva (37)
- # cider (9)
- # clara (4)
- # clj-kondo (17)
- # cljsrn (1)
- # clojure (106)
- # clojure-europe (4)
- # clojure-india (2)
- # clojure-italy (12)
- # clojure-nl (27)
- # clojure-spec (33)
- # clojure-uk (20)
- # clojurescript (103)
- # clojutre (3)
- # core-async (1)
- # cryogen (10)
- # cursive (24)
- # datomic (113)
- # dirac (5)
- # emacs (12)
- # events (4)
- # fulcro (64)
- # garden (5)
- # jobs (1)
- # kaocha (5)
- # luminus (2)
- # malli (14)
- # off-topic (53)
- # planck (11)
- # re-frame (9)
- # reagent (16)
- # reitit (26)
- # remote-jobs (2)
- # shadow-cljs (137)
- # spacemacs (34)
what's the clj/cljs way of linking a dependency so you can use the local version rather than remote one? I know I can reference a dependency by local path but is there a way to do it without changing code?
One possible way is, in src/main of your project, create a symlink to the src directory of the local dep, e.g. src/main/foo
where foo is a link to ~/dev/foo-project/src/foo
Or if you use emacs, you can simply link a buffer of the local dep project to the cider session of your own project, so you can modify the source of the local dep project, and eval it in your repl
another way if you use deps.edn is :local/root
{:paths ["src" "resources"]
:deps {com.fulcrologic/fulcro {#_#_:mvn/version "3.0.3"
.... :local/root "/Users/me/fulcro"}
lilactown/hx {:mvn/version "0.5.3"}}}
Hi everybody, I'm trying to get css reloading working, but I just can't figure it out. I'm not using the built-in web server, my app contains a web server that serves static assets. I've set my :watch-dir
to "resources/public"
, which is the root that the web server serves from; still no changes are ever pushed (i see them when i reload the page). My css lives at resources/public/css/compiled
, and is linked in the HTML as <link rel="stylesheet" href="/css/compiled/cue.css?cache-buster=<cache-buster>" />
. What am I doing wrong?
maybe there's something i need to run as part of the command i use to kick off shadow-cljs? at the moment i run npx shadow-cljs watch app
it looks fine to me. maybe try without ?cache-buster
? your webserver just may be caching to aggressively too and only serving the "old" content when another request is made?
here's my config
{:lein {:profile "+dev"}
:builds
{:app {:target :browser
:output-dir "resources/public/js/compiled/"
:asset-path "/js/compiled"
:compiler-options {:infer-externs :auto}
:dev {:compiler-options {:closure-defines
{"day8.re_frame.tracing.trace_enabled_QMARK_" true
"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:preloads [day8.re-frame-10x.preload]
:after-load user/after-load
:watch-dir "resources/public"}
:external-config {:devtools/config {:features-to-install :all}}
:pretty-print true
:print-input-delimiter true
:source-map true}
:release {:compiler-options {:closure-defines {goog.DEBUG false}
:optimizations :advanced}}
:main cue.core
:modules {:cue {:entries [cue.core]}}}}}
pretty-print and source-map default to true and would other also need to be in :compiler-options
yeah i don't think i've gone crazy here. ok could it be the way i run shadow, which is with this?
(require
'[orchestra.spec.test :as stest]
'[shadow.cljs.devtools.api :as api]
'[shadow.cljs.devtools.server :as server])
(server/start!)
(api/watch :app)
(api/repl :app)
(stest/instrument)
i'll try that. no, i'm seeing nothing about css in the console, i'm pretty sure it's not watching for changes
am i right to have "resources/public"
as the value for my :watch-dir
when my css lives at resources/public/css/compiled
?
my css compilation occurs in WSL, but shadow-cljs is runnign in windows. it's all on a windows filesystem though. could there be a problem with watching files on a windows filesystem?
well, thanks for your help. the only way forward i can see is to stop using my webserver and pass my handler to shadow-cljs and see if i can get that working. much appreciated as ever!
the webserver isn't even involved in this so it should be working fine. I know its working for others too
other than that I don't really know. I'm on windows too so that shouldn't be an issue
same deal running from a terminal inside wsl, so it's something to do with my project and not my environment
oh. i read in the docs that :watch-dir
was only needed for non-webserver setups, but your comment about the webserver not being involved makes me wonder whether i misunderstood?
I've stripped it down and have a small repro https://github.com/conan/css-reload
same deal. tested using cursive and the command line, in windows, wsl and on mac. i'd be super grateful if you had time to cast an eye, but obviously only if you're curious.
I rewrote the config to be
{:source-paths ["src/cljs"]
:dependencies
[[reagent/reagent "0.8.1"]]
:builds
{:app {:target :browser
:output-dir "resources/public/js/compiled/"
:asset-path "/js/compiled"
:compiler-options {:infer-externs :auto
:external-config {:devtools/config {:features-to-install :all}}}
:devtools {:after-load user/after-load
:watch-dir "resources/public"}
:modules {:css-reload {:entries [css-reload.core]}}}}}
I don't have time right now to figure out why ... there are many things wrong with the config though
I'm trying to do some more code splitting on my project. I looked at the build report > main (default module> project files and picked a namespace that i dont believe needs to be loaded with the initial/default/main module. That is, i assume the namespace in question is shared by two modules which means its pushed into the default/main module. So if i make the shared namespace its own module then explicitly declear it a dep of the other ones, it wont be loaded with the main module: Before MainModule -> ns1 After MainModule -> XModule -> ZModule (ns1) YModule -> ZModule (ns1) I attempted to do just that, Then, when i try to build a report (or a build) I get an exception and then this message: Module Entry <Module Name> was moved out of module <Module Name> It was moved to <Module Name 2> and used by <some set of modules> I'm not sure what this is telling me. My intent was to create a new module (the <Module Name> from the msg above) so the message seems to be telling me that my it shouldnt create the new module because it was used by the other set of modules. Specifically, in that set of modules it lists the main module. Which from checking the dependencies isnt true. as in, main doesn't seem to depend on that module in any way.
@drewverlee that error is telling you that an entry-ns (so either :entries
or :init-fn
) specified for one module was moved out
Thanks. So say i just have a small app with 3 namespaces: main, a, b. main requires a and b. So in shadow-cljs.end the setup would just be:
:modules
{:main {:init-fn some.app.main/-main}
:a {:entries [some.app.a} :depends-on #{:main}}
:b {:entries [some.app.a} :depends-on #{:main}}}
What would be an example of a something that would cause this error? Your implying something could be wrong with the requires? but i can't imagine what that could be. The app worked before the modules were added so in what scenario would it not work after modifying the shadow-cljs config to add modules.some.app.main cannot require some.app.a or b directly
Concretely, you mean you cannot have:
(ns some.app.main (:require [some.app.a :as a]) ?
You have to use the lazy load functionality?
I have a JS file Iâm including a CLJS lib that does this: import * as React from "react";
I tried to use import React from "react"
at first, but I get an error when I execute the code from a REPL that React
is undefined. Using the glob syntax fixed this.
However, now a user has reported that trying to use it in React Native they receive this error:
--- helix/impl/class.js:1
Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import React from 'goog:shadow.js.shim.module$react';?
link to issue: https://github.com/Lokeh/helix/issues/1 link to JS code: https://github.com/Lokeh/helix/blob/master/src/helix/impl/class.js
and what makes things worse it that this is an "upcoming" default ... meaning that most libraries have not adopted this yet
so they would break too because they still expect import {createElement} from "react"
or whatever to work
this is ~34 lines of code so I donât think missing out on advanced compilation will be a big deal
I also doubt it will be used super often, as itâs only used to construct a React class which is only necessary when using error boundaries
so as long as it doesnât âinfectâ other code too much with itâs lack of optimizations I am fine with switching to CJS
it'll be better when webpack v5 comes out and people adopt (since it will also break there)
well this seems to only be a problem when using npm packages inside of a JS file on the classpath
but dunno how long that'll be and don't know what fun kind of changes the closure compiler throws into the mix until then
@U05224H0W can you maybe transpile it differently and output it to different file extensions, i.e. native.js
versus web.js
so is the syntax that is meant to work is this
import * as react
so that you can do this
["react" :as react]
but react native isn't recognizing that syntax since it transpiles the JS itself (yet it has to be this way in es6 for the cljs import statement to work)
tried to test this out in helix but doesn't look like shadow-cljs recognizes the different platform extensions.
in either case, maybe that could be a solution since react native will look for .native.js
before .js
@lilactown actually what I'd suggest is not importing react at all in the .js
file
Is there anything written about how shadow is doing the code splitting under the hood? I orginal through it was using webpack but i'm not sure and one of the tutorials implies its not.
@U05224H0W has an article on code splitting cljs, maybe it's what you're looking for https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html
https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html
Hi all, I'm trying to use shadow-cljs in a project and it seems to be getting stuck when I try to "watch" my app. Here's what happens (<https://gist.github.com/TomLisankie/eb7cedb746fd18b53393ae7e197ee928>) when I run shadow-cljs watch app
from within my project directory and here's the shadow-cljs.edn (<https://gist.github.com/TomLisankie/ed0c3ab4e83c14aaf0bdf48b18594d47>).
I thought it was just taking a really long time to start or something, but then I tried the same command in a different shadow-cljs project and it was pretty quick. I'm guessing it's something wrong with my configuration, but I can't seem to figure out what.
Any help would be much appreciated.
@thomas745 I donât see anything wrong with that output
@thomas745 shadow-cljs does not operate like figwheel. so if you are waiting for a REPL to show up that will never happen. instead you run shadow-cljs cljs-repl app
separately to get your REPL when needed. the watch is independent of that
@lilactown I'm expecting my app to show up when I go to the localhost URL provided like it does with figwheel but instead I just get a shadow-cljs dashboard with a list of active builds. It also has a listing for active HTTP servers but there aren't any running I'm guessing since none are being listed
@lilactown That works. Thanks a lot!