This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-13
Channels
- # aleph (15)
- # announcements (4)
- # babashka (36)
- # babashka-sci-dev (1)
- # beginners (15)
- # biff (2)
- # calva (15)
- # cider (3)
- # clj-kondo (8)
- # clojure (149)
- # clojure-europe (14)
- # clojure-norway (13)
- # clojure-switzerland (1)
- # clojure-uk (1)
- # clojurescript (21)
- # community-development (5)
- # cursive (20)
- # data-science (2)
- # datomic (7)
- # duct (5)
- # emacs (19)
- # etaoin (3)
- # events (2)
- # fulcro (11)
- # introduce-yourself (2)
- # jobs (4)
- # jobs-discuss (19)
- # joyride (1)
- # leiningen (11)
- # malli (7)
- # membrane (131)
- # nbb (12)
- # nginx (1)
- # off-topic (33)
- # pathom (8)
- # polylith (28)
- # re-frame (8)
- # sci (7)
- # shadow-cljs (225)
- # spacemacs (10)
- # specter (1)
- # vim (10)
- # xtdb (8)
I have an awkward macro in SCI that attempts to do the following:
When the macro is used from ClojureScript, it should load the cljs.analyzer.api
and populate a var, so that I can use the var in another namespace (to resolve metadata about vars in CLJS).
When the macro is used from outside of ClojureScript, it's a no-op.
This approach works well, but has a problem with the analysis cache of CLJS. So when I change a dependency or so and restart the compiler/watch process, it crashes, unless I remove this cache, in shadow's case, the .shadow-cljs
directory.
What's the story with macro calls from .cljs namespaces - are these cached somehow?
The gnarly piece of code is here: https://github.com/babashka/sci/blob/26553568f3b7f0f07795d99f00f13368fb936606/src/sci/impl/cljs.cljc#L20
When I put a logging statement in the macro which runs in the JVM:
(binding [*out* *err*] (println "Requiring cljs.analyzer.api!"))
I see the output on the first invocation of shadow-cljs, but not in the second one.I'm unsure that this is supposed to be doing though? looks like it tries to do a dynamic require?
but wouldn't it be easier to make that sci.impl.cljs
entirely unconditional and make it do whatever it needs to do for CLJS
Yes, if I could change things, I might have made a separate CLJS API namespace, but this would be kind of breaking. So I'm trying to solve the problem without doing this first. Thanks for the hints!
there is also the :dev/always
hook https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks
so what I'm trying now is on the first def
, I have this:
#?(:clj (def cljs-ns-publics (resolve 'cljs.analyzer.api/ns-publics)))
This sometimes works and also after recompilation it works. But it hasn't always worked, probably due to the order of dependency loading: SCI first or CLJS first
thinking about .cljc makes my head hurt. why do you do it as .cljc? it really doesn't need to me as far as I can tell?
I agree that it would be simpler. I think I've tried that before but I ran into different issues, possibly with self-hosted or so
> so that I can use the var in another namespace (to resolve metadata about vars in CLJS).
ok may I make the following suggestion. create or use a namespace that everything can import. sci.impl.env
or so, which just has a (def resolve nil)
which you'll call whenever you need to resolve something.
in sci.core
as your first require you do a conditional so #?(:cljs [sci.impl.cljs] :cljs [sci.impl.cli])
the cljs variants is just a regular CLJS requiring cljs.anylzer and whatever else it may need
any by putting it in a well known var that always exists things become much cleaner no?
the well known var that always exists is inside sci.impl.cljs
, it's called cljs-ns-publics
That is already the ns that everyone can import - trying to understand how your approach might work better
I assume that means you need it during macro expansion? or actually at JVM runtime, meaning in the final created binary?
btw, the workaround I pushed a minute ago, seems to work reliably after stopping and starting the compiler now...
as far as I can tell my suggestion would remove a whole lot of conditional code and work in all environments. albeit being a little unclean when loading the sci.impl.cljs
cljs/clj macro combi in CLJ environment
but as far as I can tell that shouldn't happen. I mean you could even control via build config
and consumers of sci as a lib probably never use sci.impl.* namespaces anyways right? only sci.core?
but if your problem is solved then rewriting a bunch of stuff might not be necessary š
I'll revisit this when the issue persists with your remarks in mind. Thanks a lot :)
If people can ensure the loading order CLJS and then SCI, then the issue won't happen anymore. But this order of loading isn't always guaranteed I think
Is there a way to ignore :redef warnings from some namespaces? After cljs 1.11 I get a few of them on every rebuild:
[1] [:app] Build completed. (1684 files, 469 compiled, 5 warnings, 15.44s)
[1]
[1] ------ WARNING #1 - :redef -----------------------------------------------------
[1] Resource: day8/re_frame_10x/inlined_deps/garden/v1v3v10/garden/color.cljc:390:1
[1] abs already refers to: cljs.core/abs being replaced by: day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color/abs
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #2 - :redef -----------------------------------------------------
[1] Resource: zprint/range.cljc:81:1
[1] abs already refers to: cljs.core/abs being replaced by: zprint.range/abs
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #3 - :redef -----------------------------------------------------
[1] Resource: cljc/java_time/duration.cljc:33:1
[1] abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #4 - :redef -----------------------------------------------------
[1] Resource: no/en/core.cljc:131:1
[1] parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #5 - :redef -----------------------------------------------------
[1] Resource: no/en/core.cljc:136:1
[1] parse-double already refers to: cljs.core/parse-double being replaced by: no.en.core/parse-double
I get that they are a real thing and due to the new cljs fns, but I donāt control these files, nor am I changing them. I know I can set :warnings {:redef false}}
on compiler options, but then I donāt get other real redef issues.I would assume that all these libs probably have new versions to address this for 1.11?
some might, some might not, but it only takes one of these warnings to make rebuilds very noisy, and updating them is a bit of a crapshoot (maybe new errors, maybe new api, etc)
I think Iāll just remove the redef warning completely then
thank you for taking a look
but didn't I change it so warnings in files you don't control only appear once on the initial build for watch
but not on recompile?
you know, thatās actually weird: two of these appear on startup, the rest appear on every reload
they also show up differently
startup
[1] [:renderer] Configuring build.
[1] [:app] Configuring build.
[1] [:main] Configuring build.
[1] [:main] Compiling ...
[1] [:renderer] Compiling ...
[1] [:app] Compiling ...
[1] [:main] Build completed. (86 files, 85 compiled, 0 warnings, 4.00s)
[1] WARNING: abs already refers to: #'clojure.core/abs in namespace: day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color, being replaced by: #'day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color/abs
[1] WARNING: abs already refers to: #'clojure.core/abs in namespace: cljc.java-time.duration, being replaced by: #'cljc.java-time.duration/abs
[1] [:renderer] Build completed. (1684 files, 1683 compiled, 0 warnings, 33.24s)
[1] [:app] Build completed. (1684 files, 1683 compiled, 0 warnings, 33.35s)
[1] [:app] Configuring build.
[1] [:renderer] Configuring build.
then on any file save, I get the previous set of warnings
hmm maybe something is messed up and it logs the "noisy" warnings when it shouldn't?
I don't use libs that produce warnings so not something I would never notice myself š
lemme make a repro then, should be able to isolate it
here it is
npm install
npm start
on startup it shows
filipesilva@MacBook-Pro ~/s/repro-shadow-cljs-warnings (master)> npm start
> [email protected] start
> shadow-cljs watch app
shadow-cljs - config: /Users/filipesilva/sandbox/repro-shadow-cljs-warnings/shadow-cljs.edn
[2022-07-13 12:39:07.507 - WARNING] TCP Port 9630 in use.
shadow-cljs - server version: 2.19.5 running at
shadow-cljs - nREPL server started on port 58223
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
WARNING: abs already refers to: #'clojure.core/abs in namespace: cljc.java-time.duration, being replaced by: #'cljc.java-time.duration/abs
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 1.77s)
------ WARNING #1 - :redef -----------------------------------------------------
Resource: cljc/java_time/duration.cljs:33:1
--------------------------------------------------------------------------------
30 | (clojure.core/defn of-nanos {:arglists (quote (["long"]))} (^js/JSJoda.Duration [^long long14686] (js-invoke java.time.Duration "ofNanos" long14686)))
31 | (clojure.core/defn of-millis {:arglists (quote (["long"]))} (^js/JSJoda.Duration [^long long14687] (js-invoke java.time.Duration "ofMillis" long14687)))
32 | (clojure.core/defn negated {:arglists (quote (["java.time.Duration"]))} (^js/JSJoda.Duration [^js/JSJoda.Duration this14688] (.negated this14688)))
33 | (clojure.core/defn abs {:arglists (quote (["java.time.Duration"]))} (^js/JSJoda.Duration [^js/JSJoda.Duration this14689] (.abs this14689)))
-------^------------------------------------------------------------------------
abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
34 | (clojure.core/defn between {:arglists (quote (["java.time.temporal.Temporal" "java.time.temporal.Temporal"]))} (^js/JSJoda.Duration [^js/JSJoda.Temporal java-time-temporal-Temporal14690 ^js/JSJoda.Temporal java-time-temporal-Temporal14691] (js-invoke java.time.Duration "between" java-time-temporal-Temporal14690 java-time-temporal-Temporal14691)))
35 | (clojure.core/defn get-seconds {:arglists (quote (["java.time.Duration"]))} (^long [^js/JSJoda.Duration this14692] (.seconds this14692)))
36 | (clojure.core/defn from {:arglists (quote (["java.time.temporal.TemporalAmount"]))} (^js/JSJoda.Duration [^js/JSJoda.TemporalAmount java-time-temporal-TemporalAmount14693] (js-invoke java.time.Duration "from" java-time-temporal-TemporalAmount14693)))
37 | (clojure.core/defn minus-nanos {:arglists (quote (["java.time.Duration" "long"]))} (^js/JSJoda.Duration [^js/JSJoda.Duration this14694 ^long long14695] (.minusNanos this14694 long14695)))
--------------------------------------------------------------------------------
if you edit src/main/app.cljs
, you get the warning
------ WARNING #1 - :redef -----------------------------------------------------
Resource: cljc/java_time/duration.cljs:33:1
abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s)
------ WARNING #1 - :redef -----------------------------------------------------
Resource: cljc/java_time/duration.cljs:33:1
abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.05s)
------ WARNING #1 - :redef -----------------------------------------------------
Resource: cljc/java_time/duration.cljs:33:1
abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.05s)
------ WARNING #1 - :redef -----------------------------------------------------
Resource: cljc/java_time/duration.cljs:33:1
abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s)
------ WARNING #1 - :redef -----------------------------------------------------
Resource: cljc/java_time/duration.cljs:33:1
abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s)
------ WARNING #1 - :redef -----------------------------------------------------
Resource: cljc/java_time/duration.cljs:33:1
abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
it only shows the verbose warning once, after that it is shortened and doesn't show the code excerpt
actually unsure where WARNING: abs already refers to: #'clojure.core/abs in namespace: cljc.java-time.duration, being replaced by: #'cljc.java-time.duration/abs
that is coming from
hmm also noticed that itās slightly different on a cljc file, which is what Iām using in the real code
gonna update it
well in case of a CLJC file it'll also be reloading the CLJ portion. can't do much about warnings coming from there I guess
ah no, I donāt think the difference is between cljs and cljc, I think it might be due to using deps or somethingā¦ I donāt get the full verbose on startup on my real code
but itās not important
Interesting case with error and code location reporting. If I have :warnings-as-errors true
set and a custom analyzer warning that is being emitted during macro expansion time, then code excerpt in the reported warning (as error) will be pointing at macro call site (which is expected given that the warning was thrown), but instead what I want is to point the code excerpt at the location that was provided to ana/warning
. Not sure if that's also the default behaviour in cljs compiler itself, but I'm curious if there's something can be done to achieve desired behaviour
the location is derived from the metadata on the emitted form most of the time. so you can influence what the error actually says
I do this all over the place for example with this helper fn https://github.com/thheller/shadow-grove/blob/master/src/main/shadow/arborist/fragments.cljc#L85-L91
look for with-loc
uses in that file. of course if you manually call ana/warning
it comes solely from the env
arg passed to it, which you can also modify prior to calling
that's exactly what I'm doing, passing env
with desired location to ana/warning
, but the thrown warning during macroexpansion still points at the macro call site rather than a form within an expression that I'm interested in
(my-macro ... (inc) ...) ;; should report at `(inc)` location
yep, works correctly as a warning. I guess ex-info
on a thrown error is not picked up
do you have a repro for that? glancing at the code it should pickup the location properly from the warning? https://github.com/thheller/shadow-cljs/blob/f66ab9bb3945b75ee06f8397d14e5787ff045574/src/main/shadow/build/compiler.clj#L486-L490
let me put up a quick one
------ ERROR -------------------------------------------------------------------
File: C:\Users\thheller\code\shadow-cljs\src\main\shadow\cljs\ui\components\inspect.cljs:310:13
--------------------------------------------------------------------------------
307 | (when label
308 | (str " - " label)))]
309 | [:div.truncate
310 | (foo.bar)
-------------------^------------------------------------------------------------
null
Use of undeclared Var shadow.cljs.ui.components.inspect/foo
{:warning :undeclared-var, :line 310, :column 14, :msg "Use of undeclared Var shadow.cljs.ui.components.inspect/foo"}
ExceptionInfo: Use of undeclared Var shadow.cljs.ui.components.inspect/foo
shadow.build.compiler/warning-collector (compiler.clj:493)
but this is not calling ana/warning
directly so I guess that isn't really comparable
not sure if the problem is the fact that I'm not passing entire env
, but only location data, but that's enough for the warning to be printed correctly
how did you get correct location printing? I'd use it for now
Perhaps I misunderstood this > but this is not calling ana/warning directly so I guess that isn't really comparable
ah well, you are trying to get metadata from a number which doesn't have metadata š
well that's fair š but it doesn't work with IMeta's as well
the actual app code that I'm testing takes location from meta in a hashmap
here's the same warning with and w/o :warnings-as-errors true
Maybe in your example with undeclared var it works fine because the erroring location matches analyzed location. In my case with the macro, analyzed location is the callsite of a macro.
hmm so I guess this happens due to the cljs.analyzer macroexpansion code try/catching the error and throwing a new one with its own location data added. which it takes from the source form.
makes sense
I guess I can include my own excerpt into the error message then
Cool! I wonder if cljs analyzer itself could use thing change, unless it breaks other errors
Are you gonna read location from the re-thrown error e
?
(throw (ex-info nil (error-data env :macroexpansion (var->sym mac-var)) e))
thinking about it yeah. the relevant code starts here https://github.com/thheller/shadow-cljs/blob/f66ab9bb3945b75ee06f8397d14e5787ff045574/src/main/shadow/build/compiler.clj#L962
so that could check the data
if its a macroexpansion error and then get the data from the (.getCause e)
instead
but I'm unsure that this will always be correct. meaning pointing to the correct location if it has line/column.
there might be cases where that location is actually worse than showing the location of the macro
do you have an example?
I'll have to patch shadow on my side to have meaningful error messages in the meantime, but that's a good point.
I mean this only happens because of :warnings-as-errors
so it is isolated to shadow-cljs. so I guess I could add a marker of sorts
https://github.com/thheller/shadow-cljs/commit/732577ea5257f6418d4926d10f5c0e3261303e8b
needs some more testing before I make a release but seems to be ok for your repro
(although modified your repro since keywords can't take meta and won't have location data)
On that note: I think shadow's ERROR reporting browser UI could use more love, the warning reporting screen is much easier to read because of formatting (bold text, marings, etc)
yeah but its a lot of work since errors are captured as text for the terminal. wiring the whole error reporting again to capture html is meh
I just made it nice looking with a bunch of regexes š
@U05224H0W Just noticed that code location pointing is also wrong for "undeclared var" warnings with :warnings-as-errors true
hmm, probably the exception being wrapped multiple times. feel free to open issue, can't look into it currently
Hi there, I am trying to get a runtime against wrangler
(Cloudflare worker) up
However, when I start it I get:
[mf:err] Error: Failed to construct 'WebSocket': the constructor is not implemented.
at Object.construct (/home/cokap/git/arudik-website/cloudflare-workers/backblaze-download-token-to-secrets/node_modules/@miniflare/web-sockets/src/plugin.ts:37:19)
at shadow$cljs$devtools$client$websocket$start (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/websocket.cljs:12:16)
at shadow.cljs.devtools.client.shared.Runtime.attempt_connect_BANG_ (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/shared.cljs:324:25)
at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/shared.cljs:509:24)
at ../.cljs/cljs-runtime/shadow.cljs.devtools.client.browser.js (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/browser.cljs:337:3)
Is there a way to avoid compiling the browser dev tools in a module?import "./cljs-runtime/shadow.cljs.devtools.client.browser.js";
SHADOW_ENV.setLoaded("shadow.cljs.devtools.client.browser.js");
If I remove the two lines up it seems to work@U05224H0W oh thanks you, will try that out
I am experimenting with the new js-await
macro
I did this
(ns cloudflare.workers
(:require [shadow.cljs.modern :refer (js-await)]))
(defn backblaze-download-token-to-secrets
[controller env ctx]
(js-await [result (js/Promise.resolve #js {"foo" "bar"})]
(js/console.log "environment" env)
#js {:response "response"}))
but I don't see any compiled file...the module contains only
import "./cljs_env.js";
{:target :esm
:output-to "target/cloudflare-workers.js"
:output-dir ".cljs"
:modules {:backblaze-download-token-to-secrets
{:exports {default cloudflare.workers/backblaze-download-token-to-secrets}}}
:compiler-options {:output-feature-set :es-next}
:js-options {:entry-keys ["module" "browser" "main"]}
:devtools {:enabled false}
:release {:compiler-options {:source-map true}}}
I am looking at both this two guys
$ cat .cljs/cljs-runtime/shadow.module.backblaze-download-token-to-secrets.
shadow.module.backblaze-download-token-to-secrets.append.js
shadow.module.backblaze-download-token-to-secrets.prepend.js
.cljs/cljs-runtime/cloudflare.workers.js
will have the source from cloudflare.workers
ns
yeah that contains the right code..sorry for the newbie question, but would that match the expected format here? https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/#syntax-module-worker ?
basically I am not sure I am producing the expected async scheduled
function
well yeah, I am trying stuff š basically I need to export this
export default {
async scheduled(event, env, ctx) {
},
};
an export list with scheduled
in itoh I think I just saw how to do that sorry
(def exports #js {:g f
...})
thank you Thomas
does that runtime just accept the watch
output as is or do only release
builds work?
I am still trying to get the watch
- haven't tried release yet
but I might cause I get this error now
[mf:err] TypeError: Cannot read properties of undefined (reading 'module_loaded')
at /home/cokap/git/arudik-website/cloudflare-workers/.cljs/backblaze-download-token-to-secrets.js:92:33
as shadow.cljs.devtools.client.env
is undefined
trying :console-support false`
I'm guessing that it doesn't actually support the globalThis
hacks the watch/compile builds do
oki, trying that as we speak
seems good apart from one little warning
npx wrangler dev --local
ā
ļø wrangler 2.0.17 (update available 2.0.19)
-------------------------------------------------------
Your worker has access to the following bindings:
- Vars:
- B2_APPLICATION_KEY_ID: "foo"
- B2_APPLICATION_KEY: "bar"
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā®
ā [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit ā
ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāÆ
ā² [WARNING] Source maps with "sections" are not supported [sections-in-source-map]
../.cljs/backblaze-download-token-to-secrets.js.map:1:61:
ā Starting a local server...
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā®
ā [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit ā
ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāÆ
[mf:inf] Worker reloaded! (0.54KiB)
[mf:inf] Listening on localhost:43843
[mf:inf] -
[mf:inf] Updated `` object cache!
SCHD /cdn-cgi/mf/scheduled 200 OK (0.75ms)
it is weird though, I am calling the code but nothing is printed out, I will debug further
@U05224H0W can I watch a release configuration?
Sorry to come back on this, but is shadow.cljs.devtools.client.env
/ globalThis
an issue can be solved with an additional bundler?
Working against the release
code is a bit slow (7s every run before I can try new code)
if I comment out // shadow.cljs.devtools.client.env.module_loaded("backblaze-download-token-to-secrets");
Things seem to work - having a REPL is nice maybe I'll just go with that š
Well ok, the JS runtime also needs to be hooked up here and I see šs there as well
Ok I guess I read this document and now at least I know more about the problem(s) https://github.com/thheller/shadow-cljs/blob/master/doc/esm.md
well as always. I cannot comment much without seeing actual code and actual errors. slack descriptions do not have enough information to make accurate guesses
shadow.cljs.devtools.client.env.module_loaded("backblaze-download-token-to-secrets");
should be find and I'm unsure why it wouldn't be
ok I'll create a repo with some code
@U05224H0W here it is, I hope things are going to work there, let me know if you find any issue https://github.com/arichiardi/cloudflare-workers
it's working with a bundler now and it all seems good, I could go for one module per worker and get rid of main.js
but I am in the middle of something else now
backblaze-download-token-to-secrets$ wrangler dev --local
:partly_sunny:ļø wrangler 2.0.21
--------------------
Your worker has access to the following bindings:
- Vars:
- B2_APPLICATION_KEY_ID: "foo"
- B2_APPLICATION_KEY: "bar"
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā®
ā [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit ā
ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāÆ
ā² [WARNING] Using direct eval with a bundler is not recommended and may cause problems [direct-eval]
out/cljs-runtime/cljs.core.js:37984:63:
37984 ā return cljs.core.find_ns_obj_STAR_((function (){try{var ctxt = eval(cljs.core.first(segs));
āµ ~~~~
ā Starting a local server...
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā®
ā [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit ā
ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāÆ
Debugger listening on
For help, see:
Debugger attached.
[mf:inf] Worker reloaded! (2.40MiB)
[mf:wrn] Worker's uncompressed size exceeds the 1MiB limit! Note that your worker will be compressed during upload so you may still be able to deploy it.
[mf:inf] Listening on localhost:8787
(ns cloudflare.workers
(:require [cloudflare.workers.backblaze :as backblaze]))
(def exports
#js {:fetch (fn [request]
(js/Promise.resolve (js/Response. "Hello World.")))
:scheduled backblaze/upload-download-token-to-secrets})
I get the expected Hello World.
on http://localhost:8787/
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[]
:builds
{:workers {:target :esm
:output-dir "backblaze-download-token-to-secrets/out"
:modules {:main
{:preloads [shadow.cljs.devtools.client.env]
:exports {default cloudflare.workers/exports}}}
:compiler-options {:output-feature-set :es-next}
:js-options {:entry-keys ["main" "module"]}
:devtools {:enabled false}
:release {:compiler-options {:source-map true}}}}}
(which would be the module_loaded
being emitted when it shouldn't be, due to :enabled false
)
Ok cool, don't worry about the esbuild
stuff, it was there because I was fiddling with cljs.main
as well
I think what I was missing was the :preloads
then
well thats not required if you have :runtime :node
but effectively that also does nothing
https://clojurians.slack.com/archives/C6N245JGG/p1657823184135329?thread_ts=1657734026.412249&cid=C6N245JGG
About this, if you curl
that endpoint, some traces are written in the wrangler
terminal
Ok I am fine with watch
only for now, thanks for your help, if you want me to try any build to get the REPL working I can also definitely do that
with cljs.main
too there was no way to get the REPL running and I was only getting watch
working with -O advanced
I have the wrangler thing working. just too tired to dive deeper into the REPL support now
but the wrangler command also always seems to restart everything when you make a change
> I have the wrangler thing working. just too tired to dive deeper into the REPL support now
Of course no worries
> I mean could always just run a browser-repl
or node-repl
I guess
right, that probably would suffice, I'll try to see if it "sees" the wrangler runtime, probably now that will work
ah I see what you mean now, the node-repl
would not need wrangler at all
(sorry it's been a while since I last used shadow-cljs)
When I quit from npx shadow-cljs browser-repl
, I get this really long error report:
Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
ā¦
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Worker shutdown.
I'm wondering if there is something wrong with my setup. Or is it possible to disable this output? It is not critical, just annoying that terminal gets spammed with 50+ lines.how did you quit it? which OS is this? which shadow-cljs version? which java version? I've never seen this so dunno what would be causing it
Sorry for not providing all the info from the beginning.
> how did you quit it?
Ctrl + C
> which OS is this?
macOS Big Sur 11.6.1
> which shadow-cljs version?
2.19.6
> which java version?
openjdk 17.0.1 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-39)
OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)
hmm yeah dunno. I dont have a mac available with that version. versions all seem fine. I have no guesses as to what that may be