Fork me on GitHub
#boot
<
2017-01-10
>
micha00:01:28

@michael.heuberger woudl you not do this in the client?

micha00:01:47

how would boot know in advance which browser would be loading the application?

michael.heuberger00:01:16

rather meant a recipe @micha

michael.heuberger00:01:38

compiler options, modules, cljsjs packages, something along these components, not sure here

micha00:01:32

@michael.heuberger usually i think you include all the polyfills, and they just are no-op when the feature is supported in the browser natively?

michael.heuberger01:01:19

what if i dont want to load them at all unless it’s i.E. IE11?

michael.heuberger01:01:25

this to reduce page load and risks

michael.heuberger01:01:58

goog.userAgent can come in handy - just haven’t figured out to dynamically load i.E. babel-polyfill or so

micha01:01:51

ah yeah i don't know about that

micha01:01:24

in my experience polyfills are doing feature detection, not UA

michael.heuberger01:01:06

it’s just a special case we’re having here and wonder if there is a recipe for that

michael.heuberger01:01:20

how can we dynamically load another cljsjs package?

micha01:01:24

i think ie has conditional html even

micha01:01:52

well cljsjs should be simple

michael.heuberger01:01:56

dont want to solve this on the html layer

micha01:01:00

since they're all just external js scripts anyway

micha01:01:28

you can dynamically load the script in the normal way, create a <script> tag etc

michael.heuberger01:01:39

but what src to use?

micha01:01:43

the advantage of the conditional html is that it's synchronous

micha01:01:06

like the jquery cljsjs package

micha01:01:11

it contains jquery.inc.js

micha01:01:22

you can just serve that, no?

michael.heuberger01:01:29

for example we have an entry [cljsjs/babel-polyfill "6.20.0-1”] in our build.boot … how can i dynamically load it in the app code?

micha01:01:40

you would want to look in the jar

micha01:01:45

and find the js file you want

micha01:01:02

then you can include that in your artifact, your js application

micha01:01:07

and load it dynamically

michael.heuberger01:01:11

i ll try this with goog.globalEval = function(script) {…

michael.heuberger01:01:03

or maybe goog.net.jsloader.load = function(uri, opt_options) { is better? i dont know

michael.heuberger01:01:58

@micha dont have a jar here … is there another way to figure out the path?

micha01:01:38

if you have the cljsjs package as a dependency you would have the jar, you can do boot uber show -f

micha01:01:27

or boot -BPd cljsjs/babel-polyfill:6.20.0-1 uber show -f

micha01:01:15

the babel-polyfill one doesn't appear to be in clojars

micha01:01:22

but for example you can do this:

micha01:01:26

boot -BPd cljsjs/async:2.0.0-rc.4-0 uber show -f

micha01:01:31

just to see how that works

michael.heuberger01:01:11

doing a PR for babel-polyfill here

michael.heuberger01:01:18

… that command boot uber show -f categorises them in common, development and production. can this be automated which one to pick?

micha01:01:39

that's just showing you the structure of the files in the jar

micha01:01:52

you can pick any of those

micha01:01:02

like for example

micha01:01:46

boot -BPd cljsjs/async:2.0.0-rc.4-0 sift -j 'cljsjs/async:development/.*\.inc\.js$' show -f

micha01:01:32

and you can use sift --move ... to move the file to a different path if you want, etc

michael.heuberger01:01:59

ok, so for example i have this

michael.heuberger01:01:00

~/c/ui ❯❯❯ boot -BPd cljsjs/babel-polyfill:6.20.0-1 uber show -f                                                                              
Adding uberjar entries...

├── deps.cljs
├── cljsjs
│   └── babel-polyfill
│       ├── common
│       │   └── babel-polyfill.ext.js
│       ├── development
│       │   └── polyfill.inc.js
│       └── production
│           └── polyfill.min.inc.js
└── META-INF
    └── maven
        └── cljsjs
            └── babel-polyfill
                ├── pom.properties
                └── pom.xml

michael.heuberger01:01:46

and then have this in the app code after an if block (goog.net.jsloader/load “cljsjs/babel-polyfill/production/polyfill.min.inc.js”)))))

michael.heuberger01:01:59

is this looking good to you @micha?

micha01:01:27

i am not familiar with the jsloader/load function

micha01:01:35

but the path looks legit

micha02:01:19

the jsloader/load fn doesn't expect it to be a google closure compatible namespace?

micha02:01:56

sweet, looks good

michael.heuberger02:01:14

looks like it is working here

michael.heuberger02:01:32

will do some tests now

micha02:01:20

the sift -j ... task will help you extract just the files you want from the jar

micha02:01:28

without needing to do a whole uberjar

michael.heuberger02:01:18

ok, will keep that in mind

cal13:01:54

The previous issue is a blocking problem for us. Any help on where to look for the cause or ways to efficiently debug this is welcome.

lwhorton14:01:59

what am I doing incorreclty here? I’m getting a null pointer so it’s pretty hard to debug:

(set-env!
  :resource-paths #{”src”}
  ...

(deftask tdd
  "Launch a test environment, and visit localhost:9003/test.html. Note this
  does not publish the library locally, and is only for testing purposes."
  []
  (comp
    (set-env! :source-paths #(conj % "test"))
    (set-env! :resource-paths #(conj % "resources"))
    (serve :dir "target"
           :port 9003)
    (watch)
    (reload :on-jsload 'aft.testing-util.runner/rerun)
    (cljs)
    (target :dir #{"target"})))

lwhorton14:01:27

What I want to do is completely change the :source-paths and :resource-paths when running in a test environment. My boot process should normally emit code for others to consume, and therefore my “src” is emitted as a resource. However, when I’m testing, I don’t really want to emit anything, and want to use a more normal “source-paths is src/…” and “resources include things like test.html"

lwhorton14:01:13

I have a resources/test.html that includes test setup / teardown, for example… but I dont want it to be a resource because consumers of my lib shouldn’t get some random testing html in their build after including my lib

tolitius15:01:43

try

(set-env! :source-paths #(conj % "test"))
    (set-env! :resource-paths #(conj % "resources"))
outside / above comp

erwin15:01:46

@lwhorton the nullpointer exception is because comp doesn't like nil functions e.g: ((comp nil identity) 1). I think your problem can be solved with sift

tolitius15:01:59

since they do not return a fileset

erwin15:01:17

if I understand correctly: when generating a jar / uberjar, code should be generated and when testing test-resources should be used, which should not be included in the generated jar / uberjar.

lwhorton15:01:39

test-resources? I dont see that in the environment wiki

lwhorton15:01:22

But thanks for the heads up, pulling the set-env out of comp worked

erwin20:01:03

it was a question not a suggestion (should have been a question mark at the end ...) 🙂 Glad it worked!

clojuregeek23:01:43

if someone has a moment ... i want to some something like lein install to install a clojure lib locally .. how can i do that with boot ?

micha23:01:43

@clojuregeek boot has a built-in install task for that

micha23:01:33

$ boot install -h
or in the repl
boot.user=> (doc install)

clojuregeek23:01:14

ok cool 🙂 thanks