@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. 😃
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?
Still curious about that one. Where did it come up?
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.
If so, why do you need the fix? I'll fix it, no problem, but still wondering
I can check if I still need it.
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. 😃
I think it'll work if you surround it with try/catch
or perhaps we can just replace it with (js* "(x) => import(x)") but I think google closure had some issue with it or so
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.)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.such bullshit, why would I transpile anything
https://clojurians.slack.com/archives/C6N245JGG/p1769288393466989
I don’t understand the implications of this. 😃
I found a way:
:append "globalThis.import = (x) => import(x);"in the scittle module
as opposed to :append-js which still goes through Closure
https://github.com/babashka/scittle/commit/df9cfcf6fd8e3aaafd258ed515ae96c0686e9e31