Hi! I'd like to add [shadcn](https://ui.shadcn.com) components to a UIX project. However, shadcn is distributed as individually installable components that require some additional compilation steps. In particular, shadn defaults to a local install that is not playing nicely with the shadow-cljs compiler. I am wondering if there is a simple step to get these files to be picked up. You can see my initial attempt to override js-options below and in the screenshot. Pointers appreciated. Thank you.
// shadow-cljs.edn
{:builds {:app
{:target :browser
:js-options
{:resolve {"@" {:target :file
:file "@"}}}}}}doesn't this generate jsx or tsx files? those need to be processed by something else first since shadow-cljs doesn't support those syntaxes
I see this prior art: https://clojurians.slack.com/archives/C6N245JGG/p1709586164193269
You can get the components as plain JS.
( i think )
can you override the @ or is that hardcoded? could it generate my-ui/components/ui/accordion instead?
I think you can do that. Prett sure @ is only a convention.
I'm asking because I'm not sure if @ is a good name for a directory 😛
JS world is .... wild : )
either way you can generate the files into packages/my-ui, then in the build config use :js-options {:js-package-dirs ["packages" "node_modules"]}
ah! okay. Let me give it a go. Thank you
in the code then (:require ["my-ui/components/ui/accordion" :as x]) and it'll first look in packages/my-ui/components/ui/accordion and if that isn't found in node_modules
packages/@ is kinda meh but I guess is a valid directory name 😛
just needs its own dedicated directory somewhere
If I can get this to work. I'll make a template to follow allong.
basically packages becomes our own private local npm repo. you could generate into node_modules/my-ui but npm usually doesn't like you putting files there and will randomly delete them
So yeah., you're right. the JS options are still JSX:.
you can run that through babel or something. just needs the jsx -> js conversion somehow
many years ago I documented this https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects
no clue if that still works 😛
How do i develop node-script with REPL through shadow-cljs? Since there's no runtime like in a browser
you launch the node script output, then there is the node js runtime, node the-output.js
or your use npx shadow-cljs node-repl
I'm having issues trying to do a node script in cljs using shadow-cljs and having npm dependencies that are ES modules
that is a node issue that shadow-cljs cannot do anything about with :node-script. if you must use es modules use :target :esm instead
I'm trying to figure out :target :esm but I'm not really sure what I'm supposed to add in :modules
is there an example?
:modules {:main {:init-fn creates a main.js in :output-dir
and calls ( on startup
Well now I'm getting this issue
The required JS dependency "node:stream" is not available, it was required by "node_modules/ink/build/render.js".:js-options {:js-provider :import} in the build config
default for :esm is to bundle dependencies, which it cannot do for node built-ins
SyntaxError: Cannot use import statement outside a moduleset "type":"module" in your package.json
and if i want to run it i just run the output with node?
hmm?
var SHADOW_IMPORT_PATH = __dirname + '/../.shadow-cljs/builds/memehunter/dev/out/cljs-runtime';
^
ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/nikolaspafitis/IdeaProjects/memehunter/package.json' contains "type": "module".How can i run that script
the resulting js script using node
that is not from a :esm output?
Sorry ignore the above
node target/app.js
/Users/nikolaspafitis/IdeaProjects/memehunter/node_modules/react-reconciler/cjs/react-reconciler.development.js:491
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
^
TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner')
at $$$reconciler (/Users/nikolaspafitis/IdeaProjects/memehunter/node_modules/react-reconciler/cjs/react-reconciler.development.js:491:46)
at file:///Users/nikolaspafitis/IdeaProjects/memehunter/node_modules/ink/build/reconciler.js:61:16
Node.js v20.15.1I'm trying to build a TUI using uix react and ink
🤷♂️
thats node, not shadow-cljs
Okay thanks
@thheller Hi it turns out ink doesn't work with react 19, had to downgrade to 18 your solution worked