Fork me on GitHub
#boot
<
2015-10-12
>
freyert00:10:54

Question: Can I add the Google Maps API as a dependency?

alandipert00:10:41

the answer looks to be yes

freyert01:10:44

@alandipert: I was able to add it as a dependency and it downloaded, but I can't seem to require it in the actual application.

freyert01:10:01

cljsjs/google-maps isn't found

alandipert01:10:28

what does your ns look like?

freyert01:10:03

No such namespace: cljsjs/google-maps

alandipert01:10:31

"The jar only provides an extern file required for advanced compilation. The Google Maps js API will still need to provided through some other mechanism."

freyert01:10:33

Oh 😞

freyert01:10:38

good reading haha

alandipert01:10:11

it doesn't appear to be hoplon specific... uses another library to load the google maps js on page load

freyert01:10:29

I suppose my question now is, if I have the extern, do I need to add this to foreign dependencies?

freyert01:10:23

Maybe I need to read the docs on foreign dependencies.

freyert01:10:22

Yeah, it's still a bit unclear what I do now, that I have the CLJSJS jar for googlemaps. How do I interact with it to add the path to the javascript?

freyert01:10:29

Eh, hold on I got this

alandipert01:10:56

you can do it, i believe in you 😃

freyert01:10:22

I'm just so used to doing this the NodeJS way. There I would expect my dependency management system to install the dependencies locally . . . But munging a local dependency would not work well in deployments . . . so I'm assuming I just need to throw these values into :foreigndeps

freyert01:10:50

Well, well, well I'm missing a project.clj. But I'm using boot . . .

alandipert01:10:41

@freyert: the cljs task takes options that it passes to cljsc

alandipert01:10:00

but yeah, the level of ceremony is intense

freyert01:10:00

Mmm good hint, I'll go read about those

alandipert01:10:15

also hoplon would be something to experiment... at least, if you need to move fast

alandipert01:10:33

we made a framework in an effort to alleviate shenanigans such as these

freyert01:10:07

Oh yeah, I'm trying out hoplon at the moment to try and get a hang of this. It's pretty clear I don't know up from down at the moment though haha

mccraigmccraig09:10:58

deraen: i did a custom build of react 0.13.3 with addons and the tap-event-plugin (which requires a custom browserify build) - seems like it would be a useful addition to cljsjs, but i'm not sure where to add it - i've currently just bastardised the react-with-addons package, but clearly that's not mergeable to cljsjs/packages - do you have any thoughts about what would be best ?

mccraigmccraig09:10:54

oops - should have been a pm - sorry

bensu09:10:54

@freyert: the reason google maps is not packaged in cljsjs is that to use it you need to get it from google with an API key with something like <script src='goog/cdn/maps?API=123123123'>

bensu09:10:07

follow Google Maps' Quick Start from ClojureScript and when it's time to do advanced compilation use cljsjs's externs.

martinklepsch10:10:02

@mccraigmccraig: packaging it as a separate package would be the best option I guess, don’t know if that would be possible though.

mccraigmccraig12:10:45

@martinklepsch: i can do it as a separate package easily enough... i'm not sure if that will work with things requiring react though - what's the reason cljsjs/react-with-addons is in the same package as cljsjs/react ?

martinklepsch12:10:34

@mccraigmccraig: that’s just a technicality because they’re so close and because reacts packaging is broken in a way that they can’t ship addons as a separate file

martinklepsch12:10:10

@mccraigmccraig: you can make your package depend on cljsjs/react-with-addons and then react with addons will be included in the build

mccraigmccraig12:10:02

@martinklepsch: no, i can't do that - react's packaging is broken in such a way that if you want to use the tap-event-plugin you have to create an entirely new custom build of react - with addons if you want them too !

martinklepsch12:10:27

oh ok, then I misunderstood and it won’t work 😉

mccraigmccraig12:10:38

martinklepsch: is there any reason why a separate project react-with-addons-and-tap-event-plugin wouldn't work ? i currently just exclude cljsjs/react from my reagent dependency and add a cljsjs/react-with-addons dependency...

martinklepsch12:10:38

glorious indeed

martinklepsch12:10:58

no that could work and seems to be the only option really

martinklepsch12:10:16

just would have been nicer to have it as separate package simple_smile

mccraigmccraig12:10:37

by separate package you mean a package which didn't also include the main react js ?

martinklepsch12:10:39

@mccraigmccraig: yeah, similar to how react-with-addons is packaged I guess

micha13:10:06

@mccraigmccraig: the problem with making a new package is that it completely breaks transitive dependencies

micha13:10:42

imagine if in clojure we had http-kit-with-ring-and-compojure and http-kit-with-ring-and-noir packages

mccraigmccraig13:10:50

@micha: do you see another option ?

micha13:10:01

you'd end up with multiple different versions of http-kit in every application

micha13:10:05

via transitive dependencies

micha13:10:16

fix the react packaging nonsense?

mccraigmccraig13:10:17

@micha: any realistic option ? react is packaged with browserify from npm packages... there's no way afaics of exposing the internals of that to cljsjs / maven

micha13:10:39

i guess it's fundamentally incompatible with maven

micha13:10:03

maven requires at least the ability to assign an artifact id and version to each jar

micha13:10:18

but it seems that it's impossible to do this with react

micha13:10:51

but an enterprising programmer might be able to find a way to repackage their stuff

micha13:10:57

like not use their build scripts or whatever

micha13:10:02

and do it the right way

martinklepsch13:10:19

react packaging is borked, definitely good to speak up where appropriate, e.g here https://github.com/facebook/react/issues/680

mccraigmccraig13:10:30

@martinklepsch: that's already done - npm has separate packages for each of the addons as of 0.14 - so maybe there is hope

micha13:10:54

so why not just pull those in and repackage in cljsjs?

mccraigmccraig13:10:00

but the tap-event-plugin still requires a custom build of react

mccraigmccraig13:10:28

which apparently won't be fixed until 1.0

mccraigmccraig13:10:51

@micha: that may be possible for 0.14 - i'm still stuck on 0.13.3 though, since reagent isn't happy with 0.14 yet

mccraigmccraig13:10:45

but even for 0.14, there's no solution other than a custom build for the tap-event-plugin

micha13:10:30

packaging is so fundamental, i don't get why it's not respected

micha13:10:56

how can you build abstractions when you need to make a special build of all your dependencies and dependencies of dependencies

micha14:10:00

it's ludicrous

alandipert14:10:21

i wonder if facebook has something like bazel internally also

alandipert14:10:24

the google build system thing

alandipert14:10:34

that would be good motivation not to care about 3rd party packaging

alandipert14:10:41

why care when you never use libraries

micha14:10:06

we all just need to work at facebook

micha14:10:18

that's the only solution for computing in the 2010s

mccraigmccraig14:10:59

it might be something to do with the npm packages - as i understand it (no doubt badly), npm is pretty brutal about hiding details and only exposing an explicit api to a requesting caller (and not in a global namespace as is the norm with maven / clojure / java) - this is presumably a good thing and can mitigate problems with dep-hell (i.e. multiple versions of some lib can co-exist in the same process) - but maybe it doesn't play nicely with packaging systems which assume a global namespace ?

micha14:10:33

i guess the real issue is separating building of artifacts from consuming them

micha14:10:21

java is pretty awesome at this, they really thought it through

mccraigmccraig15:10:54

java is not awesome at this - having multiple versions of an artefact coexisting in the same process is painful, so as any project gets large there isn't any way of saying "i don't care if these two dependencies require different incompatible versions of the same minor lib"

micha16:10:22

yeah but that's an unsolvable problem

micha16:10:33

at least it does the sane thing and you know what the problem is

micha16:10:57

imagine if java didn't even have artifact ids and versioned artifacts

micha16:10:56

like maybe two things depend on different versions of some library, but at least the library has a unique name

micha16:10:18

and maven won't try to pull both versions into the classpath

mccraigmccraig16:10:42

as i understand it, with npm two things can depend on different versions of some library, both things will get the version of some-library they asked for and the two versions of some-library will not interact with each other because all their functions and state are hidden away in closures and only exported to the requestor

micha16:10:54

that won't work though

micha16:10:05

like suppose i have libraries A B and C

micha16:10:14

A and B depend on different versions of C

micha16:10:57

the version of library C that A needs defines some type Foo, where Foo has a .safeOperation() method that prints "don't panic" to the screen

micha16:10:18

and in the other version of C the Foo type has a .safeOperation() method that nukes the world

micha16:10:38

now library B makes a Foo object and passes it to A

micha16:10:43

indirectly of course

micha16:10:54

and A nukes the world instead of printing a friendly message

micha16:10:13

so trying to mix things like that is utter insanity i think

micha16:10:48

it's an unsolvable problem

micha16:10:58

you run up against the halting problem i'm sure

mccraigmccraig16:10:35

i gather you can also require only a single version of some lib to be installed in the process where necessary with peer dependencies - it's a tradeoff afaics - dependency hell in the java scheme, or avoidance of dependency hell and some other problems in npm

micha16:10:38

also the kinds of dependency hell you see in java are actually a testament to the robustness of maven

micha16:10:12

like we see some issues where pomegranate depends on some version of apache http and ring depends on jetty which depends on another one, things like that

micha16:10:28

but if you delete your local maven cache and try to run even a simple web app

micha16:10:39

you'll see hundreds or maybe thousands of transitive dependencies

micha16:10:48

like your library has maybe 5 deps

micha16:10:54

and that expands to hundreds

micha16:10:15

the only way that kind of code reuse is possible is because of the strict organization of artifact ids

micha16:10:06

that's the only thing that makes powerful abstractions possible, really

juhoteperi16:10:16

NPM also has dependency hell but it's mostly caused by libraries not following semver and depending on other libraries using ^ and ~

juhoteperi16:10:02

I used to think NPM is quite good but nowadays I won't use it if don't absolutely must

micha16:10:04

separate parts need to have separate cordinates though

micha16:10:20

like i can't make a library that depends on react

micha16:10:26

because how would i express that?

micha16:10:32

which coordinates would i use?

micha16:10:39

this means i can't make abstractions on react

micha16:10:50

because abstraction is about encapsulation

juhoteperi16:10:57

@micha: Clojure or Node? And why not?

micha16:10:05

so i can make a "pattern", maybe

micha16:10:24

like with hoplon you can depend on [hoplon/google-maps "1.2.3"]

micha16:10:26

for example

micha16:10:40

and that has transitive dependencies on the google jsapi loader and other things

micha16:10:47

but you don't need to manage that

micha16:10:51

it's abstracted away

micha16:10:11

and if you have another google thing, like google places or whatever that uses the google jsapi it's also fine

juhoteperi16:10:23

(okay looks like JS libraries don't depend on React)

micha16:10:58

so you need to ask someone, hey does this work with this version of react?

micha16:10:14

tooling can't help you

colin.yates16:10:17

hi all - any examples of a boot project that uses (clj) testing? I think I am being a numpty and prior art will help

mccraigmccraig16:10:43

@micha: npm does transitive deps just fine - take a look at a package.json in any node project. doesn't look much different from clojure deps, or gemfile deps or whatever

mccraigmccraig16:10:26

react however hasn't historically been very good at using the features of npm packaging ... they have now split out the addons into separate npm packages, but the tap-event-plugin still requires a custom build, which is where i started from

colin.yates16:10:29

@alandipert: I did say I was being a numpty simple_smile

micha16:10:47

@mccraigmccraig: sorry, depdendency management is like the bane of my existence

micha16:10:50

i get worked up about it

alandipert16:10:11

@colin.yates: there's also a midje task, and maybe other test tasks... consulting the "community tasks" page might be enlightening (i haven't checked in awhile myself)

mccraigmccraig16:10:39

@micha: simple_smile i've not been loving it too much today either

colin.yates16:10:23

@alandipert: I was trying to add the test directory in a deftask:

(deftask testing
  "Test the clojure sources"
  []
  (set-env! :source-paths #(conj % "test/clj"))
  identity)
and then running boot testing tests but that caused the project not to be built with the following error:
boot testing test
             clojure.lang.ExceptionInfo: java.io.FileNotFoundException: Could not locate boot/core__init.class or boot/core.clj on classpath., compiling:(backend/boot.clj:1:1)
    data: {:file
           "/var/folders/1j/rmvwckss5775bbky8cqgk0cc0000gn/T/boot.user3564447694034566375.clj",
           :line 21}
java.util.concurrent.ExecutionException: java.io.FileNotFoundException: Could not locate boot/core__init.class or boot/core.clj on classpath., compiling:(backend/boot.clj:1:1)
clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate boot/core__init.class or boot/core.clj on classpath., compiling:(backend/boot.clj:1:1)
          java.io.FileNotFoundException: Could not locate boot/core__init.class or boot/core.clj on classpath.
                                 ...                      
                clojure.core/load/fn        core.clj: 5866
                   clojure.core/load        core.clj: 5865
                                 ...                      
               clojure.core/load-one        core.clj: 5671
            clojure.core/load-lib/fn        core.clj: 5711

colin.yates16:10:48

the rest of the project (which is @juhoteperi’s excellent https://github.com/Deraen/saapas project) builds fine. I added the appropriate requires and refers - most weird

martinklepsch17:10:22

hi @colin.yates simple_smile did you modify the list of dependencies in another place?

martinklepsch17:10:40

also never hurts to check boot -V

colin.yates17:10:24

hi @martinklepsch - no I literally cloned @saapas, added the boot-test dependency and the requires

pandeiro17:10:31

how can i get org.webjars/bootstrap's fonts directory into boot's output files so they are included in target?

juhoteperi17:10:55

@colin.yates: Could be that boot-test depends on really old Boot/core

juhoteperi17:10:32

Try adding [boot/core "2.3.0" :scope "test"] to your project

colin.yates17:10:50

hi @juhoteperi - no joy :

boot testing tests
        clojure.lang.ExceptionInfo: No value supplied for key: (clojure.core/seq (clojure.core/concat (clojure.core/list (quote adzerk/boot-cljs)) (clojure.core/list "1.7.48-5") (clojure.core/list :scope) (clojure.core/list "test")))
    data: {:file
           "/var/folders/1j/rmvwckss5775bbky8cqgk0cc0000gn/T/boot.user1377485475066217225.clj",
           :line 5}
java.lang.IllegalArgumentException: No value supplied for key: (clojure.core/seq (clojure.core/concat (clojure.core/list (quote adzerk/boot-cljs)) (clojure.core/list "1.7.48-5") (clojure.core/list :scope) (clojure.core/list "test")))
                             ...                                        
           clojure.core/hash-map                          core.clj:  371
                             ...                                        
              clojure.core/apply                          core.clj:  630
       boot.pod/apply-exclusions                           pod.clj:  268
         clojure.core/partial/fn                          core.clj: 2493
            clojure.core/mapv/fn                          core.clj: 6616

pandeiro17:10:00

@colin.yates: you could try just requiring and running your test ns from the REPL to see if it's boot-test-related issue

colin.yates17:10:50

I see - so a boot testing repl will get me a repl with the (set-env!) from the testing task?

juhoteperi17:10:32

Strange, boot/core dep fixed it for me. Anyway, Saapas has now test example.

alandipert17:10:11

i wonder if it's because boot-test runs your tests in a pod

colin.yates17:10:30

ah - so it really helps if you don’t have a trailing ‘`’ which is impossible to see on the end of the dependency simple_smile (blush)

alandipert17:10:43

yeah, i think tha'ts what it is - boot.core isn't in the boot-test pod

colin.yates17:10:21

so yes, adding boot/core works

pandeiro17:10:23

if i have a file foo/bar/baz in a jar in my deps, shouldn't i be able to access that file with ( "foo/bar/baz")?

nberger17:10:07

@pandeiro: I think it's ( ( "foo/bar/baz"))

pandeiro17:10:40

@nberger: thanks, still not working though. Something is strange here.

nberger17:10:24

Humm ok, but what doesn't work? Something that you want to do on that file?

pandeiro17:10:33

The org.webjars/bootstrap jar has a file: META-INF/resources/webjars/bootstrap/3.3.2-2/fonts/glyphicons-halflings-regular.eot

pandeiro17:10:45

I can't access that file from a standard boot repl

nberger17:10:34

so you can't slurp it, for example?

pandeiro17:10:52

(.isFile (io/file <that-path>)) returns false, for example

pandeiro17:10:00

I didn't try slurping b/c it's binary

nberger17:10:48

Ok, well, the thing is that (io/resource ...) returns a url, not a file... you can slurp it, but it's not a file

nberger17:10:07

Try to print it, you'll see something like #<URL jar:file:/....>

pandeiro17:10:25

yeah io/resource returns nil

nberger17:10:48

Oh ok, that's worse...

nberger17:10:03

I think that even when you get past the path issue (I guess you have an issue with the path that you are using to get to the file), it will help you to know that (.isFile ...) won't return true

pandeiro17:10:54

@nberger: Ah yes that definitely helps to know simple_smile

pandeiro17:10:24

I am not able to access any of the files in that jar, even though boot-less is accessing it fine

juhoteperi17:10:37

@pandeiro: What are you tring to do? You can access files in classpath using io/file

juhoteperi17:10:03

And you can't make file out of URL (resource)

juhoteperi17:10:13

but you can read contents of an URL using input-stream/reader/slurp

pandeiro17:10:30

@juhoteperi: I need to output the .../fonts/... stuff from the bootstrap jar into target for packaging with static assets

juhoteperi17:10:38

(sorry for typos)

juhoteperi18:10:02

Just use io/resource

pandeiro18:10:36

At the boot REPL (io/resource ...) is returning nil

pandeiro18:10:41

I must have the path wrong

pandeiro18:10:58

or would something in :dependencies not automatically be on the resource path?

pandeiro18:10:28

In boot less do you have to do something to get the webjars stuff before accessing it?

pandeiro18:10:43

Wrong version in the path

pandeiro18:10:41

Somehow I am including org.webjars/bootstrap "3.3.5" but the only thing in my ~/.m2/repository was 3.3.2-2

pandeiro18:10:58

and the version is in the path to the files

pandeiro18:10:20

I guess webjars does that so you can have multiple versions

podviaznikov18:10:34

I want to add boot projects support to http://jarkeeper.com/. Any tips how I can easily parse build.boot file and extract dependencies?

pandeiro18:10:41

@juhoteperi: would there be any way I could "search for" eg a .ttf file that was in a webjars jar? I can't get it with by-ext, right?

juhoteperi18:10:23

@pandeiro: If you are accessing classpath it's not very easy, you need to go through all JARs in the classpath and check their contents:https://github.com/Deraen/less4clj/blob/master/src/less4clj/webjars.clj#L11

juhoteperi18:10:54

But alternatively you could import some files from specfic JAR to fileset using sift and then you can use by-ext

pandeiro18:10:28

I could sift for a regex pattern then use by-ext? That sounds great actually