This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-21
Channels
- # announcements (3)
- # aws (8)
- # babashka (14)
- # beginners (39)
- # biff (22)
- # cider (5)
- # clj-kondo (1)
- # cljs-dev (12)
- # cljsjs (4)
- # clojure (16)
- # clojure-europe (47)
- # clojure-germany (6)
- # clojure-uk (2)
- # clojurescript (36)
- # core-async (29)
- # cursive (19)
- # datalevin (14)
- # etaoin (10)
- # helix (1)
- # hyperfiddle (6)
- # introduce-yourself (5)
- # kaocha (43)
- # keechma (1)
- # lsp (7)
- # nbb (68)
- # new-channels (1)
- # off-topic (12)
- # pathom (11)
- # quil (14)
- # rdf (3)
- # re-frame (5)
- # reitit (6)
- # shadow-cljs (88)
@raymcdermott Feel free to post an issue so that we can include that. Not included yet. But there is a workaround: https://clojurians.slack.com/archives/C029PTWD3HR/p1654207070552289
there are ways to get sha256 ... I just thought I would avoid a dependency but depending google clojure is ok
@xander.carls Thanks for writing this awesome blog post and creating that project! https://www.alexandercarls.de/markdoc-nbb-clojure/
Thank you. This took me quite a while. Also learned Clojure along the way. The help from you with the "Prism" library imports was also greatly appreciated.
dumb question ... how do I access crypto
from nbb
? ... I tried js/crypto
and it said Cannot find namespace node.crypto
aaah
user=> (require '["crypto" :as c])
nil
user=> c
#object[Object]
user=> c/sign
#object[signOneShot]
Has anyone tried building a nbb github action with ncc and with cljs files that contain npm dependencies? I don't think https://github.com/borkdude/nbb-action-example covers this scenario. When I https://github.com/logseq-cldwalker/graph-validator/commit/d8ebd1da4e550cfca34d5df3ca306d81bc58c7f4, the ncc build errors with Cannot find module 'import-meta-resolve'
. I've tried this with two different cljs projects containing npm deps, https://github.com/logseq/logseq/tree/master/deps/graph-parser and https://github.com/chr15m/sitefox
No worries. When you're back, there's more info in my comment. I've tried the nbb-action example but my scenario is more complex. The cljs files I'm requiring have npm deps e.g. https://github.com/logseq/logseq/blob/59c0b9a83a13fb4d5d8b34599c0224796eb21acd/deps/graph-parser/src/logseq/graph_parser/mldoc.cljc#L5
Put up a minimal repro at https://github.com/logseq-cldwalker/graph-validator/compare/main...minimal-repro
@U08ALHZ2N yes, this is what the nbb github example works around by not doing that
> All JS dependencies, including nbb, are compiled into a single file, dist/index.mjs
, using https://github.com/vercel/ncc/. This is recommended in the Github docs as an alternative to commiting your node_modules
into git. Because ncc
needs to statically know which dependencies are required, this is done in the index.mjs
wrapper and not inside the action.cljs
script. The dependencies are then passed as parameters into a function defined in action.cljs
.
For including build-in cljs deps, you can pre-import them in the wrapper using import 'lib/nbb-promesa.js
for example
I am trying the repro locally, but I'm missing information on what to do exactly. Also npm install is failing on me
$ npm install
npm ERR! code 1
npm ERR! The git reference could not be found
npm ERR! command git --no-replace-objects checkout workspace=@logseq/db&head=dev/yarn-workspaces
npm ERR! error: pathspec 'workspace=@logseq/db&head=dev/yarn-workspaces' did not match any file(s) known to git
if you can add more info to the repro with very explicit steps on how to run without ncc and with ncc, etc, I can take another look tomorrow
Ah. Missed the last couple sentences in that paragraph. For the graph-parser it'd be somewhat onerous for the ns to receive the js dependency as an arg because it sits about 3-4 namespace levels below the public api and is called by probably a dozen different fns across namespaces. All these caller fns are now coupled to an implementation detail in a child ns and if the implementation changes, all of the caller fns have to be updated. I'll probably try a different approach than ncc, starting with node_modules and then maybe docker. Was the https://clojurians.slack.com/archives/C029PTWD3HR/p1643724438954269?thread_ts=1643723841.896719&cid=C029PTWD3HR approach you mentioned for use with docker?
> if you can add more info to the repro with very explicit steps on how to run without ncc and with ncc, etc, I can take another look tomorrow
If you're curious to try, yarn install
should do it and then it's the same steps as the example for calling dev and release scripts. yarn -v
should show up as 3.2.1. The install only works for yarn since I'm using https://yarnpkg.com/features/workspaces to pull a git dep from a non root directory
I tried fixing this error but I keep running into:
file:///private/tmp/graph-validator/dist/index.js:5049
aw(a){return a.toUtf16()}if(S.process&&S.process.cwd)var
^
TypeError: Cannot read properties of undefined (reading 'process')
I tried once more. This error comes from:
import 'mldoc';
When I remove it, this error disappears@U08ALHZ2N I'd be interested to hear how that works
https://github.com/logseq/graph-validator/blob/main/action.yml shows how it works. Basically downloads deps on every job run. Not great but at least deps are cached. Happy to add a link to this repo on the nbb-action-example or nbb repo if it it's helpful
I think this is a much better approach than what I did. Cc @U04V4KLKC
Afaik it's required to have a reproducible yarn 3. Was generated by yarn set version stable
. I needed yarn 3 to use its workspaces feature
So where do I see an example run of this action? In the README it says that it's used in https://github.com/logseq/docs
It's also running on 3 private repos but may soon be running on more public repos depending on how much the community embraces it
I used workspaces because I needed to make a gitlib of a subfolder, like a :deps/root for deps.edn. Afaik npm doesn't support this and only yarn's workspaces supports this. It's not well advertised and buried in git issues like https://github.com/yarnpkg/yarn/issues/4725#issuecomment-753416391. If someone doesn't have this requirement, then they should be able to use the composite action with either manager
@U08ALHZ2N Since the github actions distribution model is super ugly anyway, maybe one could also just work with a zipped node_modules file in the repo and unzip it in runs.pre