Fork me on GitHub
#clojurescript
<
2016-07-11
>
vinodg08:07:09

For the following https://apis.google.com/js/client.js i wrote externs.js as var gapi = function () {}; it is working well in development mode ,but in production mode it is not working

vinodg08:07:26

can any one help

rohit09:07:50

@vinodg: looking at the API docs, it doesn't seem that the externs are complete. Thats the most likely cause of the problem. A good guide for creating externs is: https://github.com/cljsjs/packages/wiki/Creating-Externs

rohit09:07:41

its likely you are using functions from the API which haven't been provided in the extern

rohit09:07:54

so best to expose those in the extern

vinodg09:07:19

thank you @rohith

rohit09:07:44

@vinodg: btw, I think what you are using may already by packaged by #C0E66E1H7 team. Have a look at this: https://github.com/cljsjs/packages/tree/master/google-platformjs-extern

rohit09:07:26

Looks like the extern file is already present for it. So just include this repo as a dependency in your project and you should be good to go if its the right one

urbanslug09:07:20

Hey I am refering i.e. refer a record from a cljc namespace into cljs but when I use it ->Foo it says that the var is undeclared.

urbanslug09:07:15

According to brave clojure "When you create a record, the factory functions ->RecordName and map->RecordName are created automatically."

rohit09:07:48

@urbanslug: could you share some basic code of how you are using them. For me, they work as expected even from a cljc namespace.

rohit09:07:58

(ns cljctest.record)

(defrecord RecordName [data])

rohit09:07:09

(ns cljctest.core
  (:require [cljctest.record :as r]))

(def a (r/map->RecordName {:data 1}))

rohit09:07:23

The first file was a cljc file

rohit09:07:35

and the second one is a cljs one

urbanslug09:07:41

Okay I had used :refer not as

urbanslug09:07:45

Let me try your way

rohit09:07:05

For me even this works:

(ns cljctest.core
  (:require [cljctest.record :as r :refer [map->RecordName ->RecordName]]))

(def a (map->RecordName {:data 1}))
(def b (->RecordName 1))

urbanslug09:07:54

You have to use the . after ->RecordName too?

rohit09:07:34

nope. sorry. typo

urbanslug09:07:39

Because I did try that refer, maybe a different error šŸ˜ž let me see. I seem to get the error elsewhere

Petrus Theron10:07:11

How do I begin to debug an advanced cljs build that just tells me Uncaught TypeError: Cannot read property 'core' of undefined? Non-optimized runs fine.

rohit10:07:23

@petrus: are you using any external js libraries for which you haven't provided externs?

Petrus Theron10:07:04

@rohit, AFAIK, only using reagent/react. How do know if a dep is an external js lib?

rohit10:07:49

@petrus: it shouldnā€™t be the case

Petrus Theron10:07:00

Does unoptimized cljs also look minified?

rohit10:07:03

@petrus: donā€™t think so.

Petrus Theron11:07:41

OK, so Iā€™ve confirmed that :optimizations :none is fine, but :advanced breaks with no error or stack trace aside from the above. Is this most likely to be missing externs?

rohit11:07:59

@petrus: do you have source mapping enabled?

rohit11:07:22

if you are just using reagent, then it shouldnā€™t be an extern issue

rohit11:07:29

@petrus: have you exported any functions from cljs which you are calling from js?

Petrus Theron11:07:04

Ooh, I think I know the problem xD I havenā€™t exported my main function that Iā€™m calling! Thank you @rohit

dnolen11:07:58

@eyelidlessness: Iā€™m pretty sure binding inside of a go block isnā€™t going to work - you might want to double check the behavior under Clojure - but I donā€™t think it will work there either

dnolen11:07:45

@denisj: whatever people use for Node.js should work - Iā€™m assuming people have already tried to figure this out for TypeScript, JSX, etc.

eyelidlessness14:07:28

@dnolen: is that by design/expected, or just a defect?

dnolen14:07:43

not a defect

eyelidlessness14:07:56

er. shouldn't it error rather than corrupting vars?

dnolen14:07:05

bindings donā€™t work across async boundaries

eyelidlessness14:07:59

why would it be preferable to silently corrupt state?

dnolen14:07:50

@eyelidlessness: Iā€™m not the person to talk to about this

dnolen14:07:58

in anycase, far as I know not intended to work

eyelidlessness14:07:07

i'm just trying to understand why you said it's "very debatable"

dnolen14:07:07

bring it up in #C03S1KBA2, I donā€™t have anything more to add. I said ā€œdebatable" since most people donā€™t use binding in async situtations because it doesnā€™t work

dnolen14:07:13

never worked, long before core.async arrived

dnolen14:07:59

meaning you would have encountered the exact same problem with any async code, core.async not with-standing

dnolen14:07:34

whether core.async should warn or error about a this kind of mistake is another thing

dnolen14:07:48

and Iā€™m not the person who makes decisions about such things

zerusski15:07:59

Hi all. Would anyone know why source-mapped files won't show CLJS content in Chrome? Source-maps are correctly detected, I can see cljs files in the source tree in dev tools but when I jump to cljs source Chrome shows empty file. Problem seems to concern only files that have &rel=some-long-number show up in the tooltip when u hover over them. So, for instance cljs/core.cljs shows up fine, but cljs/reader.cljs&rel=14...07 doesn't show any content. Same goes for my client code. Could anyone help me investigate what's wrong? I don't see any errors in the console. Compilation is done with figwheel.

eyelidlessness15:07:35

where is &rel=... coming from?

eyelidlessness15:07:26

if it's being appended to some URL intended as a query string, the query string must begin with ?, with additional params separated by &

zerusski15:07:30

i honestly wouldn't know where those & come from. Source maps are generated elsewhere, right.

eyelidlessness15:07:56

presumably from the cljs compiler. but something is appending to those paths.

zerusski15:07:03

ok, so looking at actual source.js.map

zerusski15:07:08

they are coming from there

zerusski15:07:44

so I see stuff lieke this there:

"sources":["client.cljs&rel=1468248434134"],"lineCount":15

eyelidlessness15:07:05

not deeply knowing how cljs compiler builds source maps, i would suspect that it's being appended before the compilation, somewhere either in configuration or some library

delaguardo15:07:56

this is timestamp appended by cljs compiler if you use option :source-map-timestamp https://github.com/clojure/clojurescript/wiki/Compiler-Options#source-map-timestamp

delaguardo15:07:59

but it should be appended with ? not with &

zerusski15:07:50

well, there it is. Although i don't know where :source-map-timestamp is even set. Not in my project.clj that's for sure

zerusski15:07:13

a couple of weeks ago i did not have that problem

zerusski15:07:08

oh, it's for live-reloading. So must be figwheel setting it?

zerusski15:07:55

But u right, real problem is & instead of ? I guess.

zerusski15:07:10

So, i don't know how this stuff works but I wonder if this commit created the problem or actually solved it https://github.com/clojure/clojurescript/commit/ad3aa4a403a3024e818902dc7a2e45831bde6dad?diff=split

dnolen15:07:01

@zerusski: use 1.9.89, thatā€™s the official release

dnolen15:07:42

the various incremental releases arenā€™t necessarily all that well tested

dnolen15:07:57

the next official release will fix the source map issue

zerusski15:07:17

ah, duly noted. Thank you

leo.ribeiro16:07:51

hello guys! I wanna your sincerely opinions about this: if Iā€™m already good on html + css + js, used to work with ReactJS everyday, should I still learn clojure script or I can keep my frontend with my JS skills? what do you guys think? I mean, for me itā€™s ok to learn that, as Iā€™m already doing the backend in Clojure, but if one day the company decides to keep me only in the backend, I suppose we are going to restrict a lot to hire a frontend guy.

dnolen17:07:34

@leo.ribeiro: I think it just depends on whether you want to keep such a strong front/back distinction

dnolen17:07:51

I know a lot of instances where yes itā€™s Clojure on the backend and X on the frontend. But lots of people like the conceptual unity of Clojure effectively for both tasks.

miguelb20:07:24

anyone use sente?

blance21:07:08

anyone know how can foreign-libs export themselves to the global scope so that they can be accessed by js/

blance21:07:00

context: I'm building a cljs app which needs few JS foreign-libs, I compile my cljs app with its js lib dependencies to one js file and require that from some large JS application using webpack's require() function

blance21:07:23

But this way, webpack's require() would create a closure around the module, so that my JS dependencies cannot be seen at the global scope

blance21:07:33

Does anyone know any workaround?

dnolen21:07:05

@blance it is something to handle at the Webpack or some other build tool level - Iā€™m assuming libraries can export themselves to the global scope if need be

dnolen21:07:22

nothing can be done about this via ClojureScript build options

blance21:07:59

you are saying I need to edit the config of those libs and build them manually

dnolen21:07:40

yes the simplest thing to do is to make a foreign dep of all the various things you want to use from NPM or whatever via whatever build tool you want, exporting whatever you need (if these deps arenā€™t available on http://cljsjs.github.io)

dnolen21:07:06

we do have basic support for integrating ES6 modules and CommonJS modules but this support probably needs more eyes and more work

blance21:07:30

are there a link I could look at?

dnolen21:07:34

thereā€™s also been some Closure breaking changes here which I havenā€™t had time to look into

dnolen21:07:54

@blance I do not recommend going down that path unless you have a lot of time on your hands

blance21:07:56

there are cljsjs packages for the lib I use but it needs to be exported to global scope anyway correct?

dnolen21:07:59

fix it via your JS build tool

dnolen21:07:19

@blance yes thatā€™s how Google Closure works, via the global scope

blance22:07:13

so not much difference than foreign-libs in terms of using them and the scope etc..

blance22:07:31

I guess I'll just look at the source code of those lib and rebuild them for my project

blance22:07:10

So all in all, Clojurescript can only use JS libs through global scope? That doesn't seem like a very good design choice?

dnolen22:07:03

this is how Google Closure works

dnolen22:07:17

Google builds some of the most complex JavaScript applications in existence

dnolen22:07:32

so ā€œgood designā€ is a matter of perspective here

blance22:07:09

I guess you are right..

blance22:07:39

That doesn't bother me much but my cowoker doesn't like the idea.. šŸ˜ž

dnolen22:07:42

thereā€™s lot of things like this where ClojureScript does not follow JavaScript ā€œbest practices"

blance22:07:02

yea they are js developlers for years and I just got into frontend

dnolen22:07:31

right, we donā€™t cargo cult that stuff

blance22:07:00

well, thanks anyway. Didn't thought I would get help from the lead developer haha