This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-03
Channels
- # bangalore-clj (1)
- # beginners (160)
- # boot (174)
- # cider (57)
- # cljs-dev (16)
- # cljsrn (5)
- # clojure (144)
- # clojure-argentina (1)
- # clojure-austin (6)
- # clojure-finland (2)
- # clojure-france (4)
- # clojure-russia (185)
- # clojure-serbia (4)
- # clojure-spec (61)
- # clojure-uk (126)
- # clojurescript (212)
- # community-development (7)
- # core-async (2)
- # cursive (17)
- # datomic (210)
- # emacs (10)
- # euroclojure (2)
- # gsoc (23)
- # hoplon (86)
- # jobs (8)
- # lein-figwheel (9)
- # luminus (19)
- # lumo (12)
- # off-topic (4)
- # om (14)
- # om-next (6)
- # pedestal (38)
- # perun (11)
- # planck (35)
- # portland-or (2)
- # ring (1)
- # ring-swagger (28)
- # specter (6)
- # untangled (6)
- # yada (2)
With 1.9.456 it appears that if you have JavaScript files in foreign-libs that use functions like require()
but are NOT any of the common module types, its not possible to upgrade without breaking the build with errors like “something.js is not a relative path”. Its an unusual case for that project as the module system is a proprietary one that pre-dates commonjs/es6 etc by many years, its one that is loading JS from LDAP.
I guess in other words I can’t find a way to turn off the new foreign libs module behaviour as with .293 this project built fine.
@superstructor I’ve been aware that something like that may happen - it would be super useful to put together something minimal and open a ticket
I’d like anything than used to work to at least be supported even if it means a flag of some kind
@superstructor also this issue should really only be a problem for dev
the way the we bootstrap the Node.js environment for hot-loading and global require to preserve Closure semantics is highly unusual
ok thanks @dnolen, yeah its an unusual case as its not targeting Node.js. Its running inside SpiderMonkey threads within a C++ server, and that environment provides require()
to load JavaScript from LDAP servers. The problem I guess is that it is now attempting to interpret require()
in foreign-libs as meaningful at dev time, when in this case it is only meaningful at runtime ?
@superstructor hrm then the problem is not what I think
Has anybody toyed with 'eval'? I'm having trouble getting to work properly outside of figwheel
does not appear to be using :target :nodejs
, it is using the default which is browsers according to docs @dnolen
@superstructor then there shouldn't be a problem
later I’ll try to cut it down to a minimal example, and raise a ticket? @dnolen
@superstructor yes please thanks
ok thanks 🙂
@bpicolo ClojureScript doesn’t include the compiler normally that’s why you can’t eval
https://bpicolo.github.io/cljs-presentation/#!/presentation.collections It's unhappy about defn, you see
I don’t have much time right now to look into this - but a quick look at that url doesn’t show a main entry point file
@bpicolo I might know what's wrong by looking at the example
did you (set! (. js/cljs -user) #js {})
somehwere?
you may need to create that object
I figured it just doesn't know where to define bits but had no idea what that would mean 🙂
this is how Lumo bootstraps its environment: https://github.com/anmonteiro/lumo/blob/master/src/js/cljs.js#L85-L88
namespaces in Google Closure are reified as JS objects
and you need to create the cljs.user
namespace upon starting
@bpicolo I just evaluated cljs.user = {}
at Chrome devtools and the examples started working
so that'll solve your issue
check that builds are not cached etc.
I don't know 🙂
I just had the same problem before and remembered it
Yeah, that's awesome, thanks. Being able to host a presentation so people can follow along and toy with examples seems well
doing stuff with bootstrapped is still considered advanced - we should probably put together a guide to suss out stuff like this
@anmonteiro @dnolen ^^ that made it compile perfectly under :simple
A question about performance, is it true in clojurescript as well that protocols are faster than multimethods?
vikeri: Looking at the generated code, I suppose protocols are faster, although I have no idea of how much.
protocols are backed by JavaScript's native inheritance mechanism, so you can expect it to be well optimized by JS engines. ClojureScript's standard library is implemented with protocols at the bottom, so you can expect them to be fast 🙂
I wrote an architectural overview of the nREPL, and I'd be chuffed as nuts if you read it. “If you give a mouse an nREPL” https://medium.com/@eniessenderry/if-you-give-a-mouse-an-nrepl-8f309faa6bc3
then he'll ask for a glass of cider?
Wondering if someone can help with the following...
;; Foo namespace
(ns app.foo)
(defn a [])
(defn b [])
;; Bar namespace
(ns app.bar
(:require [app.foo :as foo]))
(def my-func-name "a")
;; How do you call the function a in the foo namespace
;; from a string or keyword. E.g. foo/a
;; Doesn't work
(foo/my-func-name)
@ashnur lists in Clojure(Script) are immutable, they can't be mutated
Do you mean a JavaScript array?
no, i mean the abstract concept of grouping things together such that same element can be included multiple times and the group's elements have a well defined order relative to each other. the english meaning of the word list.
I don't understand what you want. We're back to my first point. You can't mutate things in CLJS
what you can do it apply a transformation to some or all elements of a list
Returning a new list
look, if you don't understand, why you think repeating stuff we established is irrelevant will help me ? 🙂
ashnur: I don't want to speak for @anmonteiro here, but this wasn't exactly a respectful answer to somebody who's trying to help. Especially given that I suspect everyone here would've told you exactly the same thing
ashnur what do you expect to happen when you mutate these things?
doseq should work provided the things are mutable
(doseq [item [thing1 thing2]] (some-mutating-call item))
@ashnur you won't find the list 'concept' in cljs, or anywhere else, there are implementations, like clojurescript lists, or javascript arrays
i think ultimately i will have to do some ugly stuff to reach this kind of performance though https://bl.ocks.org/ashnur/910a4fdc3556a32f435f248c04108c8f
generally, just looping over a bunch of things is not the bottleneck.
yeah, that's why i will check it first, now that i see it's not as straightforward as i hoped
any idea why upper-case
would get mangled during advanced compilation? they're functions known to clojure:
(:require [clojure.string :refer [join split upper-case]])
(defn uncamel [s]
(join (update 0 (split (join " " (split s #"(?=[A-Z][^A-Z])")) "") upper-case)))
Uncaught TypeError: Cannot read property 'toUpperCase' of null
uhg, that's totally right, i merged two errors together in my head. thanks for the reality check.
no. i am trying to create a javascript array that i can give to d3 so d3 will mutate it and then i will read the new values
okay, for the sake of argument (just trying to understand what you mean), can you give an example array and an example d3 function?
"for the sake of argument". i love how only i am called out on being "disrespectful", yet every time I ask for help someone wants to ARGUE
joshkh https://gist.github.com/ashnur/910a4fdc3556a32f435f248c04108c8f#file-index-js-L51
you can see what it does here https://bl.ocks.org/ashnur/910a4fdc3556a32f435f248c04108c8f
does anybody see anything immediately wrong with this cljsbuild profile & my directory structure?
ooookay. well, i'm not totally sure who/what conversation you were having before or what got you riled up, but maybe this will help show how d3 and clojurescript can work together: http://blog.getliquidlandscape.com/2015/01/08/practical-time-series-visualization-using-d3-om/
but in IE, Edge and the webkit browsers canvas is at least a hundred times faster and that's not an exaggeration, you can join the d3 community and ask them too
yes, you're absolutely right that canvas is faster than svg! i meant your question about using d3 with cljs, that's all.
so it seems like it can't find my :main
file but it's in the correct location (if I'm understanding the structure correctly)
@jondale Try (@(resolve (symbol "foo" my-func-name)))
.
@henriklundahl Thanks, will try that
@samueldev yes it can’t load goog/base.js
note the url - not sure how loading stuff from the file system works for Explorer on Windows
@samueldev seems like you need setup a webserver and specify :asset-path
Short question: If I want to leverage node modules on the web, I'll am likely stuck with webpack for the time beeing, right? In a cljs app that is.
@dnolen Cutting edge is fine with me. Got a rough vision how to get node modules working on the web?
regarding the recent clojurescript version announcement, is there anything that can be leveraged to facilitate asynchronous module loading?
this lead me down a bit of a rabbit hole https://rasterize.io/blog/cljs-dynamic-module-loading.html
but note by “module” here Google Closure means code splitting - not loading an individual namespace
the last time i tried react threw a tantrum. i'll have to take another crack at it. thanks. 🙂
@dnolen On the web the "Node Modules" approach outlined ends up failing due to process
undefined. 🙂
@deas for now you can hack around it. see this for example: https://github.com/anmonteiro/om/commit/686921531c7bcbbd75804e6b9240b12d92eaaa5f
there are also deeper problems not so easily fixed like Google Closure’s handling of the hoisting semantics
or make a process
ns with a env
goog-define
and set it in your compiler build settings
@anmonteiro Thanks.
How do I request my company be added to this list? https://clojurescript.org/community/companies We’ve been using CLJS and Om Next very happily for some time now.
Oh on the Clojure site it says > Below is a partial list of some companies using Clojure or ClojureScript. Most of this information comes from direct contacts, presentations, or other online resources. If you would like to be added or removed from this list, please contact <mailto:[email protected]|[email protected]>.
Maybe that should be on the Clojurescript site also?
@currentoor you can probably submit a PR to the clojurescript-site repo
@anmonteiro thanks!
how can I elide certain deps for prod compiles like loggers, devtools or whatever else I want?
You use the :preloads
compiler options https://clojurescript.org/reference/compiler-options#preloads.
You make separate namespaces for you development files e.g. dev.logger
or dev.tools
and then load them into the development build via :preloads '[dev.logger dev.tools]