Fork me on GitHub
Ivan Fedorov09:08:26

Is there a section on the tutorial on how shadow resolves, for instance, react subdependency for reagent?

Ivan Fedorov10:08:08

I mean reagent itself depends on cljsjs/react, but as I understand, in the shadow-cljs’s context it’ll be used only for externs. It would be super cool to have a single place to see all deps that make their way into the release bundle. I know pom.xml, but AFAIK it only lists cljs part.

Ivan Fedorov10:08:28

Not urgent, though

Ivan Fedorov10:08:53

I can submit a card on github, if you would like to have it on the horizon

Ivan Fedorov11:08:58

Whoa, build report is very nicely done, good job!

👍 4
✔️ 4

Is there anyway to split up the release build process between what requires Node and what requires the JVM? I know the answer is most likely no, but I had to ask before spending a bunch of time making my own Docker image. Trying to get our new shadow-cljs project into our GitLab CI and I need to build the project in a Docker image. If I can split the steps I can just use the official images for Node and Java. If not I have to build my own in house Docker image that has both.


@kasuko not sure what you mean by "what requires Node"? or what the docker image has to do with this? there are plenty of images that have node+JVM available?


Unfortunately due to security policies at my company I can only use approved Docker images. We have a node and a jdk image approved and I was curious if it was possible to split up the build. So I could compile all the Clojurescript in a Docker image that just had JDK then package all the Javascript up in the image that has Node.


FROM node as node

RUN npm install

FROM clojure

COPY --from=node node_modules

RUN clj -A:cljs:build

RUN aws s3 put target/out.js s3://


something like it?


Ya exactly


npm isn't required technically so the above example would work with shadow-cljs


clj -m shadow.cljs.devtools.cli release your-build


just need the node_modules folder and the package.json so it doesn't try to install deps from deps.cljs


Awesome, I will give this a go! I honestly didn't expect this to pan out.


I'm trying to use some protobuf-generated JS in a shadow-cljs app. When I generate it with "commonjs" output format it works but needs unsafe-eval in the Content-Security-Policy header, which I'd rather avoid. But when I generate it with "commonjs_strict" output it doesn't work. Here's the diff (`---` is working but unsafe; +++ is safe but non-working): Anyone know if / how I can use the +++ version in a shadow-cljs app?


Can I do this in shadow-cljs? Looks like this create a namespace for a npm dependency.


@cap10morgan I have a hard time deciphering that gist. can just just post the 2 separate variants not as a diff?


never done any protobuf stuff with generated code but there should be something easy that just works


@doglooksgood see ie. :js-options {:resolve {"create-react-class" {:type :npm :require "preact-compat/lib/create-react-class"}}}


@thheller Yeah, thanks. I'm trying out a slightly different approach. I'll post both files if it doesn't pan out.


@thheller OK, yeah, didn't work. Here are the 2 versions I'm trying now: - working but not safe: - not working but safe(r) (uses ES6-style import statements but I get the error goog is not defined when I run it):


I'm trying to use the library in CLJS with (:require ["path/to/js_file" :as game-lib]) in both cases.


@cap10morgan hmm does it have another output format for closure directly?


looks very much like closure js?


It does yeah, but that output is very different in that it's all separate files. I was trying to see if I could get it to work in one file first. But if the closure way is best, I'll bite the bullet. 🙂


does it have goog.provide/goog.require calls at the top?


yes that would be best


don't need JS interop at all then and get full benefit of :advanced


OK I'll dig into that then. Thanks for the pointer!


just put the files on the classpath. ie. generate into src/gen and :source-paths ["src/main" "src/gen"]


then import like regular cljs/closure namespaces

👍 4

(:require [ :as x]) or so


shadow-cljs - failed to load module$node_modules$preact_compat$dist$preact_compat What does this error mean? this file is exists.


I got this error in the console of browser. the compile is succeed.


Ohh, preact-compat is for preact 8, I'm using the version 10


@thheller Alas, one of the protobuf plugins we're using isn't compatible with closure-style JS. The best I can do is this CommonJS strict version (which I can't get working in shadow-cljs):


Oh, I think I figured it out. Pretty simple in the end. Because it's extending exports with proto, I can just refer to game-lib/game.Thingy in my CLJS code.


I would suspect that closure-js style results in a substantially smaller JS file in the end


so might be worth getting that to work