Fork me on GitHub
#clojurescript
<
2017-09-05
>
bcbradley05:09:07

does anyone else receive a bunch of violation errors in google chrome when loading clojurescript webpage?

bcbradley05:09:35

i receive a bunch of [Violation] Parser was blocked due to document.write(<script>)

bcbradley05:09:49

and [Violation] Avoid using document.write().

bcbradley05:09:38

i don't use document.write, but the stack trace says goog.require does, through a function called goog.writeScripts_

bcbradley05:09:58

i believe clojurescript relies on the blocking behavior of goog.require to load scripts, but the issue is that chrome doesn't like document.write at all, and will complain and yell if you use it

bcbradley05:09:08

its not a dealbreaker but it is annoying-- is this just something the people in the clojurescript community have no control over or they just use firefox, or don't care, or am I missing something?

bcbradley05:09:15

I mean i guess I can toggle off verbose messages in chrome devtools. I hadn't considered doing that.

thheller07:09:21

@bcbradley that is only an issue during development while using :none. as soon as you use an optimized build for production that issue goes away.

thheller07:09:45

personally I just disabled verbose messages in chrome

daedelus198210:09:56

Hi, complete noob to clojurescript here. I was running through the online tutorial modern-cljs and hit a wall on lesson 4 here: https://github.com/magomimmo/modern-cljs/blob/master/doc/first-edition/tutorial-04.md. The lesson just displays a simple login form and validates it using the compiled clojurescript. This should display an alert if the boxes in the form are blank. Except it doesnt and I get errors at the console instead: "goog.require could not find: cljs.core". Is this a common error?

magomimmo10:09:03

@daedelus1982 have you tried to do the following: git clone https://github.com/magomimmo/modern-cljs.git cd modern-cljs git checkout se-tutorial-04

daedelus198210:09:36

@magomimmo Yes I have tried that. Strangely I get the same problems and errors, so im guessing there no typos or anything in my code? I do "lein clean" and "lein cljsbuild once" to force a new compilation

magomimmo10:09:24

@daedelus1982 I suspect you're using the first edition of the series, because the second edition is based on boot not on lein and as I explained in the README.md I'm not going to support the first edition anymore

daedelus198210:09:58

yes its the first edition, i didnt fancy learning boot so i stuck with lein, thanks for the tutorial, got further with this than any book on cljs anyway. I will have another think

magomimmo10:09:46

@daedelus1982 you could eventually contribute to update the first edition, by PR it simple_smile

ericnormand11:09:26

@flyboarder the elements [a b c] are the state, though they're not mutable. No need to use reify.

ericnormand11:09:36

@flyboarder if you want them to be mutable, put something mutable in them, like an atom or ref

ericnormand11:09:58

(Foo. (ref 1) (ref 2) (ref 3))

daedelus198211:09:55

@magomimmo would love to if I get past this. quick question... I am using windows 10 whereas the tutorial is using a Mac I think. Do you think the OS could be the cause of the errors?

magomimmo11:09:44

@daedelus1982 I don't think so, but I could not say for sure, because the last time I used Windows was 1995 😞. I think that the error as something to do with old version of clj/cljs or any cljs library used in modern-cljs

daedelus198211:09:59

@magomimmo ok thanks, thats what i thought but i tried different versions. maybe i forgot to save the changes or something silly like that. cheers, will have a fiddle later

ingesol13:09:12

I'm trying to use a jquery-ui plugin in my app as an NPM dep. Not sure what to do to hook it in, as it does not provide a module, just a direct call to jquery function...

vinai13:09:45

@ingesol something like (.functionName (js/$ ".some-class")) maybe? That would be like $('some-class').functionName()

ingesol13:09:10

yeah, thanks, that's what i'm doing right now. But I'm not talking about usage of jquery in the code, i'm talking about how to get it compiled with the rest of my code as an NPM dependency

ingesol13:09:38

because I don't think its source is included before it is required in some namespace of mine

vinai13:09:57

@ingesol Ah I see. Sorry, never used NPM dependencies, browser only.

hlolli13:09:35

@ingesol require cljsjs.jquery, browserify the jquery library and include it as external dependency? use extern-generator for advanced compilation (where you need to include jquery file assumeably to make externs).

hlolli13:09:29

even easier, luckily someone alreadt package'd it https://github.com/cljsjs/packages/tree/master/jquery-ui

ingesol13:09:56

yeah, I saw that. So I basically just need to do a simple cljsjs procedure for jquery-ui

ingesol13:09:11

the problem is with the actual jquery-ui plugin, that does not have a cljsjs package

hlolli13:09:55

you mean there are features in the jquery-ui plugin that are not bundled in cljsjs package? Otherwise it should be simple as

(ns yourns
  (:require cljsjs.jquery-ui))

(.button js/jQuery param1 param2...)

ingesol13:09:34

No, I mean that I want to use a JS library that is packaged as a jQuery plugin, and also depends on jqueryUI. Sorry for not being clear here 🙂

hlolli13:09:33

then you could I guess add it as external library and require cljsjs.jquery-ui for the functions that library needs from that library, jquery-ui already requires jquery so the library should have access to all symbols and functions it needs.

rnagpal13:09:36

I need to pass props to a component. and I want props to follow a contract. It will have few vars(atoms + maps) and some callback functions. If it was to have just functions, I could have declared a defprotocal. what are my options now ?

ingesol13:09:43

Thanks, I'll try that. The load order of scripts is a bit difficult when mixing jquery and react...

hlolli13:09:42

yes, you can even control the dependency order in :foreign-libs map.

ingesol13:09:27

never tried that, but read about it. I'll take a look

hlolli13:09:02

no sorry, so Im saying the right things, you can state that a foreign lib depends in other lib, this causes goog.depends order to be ordered accordingly.

ingesol13:09:40

right. so I wrap my weird plugin in a foreign lib and states dependency on jquery-ui cljsjs package

ingesol13:09:54

and require the synthetic namespace from my code

hlolli13:09:23

yes :foreign-libs[{:file ".." :requires ["cljsjs.jquery-ui"]}]

daedelus198215:09:29

@magomimmo regarding the earlier issue, this is just an update... I deleted the other 2 cljs files (connect.cljs and modern.cljs) and recompiled with just login.cljs in the folder. the login form worked as expected then. no idea why that worked but it did

ingesol20:09:00

@hlolli Never used foreign-libs like that before, seems to work!

reefersleep20:09:03

What is a good leiningen template for a Clojurescript library?

reefersleep20:09:13

Tried cljs-start, but after editing the project.clj to use more up-to-date dependencies, I'm having trouble compiling

reefersleep20:09:08

Actually, scratch that, I managed to fix my problem. 🙂

ag23:09:06

has anyone used Enzyme in Clojurescript? Any tips? Is it worth trying?