This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-26
Channels
- # announcements (6)
- # beginners (88)
- # calva (12)
- # cider (13)
- # cljs-dev (27)
- # cljsrn (2)
- # clojure (68)
- # clojure-argentina (2)
- # clojure-dev (10)
- # clojure-europe (1)
- # clojure-greece (1)
- # clojure-italy (5)
- # clojure-nl (15)
- # clojure-spec (33)
- # clojure-switzerland (1)
- # clojure-uk (10)
- # clojurescript (121)
- # clojutre (3)
- # code-reviews (2)
- # core-async (1)
- # cursive (10)
- # data-science (1)
- # datomic (21)
- # emacs (10)
- # events (1)
- # fulcro (25)
- # graphql (6)
- # joker (4)
- # kaocha (12)
- # lambdaisland (3)
- # music (2)
- # off-topic (112)
- # om (2)
- # re-frame (25)
- # reagent (29)
- # reitit (93)
- # rewrite-clj (2)
- # shadow-cljs (18)
- # slack-help (4)
- # spacemacs (8)
- # tools-deps (1)
- # vim (2)
- # yada (5)
Does anybody happen to know if pre and post conditions are stripped out in advanced compilation?
On defn
RTFM
lol
I can dynamically require at the top level in a cljs REPL, but given that it seems to only be supported to do require
at the top level in cljs, anything you can do to restrict your technique to require only at the top level is good.
I can see it being potentially useful in a code splitting context if you were trying to keep upfront load really tiny
Lazy loading and whatnot
I would be perfectly happy if ClojureScript allowed me to do non-top-level require
s -- I just do not know how to do it, and it might be impossible for implementation reasons that I do not yet know.
it isn't possible. partly due do :advanced
optimizations not allowing that and partly because all IO is async in JS
hi, js/setTimeout function doesn't work for me for reloading page automatically. Is there anybody can figure out why?
What’s the code you’re running?
Hello guys how can i set browser back button to refer to specific page ? for example if i do a payment of something and need if the payment is completed and user want to back, he don't get the previous page but to specific other page how can you guys handle this ?
probably want to use https://developer.mozilla.org/en-US/docs/Web/API/History_API
Also checkout goog.History
you might also like this -> https://github.com/clj-commons/secretary
hi. when reagent/render method called? actually how render function realize browser page difference for refreshing?
It’s called when mounting the app, when a change is detected in an atom that the component depends on, or when instructed to do so by a parent component (for example, a component might re-render when called from a for
, and the for
re-runs).
hi guys
is this line right? (set! (.. js/window -onpopstate) (fn [] (.go js/history -1)))
to change event of browser back to previous page?
maybe i can change -1 to whatever value right?
can i confirm? :npm-deps
is considered deprecated and should prefer to use the webpack guide?
my personal suggestion if your workflow allows is to use figwheel's webpack
it saves a lot boilerplate
@dpsutton not deprecated but we're not working on improving it for the browser use case
thanks @dnolen. We're targeting browser and would like to reuse some Icon -> SVG React components. Investigating :npm-deps vs webpack and i thought i had remembered the webpack guide was considered the more modern and supported way forward
cljs-bean has ()
in some places without single-quoting and I thought that that’s usually a syntax error, why is it not? https://github.com/mfikes/cljs-bean/blob/69f258871c1b5cb7051a3e4a0b93d7f3380dcbad/src/cljs_bean/core.cljs#L202
And is there a way I could make a custom type that wraps a bean so that ILookup works as if it’s a bean but also extend these things with additional protocol methods? I guess specify!
would work?
let me know if the question is clear and I’ll try to rephrase / elaborate
I suppose you have at least three alternatives to consider:
1) specify!
, which affects a single instance
2) Extending the cljs-bean
types to new protocols
3) Making your own custom deftype
that wraps a bean, perhaps implementing ILookup
by delegating to the wrapped bean.
Thanks, that’s roughly what I considered. With option 3 is there a way to achieve that in a somewhat concise way? I assume I would have to list every protocol I want to delegate to the bean?
Are there any downsides to using specify?
@martinklepsch not a syntax error. it is allowed syntax for an empy list.
yeah I didn't know that either
https://github.com/clojure/tools.reader/blob/master/src/main/cljs/cljs/tools/reader.cljs#L219
quote means read-but-don't-evaluate
but you don't need that because (eval ()) => ()
the "special" case is non-empty lists
in general, almost everything in clojure evaluates to itself, symbols and non-empty lists are the exceptions
Am I right in the understanding that using cljs-bean records will not yield the same fast-equality check characteristics that persistent data structures provide? (thinking in the context of using it in a React app)
Are you referring to https://github.com/mfikes/cljs-bean ?
Oh, I see you are, from the backlog 🙂
Well, if the underlying library you are using employs identical?
then cljs-bean
instances work properly with identical?
because they are immutable. (But not persistent—in many cases they are closer to CoW).
If you are curious about the CoW aspect, here is a concrete example of that, where assoc
results in a mutation being made to the result of a goog.object/clone
call: https://github.com/mfikes/cljs-bean/blob/master/src/cljs_bean/core.cljs#L283
Awesome, thanks 🙏 Given that a big number of people use react maybe that’s something worth documenting more explicitly
@scknkkrer mostly scattered legends and whispers
I'm familiar with quite a few if you have any questions
I know that Google Closure trash out my symbols.
Since when I find out this; I use only goog.object/getValuesByKeys
to access object properties.
But, What about setting them ?
ahhh yes that's the main thing. what also works is js/thing.attribute.method
but the (.. thing -attribute method)
doesn't always work reliably
and no -- there's no good way that I know of to prevent advanced compilation from occasionally trashing some of your symbols, but when I found the two solutions you mentioned I stopped investigating
core.cljs:10727 Uncaught TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
at $cljs$core$thisfn$$ (core.cljs:10727)
at Function.cljs.core.clj__GT_js.cljs$core$IFn$_invoke$arity$variadic (core.cljs:10738)
at cljs.core.clj__GT_js (core.cljs:10713)
at events.cljs:20
at std_interceptors.cljc:115
at std_interceptors.cljc:114
at re_frame.interceptor.invoke_interceptor_fn (interceptor.cljc:68)
at re_frame.interceptor.invoke_interceptors (interceptor.cljc:106)
at re_frame.interceptor.execute (interceptor.cljc:199)
at re_frame.events.handle (events.cljc:65)
@goomba, an interesting stack-trace.what's the offending line of code? events.cljc line 65
it looks like
or is that the re-frame code
so I take it you think that this is a munging issue?
are you able to access the javascript that you think is being munged from the console?
oh and you said that this does work with no optimizations? Did you try :simple
?
Keep throwing me that; https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]=
sorry, had to grab some lunch, how's it going?
whitespace
optimization flag changed my problem.
(index):305 Uncaught Error: Namespace "process.env" already declared.
at Object.goog.provide ((index):305)
at env.cljs:9
says, now.is this in figwheel? what command are you using to compile?
and is this a runtime error or compiletime error?
what command are you using to compile?
I’m using a project template called descjop
.
But, I’ve add some libraries like re-frame and secretary, and keep up-to-date some of them.
:dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.520" :exclusions [org.apache.ant/ant]]
[re-frame "0.10.6"]
[org.clojars.scknkkrer/suluk "0.0.20"]
[figwheel-sidecar "0.5.18"]
[org.clojure/core.async "0.4.490"]
[reagent "0.8.1"]
[ring/ring-core "1.5.1"]
[figwheel "0.5.18"]
[clj-commons/secretary "1.2.4"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-externs "0.1.6"]
[lein-shell "0.5.0"]
[lein-figwheel "0.5.18" :exclusions [org.clojure/core.cache]]]
and... what's the command? lein cljsbuild once
...?
{:source-paths ["src_front" "src_front_profile/desktopnew_front/dev"]
:incremental true
:jar true
:assert true
:compiler {:output-to "app/dev/js/front.js"
:externs ["app/dev/js/externs_front.js"]
:warnings true
:elide-asserts true
;; :target :nodejs
;; no optimize compile (dev)
:optimizations :none
:output-dir "app/dev/js/out_front"
:foreign-libs [{:file "app/dev/js/bundle.js"
:provides ["react" "react-dom"],
:requires ["react" "react-dom"]
:global-exports {react React
react-dom ReactDOM}}]
;; simple compile (dev)
;;:optimizations :simple
;; advanced compile (prod)
;;:optimizations :advanced
;; :source-map "app/dev/js/test.js.map"
:pretty-print true
:output-wrapper true}}
This build just fine.
But this;Here is the production
:
{:source-paths ["src_front" "src_front_profile/desktopnew_front/prod"]
:incremental true
:jar true
:assert true
:compiler {:output-to "app/prod/js/front.js"
:externs ["app/prod/js/externs_front.js"]
:warnings true
:elide-asserts true
:foreign-libs [{:file "app/prod/js/bundle.js"
:provides ["react" "react-dom" "create-react-class" "react-dom/server"]
:global-exports {react React
react-dom ReactDOM
create-react-class createReactClass
react-dom/server ReactDOMServer}}]
:output-dir "app/prod/js/out_front"
:optimizations :whitespace
:source-map "app/prod/js/test.js.map"
:pseudo-names true
:pretty-print true
:output-wrapper false}}
are your global exports different for a reason?
also, if you're using reagent
and re-frame
from any recent version, you shouldn't require react or react-dom as foreign libs
ah, that's probably what the externs.js
how are you including reactstrap?
Directly via Webpack. Like;
import React from 'react';
import ReactDOM from 'react-dom';
window.React = React;
window.ReactDOM = ReactDOM;
window.ReactStrap = require("reactstrap");
window.TextMask = require("react-text-mask");
window.TextMaskAddons = require("text-mask-addons");
gotcha. and what's going on at env.cljs
line 9?
Compiling ["app/prod/js/front.js"] from ["src_front" "src_front_profile/desktopnew_front/prod"]...
WARNING: var: suluk.response/res->text is not public at line 21 app/prod/js/out_front/suluk/constants/constants.cljs
WARNING: get already refers to: cljs.core/get being replaced by: suluk.requests.get/get at line 7 app/prod/js/out_front/suluk/requests/get.cljs
WARNING: get already refers to: cljs.core/get being replaced by: suluk.requests.core/get at line 7 app/prod/js/out_front/suluk/requests/core.cljs
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/object-assign/index.js:4: WARNING - constant $jscomp assigned a value more than once.
Original definition at [synthetic:base] :26
var $jscomp = $jscomp || {};
^^^^^^^^^^^^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:1614: WARNING - unreachable code
return "";
^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:3242: WARNING - unreachable code
return null;
^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:3272: WARNING - unreachable code
return null;
^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:5296: WARNING - unreachable code
return null;
^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:5852: WARNING - unreachable code
return namespace;
^^^^^^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:5861: WARNING - unreachable code
var parentNamespace = parentHostContext;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:7567: WARNING - unreachable code
return false;
^^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:16495: WARNING - unreachable code
return findHostInstance(component);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/sckn/projects/business/qulak/desktopnew/app/prod/js/out_front/node_modules/react-dom/cjs/react-dom.development.js:16932: WARNING - unreachable code
return findHostInstance(componentOrElement);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aug 26, 2019 9:43:29 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 10 warning(s)
Successfully compiled ["app/prod/js/front.js"] in 41.537 seconds.
I meant what is the code in your file env.cljs
on line 9 (where the stacktrace says the error occurs)
(ns process.env
"A shim namespace for the Node.js process library")
(goog-define NODE_ENV "development")
hmm.. well according to that error message, process.env
is being declared multiple times from different files
😕 so whatever it is looks like it isn't going to be an easy fix, sorry. I don't think there's much more I'd be able to do from here
No problem, thank you for your help. If I get the error, I’ll share the solution.
good luck!
@goomba,
It’s about externs.
I did prove my hypothesis.
I removed foreign-libs
from compiler options.
Added webpack file externally.
hey great!! good work!!
I use figwheel-main
I’m using a couple of external libraries that I should take care of. That’s the problem.
good morning guys - having issues here compiling a cljs project using a scoped npm package. always complains with
No such namespace: @microsoft/office-js, could not locate _CIRCA_microsoft_SLASH_office_js.cljs, _CIRCA_microsoft_SLASH_office_js.cljc, or JavaScript source providing "@microsoft/office-js" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file src/cljs/smx_ms_outlook_addin/app.cljs
Try compiling with http://shadow-cljs.org/. It’s considerably easier to use NPM libs with Shadow.
I'd also recommend figwheel-main
with deps.edn
using the webpack approach
thanks guys but don’t think can switch to shadow or figwheel for that project. only can stick to boot-clj and clojurescript’s npm-deps
compiler option. works very well when package is NOT scoped. only giving me headaches when scoped.
wondering if it’s this bug https://clojure.atlassian.net/browse/CLJS-2633 ? if you read the latest comment then it is unclear on that ticket if it’s already fixed or not?