This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-09
Channels
- # beginners (20)
- # boot (4)
- # cider (2)
- # cljs-dev (25)
- # clojure (45)
- # clojure-dev (1)
- # clojure-greece (5)
- # clojure-italy (20)
- # clojure-nl (12)
- # clojure-russia (11)
- # clojure-uk (256)
- # clojurescript (176)
- # data-science (33)
- # datomic (47)
- # docs (1)
- # duct (13)
- # fulcro (54)
- # graphql (24)
- # hoplon (3)
- # jobs (1)
- # leiningen (32)
- # luminus (3)
- # midje (1)
- # mount (2)
- # off-topic (3)
- # onyx (5)
- # overtone (1)
- # parinfer (12)
- # pedestal (4)
- # re-frame (60)
- # reagent (11)
- # reitit (3)
- # ring-swagger (21)
- # rum (1)
- # shadow-cljs (16)
- # spacemacs (23)
- # tools-deps (19)
- # vim (79)
[FIXED] just disable parallel build I'm using the "webpack method" and it's working ok for dev, but when I try "advanced" build, it warns about some goog's namespaces.... I can safely ignore it?
Compiling ["resources/public/javascript/main.js"] from ["src"]...
Jul 08, 2018 10:58:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: target/cljsbuild-compiler-0/inferred_externs.js:39: WARNING - name goog is not defined in the externs.
goog.DEBUG;
^^^^
Jul 08, 2018 10:58:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: target/cljsbuild-compiler-0/inferred_externs.js:40: WARNING - name goog is not defined in the externs.
goog.string;
^^^^
has anyone else encountered this error during closure compilation?
Jul 09, 2018 8:21:42 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /out/cljs/core/async.js:7197: ERROR - Parse error. '}' expected
cljs.core.async.t_cljs$core$async61681.getBas
^
Jul 09, 2018 8:21:42 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /out/js/radiant/test-runner/out/cljs/spec/alpha.js:1120: ERROR - Parse error. ',' expected
cljs.core._STAR_print_fn_STAR_ = ((function (_STAR_print_newline_STAR_61674_61684,_STAR_print_fn_STAR_61675_61685,sb__4432__auto__,ed,arg_spec,temp__5459__auto__,spec
^
Jul 09, 2018 8:21:42 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 2 error(s), 0 warning(s)
ERROR: JSC_PARSE_ERROR. Parse error. '}' expected at /out/js/radiant/test-runner/out/cljs/core/async.js line 7197 : 45
ERROR: JSC_PARSE_ERROR. Parse error. ',' expected at /out/js/radiant/test-runner/out/cljs/spec/alpha.js line 1120 : 166
java.lang.Exception: Closure compilation failed
using: [org.clojure/clojurescript “1.10.126”]
and lein-doo for test running https://github.com/bensu/doo
@biscuitpants looks like that CLJS output files were truncated or did not finish writing. closure probably has nothing to do with this. I have seen similar strange results like this when running 2 instances of the CLJS compile in parallel that write to the same output-dir. or maybe the disk is just full? should get an exception during CLJS compilation then though so I'm just guessing
interesting thanks @thheller - i don’t think more than one instance of the compiler is running. is it possible that a logger could be messing with the writer to the file?
i don’t think the disk is full
no logger no but if you can check the /var/lib/buildkite-agent/builds/BuildkiteSlave-i-08751208534127368-1/cognician/monolith-develop/out/js/radiant/test-runner/out/cljs/core/async.js
if it actually ends in .getBas
ok i’ll do that, trhying another build now
@thheller so it looks like if i turn off :language-in :ecmascript5 :language-out :ecmascript 5
compilation works again 🙂 we had that turned on for a bug in one of our dependencies. luckily, that bug has since been fixed upstream
neither, but with an entirely clean build with the option ON, it breaks. with a clean build, with it OFF, it works
not yet. trying to reproduce the broken situation again. i cleared .cljs/
and now i can’t hit that closure compilation issue again
What’s the state-of-the-art for re-frame table views, with sortable columns, filtering badges, etc?
Is there a component or group thereof that would be a good start?
I use https://react-table.js.org which works well. I do not use re-frame though so can't comment on that
@thheller I’ll check it out.
I'm looking to get a node based cljs.main repl with deps.edn up and running with an nrepl server, so I can connect from cider or proto-repl or anything. Seems like a common need, but I'm flailing 😞 I'm trying to move to deps.edn for new projects, after using lein project.clj until now. Does someone have a pointer to a gist or such maybe?
@vinai you can also try shadow-cljs, it has a good integration with deps.edn and its strait forward to use a node repl with it: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn / https://shadow-cljs.github.io/docs/UsersGuide.html#_node_repl
@bhauman Even with node? This is for a non-browser project. I thought figwheel was intended for browser use (at least that's how I've been using it).
@wilkerlucio Thanks! I will check it out. Would have liked to use plain cljs.main to be honest, just for the sake of understanding the setup better. Still, will try it out.
This seems like good advice for a cljs + figwheel browser repl, but like I said, no luck with node yet. https://gist.github.com/reedho/302fabea63ab3416200462e192c39827
I have this set up in one of my deps.edn
-based projects. The one bit I haven’t explored is the nREPL aspect.
:aliases {:repl {:main-opts ["-m" "figwheel.main" "-co" "compile-opts.edn" "-co" "{:main,my-project.core}" "-ro" "repl-opts.edn" "-d" "target/dev" "-t" "node" "-r"]}
:build-dev {:main-opts ["-m" "cljs.main" "-co" "compile-opts.edn" "-d" "target/dev" "-t" "node" "-c" "my-project.core"]}
:test {:main-opts ["-m" "cljs.main" "-co" "compile-opts.edn" "-d" "target/test" "-re" "node" "-m" "my-project.runner"]}
:build-prod {:main-opts ["-m" "cljs.main" "-co" "compile-opts.edn" "-d" "target/prod" "-O" "simple" "-t" "node" "-c" "my-project.core"]}}}
Yeah, I’m willing to try that @bhauman. Just exploring different ways to do this myself. 🙂
its just that having a stable unique name makes repl connections and automatic output-dirs easier to isolate
Thank you very much, this is great. I am unfortunately on a meeting call atm, but am eager to try it out!
@bharathmuraleedharan There is also a #cljsrn channel if you don’t get help here
Hi. Am I right in assuming that the :pseudo-names flag should not make any difference to the dead code elimination?
I have a situation where my app runs fine with :pseudo-names true, but fails with a "is not a function" error when its false. Stepping through the code in the browser debugger seems to suggest that the error happens in a React function, but there should be no UI stuff involved at this point. Stepping through with pseudo-names on, React is nowhere to be seen
(merge validated-word
(if (contains? (:next validated-word) :end)
(parse accumulated-words)
{:valid-cmd false}))
the parse function is a javascript thing, but I can tell it finishes its job by littering the code with console.log statements. The failure seems to happen in merge itself
I can try moving the call to parse out into a let binding to see if it fails earlier
Yes, it ran passed the parser, and I printed the result of the parsing which is just a map. It still crashes in the call to merge
(defn validate-with-parser
"transform result of parsing s into a predictable hash"
[s]
(let [parser-js-response (build-cmd (string/trim s))
parser-response (js->clj parser-js-response :keywordize-keys true)]
(when-not (helpers/d "parser-response type " (:type parser-response))
(helpers/error-log! "WARNING! Parser disagrees with Rose"))
{:command parser-response
:type (:type parser-response)
:valid-cmd (not (nil? (:type parser-response)))}))
sorry, I renamed validate-with-parser to parse in the first snippet. "validate-with-parser" is the actual function called, and build-cmd is an even thinner wrapper:
(defn build-cmd
"Wrap the javascript RAIRD syntax parser. Returns cmd objects that can be
sent to server. Makes exceptions look like regular responses"
[s]
(helpers/d "Calling parser with " s)
(try
(.parse js/parser s)
(catch :default e e)))
yes, I log the response from validate-with-parser (which is now run before the merge in a let), and it prints out the expected map
But if this is an externs thing, should it not fail even with :pseudo-names enabled?
no, because I've littered the code with console.logs, and then searched for those strings in the compiled code, placed breakpoints and stepped through
:pseudo-names
really can’t tell you anything - in general i find it works only if it fails with :pseudo-names
too
one trick I’ve used that could help find the source of the error, more so than printing
then you can search the advanced compiled code :pretty-print
true for your debug string
I have logging before and after the call to merge. The one before prints, the one after does not. both maps that are fed to merge prints fine
map keys should be immutable JS values (booleans, strings, numbers) or ClojureScript values only
{:command {:type "statOp", :command "tabulate", :variables ["kjon"], :subset nil, :options []}, :type "statOp", :valid-cmd true}
the other map is just s cljs map. not touched by any external js libraries. v looks like a map also
Hi all, I'm trying to run a cljs function using the cli like: clj -m cljs.main -re node -m seeds.core
however I'm getting that it can't find a node dependency (even though it is inside of the node_modules folder). Anyone know what I might be doing wrong?
hmmmm try (js/require
and make sure that you are launching from the root dir of your project
@dnolen I replaced the call to build-cmd with a hardcoded map, and that made the problem disapear. I am somewhat confused, but at least I now know that the problem is indeed the js parser 🙂 Thank you for pointing me in the right direction, and sorry for wasting your time.
Thanks! Using js/require
gives the same error. Note that I don't get this problem when I use cider-jack-in-cljs
and I can build the project fine. It just throws this error when I'm trying to run that individual main
Error: Cannot find module 'aws-sdk'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
guys, does somebody know why i get false
here
(extend-type object
IPrintWithWriter
(-pr-writer [obj writer _]
(write-all writer "blah-blah")))
(print (implements? IPrintWithWriter (js-obj))) ;; => false
@akond implements?
doesn’t check native objects like satisfies?
does. In short, since the printing code doesn’t check satisfies?
you can’t override printing of object
https://github.com/clojure/clojurescript/commit/7d3ce70a1c2f4d54b9044d2e44b62c8252e5dea6
Perhaps it was an oversight, with the last revision in the commit referenced above. Evidently prior to that change it was possible.
What’s the best way to elide some code in Clojurescript? I’ve been using goog-define, but am wondering if I could do so with a macro
@colindresj For library code, goog-define
is better because it is compatible with the AOT cache feature. (See the note at https://clojurescript.org/news/2018-03-28-shared-aot-cache)
I’m running into a funny problem: I am building a small Tic Tac Toe page to get familiar with basic web design, react, ant design, and clojurescript. Here is the snippert of my code: [antizer.reagent/button {:value i :on-click #(do (println “Button: ” (.-value (.-target %))) (re-frame/dispatch [::events/square-clicked (-> % .-target .-value)]))} (or @sq “foo”)] Here is the translated HTML <button value=“7” type=“button” class=“ant-btn”> <span>foo</span> </button> So the text foo is a “span” tag in the button. What i see: Now if i click on the “foo”, the “on-click” handler on the button get triggered, but the “value” is nil. If i click outside the “foo” text (on the actual button) then the value is what i am expecting, in this case “7” I think this is becasue when i click on “foo” text, i am picking up the attributes of the “span” tag and it doesn’t have a “value” attribute attached to it. In this case, why does the “:on-click” handler still get activated? What i want: click anywhere on the button, and extract the correct “value” attribute.
reason for adding a “value” attribute to each button: i have 9 squares for “Tic Tac Toe”, and I am associating a value to each square from 1 to 9. when a square is clicked, I know which square from reading the value attribute is clicked and I can update my DB accordingly and calculate a winner after each click.
Got it, thanks @mfikes
@dhruv1 First a tip: if you put triple backticks around your code, it will format nicely in Slack. Second, I’d recommend passing in value
as a parameter to your component code, like this (or similar)
(defn my-tic-tac-toe-button [value]
[antizer.reagent/button {:on-click (fn [e]
(println "Button:" value)
(rf/dispatch [::events/square-clicked value]))}
(or @sq "foo")])
@manutter51 thanks. the value is associated with the button so I know which button was clicked if you’re asking me to pass in the value, then i am recording the value somewhere else. then how do i know which button was clicked?
What you do is make a button component (which you’ll probably call something nicer than my-tic-tac-toe-button
like I did in my example). Then you’ll build your tic-tac-toe matrix using [my-tic-tac-toe-button 1]
, [my-tic-tac-toe-button 2]
, and so on
Each button will have its own value, which you passed in as the argument to my-tic-tac-toe-button
hmm. that’s actually what I’m doing here is the whole functino:
(defn square [i]
(let [sq (re-frame/subscribe [::subs/square (str i)])]
[ant/button {:value i
:on-click #(do
(println "Button: " (.-value (.-target %)))
(re-frame/dispatch [::events/square-clicked (-> % .-target .-value)]))}
[:i {:class-name "far fa-circle"}]]))
Ok, good, but when you dispatch your event, don’t get value from .-target .-value
, get it from your argument i