This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-09
Channels
- # aws (1)
- # babashka (61)
- # bangalore-clj (5)
- # beginners (83)
- # biff (2)
- # calva (4)
- # cider (6)
- # clara (5)
- # clj-kondo (72)
- # cljs-dev (31)
- # cljsrn (28)
- # clojure (8)
- # clojure-australia (1)
- # clojure-europe (19)
- # clojure-france (1)
- # clojure-losangeles (21)
- # clojure-nl (2)
- # clojure-spec (2)
- # clojure-uk (9)
- # clojurescript (13)
- # clojureverse-ops (5)
- # code-reviews (1)
- # conjure (7)
- # cursive (4)
- # datascript (2)
- # datomic (8)
- # depstar (1)
- # emacs (3)
- # etaoin (1)
- # events (3)
- # exercism (7)
- # fulcro (6)
- # girouette (2)
- # graalvm (125)
- # honeysql (19)
- # integrant (1)
- # jobs (12)
- # lsp (1)
- # numerical-computing (1)
- # off-topic (23)
- # portal (12)
- # practicalli (1)
- # re-frame (35)
- # reitit (5)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (51)
- # tools-deps (14)
- # vim (3)
- # xtdb (20)
So, I haven’t been able to figure out how to get this to work still. I tried adding :target :bundle
to my build.edn
, but that didn’t seem to have an effect. I think part of the issue is that I’m not trying to import something from node_modules
. I’m trying to import a JavaScript file from within my project. Relative to my core.cljs
file, it’s located at ../../storybook/index.js
. In JavaScript, I would import by doing something like import StorybookUIRoot from '../../storybook'
. In Clojurescript, I’m not sure how to do that - I’ve tried lots of incantations and none of them worked (most of them I didn’t expect to work):
:require [storybook]
:require [../../storybook :as storybook]
:require [(symbol ../../storybook :as storybook]
(js/require "../../storybook")
Since I haven’t been able to find any documentation about how to require JavaScript that is within my project (and not in node_modules
), I’m not sure where the problem lies. I’ll try to narrow it down through experimentation and maybe reading some code to understand how the different pieces are supposed to work.I’ve managed to require my own JavaScript by a creating a local npm module: https://docs.npmjs.com/creating-node-js-modules
After that, you can require it like any other JS library via package.json
"mylocalmodule": "./npm-local/mylocalmodule",
./npm-local/mylocalmodule
is located in the top-level React Native directory of your project
Great idea! I thought of doing something like that with npm link
or something but I think I like your idea even better, since it gives me more flexibility where I put my code. I’ll give that a try!
the storybook npm library is the standalone CLI command you are supposed to use for storybook?
why are you trying to include it in a CLJS build? its not meant to be used as a library
Yes, more specifically it’s the file created by the storybook command:
npx -p @storybook/cli sb init --type react_native
@soxley right, you cannot put paths in the ns
form in ClojureScript - we could probably support some very restricted pattern - like foo/index.js
for local node_module resolution?
though ... probably least problematic thing to do and the most minimal change, is just to allow additional paths for node_modules
indexing - seems like that would cover this problem
I’m trying to split my shadow-cljs + expo project into different namespaces for difference platforms, but coming up show on examples/documentation. Curious if and how this can be done?
ah you just mean expo target? I thought you meant actually switching the code that gets compiled, not what expo makes out of that
can't comment on the expo part. shadow-cljs stays with :target :react-native
, you just start the expo thing differently I guess
Hm, maybe I need a dynamic require? The platform comes from the OS function on react-native/Platform
no, flip it. you build based on the target platform. and whatever you build directly requires that it needs
so you create a your.app.web
your.app.android
and/or your.app.ios
namespace for each
this thread has relevant details: https://github.com/thheller/shadow-cljs/issues/651