Fork me on GitHub
#cherry
<
2022-08-21
>
armed15:08:19

Hello, everyone. Recently had strange issue with macro requirement. Basically macros can’t be loaded if it is at least one level above source-file. E.g. • put macro in src/macros.cljs dir • nest sourcefile in src/my-ns/somefile.cljs • try to require (:require-macros ["../macros.mjs" :refer [foo]]) I’ve got following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/<path-to-project>/cherry-hn/node_modules/cherry-cljs/macro/macros.mjs' imported from /<path-to-project>/cherry-hn/node_modules/cherry-cljs/lib/cli.js
...
Not sure is this a real issue or I’m doing something wrong.

borkdude15:08:19

Yes, macros in cherry are currently implemented in a very basic way. This will change (both here and in #clavascript): to be able to run the compiler in both JVM/bb/JS SCI will probably be used so you can directly refer to a .cljc namespace to load macros

👍 1
didibus21:08:30

Nice, but a site like that should not use JS in my opinion 😛

armed16:08:57

Completely agree, HN API is just very convenient to play with.