Fork me on GitHub

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


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


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


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


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


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?


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


@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.


personally I just disabled verbose messages in chrome


Hi, complete noob to clojurescript here. I was running through the online tutorial modern-cljs and hit a wall on lesson 4 here: 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?


@daedelus1982 have you tried to do the following: git clone cd modern-cljs git checkout se-tutorial-04


@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


@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 I'm not going to support the first edition anymore


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


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


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


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


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


@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?


@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


@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


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...


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


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


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


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


@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).


even easier, luckily someone alreadt package'd it


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


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


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...)


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 🙂


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.


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 ?


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


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


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


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.


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


and require the synthetic namespace from my code


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


@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


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


What is a good leiningen template for a Clojurescript library?


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


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


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