Fork me on GitHub
#nbb
<
2023-04-14
>
borkdude12:04:59

@U5H74UNSF why do we need this if have already have a REPL, and e.g. https://github.com/borkdude/deflet? You can "debug" your build as you're writing it and use the code you wrote to "debug" as the final product

mkvlr12:04:29

yeah, doesn’t get me the selectors/locators though

mkvlr12:04:10

the inspector lets me drive the browser interactively and generates the test code for us

2
👀 2
mkvlr12:04:28

including the locators at the right specificity

mkvlr12:04:43

it’s pretty neat

borkdude12:04:04

then maybe you don't need to write any CLJS, just use what it produced?

borkdude12:04:14

you can load / wrap that code from nbb

mkvlr12:04:15

yeah, considering that

mkvlr12:04:17

all this tooling is pretty great, uphill battle to replicate it, maybe better to just use nbb to talk to our api but stick to js for the browser tests

mkvlr12:04:16

these reports and traces also look pretty nice https://playwright.dev/docs/trace-viewer-intro

borkdude12:04:16

Maybe they have an API to let you plug in what language you want to generate, but not sure if it's worth it compared to the generated JS

Mario Trost20:04:17

npx playwright codegen is so good and the reason we have typescript test files in our cljs project

ericdallo15:04:49

Regarding https://github.com/clojure-lsp/clojure-lsp/issues/1418#issuecomment-1443705502, I tried add that to nbb and failed after recall I can't shell-out in js 😅 any tips?

ericdallo15:04:58

what I tried to add at src/nbb/impl/main.cljs

(when (:print-classpath opts)
  (println (process/shell "bb" "print-deps" "--format" "classpath"))
  (js/process.exit 0))

borkdude15:04:59

what is process here?

ericdallo15:04:51

I tried with both babaska.process and clojure.java.shell, for babashka.process I tried adding on deps.edn but didn't find the deps, not sure if I should do something else

borkdude15:04:59

you can look at impl/deps.cljs to see how to shell out to bb

👀 2
borkdude15:04:20

babashka.process and clojure.java.shell don't work in CLJS

ericdallo15:04:41

yeah, that was what I thought since runs on js, thanks will take a look

ericdallo15:04:10

Works :)

🎉 2
ericdallo15:04:12

I'm doing ATM

(println (.toString (cproc/execSync "bb --config nbb.edn print-deps --format classpath")))
now we need to include nbb deps or you think this is already enough? (note the --config nbb.edn there, not sure if we should pass a different cwd)

borkdude15:04:54

config should be sufficient

ericdallo15:04:39

nice, so I think it's done, I will try to add tests and send a PR, thanks!

👍 2
ericdallo17:04:00

I couldn't find a better way to test the shell-out https://github.com/babashka/nbb/pull/321

ericdallo17:04:16

My first nbb PR :D

borkdude18:04:26

I think it would be useful to have the same API as with bb:

bb print-deps --format <classpath> | <deps>

ericdallo18:04:12

Sounds good, is it ok to support only classpath format for now?

ericdallo18:04:36

well I will only delegate to bb so I think it's ok to support both right now

borkdude18:04:04

yes, only classpath is ok

borkdude18:04:10

you can use babashka.cli to parse args

borkdude18:04:25

haven't looked at the code yet ;)

borkdude18:04:14

I think print-deps might print too much when going through bb though, it will print its own deps too and e.g. not promesa etc, I think?

ericdallo18:04:54

hum, yeah, I think so

ericdallo18:04:02

what you think nbb should print?

borkdude18:04:16

the deps that it has built-in, see the nbb deps.edn

ericdallo18:04:39

Ah yeah, what's your suggestion of print those deps?

borkdude18:04:23

what do you mean?

ericdallo18:04:07

I mean, the correct for nbb would be to print the deps from nbb's deps.edn right? but bb print-deps --format classpath would print bb deps which are not included in nbb IIUC

borkdude18:04:54

I think we need to include the deps.edn into the CLJS build via a macro

borkdude18:04:03

so we can print it later

ericdallo18:04:04

bb print-deps --config <nbb-deps.edn-location> would probably work right?

borkdude18:04:31

that will work, but it will not print the built-in deps

borkdude18:04:45

and it will also still print the built-in deps of bb

ericdallo18:04:26

> include the deps.edn into the CLJS build via a macro how can we do that, not sure I get how that will work

borkdude18:04:59

I think it might be better to not use bb print-deps after all. See nbb.impl.deps which extracts the dependencies of nbb.edn into .nbb/.cache/.blablabla and this is what nbb uses as its classpath. you can get this classpath with nbb.classpath/get-classpath

borkdude18:04:15

The only thing left is to add the built-in deps to the classpath

ericdallo18:04:32

so would be a merge of nbb.classpath/get-classpath + builtin deps that are in nbb's deps.edn

borkdude18:04:42

for the built-ins we can still use babashka, by doing:

(babashka.deps/add-deps {:deps {built-in-deps}}) + babashka.classpath/get-classpath

borkdude18:04:24

and then combine those

ericdallo18:04:27

cool, I'll give it a try, I think I got it