Fork me on GitHub
#shadow-cljs
<
2019-08-28
>
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
kasuko12:08:15

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.

thheller15:08:07

@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?

kasuko17:08:34

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.

souenzzo17:08:49

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://

souenzzo17:08:57

something like it?

kasuko18:08:48

Ya exactly

thheller18:08:15

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

thheller18:08:52

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

thheller18:08:12

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

kasuko12:08:49

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

cap10morgan18:08:34

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): https://gist.github.com/cap10morgan/b9f283fa8035b8c0bc527b0911eed1fb Anyone know if / how I can use the +++ version in a shadow-cljs app?

tianshu18:08:49

Can I do this in shadow-cljs? https://github.com/tomconnors/problems/blob/reagent-preact/project.clj#L40 Looks like this create a namespace for a npm dependency.

thheller18:08:10

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

thheller18:08:27

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

thheller18:08:30

@doglooksgood see https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve ie. :js-options {:resolve {"create-react-class" {:type :npm :require "preact-compat/lib/create-react-class"}}}

cap10morgan18:08:28

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

cap10morgan18:08:10

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

cap10morgan19:08:34

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

thheller19:08:11

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

thheller19:08:16

looks very much like closure js?

cap10morgan19:08:05

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

thheller19:08:38

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

thheller19:08:16

yes that would be best

thheller19:08:36

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

cap10morgan19:08:52

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

thheller19:08:03

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

thheller19:08:13

then import like regular cljs/closure namespaces

👍 4
thheller19:08:29

(:require [proto.game.Whatever :as x]) or so

tianshu20:08:41

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

tianshu20:08:13

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

tianshu20:08:33

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

cap10morgan20:08:39

@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): https://gist.github.com/cap10morgan/2d29db3e9a3f8326dde71a56a21c6d7d

cap10morgan20:08:22

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.

thheller20:08:59

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

thheller20:08:26

so might be worth getting that to work