Fork me on GitHub
#clojurescript
<
2017-12-03
>
souenzzo01:12:39

1- Is possible use javascript-modules with export default? 2- Should I import js.foo or js.foo.index in case of src/js/foo/index.js with "export default"? 3- When I run the example from https://clojurescript.org/guides/javascript-modules , on the repl says WARNING: JavaScript file found on classpath for library js.hello, but does not contain a corresponding goog.provide declaration: file:/home/souenzzo/top-secret-project/src/js/hello.js It's excepteced?

christos07:12:27

Hi, I am trying to use reader literals with the latest figwheel, Template. The data_readers.clj file contains

{dbz/l debuz.utils/cmlog}
but when I
(:require [debuz.utils])
in the name space decleration I get
^--- Attempting to call unbound fn: #'debuz.utils/cmlog i 
implying that the cmlog function is not binded. What am i doing wrong ?

Ivan Fedorov19:12:36

Good day channel! I'm trying to get into clojurescript and reagent, but stuck with Uncaught ReferenceError: react_dom is not defined. Non-reagent clojurescript works fine. All of it regardless if figwheel is turned on or off. So what can I read to understand the cause?

au-phiware20:12:57

@ognivo Try using a stable release of reagent instead of an alpha. I believe the alpha requires some npm-deps im the compiler options: https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules

Ivan Fedorov21:12:17

ok, now its base.js:639 goog.require could not find: create_react_class

Ivan Fedorov22:12:17

I even see ReactDOM in globals

au-phiware23:12:24

What's in your :npm-deps? Are you able to share your complete project on github or something?

au-phiware00:12:35

I don't see a project.clj file(?)

Ivan Fedorov00:12:04

oh well, fixed now

Ivan Fedorov01:12:57

for a reason I don't know yet similar configuration lein new reagent produces single module, whilst mine inferred from lein new chestnut produces a set of modules. With :optimizations :advanced it becomes a single module, but the error seems to persist, just with mangled names.

au-phiware01:12:51

fixed? are you still getting "could not find: create_react_class", I think you might need to npm install [email protected]

Ivan Fedorov08:12:15

Fixed on 0.8.0-alpha2. So the fixed error is `Uncaught TypeError: Cannot read property 'render' of undefined at reagent$dom$render_comp (calendrie.js:63913)`. Fixed by deleting node_modules dir. Jee, that was a bit obscure that compilation depends on it at all.

au-phiware20:12:52

@hee-foo Not sure, but I think you need to quote it: {dbz/l #'debuz.utils/cmlog}. A fuller example would help give me more context to your problem.

christos20:12:57

@au-phiware Quoting doesnt work. Here is the full debuz.utils

( ns debuz.utils
(:require
   [clojure.string :as str]
   [goog.dom :as dom]
   [goog.dom.dataset :as domdata]))

(defn- cmessage [f]
  (fn [& args]
    (if js/goog.DEBUG (f args) nil)))

(def cmlog (cmessage js/console.log))

christos21:12:27

then in core.cljs :

(ns debuz.core
  (:require [debuz.utils]))

(enable-console-print!)

#dbz/l "This text is printed from src/debuz/core.cljs. Go ahead and edit it and see reloading in action." 

christos21:12:33

project.clj

:dependencies [[org.clojure/clojure "1.9.0-beta4"]
                 [org.clojure/clojurescript "1.9.946"]
                 [org.clojure/core.async  "0.3.443"]] 

au-phiware21:12:00

@souenzzo 1. Yes, there should be a default property after you've required it. 2. I've found this a tricky question my self, require it with whatever you would in es6, note you can pass strings to require now. 3. Yes, depending on how you've setup your project you will get this messages.

christos21:12:33

Sorry I dont get you. There should be a default property ?

christos21:12:43

what do you mean ?

christos21:12:32

Sorry didnt see to whom you where messaging

thheller21:12:03

@hee-foo save yourself the trouble with data readers and just call (dbz/l ...) directly instead

au-phiware21:12:46

@souenzzo 2. I might of mislead you (I was thinking of something else), it should depend on what you have in your foreign-libs entry.

souenzzo23:12:40

I'm trying to use https://clojurescript.org/guides/javascript-modules + ES6 modules. I dont need foreign-libs, right?

au-phiware23:12:21

From the page you linked: "Notice that a :foreign-libs entry may now specify a directory for :file. In this case, the ClojureScript compiler will recursively search this directory for .js files and automatically create the :foreign-libs entries for you with the supplied options. The :provides namespace for each entry will be automatically computed from the directory structure." :)

au-phiware23:12:57

You might be thinking of npm/node modules