Fork me on GitHub
#clojurescript
<
2016-01-06
>
exupero00:01:31

@crocket: I think externs are only needed for :advanced optimization so the compiler knows what not to rename. It shouldn’t be necessary for :simple.

crocket00:01:57

@exupero: I was working with :advanced optimization on nodejs for exploration.

esnunes00:01:04

Hello everybody, I'm new to clojure / clojurescript. I was wondering how to make a Om app "universal/isomorphic" ? Is there a way to achieve this?

threequal00:01:11

As Om is just a Clojurescript interface to React, and React is isomorphic, it is possible

meow00:01:35

@esnunes: Welcome. There is an #C06DT2YSY channel where you might get a quicker response.

esnunes00:01:52

thanks guys

crocket02:01:06

Assume that fs.readFileSync returns a buffer object which has variables and functions. How could externs protect those in a buffer object?

crocket02:01:27

The buffer object can be named in any way. It seems I should use JSDoc to annotate that it returns js/Buffer.

mjmeintjes02:01:06

Hi. Has anyone successfully used Adzerk's cljs-repl task with boot version > 2.5? I'm trying but keep getting missing file errors and was wondering whether it is just me.

meow02:01:00

@mjmeintjes: I haven't upgraded in a while so can't help. You might get a quicker reply on the #C053K90BR channel.

currentoor06:01:54

If I want to parse and fetch a particular query param, is this the right goog lib to use?

currentoor06:01:26

I’m trying it but it’s giving me weird results.

currentoor06:01:01

I guess it works.

currentoor06:01:01

For the uri "

currentoor06:01:18

it has these keys/values

currentoor06:01:19

temp1.getKeys()
[""]
temp1.getValues()
["ferret”]

currentoor06:01:51

I didn’t think the root URI would be part of the key.

danthedev08:01:01

Being driven to near insanity by compile time errors for Clojurescript

danthedev08:01:34

Anyone know what might be causing the compiler to throw ANALYSIS ERROR?

danthedev08:01:25

Tried lein clean, tried running the same src in a fresh project, same result

danthedev08:01:06

It's throwing and referencing (seemingly) random files from my project

danthedev08:01:26

Sometimes it's one of my source files and sometimes its a dependency that I've included

danthedev08:01:47

Always pointing at line 1, column 1

logcat08:01:52

stacktrace ?

danthedev08:01:39

Yep, one sec

danthedev08:01:37

Sometimes, if I deliberately break the namespace in the file referenced by the error it will switch to referencing another file

danthedev08:01:54

Same if I insert a newline at the top of the file

shanekilkelly09:01:51

Caused by: java.io.FileNotFoundException: resources/public/js/compiled/app.js (No such file or directory). Does that file exist?

danthedev09:01:21

I'm trying to compile Clojurescript

danthedev09:01:34

The result should be the creation of that file

shanekilkelly09:01:27

sure. so looking at your stack trace it looks like one of your components is failing to start, most likely because of the absence of that file (which is silly, as it doesn’t exist yet). Is there anything in your project which is configured to look for that file, and might be trying to read it even before it exists?

shanekilkelly09:01:43

better yet, if your source code is public could you post a link?

jaen09:01:58

Are you sure all your parens are in order? That sounds like something that happens when they aren't.

danthedev09:01:45

@jaen the analysis error doesn't even seem to be specific to a single file, sometimes it throws on my source, sometimes on secretary, sometimes on reagent

shanekilkelly09:01:02

yeah, I’ve cloned down your repo and I get the same error, so it’s not just your environment/machine

shanekilkelly09:01:49

did this work before? if so then what’s the most recent thing you changed?

danthedev09:01:24

Yeah, I can point you to a working commit, but we're doing this for a game jam, so commits haven't been particularly granular

danthedev09:01:43

Trying to figure out the cause through commits hasn't got us anywhere yet

danthedev09:01:04

Just noticed that lein cljsbuild once gives a different error

danthedev09:01:37

Or a different stack trace at least

danthedev09:01:50

The constituent parts are the same

danthedev09:01:45

But the stack trace is ~2100 lines long

shanekilkelly09:01:26

Yeah, clojure errors are pretty brutal, one of the worst aspects of the language.

danthedev09:01:19

I can't find any documentation on what causes ANALYSIS_ERROR to be thrown

danthedev09:01:45

It doesn't seem to be on google as a problem anyone else has had either

danthedev09:01:53

Yeah, I love the language, but the errors are enough to make me consider leaving it alone for a few years whilst the tooling settles down and stabilizes

jaen09:01:46

Well, the tooling is already considerably better than it used to be. Errors like those are more on the account of the dynamic nature of the language, regularity of syntax and implementation, so I'm not sure waiting a couple of yeras will fix all of that. Like I said I've usually gotten similar errors where I misplaced some parens. Let's see if I can run it over here.

jaen09:01:54

Off the bat I've gotten not imported css in styles.core and when I fixed that I've got a compile-time stacktrace. Huh.

danthedev09:01:41

figwheel shouldn't even know about that

danthedev09:01:01

We started out with garden, but ditched it at some point

danthedev09:01:27

With regards to the tooling, I'm not saying that it's bad. It's gotten a lot better since I first tried Clojure (2012)

danthedev09:01:48

But this kinda of error is debilitating. I can't understand it, I can't reliably reproduce it

danthedev09:01:18

It doesn't always throw for the same file, it doesn't give me a line/col to reference

jaen09:01:17

Okay, I have a suspicion you have circular dependencies, let me check.

danthedev09:01:29

I'd wondered whether it was a dependency error

jaen10:01:52

Well, stack overflow during analysis seems to suggest as much

jaen10:01:06

For example you go game.ui.widgets -> game.state -> game.views.heroes -> game.ui.widgets

jaen10:01:49

I have no idea why no warnings about that appear though.

jaen10:01:25

I thought Clojurescript source file resolution had cycle detection.

danthedev10:01:01

But that dependency cycle has been there since long before the error appeared

jaen10:01:29

Then it might not be this one, it was an example. Maybe when you added a file the order you walk dependencies in changed and you hit a cycle? Or you know, it's a dynamic language - it sorta worked until you hit a corner case.

jaen10:01:45

But in general Clojure will not love you for circular dependencies.

jaen10:01:14

Sometimes things will apear to work in Clojurescript even if that's unintended (like aget for objects). Host language sticking through and other caveats.

danthedev10:01:46

But circular dependencies are definitely identifiable at compile/analysis time

jaen10:01:09

Sure, they ought to be; so it might be a corner case where the compiler can't notice?

jaen10:01:32

Like I said I thought Clojurescript can notice those cycles (I remember circular dependencies being pointed out to me by the compiler, thought I don't remember if that was Clojure or Clojurescript). In general - you shouldn't be getting stack overflows during the analysis phase, it's quite possible you hit some corner case compiler can't deal with.

danthedev10:01:00

Ok, well I'll follow through and resolve all the circular deps and then carry on tentatively

danthedev10:01:36

When I started getting the error, it would happen when and only when I killed and restarted figwheel

danthedev10:01:56

The usual rebuild and reload mechanism wasn't catching it at all

danthedev10:01:38

Which meant that I'd develop for half an hour or more, then restart figwheel only to find that something in the last session had brought back the analysis error

jaen10:01:23

Well, I don't know about figwheel exactly, but back when I used leiningen I remember compilation errors that only went away after a clean rebuild (or happened only after a clean rebuild).

jaen10:01:55

Boot is better in that it always does a clean build and relies on the compiler to do the caching instead, so such errors should be rarer.

danthedev10:01:27

I'll have to give it a go at some point

danthedev10:01:24

Assuming the incremental compilation is built into the compiler, then isn't the compiler already handling the important caching, regardless of Lein?

danthedev10:01:03

Or does boot disregard that

jaen10:01:35

Hah, I must say I don't really know specifics of how either handles the compiler. I am aware of Clojurescript's compiler API that gives you watch feature which recompiles only changed files, but that's probably not what either uses and they probably opt to handle the analysis environment by themselves.

jaen10:01:41

What I meant there for boot is that doesn't re-use compilation results in the way lein does across runs (so no need for clean), which might result in weird errors. Inside a single run they should probably behave similarly, but then again - I don't know the implementation details to say it with certainty.

iwankaramazow12:01:33

I think I ran into a bug with om.next, not sure if it's a actual bug or I'm messing up something: Basically when running set-query! or update-query! on a (grand)child component the params of that query get updated, but it doesn't a change anything the root query --> "No queries exist for component path (om-tutorial.core/RootView om-tutorial.core/ThResultTableView)", :data {:type :om.next/no-queries}}

iwankaramazow12:01:07

Did I overlook something obvious or should I file an issue?

jethroksy12:01:55

@iwankaramazow: your query does not compose to the root

jethroksy12:01:08

this is also better discussed on #C06DT2YSY

iwankaramazow12:01:07

ok, thanks! I'll move it to #C0DT1AZD3 (not sure why my query doesn't compose to the root..)

meow13:01:08

@danthedev: Speaking of tooling, Cursive with structural editing mode will save you a lot of grief from simple things like misplaced parens. I can't imagine writing Clojure code without Cursive (or Emacs/Spacemacs, not to start an editor war, just pointing out good tooling).

juhoteperi13:01:11

@jaen: @danthedev : Neither boot-cljs or cljsbuild uses watch from Cljs Build API but just call build repeatedly with the same compiler-env, this way Cljs compiler will take care of analysis cache between recompilations. Logic to check which files and namespaces need to be (re)compiled is built into Cljs compiler.

dnolen13:01:31

@danthedev: circular dependencies are detected, but it maybe you have found an edge case of some kind that would need a minimal repro against master. Another person has reported this as well - but as of yet no one has taken the time to create a minimal reproducer.

dnolen13:01:19

errors are high priority and always have been - but better errors come as direct result of an active community interested in helping core developers work on it

jaen13:01:35

@juhoteperi: yeah, thought so, but wasn't sure. Thanks for clarifying.

dnolen13:01:57

@danthedev: also I’ve seen Figwheel swallow analysis exceptions

dnolen13:01:21

so if it’s not a ClojureScript bug, the same rules apply - the only way for Figwheel to give better errors ...

danthedev13:01:15

@dnolen: Thanks. I'll try to put together the reproduction then

danthedev14:01:42

@meow: @dnolen Mostly the problem with the errors is just verbosity (syntactic ones I can catch in my editor)

danthedev14:01:26

Sure, and it's not helpful to hear that again and again

danthedev14:01:48

The gripe today came from the fact that the error was totally unapproachable

dnolen14:01:02

@danthedev: gripes are fine - but people make often make statements that actually end up being about whatever various tooling they’ve thrown in with. Nothing in ClojureScript itself.

dnolen14:01:16

as in it’s highly likely you would have seen the actual error w/o Figwheel

dnolen14:01:07

this is the reason why the Quick Start only focuses on using ClojureScript directly

danthedev14:01:12

lein cljsbuild throws the same cryptic message

dnolen14:01:23

so that everyone has the knowledge to sort these things out quickly instead of guessing

jaen14:01:28

Well, it at least says it's a stack overflow, that's something to go on off.

dnolen14:01:34

@danthedev: cljsbuild also isn’t ClojureScript simple_smile

dnolen14:01:53

ClojureScript does even take bug reports that involve anything 3rd party of any kind

dnolen14:01:11

4 years of development have shown the interactions are non-trivial and often in the 3rd party tooling.

danthedev14:01:09

So, best way to produce the reproduction is recreate it, then try to build the clojurescript without tools?

dnolen14:01:26

@danthedev: yes the Quick Start covers this

dnolen14:01:48

all tools either reuse what ClojureScript does or faithfully copies the behavior - it’s a bug not to.

dnolen14:01:05

bugs are issues with “reuse” and “copies"

dnolen14:01:58

probably the most important piece of advice I could give to anyone using ClojureScript would be to spend some time understanding how it works fundamentally. Tooling issues become instantly recognizable when you know the fundamentals works.

dnolen14:01:04

90% of frustration discussion I see are people stuck fighting whatever cool tooling they heard about and not understanding how it works because they don’t know how the underlying thing works.

dnolen14:01:49

which reminds me, somebody should really do a newcomer friendly FAQ on the ClojureScript wiki on the various Java-isms you should at least basically be familiar with - classpath, Maven, poms, etc.

quadrochosis14:01:27

as a newcomer, i’d love that. being a javascript developer getting into CLJS, a quick primer on Java ecosystem and common idioms would be super awesome

nha14:01:27

Even as a NodeJs guy that went into Clojure, that would have been awesome.

jaen14:01:32

Well, this is funny because I don't know more about each than: "something like LD_LIBRARY_PATH" for Java" , "some Java dependency management", "some xml file thing Maven uses" respectively and I can get by just fine. But on the other hand there are no decent explanations about deployment, so in general I can agree there are certain topics people not familiar with Java could benefit from having explained.

dnolen14:01:11

@jaen I see people struggle with deployment constantly - usually due to a lack of understanding about the Java-isms and how Clojure(Script)-isms map onto them.

dnolen14:01:26

tooling & deployment

jaen14:01:12

Also, I guess the answer is no, but need to verify - when writing a Clojurescript macro there's no reliable way to cross the phase barrier with things other than the argument macro gets, right? I wrote a macro that works great in Clojure (because I just can eval things as needed) but I need it to work in Clojurescript and I'm trying to figure out how to get it to. Hmm... I guess cljc might be useful here somehow?

nha14:01:21

@jaen I don't know a lot more than you do now, but that alone gives me an idea of what could be wrong (my dependencies? then is it caching, the network ?). Knowing that ~./m2 exists have been useful too.

dnolen14:01:17

@jaen if you actually need eval there’s no way to make it work (w/o bootstrap) - if you don’t, then yeah can probably be make to work

dnolen14:01:58

@nha yep, there’s tons of stuff like that old hands take for granted

dnolen14:01:34

weird reflex stuff like double checking multiple things aren’t polluting the classpath etc.

jaen14:01:02

Yeah, thought so. Thanks for the confirmation. I guess I just have to re-architect it somehow then. I figured that maybe if them records had the same namespaces in both Clojure and Clojurescript I just could use them from both, but this feels like a hack I'm going to regret, so I'll just probably go figure out how to structure it differently. I basically hoped I could expand my datascript queries during macroexpansion, but this requires knowledge about entities and that would then need to be shared between Clojure/Clojurescript.

jaen14:01:15

Yeah, learning about deployment was vexing. I've only dealt with Ruby deployment before and figuring out all that deployment-related part of the ecosystem was tough, where everyone just assumes you understand what a servlet container is and what arcane combination of xml tags is needed to add a port listener. Ruby was considerably simpler by comparison (if somewhat annoying due to not being able to uberjar it up like on JVM).

jaen14:01:39

But that's just about the only part of the ecosystem differences I've found hard so far.

danthedev15:01:18

@dnolen Created a build using the standalone cljs.jar and I get a slightly different stacktrace, but still the same analysis error. From here, is it best to distill the code into the bits that throw then create an issue?

dnolen15:01:44

@danthedev: yes can you please gist the stacktrace though? thanks

danthedev15:01:05

For reference (the rather large) reproduction with cljs.jar is here, too https://github.com/DanjoeGames/lispjam/tree/repro

dnolen15:01:15

@danthedev: hrm yuck - yeah not helpful (the stacktrace)

dnolen15:01:41

@danthedev: I’m assuming this is ClojureScript 1.7.170?

dnolen15:01:19

@danthedev: yeah no idea, we have circular dependency logic on the path shown by the stacktrace

dnolen15:01:39

so will need a more minimal reproducer

jaen15:01:59

Hm, is there any verbose switch for the compiler to say which namespaces it analyses in turn?

dnolen15:01:20

@jaen :verbose will tell you when things are analyzed

danthedev15:01:06

@dnolen: That's fine. I'm glad it wasn't just me that was stumped. I'll see what I can do with cutting that reproduction down. Might be a while though, currently backpacking in South Asia and network connection isn't always as reliable as today.

danthedev15:01:40

Thanks for steering me in the right direction

dnolen15:01:43

@danthedev: no rush, this one seems genuinely weird to me.

dnolen15:01:02

@danthedev: hrm I tried a minimal circular dependency thing and it seems to not be working - so will look into that first

jaen15:01:40

Yeah, I've just checked it with :verbose true and it results in this:

Compiling /home/jaen/projects/lispjam/src/game/ui/item.cljs
Compiling src/game/util/core.cljs
Compiling src/game/models/items.cljs
Compiling /home/jaen/projects/lispjam/src/game/models/hero.cljs
Compiling /home/jaen/projects/lispjam/src/game/procedural/hero.cljs
Compiling src/game/ui/widgets.cljs
Analyzing file:/home/jaen/projects/lispjam/src/game/state.cljs
Analyzing file:/home/jaen/projects/lispjam/src/game/views/heroes.cljs
and then just keeps oscillating between the last two. Seems like a fairly simple cycle.

dnolen15:01:49

yep reproduced opening up a regression ticket in JIRA

mike_ananev16:01:56

hello all! I'm trying to use Clojurescrip/Reagent. What is idiomatic way of state propagation? If I have atom @a and dependent atoms @b and @c. I want if @a changed then updates for @b and @c applied automatically. thanks!

jaen16:01:15

@mike1452: you might want to look at reactions.

mike_ananev16:01:04

@jaen: so, I need to google "clojurescript reactions"? )

dnolen16:01:44

@mike1452: there’s a #C0620C0C8 channel that’s active

jaen16:01:19

@mike1452: there's not much to it, it's basically:

( reagent.ratom/make-reaction (fn [] (something-that-depends @on @some-ratoms)))

jaen16:01:35

There's also a convenience macro for it IIRC

jaen16:01:47

You might also want to look at re-frame - it features reactions extensively.

jaen16:01:26

Generally whole readme and wiki (especially reagent tutorials - https://github.com/Day8/re-frame/wiki#reagent-tutorials - they will reach you all you need to know about reagent component definition forms and such) is a really insightful read if you want to use reagent.

jaen16:01:29

@mike1452: hope that helps.

mike_ananev16:01:58

@jaen: Thank you! Clojure/Clojurescript world has awesome community!

decoursin17:01:57

Hello, I'm having trouble (shown ^ above) with specify. The code works in the namespace something.deque, but it doesn't work in any other namespace, as shown above.

dnolen18:01:35

@decoursin: you need to refer pop-front

decoursin18:01:44

@dnolen: Ok thank you. Why, though, would this work (-conj [3 4] 8)? I'm guessing that -conj is global?

dnolen18:01:56

@decoursin: same reason first works or anything else from cljs.core

dnolen18:01:00

this has nothing to do with protocols

dnolen18:01:33

@danthedev: circular dep issue resolved in master, thanks for the report

jaen18:01:46

Hah, such a little thing.

mheld19:01:15

is lein-bower a thing that people use anymore? it looks like it hasn’t been touched for 2 years

akiel19:01:44

Is there a way to read blocking from a channel in a cljs repl?

dnolen19:01:30

@mheld: probably because CLJSJS is more useful from a CLJS context

akiel19:01:37

The best thing I found is: (go (def res (<! ch)))

dnolen19:01:16

not really possible to have blocking core.async ops in ClojureScript

akiel19:01:12

Yes understand, but would be helpful in a repl situation.

dnolen19:01:19

there’s just no such thing and there isn’t going to be

mheld19:01:56

dnolen: gracias!

magomimmo21:01:20

@dnolen: it does not work for me. I’m preparing a minimal repo to reproduce. Unless I’m too tired to catch the issue….

dnolen21:01:59

@magomimmo: you need to be more specific

dnolen21:01:03

what doesn’t work?

dnolen21:01:06

there are two examples

magomimmo21:01:43

@dnolen: give me a quarter I got an error inside a complicated project and I want to be sure about the issue

dnolen21:01:20

@magomimmo: ok, we do have tests for the described import usage - but you might have found some other edgecase

magomimmo21:01:23

@dnolen: I let you know...

tony.kay22:01:09

I have a clj/cljs project. When I enable lein cljsbuild hooks it no longer runs the clj tests with lein test. Ideas on making that work? If I use the test-refresh plugin it works, strangely.

tony.kay22:01:34

using 1.1.1 of lein cljsbuild

tony.kay22:01:55

1.7.0 clojure and 1.7.170 of cljs

magomimmo22:01:14

@dnolen: here it is: if I use (:import goog.Uri) I get `WARNING: No such namespace: goog.Uri, could not locate goog/Uri.cljs, goog/Uri.cljc, or Closure namespace "" at line 9 src/googuri/core.cljs WARNING: Use of undeclared Var goog.Uri/parse at line 9 src/googuri/core.cljs`. If I use (:require goog.Uri) everything works as expected. https://github.com/magomimmo/googuri.git

dnolen22:01:52

@magomimmo: does (:import [goog.Uri]) work?

dnolen22:01:54

@magomimmo: hrm now I’m getting skeptical

dnolen22:01:07

does (:import goog.math.Long) work for you?

magomimmo22:01:15

@dnolen: require works in both ways

dnolen22:01:18

if it doesn’t you need to check your assumptions

dnolen22:01:24

@magomimmo: I’m not interested in require

dnolen22:01:26

I know it works simple_smile

magomimmo22:01:09

@dnolen: so why if require works in both ways I should use import?

dnolen22:01:15

@magomimmo: we have an import test for goog.math.Long, [goog.math Vec2 Vec3], [goog.math Integer]

dnolen22:01:36

@magomimmo: I’m not suggesting you use import

dnolen22:01:45

I’m only trying to understand the bug if there is one

magomimmo22:01:09

@dnolen: ok, but the wiki said that

maria22:01:31

@tony.kay: Here is some more information on how to enable testing with cljsbuild in case you haven’t seen it yet: https://github.com/emezeske/lein-cljsbuild/blob/master/doc/TESTING.md

loganmac22:01:37

Hi all, I'm looking for a library/example that could help in building a spatial organizer/kanban -style board in clojurescript. Anything to do with drag/drop, sorting, etc. I'm having no luck with my google-fu and any help would be greatly appreciated.

dnolen22:01:24

@magomimmo: I just tried here, (:import goog.Uri) works

magomimmo22:01:50

@dnolen: I don’t know what to say. Have you tried the minimal repo? Perhaps I’m too tired (here it’s night)

dnolen22:01:07

@magomimmo: I don’t look at 3rd party setups

dnolen22:01:12

it’s just not a good use of my time

dnolen22:01:19

you need to repro w/o any tooling

magomimmo22:01:52

@dnolen: ok. I’ll do later. I’m going to bed now

magomimmo22:01:20

@dnolen: thanks to you...

jakemcc22:01:35

@tony.kay: might be a difference in what leiningen profiles are being activated when running lein test vs lein test-refresh.

tony.kay22:01:36

@jakemcc: Thanks. Yeah, it looks like a config bit that got missed in general. Not a cljsbuild issue I don't think.

dnolen22:01:49

@loganmac: you have a lot of options - it really boils down to whether you want to use ClojureScript w/ some JS framework or if you want to do it from scratch using only Google Closure Library DOM / event helpers

loganmac22:01:18

I'm flexible - I'm a JS dev trying to cut my teeth on clojurescript and a friend asked me to build her a kanban board as an intro project

dnolen22:01:29

@loganmac: React dominates ClojureScript since it’s immutable friendly. Lots of people like Reagent - it presents a small number of novel concepts if you’re used to JS dev.

dnolen22:01:10

if there’s no interesting network component that’s probably the route with the fewest hurdles if you’re new to Clojure(Script)

loganmac22:01:27

@dnolen thanks! Yeah it should be pretty simple. I'm just looking to demo the drag and drop organization functionality then I'll add state/saving to an API etc later

loganmac22:01:48

@dnolen looks awesome. Thank you!

dnolen22:01:34

@loganmac: there’s an active #C0620C0C8 channel if you have questions about the cookbook etc.

loganmac22:01:50

Loving this community already. Thank you!

mkulke22:01:04

reagent is indeed easy to get into, i never touched react in javascript and so far it's been very comprehensive

yaniv22:01:08

is there a best-practice way of including 3rd party react components? do people use / autogenerate externs?

dnolen22:01:50

@yaniv I’m not aware of a really good auto-generate externs thing (could be wrong about that)

dnolen22:01:15

people usually use webpack or some other thing to build the JS stuff into a single foreign dep

yaniv22:01:44

i was thinking maybe there’d be a way with react-doc-gen since it can parse into a json structure that understands components / props

dnolen22:01:09

there’s the possibility of interacting directly with npm stuff - but it requires a bit more support from Closure Compiler

yaniv22:01:19

k that’s what i’m doing. if i create a single webpack bundle I can use :module commonjs?

jaen22:01:35

You won't have to

yaniv22:01:42

i tried this and it compiled but the components were undefined

jaen22:01:49

Webpack/browserify is there to compile the modules out (IIRC).

magomimmo22:01:15

@dnolen: I can’t sleep simple_smile. I tried without any buld tool as documented in the Quickstart wiki. Same warning with import. Here is the minimal code.

(ns helloguri.core
  (:import [goog.Uri]))

(enable-console-print!)

(defn foo
  "I don't do a whole lot."
  [s]
  (let [uri (goog.Uri/parse s)]
    (.getScheme uri)))

(println (foo "”))

dnolen22:01:47

@magomimmo: ha this is a miscommunication

dnolen22:01:56

there’s nothing wrong with wiki

dnolen22:01:08

:import is for one thing and one thing only

dnolen22:01:15

importing classes that are also namespaces

dnolen22:01:24

that’s all that it is for

dnolen22:01:34

goog.Uri/parse is not valid

dnolen22:01:48

since goog.Uri is considered a class, not a namespace

magomimmo22:01:53

@dnolen: aha! Thanks so much!

dnolen22:01:54

/ is only for namespaces

dnolen22:01:15

the wiki could be further clarified

dnolen22:01:17

doing so now

magomimmo23:01:56

@dnolen: thanx so much. I appreciated a lot

dnolen23:01:37

@magomimmo: thx for making the minimal case!

yaniv23:01:40

so i’m trying to figure out why i can’t import my 3rd party components. in my boot config compiler-options I have:

{:foreign-libs [{:file “resources/js/components.js”
                                :provides [“components”]}
and in my cljs i have
(:require [components :as c])
does that look right?

yaniv23:01:44

do i have to do a umd build with webpack?

easystreet23:01:10

@yaniv: require does not look right. should just be (:require [components])

easystreet23:01:52

not sure about webpack, but seems like a umd build w/ output.library set should work

yaniv23:01:42

with umd you leak a global right? was hoping to avoid that

yaniv23:01:16

also i wanted to be able to refer to my components as c. so i can use c/view for example

yaniv23:01:27

also how do people deal with the mismatch in conventions? react world is PascalCase while cljs is kebab-case

jaen23:01:51

Well, with :foreign-libs you have to leak a global you then pick up with js/Something as far as I know.

easystreet23:01:17

^what jaen said

yaniv23:01:26

okay so i guess i have to switch to UMD then. i thought :module-type commonjs provided the other option

easystreet23:01:09

although, after the GSoC work, that may not necessarily be the case in certain circumstances, looking at this: http://mneise.github.io/posts/2015-08-04-week-9-and-10.html

yaniv23:01:31

that was my reference

easystreet23:01:46

from that post:

(ns circle-color.core
  (:require [clojure.browser.repl :as repl]
            [React :refer [createElement createClass render]]
            [Circle :as Circle]))

yaniv23:01:41

just couldn’t get that to work..

easystreet23:01:04

yeah, very few people have tried afaict, so not sure if it actually works or not

jaen23:01:34

Yeah, if you compile it to a single module it should probably work.

jaen23:01:56

But in that case you need the :module-type option to let the compiler know it needs to translate it to a GClosure module.

yaniv23:01:58

yeah i’m exporting a single object called components

yaniv23:01:05

yep did that

yaniv23:01:22

and it compiled. but then i console.logged my c and it was undefined

jaen23:01:57

You have any repo with that somewhere online?

yaniv23:01:14

i’ll put it up. just the components?

yaniv23:01:23

you can try requiring it from your cljs?

jaen23:01:41

Well, the whole project as you have it would be easiest if you can do so.

yaniv23:01:01

k i need to move some stuff around. they’re separate projects

easystreet23:01:18

there's also this project, linked from the above blog post: https://github.com/mneise/circle-color

yaniv23:01:26

ahh so she’s including the raw ES5 code with JSX and commonjs

yaniv23:01:36

not using babel / webpack

yaniv23:01:51

my js lib is transpiled to ES5 with commonjs output but has been processed with babel… so i guess it should be equivalent minus the jsx transform

jaen23:01:25

Well, the sources are preprocessed in some way though - raw React is separate files after all.

yaniv23:01:51

yeah using commonjs for that

yaniv23:01:14

i wonder if they’re using browserify under the hood to support that

yaniv23:01:59

i’m gonna have to dig through this for a while. it’s gonna be hard to do what i want. this gets you half of the way there cus essentially you need to do a single build for the whole project. and for that to work for me it’d need to be a webpack build with my webpack config

yaniv23:01:01

cus if you look at her example she’s using relative paths for react. require(‘./react’). that works in this minimal case but if you’re using npm and want to require(‘react’) or define your own webpack alias for example that won’t resolve

jaen23:01:54

Oh yeah, in that case you definitely need to work it out with webpack or browserify.

yaniv23:01:06

into a UMD build

jaen23:01:10

Clojurescript compiler is not capable of dealing with that at all.

yaniv23:01:16

don’t know how to solve the single copy of react issue

yaniv23:01:46

usually i would include an external in my webpack config so that it doesn’t inline the dependency. it’ll keep the require(‘react’). but that won’t resolve in this case