scittle

pez 2026-01-24T17:52:43.235089Z

@borkdude We discussed making Scittle truly never doing any js/eval ever here: • https://clojurians.slack.com/archives/C06MAR553/p1766953851749159?thread_ts=1766854922.549459&cid=C06MAR553 For #epupp I currently auto-patch this away, but it would be better if I didn’t need to. I would like to try requiring scittle and dependencies from CDN, but even if I will not be allowed to get away with that, it still would be nice to not have to patch. And if the dependencies have the any js/eval that can be made conditional the way you suggest, that would of course be nice too. 😃

borkdude 2026-01-24T17:55:53.893069Z

Hey sure. I've been asking you about the eval restriction and you couldn't come up with an example where eval wouldn't work with epubb due to restrictions, remember?

borkdude 2026-01-24T18:49:05.393469Z

Still curious about that one. Where did it come up?

pez 2026-01-24T18:57:58.951959Z

In think that was in a DM thread. I think the answer there is that the extension context somehow gets registered as a trusted script environment and then it can do whatever it wants.

borkdude 2026-01-24T19:12:12.265339Z

If so, why do you need the fix? I'll fix it, no problem, but still wondering

pez 2026-01-24T19:33:56.524329Z

I can check if I still need it.

pez 2026-01-24T20:08:54.122889Z

Yes, for some reason scittle.js is not allowed to do js/eval on CSP strict sites, but once it is loaded we can do it from Scittle scripts. I can’t say I understand why, but anyway. Thinking about it, since I don’t fully understand the problem, I don’t know if the change you considered will work either. I will test that now too. 😃

borkdude 2026-01-24T20:11:32.058969Z

I think it'll work if you surround it with try/catch

borkdude 2026-01-24T20:11:55.659579Z

or perhaps we can just replace it with (js* "(x) => import(x)") but I think google closure had some issue with it or so

pez 2026-01-24T20:48:07.167079Z

Things work if I do this:

(let [content (slurp scittle-path)
        patched (str/replace
                 content
                 "globalThis[\"import\"]=eval(\"(x) \\x3d\\x3e import(x)\");"
                 "try { globalThis[\"import\"]=eval(\"(x) => import(x)\"); } catch {};"
                 #_"globalThis[\"import\"]=(x) => import(x);")]
(The ignored expression is what I used to do.)

borkdude 2026-01-24T20:57:07.841879Z

if I do the js* solution, I'm getting this from Closure:

Closure compilation failed with 1 errors
--- scittle/core.cljs:71
Dynamic import expressions cannot be transpiled.

borkdude 2026-01-24T20:57:18.574039Z

such bullshit, why would I transpile anything

pez 2026-01-24T22:02:00.231579Z

I don’t understand the implications of this. 😃

borkdude 2026-01-24T22:25:03.073129Z

I found a way:

:append "globalThis.import = (x) => import(x);"

borkdude 2026-01-24T22:25:07.066889Z

in the scittle module

borkdude 2026-01-24T22:25:19.851509Z

as opposed to :append-js which still goes through Closure

🎉 1