This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-19
Channels
- # admin-announcements (1)
- # adventofcode (14)
- # announcements (2)
- # asami (7)
- # babashka (9)
- # beginners (41)
- # calva (43)
- # cider (31)
- # clerk (2)
- # clojure (34)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (166)
- # clojure-uk (7)
- # clojurescript (4)
- # datomic (1)
- # fulcro (10)
- # garden (1)
- # hoplon (2)
- # humbleui (4)
- # hyperfiddle (12)
- # jobs-discuss (6)
- # quil (6)
- # ring (6)
- # shadow-cljs (55)
- # squint (8)
- # xtdb (26)
I fail getting cljs.repl
utilities to work. The following works in a plain ClojureScript repl
cljs꞉user꞉>
; Evaluating file: core.cljs
[]
cljs꞉main.core꞉>
(try
(require '[cljs.repl :refer [apropos dir doc find-doc print-doc pst source]])
(catch :default e
(js/console.warn "Failed to require cljs.repl utilities:" (.-message e))))
nil
cljs꞉main.core꞉>
(doc doc)
:repl/exception!
;
; Execution error (TypeError) at (<cljs repl>:1).
; Cannot read properties of undefined (reading 'call')
Is it supposed to work? If I qualify the doc
symbol, it works:
(cljs.repl/doc doc)
-------------------------
cljs.repl/doc
nil
nil
first of all a require in a try is not valid, require is a special form in the REPL and can only be used at the top level
I'm trying to usehttps://shadow-cljs.github.io/docs/UsersGuide.html#_module_exports to export some cljs functions and import them in a vanilla js project, it all works for a super simple example but when I try and export a function in a file with a lot of imports then I get this:
cljs_env.js:61 Uncaught Error: Namespace "shadow.js" already declared.
at goog.provide (cljs_env.js:61:13)
at js.js:11:1
The js code looks like
import { foo } from "../shadow-output/js/foo.js";
console.log(foo);
relevant shadow config is
...
:builds {:app {:target :esm
:compiler-options {:output-feature-set :es-next}
:modules {:foo {:exports {foo app.core/foo}}}
:output-dir "shadow-output/js"}}
and app.core
(ns app.core
(:require
[re-frame.core :as rf]))
(defn foo [a b] (prn a b (+ a b)))
Without the re-frame require it works as expected, and when requiring things like 'clojure.string' it also worksI haven't set the runtime but I'm guessing it defaults to :browser? docs say only browser is supported
I'm not sure I even want a runtime, I just want shadow to spit out js files and my js app will handle the web server/hmr etc
https://github.com/armincerf/shadow-esm-issue ok strangely the error is a different one but the end result is the same, if I import re-frame it stops working (I think other imports have the same effect)
if you are using vite you must do this https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration
vite seems to reset the console quite often and in the process throwing away all shadow-cljs output
hmm yeah I think what I'm trying to do probably isn't a good idea, will have to rethink things...
this might help you @U7KPK060K i made this repo https://github.com/matheusfrancisco/poc.cljs-export-to-js to write something in clojurescript and run with nodejs and run into a react app.
I am trying to load a .mjs
file from an html script
, however I get a MIME type error, because apparently the server needs to serve this file with a MIME type other than application/octet-stream
, I believe it should be text/javascript
. Is there a way around this, besides renaming the file extension?
why does it matter that the extension is .mjs
? the browser doesn't have any special behavior for that
I think I am just using the shadow-cljs server.
It doesn’t really matter except for the fact that the library I am using provides .mjs
files.
It’s PDF.js
I mean I can add proper mime types for .mjs
for the shadow-cljs server, but since browsers literally don't care what extension you use it doesn't matter?
yeah I can rename them, I just wanted to know if there would be a more straight forward way to avoid having to write a script that renames these files.
libs/pdfjs/pdf.mjs?v=kCsG9N0xiZwKFrpo8t0Lb
It’s not being manually set, not sure what is doing that, but I guess it’s to prevent the browser from cacheing those files
https://github.com/thheller/shadow-undertow/commit/bf84dab4989f21601c52449a36fda4dabe2e067a
Thanks
btw, the versioning maybe comes from posthtml
I think I am just using the shadow-cljs server.
It doesn’t really matter except for the fact that the library I am using provides .mjs
files.
libs/pdfjs/pdf.mjs?v=kCsG9N0xiZwKFrpo8t0Lb