Fork me on GitHub
#shadow-cljs
<
2019-09-09
>
Aklscc05:09:37

Hey, I'm sorry to bother you. I'm curious whether it is necessary to write the properties and functions for all objects in app.txt, which refer to: https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs Actually, if it dosen't afford, some warning appear. But it seems that it will not affect the compile result. It's a compile mechanism, but I also want to get some solutions about it. It's too trouble to add them manually.

thheller06:09:58

but what is the problem? are you sure it is externs related?

Aklscc06:09:26

@thheller Maybe a little related. I want to avoid the externs, which also the clojurescript official suggestion. And with app.txt also a kind of externs, is it?

levitanong10:09:19

@thheller is there any way I can help bring about preamble support? This would be useful for conforming to licenses like MIT and Apache 2.0

thheller10:09:09

@levitanong its already supported?

thheller10:09:58

well, it could be better I suppose since pasting a license into your build config would suck

levitanong10:09:27

@thheller oh! I looked at this: https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options. Perhaps a line could be added saying instead of preamble, use prepend?

levitanong10:09:24

But yes, pasting a license to my build config isn’t ideal 😛

thheller10:09:30

well the intent is to use the CLJ api for emore complex things

thheller10:09:33

(-> (shadow/get-build-config :your-build) (update-in [:modules :main] assoc :prepend (slurp "whatever.doc")) (shadow/release*))

thheller10:09:58

in a custom defn and invoked via shadow-cljs run your.build/fn

levitanong10:09:58

Oh that’s funky! Never thought to use it in that way

levitanong10:09:09

Thanks for the tip!

aisamu14:09:32

Hi! Applying the proposed change (`global-eval` -> js/eval on src/main/shadow/cljs/devtools/client/browser.cljs) seems to fix the CLJS REPL breakage on 2.8.52! I'm not sure whether that's good or bad news, though 🙂

thheller16:09:38

@aisamu well it breaks the :browser builds again 😉 only fixes :npm-module

thheller16:09:09

I will find a proper way to fix that, just didn't think of anything good yet

thheller16:09:15

want to avoid hacks 😉

👍 4
aisamu16:09:42

Yup, tested only :npm-module! We can stick to 2.8.39 without issue 🙂

gerred16:09:59

@thheller 👋 hey! does shadow-cljs support css-in-js in compilation, that is to say, turning all of the CSS modules into .css files?

aisamu17:09:17

IIRC, no. We have css-in-js (via garden) and also regular clj tasks to accomplish the css file generation

thheller18:09:33

no it does not. but you can use the same approach described here to compile your own .css -> .js and include the .js files https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects

gerred18:09:54

that makes sense. thank you!

Stefan18:09:00

Hi! I’m trying to use https://github.com/yamill/react-native-orientation. I put this in my ns:

(ns app.core
  (:require [reagent.core :as r :refer [atom]]
            ["react-native" :as rn :refer [AppRegistry, Platform]]
            ["react-native-orientation" :default Orientation]))
I then try to use it: (js/console.log "Orientation:" Orientation), but it is undefined. In the verbose compile output, I see that it is being flushed (`<- Flush: shadow.js.shim.module$react_native_orientation.js (1 ms)`). What am I doing wrong? (I have infer-externs auto enabled)

thheller18:09:36

@stefan.van.den.oord try ["react-native-orientation" :as Orientation]

Stefan18:09:52

@thheller Thanks, that worked. How could I have known this? I did follow the manual correctly I believe? (https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages)

thheller18:09:10

see the section about :default exports

Stefan18:09:25

(Just trying to be more conscious of your time in the future 🙂 )

Stefan18:09:58

Right. So can I propose to add that to that table? So in the cell with :default add: > or: (:require ["module-name" :as defaultExport]) if the module is a commonJS module

Stefan18:09:08

(I’ll make a PR if you agree)

Stefan18:09:56

I can also add a (“see also”) link in the table to that section about default exports.

thheller18:09:16

hold off on that. I suspect there is going to be a few more changes in the future when more packages are actual ESM packages

thheller18:09:11

things are gonna be ugly for a while

Stefan18:09:23

Ok, no problem. Let me know if/how/when I can help you…

Stefan18:09:49

(I already made the change locally, so I can easily make the PR 😉 )

thheller18:09:28

oops. sorry.

👌 4
chadhs19:09:42

is there a way to include local javascript files rather than npm installed packages with shadow-cljs?

chadhs19:09:06

i’ve got this kinda edge case where i can install the library i need and it’s dependency via npm, but shadow-cljs doesn’t like it, as the higher level library includes the other like this

chadhs19:09:09

const AuthenticationContext = require('expose-loader?AuthenticationContext!adal-angular')

chadhs19:09:16

here’s the error i get

[:app] Build failure:
The required JS dependency "expose?AuthenticationContext!adal-angular" is not available, it
 was required by "node_modules/nm-adal/index.js".                                         

Search in:
        src/project/node_modules
You probably need to run:
  npm install expose?AuthenticationContext!adal-angular

See: 

thheller20:09:14

uhm no clue what that is 😛

thheller20:09:38

seems like it is expecting a dedicated build tool

chadhs23:09:20

Yeah think that’s a webpack thing