Fork me on GitHub
#clojurescript
<
2016-12-07
>
clumsyjedi01:12:06

A question about externs: I maintain lein-chromebuild and lein-chrome-extension - which (shockingly) provide some hooks to get cljs running in chrome extensions. The way chrome extensions work is that you specify a list of javascript files for each component of the extension, so for a popup menu I would build the main cljs bundle including the projects sources. Project sources would contain a defn like

(ns myproj.popup)
(defn popup.init []) ;; code to initialize the popup runs here
And I also include a js file like:
myproj.popup.init()
When the user clicks the popup link, the popup js file is loaded and myproj.popup/init is called. This works ok for normal compilation, but when advanced compilation is enabled, the myproj.popup/init is munged away. I have been trying to solve this by using externs, specfied in the cljsbuild step. My externs file looks like this:
var myproj = {};
myproj.popup = {};
myproj.popup.init = function () {};
This does not complain during the compilation phase, but the myproj.popup/init is still getting munged away. Am I on the right track here? It seems like most descriptions of using externs are about calling out to 3rd party libs from cljs, whereas I am trying to call into cljs. Is there something obvious about my examples above that indicate why it's not working as I expect? Any pointers would be greatly appreciated.

jrheard01:12:12

i think you want ^:export on your defn

jrheard01:12:24

externs is for accessing vanilla js names from cljs

jrheard01:12:29

^:export is for accessing cljs names from js

jrheard01:12:39

googling to make sure i have the syntax right, and to find a reference

jrheard01:12:28

let me know if i misinterpreted your question 🙂

chrisoakman01:12:56

@clumsyjedi also check out goog.exportSymbol()

chrisoakman01:12:30

That's what I typically reach for when I need to make sure JS can access something from CLJS.

clumsyjedi01:12:01

nice jrheard + chrisoakman, that's exactly what I'm looking for, thanks 🙂

hulunote02:12:14

cljs use which pagination ?

hulunote02:12:18

like jqpagination

iku00088803:12:38

We use datatables (and jQuery..)

bg03:12:46

The Google Closure compiler is now available in pure JS. https://github.com/google/closure-compiler-js This is great news for self-hosted CLJS!

mitchelkuijpers11:12:33

Does anyone know if it’s possible to use clojure spec generators in clojurescript?

dominicm11:12:58

I think I've seen some people do it, yup

mitchelkuijpers11:12:21

Aha i found it I need to get it from cljs.spec.impl.gen

asier15:12:21

Hey, I’m trying to split my code into two modules: a landing page (ns rulv.client.landing) and the user page (rulv.client.core). I’m using :modules compiler option as follows:

asier15:12:27

But a) the resulting files are empty and b) other dirs and files have been created (under "resources/public/") for libraries I’m using. What am I doing wrong?

manutter5115:12:22

@asier what version of ClojureScript?

asier15:12:51

clojurescript "1.9.198" and lein-cljsbuild "1.1.3"

manutter5115:12:54

@asier I don’t really know the advanced optimizations well enough to be much help, but fwiw you might try setting :warnings true and/or upgrading to ClojureScript 1.9.293

dnolen15:12:31

@asier first glance looks ok, is there a base file that gets generated?

asier15:12:35

thanks @manutter51 - @dnolen yes, this: cljs_base.js

dnolen15:12:59

@asier but is it empty?

dnolen15:12:46

and you set :output-dir so of course you’re going to get intermediate stuff in that location

asier15:12:59

@dnolen it's not empty, but my files landing.js and core.js are

asier15:12:07

aha, thanks

dnolen15:12:19

there’s just not information here to know what’s going on, did you trying turning on :verbose true compiler option?

dnolen15:12:35

if you set that then you will see logging during module generation

asier15:12:02

Perfect, I'll do that. Thanks @dnolen

dnolen15:12:48

@asier if you’re still confused I recommend trying the module feature on some tiny trivial thing outside your project and comparing what you might be doing wrong

anmonteiro16:12:04

@asier probably not related at all to your problem, but I recommend upgrading to the latest ClojureScript, there was a fix related to dependency ordering with modules

spacepluk17:12:24

hi, is there any way to stop clojure from referring some java classes like Byte?