Fork me on GitHub

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:


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


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


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


Like this right?


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


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".


I'll revert that config for now


The other issue seems to be resolved, thanks!


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


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


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


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?


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:


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.


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


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.