This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-07
Channels
- # announcements (4)
- # babashka (59)
- # beginners (26)
- # calva (34)
- # clj-kondo (3)
- # cljs-dev (1)
- # clojure (77)
- # clojure-austin (4)
- # clojure-europe (20)
- # clojure-nl (2)
- # clojure-norway (11)
- # clojure-spec (3)
- # clojure-uk (4)
- # clojurescript (103)
- # community-development (2)
- # cursive (15)
- # datalevin (12)
- # datascript (38)
- # datomic (1)
- # deps-new (2)
- # events (3)
- # figwheel-main (6)
- # fulcro (9)
- # honeysql (12)
- # jobs (4)
- # juxt (18)
- # kaocha (19)
- # lsp (42)
- # missionary (2)
- # pathom (14)
- # polylith (6)
- # portal (6)
- # reagent (8)
- # reitit (4)
- # releases (2)
- # shadow-cljs (17)
- # testing (1)
- # tools-deps (50)
- # vim (46)
- # xtdb (12)
I've been away from ClojureScript for a while. What's the current vision on setting up a ClojureScript environment? With live reloading etc. I used to use shadow cljs.
Alright. If I want to use an older project which is build upon Clojurescript—Figwheel—Electron, how feasible is it to use it on shadow-cljs?
I haven't used figwheel in many years and have never used Electron, so can't tell for sure. But I'd guess that it's perfectly doable. At least in my experience, shadow-cljs works better than other tools - I've never seen something not working in shadow-cljs while working under some other tool.
Hey all. I have a question about writing Chrome extensions targeting Manifest V3: or, more specifically, https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/.
I'm using #shadow-cljs and https://github.com/binaryage/chromex, which are both wonderful. And best I can tell, digging around, is that with a little tweaking both should just continue to work... with one major exception: https://github.com/thheller/shadow-cljs/issues/902#issuecomment-1021939651`unsafe-eval`https://github.com/thheller/shadow-cljs/issues/902#issuecomment-1021939651. So no REPL.
Breaking changes! Yay! 🙃
1. One suggestion I came across (h/t @namy.19) was to https://github.com/thheller/shadow-cljs/issues/902#issuecomment-1021973818, for development.
2. Another possibility is that wasm-unsafe-eval
can be utilised somehow, as https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#content-security-policy. But right now I know nothing about WebAssembly, nor how it would come into play. (@thheller, you might have some idea?)
So I was wondering if yous lot have any experience solving these problems?
Migrating is a necessity, unfortunately, as we're trying to get an extension published to the Chrome Web Store at work, and:
My plans changed and I am no longer working on the chrome extension, but I will run into this soon enough as I have a fork of the fulcro devtools which is a chrome extension and that is written in cljs.
It seems like maintaining a chromium fork with that unsafe-eval
support is the "easiest" solution (I don't know of any others). As I said in that comment, it was pretty straightforward to patch the codebase and compile a version. I imagine some members of the cljs community can maintain a fork and then host the binaries so everyone won't need to go through that slow process. It's really quite annoying. Another option is to make some noise on the chrome bugtracker about needing this feature, but not sure how far that will go.
Yeah... I'm surprised there isn't a general solution already tbh! Are there really so few people writing Chrome extensions in cljs? 😕
I thought there would be more noise too, but yea, seems like not that many unfortunately. I was playing with a plain JS dev setup and I think that community uses dynamic script tags to reload code? so they don't care about this I think
@U05095F2K, https://github.com/homebaseio/datalog-console is Manifest V2. How are you planning to upgrade? (If you are?)
maybe we should just build a new browser, lol ditch JS while we're at it
> It seems like maintaining a chromium fork with that unsafe-eval
support is the "easiest" solution (I don't know of any others). As I said in <https://github.com/thheller/shadow-cljs/issues/902#issuecomment-1124189411
> |that comment>, it was pretty straightforward to patch the codebase and compile a version. I imagine some members of the cljs community can maintain a fork and then host the binaries so everyone won't need to go through that slow process. It's really quite annoying.
Any takers? 😛
> Another option is to make some noise on the chrome bugtracker about needing this feature, but not sure how far that will go. Well, they do seem receptive to feedback at least. E.g. here's re custom formatters: https://github.com/binaryage/cljs-devtools/issues/55#issuecomment-632384007
why not just live without unsafe-eval? I mean you can still work on your code in a regular browser repl and then just have the extension specific parts without a REPL?
Well... the extension is a decently sized codebase in its own right, and set to continue to grow. Not just a little thing on the side. 🙂
that might be but how much of that codebase is actually using chrome extension APIs?
> Well... the extension is a decently sized codebase in its own right, and set to continue to grow. Not just a little thing on the side. 🙂 And there are many "extension specific parts": https://developer.chrome.com/docs/extensions/mv3/architecture-overview/#arch And it's already a headache coordinating them! I dread to think about life without Chromex (https://github.com/binaryage/chromex/tree/master/examples/shadow#code-discussion, for one) + the REPL to hand... 😅
> and how much do you actually use the REPL to work with those? 😛 I use it constantly! But you make an interesting point... exactly how much is 'necessary'? :thinking_face:
How would I even isolate things?
not a clue what you are building but should be straightforward given that a chrome extension is still essentially just a browser?
not sure I follow
> but should be straightforward given that a chrome extension is still essentially just a browser I'm curious/confused what you meant here is all!
again, without any information about what you are building this comment might not apply
say you are building a chrome extension that displays some web UI (in its own tab, or popup, whatever)
ah, no
that's just one part if I understand you right: 'UI elements' https://developer.chrome.com/docs/extensions/mv3/architecture-overview/#arch
there are separate, isolated processes for other functionality:
> Chrome extension development is more complex than regular ClojureScript front-end work. You are writing (and debugging) multiple parallel communicating processes: your background page, service worker, your popup, and all the browser pages running your content script.
— https://github.com/binaryage/chromex/tree/master/examples/shadow#debugging
I'm gonna stop commenting unless you want to provide specific examples of what you are trying to do (and maybe failing)
so, maybe I could develop the popup UI in a REPL on the side, or something...
but what about all the other functionality? e.g. injecting a button into the DOM of a specific tab with a content script, sending a message to the background page service worker when it's pressed, so that it can send a http request with access to session storage to our backend... and so on
there's lots to consider beyond the sort of thing which could be developed in a regular browser window 😕
apologies if this is still kinda vague! but I don't think this is a waste of time: I disagree that the specifics of what I'm building are relevant what's relevant are these more general details of extension development
thanks for jumping in in any case, @thheller appreciate it :))
> It seems like maintaining a chromium fork with that unsafe-eval
support is the "easiest" solution (I don't know of any others). As I said in <https://github.com/thheller/shadow-cljs/issues/902#issuecomment-1124189411
> |that comment>, it was pretty straightforward to patch the codebase and compile a version. I imagine some members of the cljs community can maintain a fork and then host the binaries so everyone won't need to go through that slow process. It's really quite annoying.
Any takers? 😛
Hello everyone. I am trying to set up a Phoenix and ClojureScript project but I did not seem to find a lot of resource online to do that. I found this though https://darioghilardi.com/how-to-setup-a-phoenix-and-clojurescript-project/. I followed the guide but it seems it's outdated. Has anyone been able to successfully create a Phoenix and ClojureScript project recently?
I also found this https://forum.devtalk.com/t/clojurescript-liveview/10671/4, but same issue.
not a clue about any of the phoenix parts but the shadow-cljs parts of the first post are still the same
@thheller
Please is the following code snippet a valid shadow-cljs
configuration?
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[]
:dev-http {9080 "priv/static/assets/js"}
:builds {:app {:output-dir "priv/static/assets/js"
:asset-path "priv/static/assets/js",
:target :browser
:modules {:app {:init-fn app.main/main!}}
:devtools {:after-load app.main/reload!}}}}
Because I keep getting errors that /js/cljs-runtime/goog.dom.nodetype.js.map
cannot be found.https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#output-paths-and-http
it likely also isn't needed at all. I assume phoenix is capable of serving static files on its own
:asset-path "/static/assets/js"
is likely what you need? depending on how you access the js in the page
Thanks for your reply. Currently, my system is down. As soon as I'm able to power it, I'll try your suggestion and read up the article that you linked. If I'm not able to get it to work, I'll send my folder structure so it's easier for your to help me. Thanks.
Hi, Please do you know the cause of this error.
c:\Users\Admin\Documents\new-things\phoenix_cljs\assets\node_modules\.bin\shadow-cljs:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
I tried to start the development process by running node_modules/.bin/shadow-cljs watch app
and I got that error. What could I be doing wrong?sorry I don't know bash. this is not from any shadow-cljs code, and you likely want to call npx shadow-cljs watch app
So the problem is I don't know how possible it is for me to call npx
directly from the config with Phoenix. It seems a lot of the problem I'm facing is more Phoenix related than cljs
.
I mean how do you run commands in general? I see this
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../assets", __DIR__)
],
is there any place or way you can put a foo.txt
in any folder and load that over http?
that is the place the CLJS output should go and phoenix doesn't need to know anything about it
Yeah, I tried that, but I get this error
Error: Cannot find module 'c:\Users\Admin\Documents\new-things\phoenix_cljs\assets\npx'
So I think it's reading npx
as a directory.node: [
"npx",
"shadow-cljs",
"watch",
"app",
cd: Path.expand("../assets", __DIR__)
]
Let me try this.
I honestly don't know why you need to be running shadow-cljs as part of phoenix though
The suggestion for npx
did not work.
It's possible for me to run them separately?
I'd say yes. but again: I know absolutely nothing about phoenix. It might be putting you into some kind of jail that doesn't actually allow this
I think I see what you mean. I run the npx
command for cljs
separately, then I run the mix
command after the development server has started.
Right?
mix
starts the Phonix server.
Alright, makes sense. I'll try that. Thanks.
https://til.hashrocket.com/posts/1a3639476e-serve-static-filesdirectories-in-phoenix
Thanks.
Now, I'll try to check the article you linked yesterday so I can fix the shadow-cljs.edn
config issue from yesterday
@thheller I really appreciate you for your help, you've been a saviour. I have been able to fix the issue from yesterday. Also, I'm now running both servers independently of each other. Thanks again.
Talking about starting the shadow-cljs
server directly from Phoenix config, with a bit of experiment, I have been able to make that work. I used bash
instead of node
bash: [
"node_modules/.bin/shadow-cljs",
"watch",
"app",
cd: Path.expand("../assets", __DIR__)
]
And it was successful.Hi everybody! Is this a bug or is it imposible to alter meta on ClojureScript?
cljs.user=> (def a 5)
#'cljs.user/a
cljs.user=> (meta #'a)
{:ns cljs.user, :name a, :file "cljs/user.cljs", :end-column 7, :source "a", :column 1, :line 1, :end-line 1, :arglists (), :doc nil, :test nil}
cljs.user=> (alter-meta! #'a assoc :foo true)
{:foo true}
cljs.user=> (meta #'a)
{:ns cljs.user, :name a, :file "cljs/user.cljs", :end-column 7, :source "a", :column 1, :line 1, :end-line 1, :arglists (), :doc nil, :test nil}
yeah I was almost sure about that, but why is there alter-meta! and reset-meta! that doesn't complain, any idea?
does anybody knows of a way of manipulating those fields? Because lets say I grab the source of #'clojure.core/map using cljs.repl/source-fn
and re evaluate it on the repl, then I don't have those fields anymore and I can't get the source a second time, I'm creating tooling and would like to grab meta, re-evaluate the source of a function and then restore that meta, any ideas?
i have an open ticket that is a bit similar: https://clojure.atlassian.net/browse/CLJS-3277 . Def’d vars don’t preserve the metadata given to them
Hi, Please do you know the cause of this error.
c:\Users\Admin\Documents\new-things\phoenix_cljs\assets\node_modules\.bin\shadow-cljs:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
I tried to start the development process by running node_modules/.bin/shadow-cljs watch app
and I got that error. What could I be doing wrong?