This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-17
Channels
- # announcements (7)
- # architecture (12)
- # babashka (5)
- # bangalore-clj (4)
- # beginners (70)
- # biff (23)
- # calva (21)
- # clojure (130)
- # clojure-bay-area (3)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-europe (55)
- # clojure-finland (4)
- # clojure-greece (5)
- # clojure-nl (3)
- # clojure-norway (10)
- # clojurescript (52)
- # code-reviews (4)
- # community-development (1)
- # data-science (7)
- # datahike (6)
- # datomic (1)
- # events (1)
- # figwheel-main (7)
- # fulcro (23)
- # helix (2)
- # honeysql (32)
- # malli (18)
- # membrane (6)
- # nbb (22)
- # nyc (1)
- # off-topic (26)
- # pathom (2)
- # polylith (34)
- # quil (13)
- # releases (1)
- # remote-jobs (4)
- # scittle (1)
- # shadow-cljs (52)
- # sql (24)
- # tools-deps (17)
- # vim (11)
- # web-security (15)
- # xtdb (6)
Load nbb in Github comments :star-struck: https://twitter.com/borkdude/status/1593183576019070976
And another surprise today, apparently you can run nbb with deno now: https://twitter.com/borkdude/status/1593213424619917314
Has anybody worked out how to import a TypeScript module into a nbb REPL?
@dave.dixon Can you be more specific?
I'm running nbb via calva. This is very handy for interactive development, but right now I'm building/running the TypeScript app externally and loading output through a file into nbb. It would be really nice if I could change the TypeScript, load that (presumably transpiled to JS) code into nbb, and call it to see the results interactively rather than doing a whole compile/run cycle.
yes, you can do this, but without some sort of repro, it's hard to be specific on how to do this
you can do (:require ["./foo.js"])
assuming that TS will spit out some .js file
Thanks. I'll work on this a bit. Pretty sure the above is possible, and maybe I can call the TypeScript API directly to compile/load from nbb. I'll research it.
How about coming at this from the other direction, and launching a REPL server from the JS end?
Ah there an issue for it here: https://github.com/babashka/nbb/issues/132
@dave.dixon Publishing 1.1.145 now which should have this: https://github.com/babashka/nbb#nrepl-api
Thanks. I seem to be stuck in module incompatbility hell, Instead change the require of /Users/dave.dixon/Projects/de_flare/node_modules/nbb/index.mjs to a dynamic import() which is available in all CommonJS modules.
, so far haven't been able to try this out. I'll see if I can find a workaround.
Yes, you could do this as a dynamic import in an async function if you’re using cjs
@dave.dixon Here is how you do that:
async function nREPL() {
const { loadString } = await import('nbb');
await loadString(`
(require '[nbb.nrepl-server :as nrepl])
(nrepl/start-server! {:port 1337})
`);
}
nREPL();
Thanks, but there's some issue with how we have our TypeScript project set up where it doesn't work. I either need to sneak in a pure JS script that avoids the TS transpiler, or get the right set of TS config options that won't break compilation on the rest of our codebase.
Found a possible workaround here. The core problem seems to be that we use ts-node
, and that has issues with ESM imports. But if I make our server startup pure JS, and tell ts-node
to not transpile files with the .js
extension, it works: ts-node --ignore \.js src/server.js
. That also explains the error, which I think occurred because ts-node
was "helpfully" converting import
to require
behind the scenes.