Fork me on GitHub
#shadow-cljs
<
2018-08-26
>
thheller07:08:20

@ghiden the built-in http servers can proxy themselves. would that work? https://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support

thheller07:08:57

ah nvm you want to proxy the API not the shadow-cljs API πŸ˜‰

thheller07:08:07

there is no built-in process management yet. but I will likely add it at some point

ghiden07:08:25

Thank you for your advice. So basically I have to start a proxy server from one terminal and start a watcher with proxy settings from a different terminal?

thheller07:08:08

hmm wait I got confused myself

thheller07:08:24

there are two proxy settings, mixed them up myself

thheller07:08:33

one isn't documented

thheller07:08:10

so say you start the built-in server via :devtools {:http-port 8080 :http-root "public" :proxy-url ""}

thheller07:08:46

every request you make to that does not exist on the file system will be requested from the configured proxy

thheller07:08:07

would that work?

ghiden07:08:26

Yep that should work

ghiden07:08:12

What’s the undocumented one?

thheller07:08:22

:proxy-url isn't documented

thheller07:08:26

:devtools-url is the other proxy-related one but for the other direction. ie. a proxy in front of the shadow-cljs dev server

ghiden07:08:35

Ah devtools-url is the one documented

ghiden07:08:15

Is it safe to use proxy-url?

thheller07:08:21

safe as any other proxy I guess?

ghiden07:08:28

I mean why isn’t documented?

thheller07:08:31

its just using the built-in undertow proxy support

thheller07:08:46

because I added it for someone and forgot to write the docs πŸ˜‰

thheller07:08:54

its a tiny amount of code

thheller07:08:44

but its not very configurable and just proxies everything that doesn't have a local file

thheller07:08:06

will still need to add more sophisticated options at some point

kwladyka11:08:07

What is the story of shadow in name? πŸ™‚

pauld11:08:49

I'm trying out the fulcro shadow-cljs template. The build launches fine in the terminal (as per README), but I'm wondering if I someone might know why I get this error when trying to launch in CIDER: Exception in thread "main" java.lang.RuntimeException: No such var: ana/cacheable-files, compiling:(shadow/build/cljs_closure.clj:569:19)

pauld11:08:05

I created a bare fulcro build using this: lein new fulcro app shadow-cljs

pauld11:08:17

Maybe using cider-connect is the better option for this.

pauld12:08:21

the template is using an old version of piggieback...

pauld12:08:02

Maybe cider can't handle launching the more complicated shadow-via-lein setup in this template.

pauld12:08:33

I might have to take this over to #cider

pauld12:08:07

Ok, after updating piggieback I get the following error after cider-jack-in-clojurescript using lein profile then choosing shadow as the cljs connection type.

pauld12:08:28

Ok, I'm getting closer? I had outdated dependencies (fulcro, shadow-cljs, etc) so now I get this error during compilation:

pauld12:08:12

The above was generated by doing cider-jack-in-clojurescript, but choosing the shadow profile instead.

thheller13:08:33

@pauld that is still a very outdated cljs dependency? should be 1.10.339

thheller13:08:52

you are trying to run the embedded version right?

thheller13:08:19

https://shadow-cljs.github.io/docs/UsersGuide.html#embedded you need to call the server/start! fn mentioned there.

thheller13:08:27

the missing instance means that no server was started

pauld14:08:27

Ah! You are a genius. It was the outdated clojurescript 'dependency'.

pauld14:08:00

I use quotes here because lein deps :tree revealed that clojurescript was not a dependency anywhere.

pauld14:08:20

so I included it in deps and that fixed my issue.

pauld14:08:54

weirdly this only occurred using cider-jack-in-clojurescript. shadow-cljs watch main did not show this compiler error.

thheller14:08:25

no idea about the cider part but it may be starting through lein and not the shadow-cljs command

thheller14:08:58

then lein is responsible for all the classpath stuff and you are on your own sorting out classpath issues

pauld14:08:51

yeah the fulcro template is using lein via the :lein option in shadow-cljs.edn.

pauld14:08:06

Cider may not be dealing well with this use case.

thheller14:08:27

its mostly about getting your dependencies right

thheller14:08:47

it should work if you just add clojurescript 1.10.339, shadow-cljs manually maybe

thheller14:08:20

but core.async and lots of other things are important too so make sure youhave the latest verisons of those too

pauld14:08:50

Yes, that did work as I said above.

urbanslug18:08:25

Hello, does shadow not work well with npm packages from git?

urbanslug18:08:14

I've installed an npm package from git but shadow-cljs gives The required JS dependency "<name>" is not available, it was required by "<namespace>".

urbanslug18:08:21

@thheller ^ ?

hlolli19:08:29

@urbanslug is the npm package in node_modules ? shadow-cljs as far as I know, doesn't do anything when it comes to installing npm pacakges from npm/git/wherever

urbanslug19:08:53

it's not in node_modules

urbanslug19:08:09

which I guess is more a yarn/npm issue then?

hlolli19:08:21

yes, it's an npm issue then

hlolli19:08:32

npm i does it work?

urbanslug19:08:39

it says it's installed

hlolli19:08:52

what package is this?

urbanslug19:08:56

but when I list contents of node_modules it's not there

hlolli19:08:21

this doesn't exist maybe?

hlolli19:08:29

if you're inside the root of this package, and you do npm install, then "main" doesn't matter. But if you for example require directory locally, it will look at "main" to know which js if the main. If none is found, it defaults to index.js

hlolli19:08:46

and how you declare a git dep matters as well in the package.json

hlolli19:08:09

protocol needs to be git:// as far as I remember

urbanslug19:08:09

the directory somehow just didn't get "cloned into node modules. What's weird is that I started a new (js not cljs) project and npm installed it and it was then in my node modules.

hlolli19:08:38

this repository is only the source code not the distribution. You could run this file, commit it, and then require the git. The developer of this lib probably runs this every time before npm publish

urbanslug19:08:42

that is weird

thheller19:08:41

nothing werid about it. pretty much every npm package has some form of build step

urbanslug19:08:34

@hlolli btw I deleted my lock files and when I yarn installed then it installed the git repo

hlolli19:08:41

@thheller was there a way to have the test runner say how many tests it ran? I'm running node-test, and I only see if I get failures.

urbanslug19:08:43

but let me prepublish and push

urbanslug19:08:59

to mae sure it works, getting installed was only one step

hlolli19:08:10

yup, I'd do that if you want to install it from git...

thheller19:08:59

@hlolli it should print the summary?

Ran 2 tests containing 6 assertions.
0 failures, 0 errors.

hlolli19:08:13

yes, I am looking for exactly this

hlolli19:08:44

I have target :node-test, and start the test just with shadow-cljs compile buildID, I just get a Build completed in the end.

thheller19:08:05

because compile only compiles the test and does not run them? unless you set :autorun true

hlolli19:08:29

it runs them, at least I get test failed, when I write a failing test

hlolli19:08:43

ok I did that

hlolli19:08:06

I should use release instead of compile?

richiardiandrea22:08:01

I use release and on completion launch node out-dir/tests.js in CI so that I can get the right exit code

hlolli22:08:23

thanks @ the problem was mainly that run-tests wasn't called. But I just used use-fixtures, like I've always done, those (few) times I take the time to write tests.

hlolli22:08:51

I'm a bad bad example of programmer in terms of lack of tests πŸ™‚

hlolli23:08:59

if I may ask, how do you trigger it on completion, with hooks?

hlolli23:08:49

or just "script" "npx shadow-cljs release x && node out/test.js", that should do the trick..

richiardiandrea23:08:27

Yep exactly the above @hlolli

hlolli23:08:47

@ a newb question, can you run shadow-cljs on circleci?

richiardiandrea23:08:34

Uhm, at the moment I am not on Circle CI, can't you?

hlolli23:08:03

I'm looking at docker images, there's one for shadow-cljs, but I'm not sure if you must run their official docker images, or I can choose from docker-hub one.

hlolli23:08:42

I can just try :=)

hlolli00:08:48

works fine to pull any image from dockerhub, so, nice

richiardiandrea00:08:41

Yes you can pull anything, you basically just need an image with jdk8 and then your package.json pulls in the rest

urbanslug19:08:33

Is it also normal for the output of the publishing to be gitignored? https://github.com/palerdot/react-d3-speedometer/blob/master/.gitignore#L4

thheller19:08:59

@urbanslug yes normal. you never put compiled code into git

urbanslug19:08:24

I guess I should prepublish after npm install then?

hlolli19:08:49

no that's a bad idea

urbanslug19:08:01

but then say I npm install it from git it won't have the dist dir

thheller19:08:33

@urbanslug what are you trying to do exactly? I can't really identify what problem you are actually trying to solve

thheller19:08:46

the git dep is not from you I assume? why are you using the git version?

urbanslug19:08:44

the git dep is from me

urbanslug19:08:52

I want to use a fork of the project

urbanslug19:08:03

and I don't want to publish the fork to npm

thheller19:08:01

then you'll need to switch to the directory manually and run the ./scripts/prepublish.sh

urbanslug19:08:44

yeah I thought so, after npm installing it from git, right?

urbanslug19:08:10

I held back because of > no that's a bad idea

hlolli19:08:36

yes, I tried makeing a release with nested node module recently. And it's paiin

thheller19:08:36

well you'll probably also need to manually install all the tools required to run the prepublish.sh script

hlolli19:08:53

I'd rather use git submodule, and there npm i etc

hlolli19:08:12

but I may be wrong

urbanslug19:08:36

the submodule would have the compilation output though, right?

urbanslug19:08:52

well I don't think you're wrong about it being a pain

hlolli19:08:53

you can try, as well you could try useing "scripts" {"install" and run it there. Maybe it can work.

urbanslug19:08:39

using scripts install?

hlolli19:08:58

to clarify what I'm saying, you can look at npm hooks. When you install a module, a module can run script.

hlolli19:08:49

the pain I mention, could arise from npm peer dependencis. You could get some module missing errors. But doesn't have to be.