Instead of "../out/**/*_story.js"
, I've added "../out/**/stories.*.js"
to the module.exports
list in main.js
and it seems to be working.
hmm I don’t think we actually need stories.core
to be included in the storybook build
I suppose you can organize how you want
Oh, really? I thought that would be the only way to do it. Where are the *_story.js
files coming from?
the part I left out is creating a corp.design.button-story
namespace
https://github.com/lilactown/storybook-cljs/tree/master/src/corp/design
Ooooh I see now. I couldn't think of why else there might be *_story.js
files, so I assumed it was a typo.
yeah. what I’m doing is a bit weird. basically, I enumerate each story namespace in two places:
• stories.core
so that shadow-cljs knows to build it
• in the storybook config using the glob pattern, so that the built file gets picked up by storybook’s CLI
Either way, you've gotten me much farther than I thought I would get with this!
I suppose another way you could do it is to configure storybook to just statically include stories.core.js
How did you find out the .babelrc
was necessary? I would never have thought of that.
years of experience working with JS bundlers 😂
I can’t remember now why it was necessary tbh
Also, how are you getting away without using the storiesOf
API?
Oh wait, I see, it seems like you're basically using the new CSF style.
Where they depend on default exports etc. I'm actually trying to avoid that, it seems to rely on having one file per React component. Reagent components are so small that I tend to have multiple per file. I'm thinking the older storiesOf
API will be more accommodating to that, let me know if you have another idea!
Hey
I'm trying to load react-vega
and I'm getting this issue
[:zubi] Build failure:
The required JS dependency "buffer" is not available, it was required by "node_modules/vega-loader/build/vega-loader.js".
Dependency Trace:
zubi/dev.cljs
zubi/client.cljs
node_modules/react-vega/lib/index.js
node_modules/react-vega/lib/Vega.js
node_modules/react-vega/lib/utils/updateMultipleDatasetsInView.js
node_modules/react-vega/lib/utils/updateSingleDatasetInView.js
node_modules/vega-embed/build/vega-embed.js
node_modules/vega/build/vega-node.js
node_modules/vega-dataflow/build/vega-dataflow.js
node_modules/vega-loader/build/vega-loader.js
Searched for npm packages in:
/home/souenzzo/src/zubi/node_modules
See: <https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install>
I think that somehow vega-loader
thinks that it's running on nodejs
(maybe ssr) and tryies to import a buffer.you need to npm install shadow-cljs
in your project ...
which you should be getting a big fat warning about
npm install --save-dev shadow-cljs
and it do the hot-reoload even before I checkout logs/output
Tnks for shadow-cljs ❤️
I'm on
thheller/shadow-cljs {:mvn/version "2.11.0"}
Using "deps"
both JVM8
and JVM14
do the same error.
@thheller would it be possible to a way to clear shadow-inspect?
Specifically remove any logged taps that are on the page
would be easier to read than (tap> "==================")
😂
@royalaid please open an issue so I don't forgot to add it this time. working on the UI but need to solve something else first 😉
Hey there! With the following build config:
:app {:target :browser
:js-options {:resolve {"foo" {:target :npm :require "foo"}}}}
Eval-ing the following code on the REPL:
(require '["foo" :as foo])
(js/console.log foo)
I get the following:
{__esModule: true, default: ƒ}
So to make an instance of foo, I have to call (foo/default.)
Is there a way to specify within the build config that default
should be “unwrapped” automatically, so that I can call (foo.)
?
What I’m trying to solve (and perhaps there’s a better way): There’s a dependency foo
which exports a constructor function directly via a UMD. Within tests I need to substitute foo
with a mock, so I’m using a separate npm package foo-mock
which is an ESM and the constructor is under the default
export property.
The config in the end might look something like this:
:app {:target :browser
:js-options {:resolve {"foo" {:target :npm :require "foo"}}}}
:test {:target :browser-test
:js-options {:resolve {"foo" {:target :npm :require "foo-mock"}}}}
Thanks in advance!@me1676 why is the mock different from the actual? seems like a strange way to mock?
you can try :resolve {"foo" {:target :npm :require "foo-mock$default"}}
if you are on a recent version but I'm not sure that'll work
Yes, that’s an unfortunate decision by the author of foo-mock. I’ll try your suggestion
shadow-cljs 2.10.21 fails:
Build failure:
:resolve override for "foo" to "foo$default" which does not exist
{:tag :shadow.build.resolve/invalid-override, :require-from #object[java.io.File 0x4aa9328a ".../test.cljs"], :require "foo", :other "foo$default"}
hmm yeah didn't expect that to work really 😛
😃
what are the packages?
It’s https://www.npmjs.com/package/pusher-js and https://www.npmjs.com/package/pusher-js-mock
to answer your other question you can use (:require ["foo" :default foo])
and direclty use (foo.)
or (:require ["foo$default" :as foo])
(new "standard" variant likely coming in next CLJS release)
the only other suggestion I can make is publishing your own npm package that uses pusher-js-mock but exports the default you want
module.exports.default = require("pusher-js-mock").Whatever
;
node_modules/pusher-js-mock-default/index.js
or so
then the :require
redirect should be fine
Thank you @thheller, these are good suggestions!
How should I use a CommonJS/ES6 namespace in a ClojureScript macro? I'm following @thheller's https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html, which suggests that defmacro
within a .`clj` file should use a fully-qualified namespace. But going by the shadow-cljs User Guide's https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages, I don't see how to use a fully-qualified namespace with CommonJS/ES6 imports, because they are referred to with strings as in (:require ["module-name"])
.