Fork me on GitHub
#shadow-cljs
<
2020-02-10
>
ikitommi11:02:13

what docker base images are people using with shadow-cljs + deps?

ikitommi11:02:50

FROM circleci/clojure:openjdk-11-tools-deps-1.10.0.414-node
seems to be an ok start..

👍 2
g7s11:02:29

After this commit https://github.com/thheller/shadow-cljs/commit/8a90e62c6af3ece959d39b8d26c49d3bc72159b6 my web worker explodes with Uncaught ReferenceError: window is not defined and I guess it is because it tries to load /shadow/cljs/devtools/client/browser.cljs instead of /shadow/cljs/devtools/client/worker.cljs.

g7s12:02:31

My :modules config has this form

{:base {:entries [cljs.core]}

 :mod {:entries    [my.ns]
       :depends-on #{:base}}

 :worker {:entries    [my.ns.worker]
          :depends-on #{:base}
          :web-worker true}}

thheller15:02:26

@UKQS17P3L set :devtools {:browser-inject :mod}

souenzzo15:02:47

I'm also in trouble with react-native target trying to access js/document. But I downgraded fulcro with shadow-cljs at once because I run out of time (so I can't be sure about shadow-cljs or fulcro issue).

g7s16:02:13

@thheller it worked, thank you! Is this documented somewhere? I am usually referencing this guide https://shadow-cljs.github.io/docs/UsersGuide.html

thheller16:02:14

no I still need to document it. I added it because previously workers didn't support hot-reload but now they do

g7s16:02:49

Yes I saw that 🙂 pretty nice

thheller16:02:48

thought nobody was using web workers so I didn't bother documenting it yet 😛

g7s16:02:19

No problem, shadow keeps improving and it is what matters

Robin Jakobsson15:02:50

Does shadow-cljs support using locally installed folders?

npm install <folder>:

Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it's linked. If <folder> sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies.

Robin Jakobsson10:02:31

I haven’t had any success with this so far, if anyone finds anything - please let me know 🙂

kenny16:02:38

I updated to the latest shadow-cljs 2.8.83 and now I see this in the Chrome console. I assume it must be using some character that my system does not have. I'm on Ubuntu 19.10.

thheller22:02:18

this is the char 🠶?

kenny22:02:38

That appears as a box as well.

kenny22:02:37

A page of boxes 🙂 I guess Ubuntu 19.10 does not have that built in?

thheller22:02:50

guess not 😛

thheller22:02:22

although there is an ubuntu at the bottom 😛

kenny22:02:17

Perhaps the default font on Ubuntu is not Ubuntu?

kenny22:02:45

Oh, right - this computer is PopOS which is a flavor of Ubuntu. They definitely could use a different font.

kenny22:02:35

Eh, I don't really mind. It just looks a bit strange.

thheller22:02:22

yeah I removed color because it was causing problems for users with dark mode themes

thheller22:02:45

still wanted something to "stand out" ... this seemed like a "standard" unicode char

kenny22:02:27

What's it supposed to be? I'd like to put a picture to the "rightwards finger-post arrow" hjaha

kenny22:02:26

Thanks 🙂

g7s17:02:47

Can i goog-define some constant in some namespace ns.a and use it in another ns.b? This doesn't seem to work if I require the ns.a from ns.b

g7s17:02:21

I tried to :refer also that constant but no luck

mazin18:02:51

Hello. I'm attempting to use https://github.com/priornix/antizer which is a wrapper around the antd package. Antizer pulls the antd package in through cljsjs, which causes bloat in my local development environment due to the size of the antd package. My thought was to change antizer to use shadow-cljs so we can target specific elements of the package, rather than importing the whole thing. We don’t know what the user would like to import, so I’m stuck on how to conditionally require parts of antd from antizer. One way I can think to handle this is to create a different file for each Antizer import that maps directly to an antd import. Ex: antizier.Button => antd/Button and then requiring the relevent element from antizier. Another way (that I think would work?) would potentially be to keep track of each distinct element that is called in antizier and calling (require) for each. Does anyone know of a better way to handle this?

lilactown18:02:47

@mazin unfortunately requires must be static, so you cannot conditionally require things in CLJS. (require) is a macro that only works in development

darwin19:02:14

@thheller would you accept a PR with this? https://gist.github.com/darwin/f9e883eef4629d462edc871b6830a4d5 …so I could drop my hacked version of shadow-cljs

thheller21:02:31

yeah ok. looks simple enough.

darwin21:02:05

cool, thanks, will prepare the PR, this is not urgent

thheller22:02:58

added something that'll make you happy 😉

darwin22:02:44

hallelujah! thanks a lot. so the PR is no longer needed I guess 🙂

darwin22:02:38

btw. this could also solve some old issues with dirac+node.js https://github.com/binaryage/dirac/blob/master/docs/node.md#source-maps

thheller23:02:43

I only added it because it seems to be the only way to make chrome exts load source maps

thheller23:02:31

it'll probably have issues on all other targets

darwin23:02:40

yep, I didn’t find any good solution either

darwin23:02:22

I still think adding that :source-map-prefix could be helpful for some future ad-hoc workarounds in similar cases when I want source maps to be server independently

darwin23:02:30

e.g. via dev-server or elsewhere

darwin23:02:06

we don’t need to document it, it will be just hidden option for desperate people like me who go digging… ;()

thheller23:02:51

as for the other stuff one option is instead of loading the content-script file directly

thheller23:02:02

it just loads a shim that loads the real files via fetch

darwin23:02:41

I tried that, but gave up, fetch part was easy, but I was running into google.provide throwing that namespaces were already declared

thheller23:02:52

that seems to work fine but requires adding https://developer.chrome.com/extensions/manifest/web_accessible_resources which is a bit annoying

darwin23:02:05

but you have better understanding of the whole closure thing, so you probably know how to do it properly

thheller23:02:31

yeah if you try to load the files over the old ones that happens

thheller23:02:41

just don't load them over the old ones and you are fine 😉

darwin23:02:00

nevcermind, I was probably doing some other mistakes, it wasn’t clear to me how to configure the build properly, that the code I’m fetching is a module which depends on what is already present in the shim

darwin23:02:14

that was the main issue, it contained the shim bootstrap code again

darwin23:02:26

and that is why it was complaining

darwin23:02:24

reading that link you posted, I didn’t run into this problem

darwin23:02:58

I used js/fetch to get the files from dev-server running on localhost, and it worked

thheller23:02:09

probably because you were still accessing files from the dev server isntead of the extension

darwin23:02:05

I think it would be acceptable for dev mode, to have dev-server auto-configured

thheller23:02:06

you can chrome.runtime.getURL("out/content-script.js")

thheller23:02:10

and fetch that

darwin23:02:23

or you could tunnel this stuff through shadow-cljs devtools ws connection

thheller23:02:30

I'd rather not

darwin23:02:21

ok, so you found a solution without relaxing manifest rules? via chrome.runtime.getURL?

thheller23:02:41

no , that way requires the manifest config

thheller23:02:26

maybe I'll just make it talk to the shadow-cljs server.

thheller23:02:37

need sleep, might look at it more tomorrow

darwin23:02:53

sure, thanks a lot

hoppy21:02:17

kind of getting back into shadow - and not getting something. My intent is to package my simple cljs file into a script that I can run anywhere node runs, but I get missing dependencies at runtime.

hoppy21:02:30

they only appear in any of my files thusly:

hoppy21:02:55

what else do I need to do to get these included in the 'release' output?

thheller21:02:41

@hoppy I recommend post-processing the file with https://github.com/zeit/ncc if you want to package ALL dependencies into the file

thheller21:02:56

shadow-cljs has something built-in for that but ncc is more feature complete

hoppy21:02:45

that helps - note, you have to have the stuff npm installed in the working dir (apparently)