This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-01
Channels
- # beginners (41)
- # boot (25)
- # cider (34)
- # cljs-dev (221)
- # cljsrn (1)
- # clojure (191)
- # clojure-dusseldorf (4)
- # clojure-hamburg (1)
- # clojure-italy (8)
- # clojure-poland (1)
- # clojure-russia (22)
- # clojure-spec (27)
- # clojure-uk (91)
- # clojurescript (101)
- # core-async (11)
- # cursive (33)
- # data-science (9)
- # datascript (3)
- # datomic (30)
- # emacs (4)
- # events (4)
- # garden (6)
- # jobs (3)
- # leiningen (8)
- # luminus (39)
- # lumo (2)
- # off-topic (158)
- # om (13)
- # onyx (1)
- # parinfer (22)
- # planck (2)
- # protorepl (5)
- # re-frame (7)
- # reagent (10)
- # remote-jobs (1)
- # ring (1)
- # ring-swagger (20)
- # unrepl (92)
- # vim (11)
the latest cljs has a config for it, actually
Sure thing @akiroz
(defn handler [response]
response)
(defn error-handler [{:keys [status status-text]}]
(.log js/console (str "something bad happened: " status " " status-text)))
(defn get-request-word [a-url]
(GET
a-url
{:handler handler :error-handler error-handler}))
(defn get-url-as-hickory
[a-url]
(let [processed-response (get-request-word a-url)]
(do
(.log js/console "processed-response: " processed-response)
(hc/as-hickory (hc/parse processed-response)))))
(def welcome-url "")
Then the actual call:
(get-url-as-hickory welcome-url)
(The problem is that (:body response) is just returning null, even though I can print the raw HTML str (from the successful request) to the console.)
@chris_ Oh sorry, I got wrong the whole time... the response
from cljs-ajax
is not a ring response map but the actual body. I got it mixed up with another library.
but that code wouldn't work as you expected, GET
doesn't return stuff so you can't so (let [processed-response (get-request-word a-url)]
should be something like this:
(defn url->hickory
"Takes a URL returns Promise of a hickory tree."
[a-url]
(js/Promise
(fn [rsov rjct]
(GET a-url
{:handler
(fn [resp]
(-> resp
hc/parse
hc/as-hickory
rsov))
:error-handler rjct}))))
Could anyone give me a hint how to nail issue which manifests itself with following error:
cljs.user> (require 'react-bootstrap-typeahead)
---- Exception ----
java.lang.RuntimeException : INTERNAL COMPILER ERROR.
Please report this problem.
...
(Full java stack trace follows)
FYI: I’m experimenting with :npm-deps {:react-bootstrap-typeahead "2.0.0-alpha.3" :install-deps true
with figwheel (`0.15.2-SNAPSHOT`)Any tips welcome, thanks!
@pawel.kapala looks like a Closure Compiler problem
@dnolen yep, NPE I guess:
null
Node(NAME animationEnd): /tmp/example/node_modules/dom-helpers/transition/properties.js:17:4
animationEnd = void 0;
Parent(VAR): /tmp/example/node_modules/dom-helpers/transition/properties.js:15:0
var prefix = void 0,
java.lang.NullPointerException :
---- Exception Stack Trace ----
java.lang.NullPointerException: null
at com.google.javascript.rhino.Node.replaceWith (Node.java:872)
com.google.javascript.jscomp.ProcessCommonJSModules$RewriteModule.updateNameReference (ProcessCommonJSModules.java:1075)
com.google.javascript.jscomp.ProcessCommonJSModules$RewriteModule.maybeUpdateName (ProcessCommonJSModules.java:954)
com.google.javascript.jscomp.ProcessCommonJSModules$RewriteModule.visit (ProcessCommonJSModules.java:712)
I’d have to try to isolate it and report it https://github.com/google/closure-library, right?
@pawel.kapala Closure Complier, not library
duh 🙂 thanks!
On top of my issue with the DCE https://clojurians.slack.com/archives/C03S1L9DN/p1501573388897284?thread_ts=1501519537.283529&cid=C03S1L9DN I'm seeing this in my output js:
ReferenceError: $cljs$core$MultiFn$$ is not defined
(opti :advanced with pretty-print and pseudo-names, else it's a random symbol .dd
or something)
And indeed, the code use the variable without initialising it before:
$cljs$core$MultiFn$$.prototype.$cljs$core$IMultiFn$_add_method$arity$3$ = ....
Seem's to be in the core, is there anything I can do to find the cause for the issue?@lsenta sorry I don’t have time to look at this, I’ve already said that I don’t think your approach is going to be fruitful
so whatever conclusions you may be arriving at about DCE I would not put a much stake in it yet
Hey David, this is super confusing, could you at least open the file and let me know what's not done in the clojurescript way?
you seem to say my approach is broken, I redid all my code using the default, dumb goog-define, I really don't see what's "my" in this
DCE is whole program optimization, Google will crawl everything to determine dependencies at the level of values
side note: this stuff is pretty well covered in Google Closure documentation, and it’s pretty easy to find more details on the Closure Compiler mailing list, the O’Reilly book is also a great resource on what expectations you should have
I'm still very frustrated by the impression that one switch-case is optimized and not the other is a bug. And I don't see how any of your answers adress this
this is why (js/console.log "Hello world")
is just a couple of K under advanced compilation
this is why code motion works - you have to be very very careful if you want something specific to happen
David, is there anyone else that'd have time to read these 50 lines of cljc and at least check that the bug is in my code?
@lsenta a better use of your time is to just write the same thing in JS and see what happens
then you also have a example which you can ask about on the Closure mailing list if something seems wrong
that's a fair point, will you review the js and the demo repo if I find something doesn't match?
if I was you however I would not spend any more time on this - I would just use the provided :modules
code splitting feature and spent my time on more interesting stuff
and change your configuration in that the catalyst.js
does not require the bots
but the bots
register themselves on load
:modules
already solve exactly what you are trying to do if I read everything correctly
instead of trying to figure out why code doesn’t get DCE’d you should probably focus on not feeding the code into closure in the first place
(doseq [namespace '(project.a project.b project.c)]
(require `'~namespace)
;; (require namespace)
)
Is there any way to require a namespace from a list of namespaces. I always get
Arguments to require must be quoted. Offending spec
@U0CAUAKCG you can't require
dynamically in clojurescript
For my usecase I can just access the list like this
(keys (get-in @cljs.env/*compiler*
[:cljs.analyzer/namespaces
'somename.space
:requires]))
@deadghost pr-str
@pesterhazy doesn't seem to actually prettify it
(with-out-str (clojure.pprint/pprint {:foo :bar}))
@pesterhazy nope still not seeing any pretty printing
@deadghost works for me: https://github.com/binaryage/dirac/blob/3b3451f59a19e344f11d5c58a5b2b7b4c93a74eb/src/shared/dirac/utils.cljs#L152-L156
@akiroz Thank you! -- I tried out httpurr and cljs-http, and I think the underlying issue is that I don't understand asynchronous programming in the slightest! So I'm going to work on that.
@pawel.kapala if you end up creating a minimal closure repro I’d be interested in adding that somewhere to the CLJSJS docs, it’s something more people will bump into with the new module processing stuff
@martinklepsch I've spent some time minimizing dom-helpers, so I might have something for you, prolly tomorrow.
awesome, I wish much success 🙂 😛
The problem is probably this one: https://github.com/google/closure-compiler/issues/2450
Var from combined var statement being exported
var prefix = void 0,
transitionEnd = void 0,
animationEnd = void 0;
exports.transitionEnd = transitionEnd;
This is fixed in Closure-compiler master, but combined var statements are broken in another way currently
(This is the problematic file from dom-helpers: https://unpkg.com/[email protected]/transition/properties.js)