This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-19
Channels
- # announcements (2)
- # babashka (1)
- # beginners (159)
- # biff (19)
- # clj-http (2)
- # clj-kondo (14)
- # clojure (105)
- # clojure-argentina (1)
- # clojure-art (3)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-spain (1)
- # clojure-spec (3)
- # clojure-uk (26)
- # clojurescript (15)
- # conjure (4)
- # cursive (17)
- # datomic (8)
- # gratitude (1)
- # humbleui (1)
- # hyperfiddle (30)
- # joyride (10)
- # kaocha (1)
- # lsp (41)
- # malli (11)
- # off-topic (1)
- # pedestal (1)
- # polylith (12)
- # releases (1)
- # sci (4)
- # shadow-cljs (136)
- # squint (32)
- # tools-deps (28)
With target esm + node I'm getting this:
The required JS dependency "fs" is not available, it was required by "squint/embed.cljs".
Dependency Trace:
squint/embed.cljs
Searched for npm packages in:
/Users/borkdude/dev/squint/examples/cljs-embed/node_modules
fs is part of the node-libs-browser polyfill package to provide node-native package support
for none-node builds. You should install shadow-cljs in your project to provide that dependency.
npm install --save-dev shadow-cljs
See:
I already installed the shadow-cljs package and restarted, but it keeps coming up, what to do?
thheller/shadow-cljs {:mvn/version "2.26.5"}
:js-options {:js-provider :import}
controls how JS packages are bundled, or in case of :import
not bundled and just imported at runtime
or alternative :keep-as-import #{"fs"}
to only import fs at runtime, but bundle others
no, this is not about the squint lib itself, it's an example project in which squint is used in a shadow project
where do I put that keep-as-import again? this didn't have any effect:
{:deps {:aliases [:shadow]}
:builds
{:squint.embed
{:target :esm
:keep-as-import #{"fs"}
:runtime :node
:output-dir "out"
:modules {:eval {:init-fn squint.embed/init}}
:build-hooks [(shadow.cljs.build-report/hook
{:output-to "report.html"})]}}}
also I don't see it mentioned in the manualJust made my head a bit more barren by trying to understand what was going on.
The original code from mousetrap
:
(function(window, document, undefined) {
[...]
var _MAP = { ... };
[...]
for (var i = 1; i < 20; ++i) {
_MAP[111 + i] = 'f' + i;
}
[...]
})(typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null)
The corresponding code that the browser gets from module$node_modules$mousetrap$mousetrap.js
:
(function(window, document, undefined) {
[...]
var _MAP = { ... };
[...]
for (undefined = 1; 0; ++undefined)
_MAP[NaN] = "fundefined";
[...]
})(typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null)
note that there is https://github.com/google/closure-library/blob/master/closure/goog/events/keyhandler.js
Right. But it doesn't provide the "listen for this particular key press" functionality and seems to be mostly dealing with the quirks of ancient browsers or some very specific keys on Mac.
I hooked it up to emit the regular event style maps, so a handler for example can use a keyword for a specific key combo
On the one hand, I really don't want to write all the necessary cruft so support stuff like "on Win/Linux Meta is Meta and Alt is Alt and undo is Ctrl+Z but on Mac, Command is Meta and Option is Alt and undo is Command+Z". On the other hand, I really don't want to study and introduce a new library that has a high chance of dealing with something in a crappy way (Mousetrap hasn't been maintained for years, and there are multiple issues). Damn programmers, they ruined programming. :D
I wish I could. But on top of proper cross-platform shortcuts, they also need to be assignable.
I mean this is a tiny amount of code to get this event hookup thing I have in the UI
https://github.com/thheller/shadow-grove/blob/master/src/main/shadow/grove/keyboard.cljs
Maybe. But the amount of code that they have there, and how seemingly 90% of it is useless in modern browsers makes it daunting.
Do you see anything wrong with this code BTW? Tried just js/document
, but same thing - nothing's printed.
(let [listener (KeyHandler. (.-body js/document))]
(.listen listener "keydown" (fn [evt]
(js/console.log "keydown" evt)))
(.listen listener "keypress" (fn [evt]
(js/console.log "keypress" evt)))
(.listen listener "keyup" (fn [evt]
(js/console.log "keyup" evt))))
Oh, that's bloody terrible for me then. :D
I need to support shortcuts like Ctrl+Shift
. Which can also be pressed as Shift+Ctrl
.
Which must not be confused by the app with e.g. Ctrl+Shift+x
.
It seems that if I rely only on KeyboarEvent.code
, I don't have to deal with any crap that pretty much all of the hotkeys libraries that I've seen are designed to deal with. So it all becomes much simpler.
However, there's still that bullshit of "if e.g. Space
is registered as a hotkey for action X, but the focus is in an input element that supports Space
, the event should be handled by that input element". Doesn't seem like there's a proper and easy way around it.
Yeah, similarly I'm checking for the type of .-target
and naively deciding whether a particular key combination is handled by the input. So e.g. if <input type="text>
is in focus, pressing Space
will emit a space character but pressing Ctrl+Space
will check whether there's such a global binding.
can't remember which one you are supposed to use, but one of them didn't respect keyboard layouts or remaps
and respecting chinese and other weird language that use code sequences for one character
What does "rebound" mean exactly? I have F14 on my Apple keyboard mapped to ScrollLock in the kernel module - that emits ScrollLock just fine.
> For example, the code
returned is "`KeyQ`" for the Q key on a QWERTY layout keyboard, but the same code
value also represents the ' key on Dvorak keyboards and the A key on AZERTY keyboards.
Mm, OK.
But shouldn't matter that much since truly special logic is only reserved for modifiers, and those are determined based on .-key
.
And I plan to make all of the predefined bindings adjustable, so since setting and using a keybinding will be done with the same keyboard and the same layout (presumably), I should be good.
There is one non-trivial problem where pressing Alt+Shift in Ubuntu generates exactly what you'd expect, but pressing Shift+Alt results in "keydown Shift, keydown Meta, [...keyups...]". But eh, I'll deal with it if anybody complains.
Hello all, I updated the version from 2.15.3 to 2.26.5 and this started to fail, executed with npx shadow-cljs run dev.build/build-release-static
. I tested with version 2.22.2
and it works. Is there something that changed?
failed to run function: dev.build/build-release-static
{:tag :shadow.cljs.devtools.cli-actual/clj-run, :main-sym dev.build/build-release-static}
ExceptionInfo: failed to run function: dev.build/build-release-static
shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:110)
shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:65)
shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:126)
shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
Caused by:
Exception: No files matched regex /js/compiled/.*\.js\.map
optimus.assets.creation/realize-regex-paths (creation.clj:106)
optimus.assets.creation/realize-regex-paths (creation.clj:98)
optimus.assets.creation/load-assets/fn--6324 (creation.clj:112)
the code seems to be failing in your code, so you tell you what you are doing there and I tell you what might have changed 😛
I mean thats a lot of versions inbetween, so there are likely things that have changed
could also be that you turned off source maps? and it is expecting to find some? no clue really
I'll tell you it was working before
😅 . I'll will investigate it. But the basic is
(clean-compiled-resources)
(export-image-assets-and-replace-paths)
(export-deeplinking-assets)
(shadow/release environment {:verbose true})
(compile-sass)
(export-assets)
But it seems that is not creating the /js/compiled/.*\.js\.map:compiler-options {:optimizations :advanced
:source-map true
:source-map-include-sources-content true}
I mean /js/compiled
doesn't look like a valid output-dir to me? unless you are actually putting them at your fs root?
source map emission has not changed, well that is unless they are empty. in that case there are no longer generated
the source map change was 2.26.3 https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md
there is no advice to give. I don't know what the problem is this tool I don't know has.
look at what your :output-dir
looks like, I don't have enough information to provide any tips
did you check the build report? https://shadow-cljs.github.io/docs/UsersGuide.html#build-report
I see you are using (shadow/release environment {:verbose true})
which will not throw an exception if it fails
that error is not a message from shadow-cljs. and not related to a shadow-cljs build failure at all. it just happens to run after shadow-cljs completes or maybe fails in this case
with actual shadow-cljs stuff I can help. I suspect now that the build is just failing and your setup not correctly identifying it and trying to continue as if everything was fine
I think I got the error:
switch (a) {
case V.types.logCustomEvent:
import("./log-custom-event.js").then(
({ logCustomEvent: logCustomEvent }) => {
e.so()
? ((i = Array.prototype.slice.call(s)),
logCustomEvent(...i))
: r.error(_);
},
);
Dynamic import expressions cannot be transpiled.ok. that is an error from the closure compiler and it never actually worked. could be that it was just ignored before.
yes. this is not something shadow-cljs can do anything about. it is entirely within the closure compiler.
if you need code like this then you can use a different JS bundler via https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider-external
I don't know what this code is and if it was ever actually used or if you can avoid it
So, @U05224H0W I'll try to use js-provider-external, but what about the problem with module split? I have 5 splitting modules.
depends. CLJS modules is fine and doesn't change. however the JS code will all end up in that single external file, which may not be ideal. https://github.com/thheller/shadow-cljs/issues/1162
note that I just added support for this style of import
that JS package is trying to do
so if you try 2.26.6
it may just work, couldn't try the actual package since I didn't find it. https://www.npmjs.com/package/braze didn't seem to be it
the package is https://www.npmjs.com/package/@braze/web-sdk
I don't know if the error is gone. It might be. I didn't try the package but the problematic snippet you posted above should now be fine and not produce an error