Hi, is there currently support (via library) to use clojure qualified keywords on javascript? I tried to find any on internet and didn't find it so i started a "blind-llm" approach using babel here https://github.com/semantic-namespace/js-qualified-keywords the final purpose is to have LSP support for kws (navigate, refactor, etc.) and easy communication with cljs (sending kws instead of strings ) I'd love any feedback on the idea or lib impl
> the final purpose is to have LSP support for kws (navigate, refactor, etc.) How is that related to keyword usage in JS? > easy communication with cljs (sending kws instead of strings ) What do you mean by "sending"?
Hi @p-himik > How is that related to keyword usage in JS? I like to write qualified-keywords as data-types (so LSP recognise them) , basically i want to easy my JS-team the use of a https://github.com/semantic-namespace/atlas project that deals around definitions and identity and fully embraces qualified keywords > What do you mean by "sending"? POST to clj backend
I see. In that case, I think would completely avoid using Babel (no need to change JS syntax) or explicit function calls and instead I'd rely on template literals with a custom tag function. So you'd end up with code like this:
const { kw } = require(...);
const theKeyword = kw`:the-ns/the-name`;and do you think i could also have LSP/IDE support?
It you would be able to have such support with a custom function, there's no reason why such support couldn't exist for custom tag functions, which are also just functions.
thanks for the feedback @p-himik, I'll give a try to your proposal approach to see if it fits properly the final purpose
Does anyone have a guide for targeting :lite-mode? I see discussion on the "mental overhead" of knowing what language features will break it. How can I adopt this mental overhead myself? For instance, how could I read the source of https://github.com/cjohansen/nexus and know whether lite-mode would work?
there's no limit to the size of the program you can write, if you're doing light weight stuff on the client you write lots of code and get small artifact because you don't actually need persistent data structures.
Google Closure Library and JavaScript apis help a lot for this style of dev
that said you do have to be more familiar w/ ClojureScript to understand what to avoid - some things still need work. And I agree that using CLJS libs w/ :lite-mode generally has very little value.
:lite-mode is more compatible w/ HTMX and derivative approaches
where you're just not interested in JS deps at all
Nexus has that going for it - no dependencies.
thats's good but that's not what :lite-mode is about
it's for people who know the want to drive a Web App from the server and aggressively minimize the JS footprint. So looking for library to combine it with defeats what it is for.
granted there's no good docs for how to use it and the rationale - that's missing
Exactly. I see the practical viewpoint, and that is my current area of research. I'm just wondering what's the right way I can learn more. So far my options look like: • read the source, starting from https://github.com/clojure/clojurescript/commit/f9a6856d91e45377391406fc34a581bc4043615e, • start compiling and try to reduce the bundle by trial/error • make an inventory of which language features use chunked-seqs and .toString
you don't need to worry about chunked-seq, handled for you
the only big foot gun is printing
adding persistent data structure will expand your baseline to about 8K brotli
printing will take you to 12k brotli, that's it
modulo missed things, and things that need feedback (some case that should be small but isn't)
if you want to build client-centric thing, lite-mode is not appropriate, if. you want to build server-centric thing lite-mode can be a sharp tool
I probably will stumble with printing - since I am looking at methods for serializing edn into and out of a cljs runtime. Maybe there are bespoke ways to read/print smaller structures without requiring every feature of edn.
impratical, if you're going to serialize to EDN then think about transit, 10K to your baseline
but Transit probably needs to be tweaked so that lite-mode can work, again, in server centric context, you often don't need to bother, you're just dealing w/ markup not data structures, and JSON suffices in the few instances you need it
I wonder how squint's printer fits in with these concerns - https://github.com/squint-cljs/squint/pull/765
it doesn't, squint doesn't have all the data structures and doesn't need to cover all the cases
also lite-mode has a relatively hard constraint that programs under lite-mode don't actually remove / alter language features (outside of optionally getting rid of toString)
Right, I got the impression that it would just yield a larger bundle again, rather than any sort of compile failure
yeap
Thanks for the insights
np!
I'd say if you writing anything above 500 lines of code don't bother. It really is only useful for very tiny programs.
so nexus alone makes it not worth using :lite-mode 🤷