scittle

Chris McCormick 2024-11-30T20:16:32.838119Z

I want to get a library working with both Scittle and shadow-cljs. Is there something like this but for Scittle?

#?(:org.babashka/nbb
   [nbb.core :refer [load-file]])

Chris McCormick 2024-12-02T12:25:22.088939Z

I want to find out more about how Scittle resolves requires. I'm interested in experimenting with this and finding out more about the current capabilities. Is this currently a sci level thing or specific to Scittle? What's the best way to learn about it?

borkdude 2024-12-02T12:25:59.045959Z

scittle doesn't resolve anything but built-in namespaces at the moment

👍 1
Chris McCormick 2024-12-02T12:47:29.792709Z

What's the best place to look in the code for where this happens?

borkdude 2024-12-02T12:48:14.223309Z

what problem are you trying to solve?

borkdude 2024-12-02T12:49:00.471679Z

This is how you implement require with SCI: https://github.com/babashka/sci?tab=readme-ov-file#implementing-require-and-load-file but this isn't used in scittle, as built-in namespace are just handled by SCI itself

Chris McCormick 2024-12-02T12:50:07.355939Z

Ultimatley I'd like to import existing .cljs libraries I've written without recompiling Scittle and in a way that's compatible with existing shadow-cljs code.

borkdude 2024-12-02T12:50:36.787439Z

you can do this by adding the .cljs files to a script tag in the right order

Chris McCormick 2024-12-02T12:51:23.223009Z

Yes and I suppose that's not that big of a step. 🤔 Ok let me try more just doing this.

borkdude 2024-12-02T12:52:06.580119Z

once a .cljs file is loaded you can use :require to refer to its namespace

Chris McCormick 2024-12-02T12:52:11.380639Z

Ah yep the problem is the thing I am requiring then in turn depends on js requires. To satisfy that I need a think like "importmap" that will tell Scittle "here's how you resovle this js dep).

borkdude 2024-12-02T12:52:36.892719Z

ok, that makes sense, so the problem lies with JS libs

Chris McCormick 2024-12-02T12:53:10.305339Z

I'd like to be able to tell Scittle that ["whatever" :as whatever] corresponds to window.whatever that came in from a script tag.

Chris McCormick 2024-12-02T12:53:51.977059Z

Even if there was a default to look for "whatever" on the global object. (I realize this could be a lot harder than it looks.)

borkdude 2024-12-02T12:54:35.154219Z

it makes sense

borkdude 2024-12-02T12:54:43.755189Z

I think you could use :load-fn for this

👀 1
borkdude 2024-12-02T12:55:00.840629Z

but this needs a change in scittle

borkdude 2024-12-02T12:55:34.523429Z

and I think we would want some configuration for this as well as global names don't always correspond to the library names on npm

borkdude 2024-12-02T12:57:01.897779Z

feel free to post an issue about this

Chris McCormick 2024-12-02T12:57:48.129769Z

Alright, will do, thanks! I'll also investigate *load-fn* as I had no idea this existed.

borkdude 2024-12-02T12:59:18.300769Z

:load-fn is a SCI option, not exposed to users

borkdude 2024-12-02T12:59:23.527469Z

no earmuffs

Chris McCormick 2024-12-02T13:02:18.411279Z

Cool, got it.

Chris McCormick 2024-11-30T20:18:39.339779Z

I saw that but how do I use it? Just #?(:scittle ...) ?

Chris McCormick 2024-11-30T20:18:51.958119Z

Will test.

borkdude 2024-11-30T20:19:08.375549Z

yes, just use scittle

👍 1