Fork me on GitHub
#shadow-cljs
<
2024-04-01
>
Nik09:04:35

Hi, can some one please tell me how to connect to custom node repl. in shadow-cljs.end :buid key I've put

:node-app {:target :node-script
                     :output-to "resources/app.js"
                     :main app.main.test/main}
with code
(ns app.main.test)

(defn main []
  (js/console.log "Hi"))
I then run shadow-cljs watch node-app and in second terminal node resources/app.js but when I connect to repl using emacs cider or vscode calva. and run js/__dirname it says __dirname is not defined. Instead if I choose :node-repl from the connect menu and then run the command it correctly outputs ".".

thheller09:04:27

__dirname is a "special" constant that is not available in the REPL generally as it is based on the filename of the currently executing file. REPL isn't based on files 😛

Nik09:04:59

hmm :thinking_face:. how come it works when I use builtin node-repl option?

thheller17:04:09

feel free to make a repo with instructions and reproduced only with npx shadow-cljs cljs-repl node-app (no calva/cider)

1
thheller17:04:15

I don't have an answer but could be a bug

thheller17:04:44

although node-repl is just a :node-script build, so not sure what the problem may be

cap10morgan19:04:37

When I convert a shadow build from :node-library to :esm and then change the code using it from const lib = require('@compiled/js') to import * as lib from '@compiled/js', I start seeing new keys in the lib object: $APP, $jscomp, and shadow$provide (in addition to the ones I'm explicitly exporting). Is that expected / necessary?

thheller21:04:06

strictly speaking only necessary for multi module builds, but currently always exist

cap10morgan21:04:45

OK. I have no reason to be concerned about them, was just curious. Thanks!