scittle

Chris McCormick 2025-10-05T12:44:15.802469Z

I have scittle installed via npm and this script:

$ cat index.js 
let window = globalThis;
scittle = require("scittle/dist/scittle.js").scittle
console.log(scittle);
require("scittle/dist/scittle.reagent.js")
Running it on Node I get this:
$ node index.js 
{
  core: {
    eval_string: [Function: hA],
    eval_script_tags: [Function: hP] {
      l: [Function (anonymous)],
      o: 0,
      v: [Function (anonymous)]
    },
    disable_auto_eval: [Function (anonymous)]
  }
}
/home/chrism/dev/test-scittle-node/node_modules/.pnpm/scittle@0.7.28/node_modules/scittle/dist/scittle.reagent.js:2
shadow$provide[0]=function(b,a,c){a.exports=ReactDOM};
^

ReferenceError: shadow$provide is not defined
    at Object.<anonymous> (/home/chrism/dev/test-scittle-node/node_modules/.pnpm/scittle@0.7.28/node_modules/scittle/dist/scittle.reagent.js:2:1)
    at Object.<anonymous> (/home/chrism/dev/test-scittle-node/node_modules/.pnpm/scittle@0.7.28/node_modules/scittle/dist/scittle.reagent.js:158:4)
    at Module._compile (node:internal/modules/cjs/loader:1529:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Module._load (node:internal/modules/cjs/loader:1096:12)
    at Module.require (node:internal/modules/cjs/loader:1298:19)
    at require (node:internal/modules/helpers:182:18)
    at Object.<anonymous> (/home/chrism/dev/test-scittle-node/index.js:4:1)
    at Module._compile (node:internal/modules/cjs/loader:1529:14)

Node.js v20.19.4
What do you think are the chances of shimming the shadow stuff correctly so I can run Scittle on Node? The reason I want to do this is to get the happy-dom scripts in Eucalypt working with Reagent. That way I can compare the Eucalypt behaviour directly with the Reageant behaviour. This is not high priority or anything I just thought it would be cool to set up if possible.

✅ 1
borkdude 2025-10-11T09:07:42.060799Z

This works:

const fs = require("fs")
globalThis.ReactDOM = require("react-dom")
globalThis.React = require("react")
const window = globalThis;
eval.call(globalThis,(fs.readFileSync("node_modules/scittle/dist/scittle.js", "utf8")))
// scittle = require("scittle/dist/scittle.js").scittle
eval.call(globalThis, (fs.readFileSync("node_modules/scittle/dist/scittle.reagent.js", "utf8")))

scittle.core.eval_string("(prn (+ 1 2 3))")
$ node index.js
6

🙏 1
Chris McCormick 2025-10-11T01:23:55.618519Z

That works but then I can't figure out how to access the Scittle API to actually eval code.

borkdude 2025-10-11T01:53:35.768529Z

You can cal the global scittle.core.eval_string

Chris McCormick 2025-10-11T02:45:25.821339Z

Doesn't seem to be attaching to the globalThis.

$ cat index.js 
const fs = require("fs")
globalThis.ReactDOM = require("react-dom")
globalThis.React = require("react")
const window = globalThis;
eval(fs.readFileSync("node_modules/scittle/dist/scittle.js", "utf8"))
// scittle = require("scittle/dist/scittle.js").scittle
eval(fs.readFileSync("node_modules/scittle/dist/scittle.reagent.js", "utf8"))
console.log(scittle);


$ node index.js 
/home/chrism/dev/test-scittle-node/index.js:8
console.log(scittle);
            ^

ReferenceError: scittle is not defined
    at Object.<anonymous> (/home/chrism/dev/test-scittle-node/index.js:8:13)
    at Module._compile (node:internal/modules/cjs/loader:1529:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Module._load (node:internal/modules/cjs/loader:1096:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.19.4

borkdude 2025-10-11T06:38:26.624079Z

You can use eval.call(globalThis,…)

borkdude 2025-10-08T12:28:18.933949Z

I don't know what causes the error. Perhaps it's just shadow's browser setting: https://github.com/babashka/scittle/blob/4ec8026b51b7476cf5bcdf9229f953404c14f1fb/shadow-cljs.edn#L13

borkdude 2025-10-08T12:40:02.295409Z

@chris358 Ah look:

> eval(fs.readFileSync("node_modules/scittle/dist/scittle.js", "utf8"))
undefined
> eval(fs.readFileSync("node_modules/scittle/dist/scittle.reagent.js", "utf8"))

borkdude 2025-10-08T12:41:48.257979Z

this fails, but with:

globalThis.ReactDOM = require("react-dom")
globalThis.React = require("react")
you can load reagent in the above way

👀 1