Fork me on GitHub
#shadow-cljs
<
2021-08-07
>
borkdude12:08:00

I may have hit a bug in shadow-cljs, but not sure. When I require a node module ["fs" :as fs] from two different namespaces, say nbb.main and nbb.core, I get

ReferenceError: import$fs is not defined
    at C8 (file:///Users/borkdude/git/nbb/out/nbb_main.js:8:313)
after advanced compilation. After this workaround, I got it working again: https://github.com/borkdude/nbb/commit/df0edd3c2a560ea3954dc6943a228c3d49668e75

thheller17:08:28

looked into it a bit and figured out what is happening. will see if I can fix it soon

borkdude17:08:47

ok, it's not blocking me currently as I have a workaround, but I'm glad you found the issue

thheller17:08:16

should be fixed in 2.15.3. I also added :compiler-options {:js-provider :import} so you don't have to list every single package in :keep-as-import, it'll just import everything

borkdude18:08:25

Like this right?

borkdude18:08:08

The required JS dependency "fs" is not available, it was required by "nbb/core.cljs".

borkdude18:08:00

When I put :js-options {:js-provider :import} directly on the toplevel of the build, then I get a different error msg:

The required namespace "react" is not available, it was required by "reagent/core.cljs".

borkdude18:08:05

I'll revert that config for now

borkdude18:08:35

The other issue seems to be resolved, thanks!

thheller06:08:09

oh my bad. should have been :js-options {:js-provider :import}.

borkdude07:08:11

I also tried that one and got me a different error about react. I’ll try again when I’m at the computer

borkdude07:08:59

Oh yes, that’s exactly what I already tried, see above.

whacked15:08:45

anybody familiar with how (whether?) shadow-cljs caches macro output? I have a cljs file -- let's say myns.cljs -- which includes a macro defined in myns.clj. The clj file slurps a file and feeds it into cljs. When I change the slurped file, the cljs file does not get updated during watch. When I touch the clj file, then it does get updated. This is understandable. But I'm observing what looks like cached macro output when running release. What's the easiest way to force re-running all macros?

whacked15:08:34

I have not yet played with :cache-blockers so I don't know if it's the same thing, but as a quick and dirty solution, it appears that rm -rf .shadow-cljs does cause a refresh. Since this works reliably in a toy example based off of shadow-cljs/quickstart-browser.git most likely my pipeline was messed up

Parvesh Monu22:08:05

Subject: Use npm package with ES6 Syntax in shadow-cljs Hi everyone, I hope you all are doing great. I am very new to Clojure World. I am working on a ClojureScript, shadow-cljs project. I am trying to use an npm package in the project.I installed it using "yarn add react-native-swipe-list-view". On building it is showing Syntax Error: "Cannot use Import Statement outside a module" According to my research shadow-cljs implements a custom JS bundler and bundles node_modules into something that can be used with clojurescript. But that npm package uses ES6 Syntax and shadow-cljs having trouble bundling with that. I think I need to use babel to convert that into browser-friendly code first. I just need to figure out how to use babel to do that. It will be a big help if someone can point me to a resource to fix this issue. I posted other Info's like screenshots on this URL: https://github.com/status-im/status-react/pull/12432#issuecomment-894633595

thheller06:08:01

shadow-cljs cannot bundle react-native stuff in general. it needs to go through metro or other react-native tools. building it directly is not supported.

thheller07:08:25

FWIW the problem here has nothing to do with shadow-cljs. you are using the :node-test target, which means that all JS requires are resolved by node. so your (:require ["react-native-swipe-list-view" :as swipe-list-view]) is just directly converted to a require("react-native-swipe-list-view") with no further processing by shadow-cljs for this

thheller07:08:53

the error you get is then from node, since the file you required that way does an import

Parvesh Monu10:08:05

@U05224H0W Thank you very much for your reply. You were right, problem was with :node-test. I was missing mock for package for testing and that's why it was crashing.