Fork me on GitHub
#clojurescript
<
2017-02-12
>
qqq04:02:29

you know how that when I get a cljs compile error, the webpage displays it at the bottom in a div taht slides up? is there a way to force assertions into that window too? so now when I get an assertion, instead of it going to the console, I want it to also go into that div where the compile errors normaly appear

Oliver George04:02:44

I think you're describing is figwheel's heads up display. That does sound quite handy but I suspect there are some complications.

Oliver George04:02:58

The types of errors you are describe are runtime errors. To my knowledge it's a bit tricky to catch top level errors reliably. Doubly so when there is something like react's dispatch loop controlling flow and catching errors itself.

Oliver George04:02:02

I believe think figwheels heads up display has an API. That should mean you can show any areas you catch successfully

Oliver George04:02:29

I'm certainly not an expert in browser error handling but I did find this article interesting.

Oliver George04:02:34

(At the time I wanted the errors thrown by spec to be presented better.)

maksimrv10:02:46

Hello, I have trouble with setting up browser repl from [Quick Start](https://github.com/clojure/clojurescript/wiki/Quick-Start#browser-repl) All steps before work as expected. When I run rlwrap java -cp cljs.jar:src clojure.main repl.clj I see a message in the terminal: Compiling client js ... Waiting for browser to connect ... After that, I go to http://localhost:9000 in Chrome. In terminal I see: WARNING: Use of undeclared Var clojure.browser.repl/repl-print at line 144 WARNING: Use of undeclared Var clojure.browser.repl/repl-print at line 145 WARNING: Use of undeclared Var clojure.browser.repl/print-queue at line 147 WARNING: Use of undeclared Var clojure.browser.repl/flush-print-queue! at line 148 WARNING: Use of undeclared Var clojure.browser.repl/xpc-connection at line 148 And that is all, no prompt appear in the terminal. If open developer tools there are no errors, and also I see that was created iframe with url 'http://localhost:9000/repl?xpc=%7B%22cn%22%3A%225hwaMJvPgJ%22%2C%22tp%22%3Anull%2C%22osh%22%3Anull%2C%22ppu%22%3A%22http%3A%2F%2Flocalhost%3A9000%2Frobots.txt%22%2C%22lpu%22%3A%22http%3A%2F%2Flocalhost%3A9000%2Frobots.txt%22%7D' So I have spent a coupl of hours to undestand what's wrong but no success. Thanks OS: macos, Terminal: iTerm Java: java version "1.8.0_72"

pesterhazy10:02:06

Clojure version?

pesterhazy10:02:13

Cljs version?

maksimrv10:02:07

So as I understand it contains clojure (inside jar clojure version 1.8.0)

pesterhazy11:02:37

let me check

pesterhazy11:02:54

(not sure if there are any differences)

pesterhazy11:02:14

hitting some problems with the Quick Start guide as well

pesterhazy12:02:16

When the repl is supposed to connect, I get

Uncaught TypeError: Cannot read property 'appendChild' of null
    at goog.net.xpc.CrossPageChannel.<anonymous> (crosspagechannel.js:482)
(anonymous) @ crosspagechannel.js:482

pesterhazy12:02:36

oh wow, this fixes it

pesterhazy12:02:38

--- a/index.html
+++ b/index.html
@@ -1 +1,7 @@
+<html>
+<head>
+</head>
+<body>
 <script type="text/javascript" src="out/main.js"></script>
+</body>
+</html>

pesterhazy12:02:21

<body>
<script type="text/javascript" src="out/main.js"></script>
</body>

pesterhazy12:02:40

<script type="text/javascript" src="out/main.js"></script>
that doesn't

pesterhazy12:02:12

I thought that browsers always added body and head if it was missing in an html file but apparently not

pesterhazy12:02:31

@maksimrv looking at your specific error, I think the warnings you mentioned can be safely ignored

pesterhazy12:02:57

I was able to get it to work with https://github.com/swannodette/mies, which is similar to Quick Start (there's a section on how to create a browser repl)

pesterhazy12:02:06

No matter which browser, if I open index.html from the Quick Start REPL section using a file:// url, I get

Uncaught Error: URI file:/robots.txt is invalid for field ppu
    at new goog.net.xpc.CrossPageChannel (repl:2457)
    at Function.clojure.browser.net.xpc_connection.cljs$core$IFn$_invoke$arity$0 (repl:2540)
    at clojure.browser.net.xpc_connection (repl:2539)
    at clojure.browser.repl.start_evaluator (repl:3043)
    at repl:3052
    at Object.goog.events.fireListener (repl:2229)
    at goog.events.handleBrowserEvent_ (repl:2232)
    at repl:2221

pesterhazy12:02:58

It works if I start an ad-hoc web server to serve index.html on any port.

pesterhazy12:02:17

That seems like an issue with the Quick Start guide to me.

victorvoid12:02:29

Hey brothers how can I create a action in form to go router ? I'm using secretary, I'm using e.preventDefault but I didn't find how to use to "go url" I puted in my button with type "submit", if I use with :href "/route" it's working ;/

pesterhazy12:02:28

I've created an issue at the clojurescript-site repo: https://github.com/clojure/clojurescript-site/issues/51 - @dnolen, let me know if there's a better place to report issues with the guides

danielgrosse13:02:56

@dnolen via trial and error I discovered the possibility to use goog.modules as dependency. If the argument {'module': 'goog'} is added to the dependency entry in cljs_deps.js, the module is loaded and the namespace available. But currently it seems not supported via compiler options. Are there any plans to add the support?

maksimrv13:02:04

@pesterhazy thanks, I have installed mies but have the same problem https://content.screencast.com/users/maksimrv/folders/Jing/media/0e3eadab-1681-4efc-a1d7-52a06ed386d8/00000399.png Am I right that repl should start in the terminal where we run './scripts/brepl'?

maksimrv13:02:16

I have used server which is started with repl on 9000 port but If I run simple python server (python2.7 -m SimpleHTTPServer 8080 ) and go to localhost:8080 the problem is same ...

maksimrv13:02:31

Also, I have checked zsh, bash and other shells .. same effect

pesterhazy13:02:00

it starts once you open a browser window showing index.html

pesterhazy13:02:05

so the process is first scripts/brepl then open the browser at the location

maksimrv13:02:21

@pesterhazy my steps 1. Run build (in Terminal) 2. Run repl (in Terminal) 3. Go to page localhost:9000/index.html (in Chrome) 4. Where should I type (+ 1 1)?

pesterhazy13:02:41

do you see "hello world" printer in the chrome console?

maksimrv13:02:45

Nice, but in my case I don't see prompt cljs.user=>

maksimrv13:02:54

I see "hello world" in developer tools

pesterhazy13:02:09

can you try firefox? same problem?

maksimrv13:02:16

and see that frame which connected to repl created

maksimrv13:02:47

but prompt string don't appear

maksimrv13:02:33

But ok I try to experiment with Ubuntu, as I see the problem in infrastructure like terminal, os etc. Thanks!

pesterhazy13:02:09

don't see how an infrastructure problem could be at fault here

pat13:02:11

@maksimrv is the prompt buffered? if you slam enter a few times, does it show up?

maksimrv13:02:57

> if you slam enter a few times, does it show up? No

pesterhazy13:02:29

one possibility is browser caching issues.. that's why I suggested trying another browser

pesterhazy13:02:49

or even restarting the computer may help 🙂

maksimrv13:02:24

@pesterhazy wow you are rigth

maksimrv13:02:32

I have tested on WebKit based browsers

maksimrv13:02:40

but now open Firefox and all work

pesterhazy13:02:08

honestly in my experience the iframe long polling solution has been more flaky than not

pat13:02:15

you can disable caching in devtools btw

pat13:02:25

@maksimrv FWIW if you are a new user, $ lein new figwheel yourappname is the way to go

pesterhazy13:02:26

websocket based repls are more stable (weasel, figwheel)

pesterhazy13:02:44

@pat, it's good to go through the Quick Start

maksimrv13:02:56

@pat I have disabled cache start in incognito open another webkit browser it does not work

maksimrv13:02:12

but in Firefox ...

pesterhazy13:02:18

Quick Start helps you understand how things hang together

pat13:02:22

sure, but spending hours debugging builds is a huge turnoff to cljs in general. skip it, start hacking 🙂

pesterhazy13:02:59

agree, but at some point it's a good idea to do the Quick Start too

pesterhazy14:02:17

also we should help Quick Start become more reliable

maksimrv14:02:23

Thank you @pesterhazy and @pat now I could complete Quick Start guide)

dnolen14:02:22

@danielgrosse I just don’t understand what you are suggesting. If it’s not normally possible in Google Closure we’re not going to bother hacking to make it possible

danielgrosse19:02:03

@dnolen As I read here: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide Closure offers an ES6 like module system. And as ClojureScript now supports these modules as output, I thought this would also work as input. Like

:foreign-libs [{:file "resources/libs/calculator.js"
                :provides ["calculator"]
                :module-type :commonjs}]
Currently, closure libraries which use goog.provide() are detected and used within CLJS. But goog.module() isn't.

dnolen19:02:33

@danielgrosse it seems to me that your mixing up several things here

dnolen19:02:42

the JS module stuff doesn’t have anything to do with goog.module

dnolen19:02:10

so let’s set that aside

dnolen19:02:31

your other point is probably true - you can’t use Google Closure compatible JavaScript code that uses goog.module (not goog.provide/require)

dnolen19:02:43

so file an issue for that with a minimal example

danielgrosse19:02:48

Okay, thank you for the answer. I will create an example for the issue.

tomaas20:02:19

hi, is there a way to make this snippet accept the bootstrap's class "modal"? It works if I add :id on modal div, and :data-target, :data-toggle attributes on the button, but then atom modal? does work in the case use the the modal is closed by clicking on overlay div?

Oliver George22:02:05

From memory the bootstrap modal uses a document.body class to handle the overlay styling.

Oliver George22:02:46

If I that is the case you need to manually add/remove that class. Not quite such a pure view because of that

Oliver George22:02:54

Here's a gist of our wrapper view.