@huxley and what was it?
I was working in a new file that was not yet required anywhere 😜
and date-fns-tz
has not been used anywhere else
the main cause of problems usually sits in front of the monitor
hmm well normally that shouldn't be a problem but I guess there is an issue with electron and eval
then
(assuming you just load-file or require the file it should be fine)
as I did a require in another ns which is used in the application and is compiled, then suddenly everything started to work everywhere and in every ns
do you have any custom :js-options
or so in your build config? anything electron related?
normally this should just work (and did in your and my tests)
Is it possible to call a node script from cljs? If so, how do I configure my shadow-cljs.edn
so that I can call it?
what do you mean by "call a node script from cljs"?
Nevermind, I finally figured out the classpath business.
(ns app.data
(:require [clojure.edn :as edn]
[shadow.resource]
["/org_processor" :as org]
))
deps.edn
:
{:paths ["src" "scripts/js"]
...}
But now I get a weird error.
[:app] Compiling ...
[:app] Build failure:
Closure compilation failed with 1 errors
--- org_processor.js:3
Parse error. '}' expected
ah you mean using a JS file in your build. by "call a node script" I assuming you mean run node some-script.js
or so 😛
whats weird about that error? seems to be invalid js?
yeah, I want to use a node script as it interacts with my local filesystem, and shadow.resource
just doesn’t suit my needs.
The error is weird because it’s output from a compiled cljs file.
It should be valid
you are not making much sense to me here
its output from a compiled cljs file? what does that mean?
please describe what you are trying to do, if possible with actual example
I’m trying to use a library that turns org-mode documents into html.
Here’s my script.
(ns scripts.org-processor
(:require ["unified" :as unified]
["rehype-stringify" :as html]
["uniorg-parse" :as uniorg]
["uniorg-rehype" :as rehype]
["uniorg-extract-keywords" :refer (extractKeywords)]
[cljs-node-io.core :as io :refer [slurp spit file-seq]]
))
(def processor
(->
(unified)
(.use uniorg)
(.use extractKeywords)
(.use rehype)
(.use html)))
#_(def org-string "
#+title: Lorem Ipsum
#+subtitle: stuff test
#+date: 2021-04-15
#+tags: test
#+author: Christian Westrom
#+id: test-1
* Here's some stuff
* Here's more stuff
- more stuff")
(defn process-org
[org]
(.processSync processor org))
(defn org->html
[org-string]
(.-contents (process-org org-string)))
(defn org->data
[org-string]
(js->clj (.-data (process-org org-string))
:keywordize-keys true))
(defn blog-post
[org-string]
{:content (org->html org-string)
:data (org->data org-string)})
(defn ^:export all-posts
[path]
(js/console.log (map #(blog-post (slurp %)) (rest (file-seq path)))))
Now the function all-posts
just outputs to the console for now, but I want to call it from my reagent site.
ok then requiring the file is that what you want here
I'd recommend to have that script output files to a certain location
and either loading those files dynamically via ajax at runtime
or including then via shadow.resource
I do NOT recommend trying to run that script as part of the compilation. that'll just end up with unnecessary avoidable problems all over the place
Looks like I need ajax then lol
Because there’s no equivalent to file-seq
in shadow-resource
.
well with a macro you could trivially write that yourself
how?
I wouldn't recommend doing that though so you'll have to figure that out yourself 😉
I mean you have the script to generate the stuff right there
so you could have that generate a single EDN or JSON file and just shadow.resource that
but I would really recommend loading them dynamically
unless you enjoy recompiling your entire code every time you make a change in the org mode files
Ok cool, any good libraries for doing ajax in clojurescript?
if you don't care about really old browser then just use js/fetch
👍
Thanks a bunch!