This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-30
Channels
- # announcements (20)
- # asami (26)
- # babashka (10)
- # babashka-sci-dev (18)
- # beginners (81)
- # biff (6)
- # calva (6)
- # cider (1)
- # clerk (1)
- # clj-kondo (34)
- # clojure (50)
- # clojure-belgium (1)
- # clojure-berlin (6)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-uk (2)
- # clojurescript (1)
- # clr (4)
- # community-development (3)
- # data-science (8)
- # datomic (3)
- # gratitude (1)
- # honeysql (6)
- # instaparse (2)
- # jobs (1)
- # jobs-discuss (13)
- # kaocha (7)
- # london-clojurians (1)
- # lsp (6)
- # malli (8)
- # matcher-combinators (9)
- # missionary (3)
- # nbb (8)
- # off-topic (20)
- # pathom (16)
- # polylith (2)
- # practicalli (3)
- # rdf (1)
- # re-frame (7)
- # reagent (3)
- # releases (2)
- # reveal (6)
- # rewrite-clj (22)
- # shadow-cljs (64)
- # tools-build (7)
- # xtdb (13)
Will a app re-compile rerun any clj macros that were used to build the intial app state? I'm running into a sitution where i have values that from a previous state that i'm trying to understand.
not if its cached. if you have macros that have side effects you might need to disable cache completely. macros are not supposed to have side effects. https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache
Thanks heller. Those docs help, and yes, i assume we have macros with side effects.
I would say it depends on what files actually changed. If you have a bunch of macros in a util
namespace and never change that namespace, then it wont be refreshed. So in that case I can understand the previous state you’re speaking of.
If I wanted to make namespaces forcibly refresh every time, I would add the ^:dev/always
metadata to them
Hello shadowians, I’m trying to compile a project which has https://www.npmjs.com/package/squint-cljs as an NPM dependency, and I’m getting the following error when starting the dev build
shadow-cljs - watching build :viewer
[:viewer] Configuring build.
-> build target: :esm stage: :configure
<- build target: :esm stage: :configure (2 ms)
[:viewer] Compiling ...
-> Resolving Module: :viewer
<- Resolving Module: :viewer (1293 ms)
-> build target: :esm stage: :compile-prepare
<- build target: :esm stage: :compile-prepare (5 ms)
-> Closure JS Cache read: 101 JS files
<- Closure JS Cache read: 101 JS files (21 ms)
-> Babel transform: /Users/amantini/dev/clerk-blank/node_modules/squint-cljs/core.js
<- Babel transform: /Users/amantini/dev/clerk-blank/node_modules/squint-cljs/core.js (394 ms)
-> Shadow JS converting 1 JS sources
<- Shadow JS converting 1 JS sources (551 ms)
[:viewer] Build failure:
Closure compilation failed with 1 errors
--- node_modules/squint-cljs/core.js:625
Transpilation of 'Computed fields' is not yet implemented.
The offending code seems indeed to be:
export const IIterable = Symbol('Iterable');
...
class LazyIterable {
constructor(gen) {
this.gen = gen;
}
[IIterable] = true;
[Symbol.iterator]() {
return this.gen();
}
}
https://github.com/squint-cljs/squint/blob/c50c4c2582aeda9e874a867e19a2bfcfc9e4caab/core.js#L452-L460
Does anyone have also encountered this issue before? Couldn’t find much around closure compiler and computed fields or properties.
Both targets :browser
and :esm
produce the same issue, changing :output-feature-set
to different ES levels also has no effect> to compile the squint cljs output
yeah, that is what I origninally tried to do, and the squint output has imports to squint-cljs/core.js
which produces the error above
also, why is babel transform pass kicking in, also for the :esm
target? What is the transformation doing?
@U05224H0W That is true, but squint-cljs/core.js
is pure es6
ah ok, @U04V15CAJ I see you do that as well here: https://github.com/squint-cljs/squint/blob/c50c4c2582aeda9e874a867e19a2bfcfc9e4caab/shadow-cljs.edn#L4-L5 how would I make squint core functions available to the browser? According to: https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration I need some extra tool to process shadow output
@U9EQP1K0X You could use another bundler on the final output, e.g. esbuild or so
npx esbuild public/main.js --bundle --minify --platform=browser --outfile=public/main2.js --format=esm
Here is a playground which also does that: https://squint-cljs.github.io/squint/
<script async src=""></script>
<script type="importmap">
{
"imports": {
"squint-cljs": "",
"squint-cljs/core.js": "",
"squint-cljs/string.js": ""
}
}
</script>
cool thanks, now I’m using shadow to compile other NPM dependencies together with real cljs sources in the same project, how can I make :js-provider
selective to just squint-cljs/core? Is that :resolve
https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve?
or perhaps this is deprecated @U05224H0W? I don't see this option mentioned in the README
ehm, with
:keep-as-import #{"squint-cljs/core.js"}
in :js-options
I still get the transpile error@U9EQP1K0X Perhaps you can make a tiny repro repository
yeah, I think I can go a bit further, and produce a repro repo if I am still stuck. Thanks a lot @U05224H0W @U04V15CAJ !
@U05224H0W Is there a way to run a tool like webpack or esbuild after shadow is done compiling in watch mode, to resolve the "keep-as-import" imports? Because the browser still needs to have those files. We could use import-maps for those and then serve those files manually, but that's also a bit tedious
@U9EQP1K0X figured it out by calling esbuild in a build hook
Is there a way to insert a “preamble” of sorts into node REPL sessions? I find it quite interruptive to have the node-repl die just because of an unhandledRejection
and usually run a snippet like the one below to avoid this. Is there a way to configure this at a project level?
(js/process.on "unhandledRejection"
(fn [err]
(js/console.log "unhandledRejection" err)
(tap> {:unhandledRejection err})))
Ah yes, that works perfectly. I somehow assumed preloads wouldn’t be a thing with node but I’m realizing I didn’t think about that very much otherwise I would have realized they probably work just the same 🙂
I find this unhandledRejection stuff sufficiently annoying that I’d love for it to be part of the shadow node repl by default somehow. I think it might also be quite confusing for newcomers because some REPL clients don’t report it very well when the underlying node
process dies.
so also in REPL internals, which may end up causing a infinite exception loop and burn your CPU to death 😛
Ah I see
Could the REPL catch errors of any promises that are coming through? (i.e. more explicit)
I mean more like it looks at whatever the user’s expression returns and adds a .catch
-- probably I’m thinking too simplistic here 🙂
> not sure thats a good idea
Assuming the mechanics are viable and the exception is still reported, I'm not sure how this could be super-harmful. It could be on-by-default in dev mode, with a preamble to the reported error that "if this was production mode, your Node process would crash here."
Using tap>
seems a bit iffy though, since then the problem goes unreported if there is no tap reporter is set up. Maybe default to just print
, but allow switching to tap>
in the config?
yeah totally, tap>
is specific to my setup