This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-27
Channels
- # aleph (3)
- # beginners (89)
- # boot (198)
- # cbus (4)
- # cider (11)
- # clara (2)
- # cljs-dev (27)
- # cljsrn (4)
- # clojure (141)
- # clojure-austin (4)
- # clojure-italy (11)
- # clojure-nl (1)
- # clojure-poland (2)
- # clojure-russia (35)
- # clojure-spec (33)
- # clojure-uk (55)
- # clojurescript (111)
- # core-logic (15)
- # cursive (2)
- # datascript (47)
- # datomic (132)
- # emacs (4)
- # jobs (1)
- # lein-figwheel (13)
- # leiningen (15)
- # lumo (20)
- # off-topic (110)
- # om (8)
- # onyx (20)
- # parinfer (2)
- # protorepl (1)
- # re-frame (36)
- # reagent (5)
- # remote-jobs (1)
- # ring (2)
- # ring-swagger (5)
- # specter (6)
- # uncomplicate (3)
- # unrepl (77)
In clojure, it’s easy to take a paginated REST endpoint and turn it into a lazy-seq and call take against it, but you can’t do that in clojurescript. Is there a nice strategy for dealing with async paginated endpoints?
core.async is probably the tool for that
thanks. looks like lazy-seq on an async response isn’t going to happen. Just going to stick with reactive logic
indeed, lazy seqs are essentially synchronous, so not compatible with event-driven I/O
probably lots of you using reagent yes? how the heck do you deal with touch events in a case where the element starting the touch event isn't the one that's supposed to track touchmove events? (like drag this element, but the container tracks the position)
A little PSA: If you use Polyfills (which you'll need to if you want to use React 16 which needs Map/Set polyfills) you'll need to load any 3rd party code (such as React) AFTER your CLJS compiled code. Or otherwise the React code will load without seeing the polyfills. This will result in an error in older IE's which rely on the polyfills. Reason: React will not see the Symbol.iterator
and map it to undefined and fallback to @@iterator
. However the polyfill from google closure compiler will later define it and CLJS will define all iterables with a different Symbol which then mismatchs and will error.
@rauh, so just load the polyfill as a separate script tag at the very top of your head?
@pesterhazy Is there a way to output the polyfills that GCC generates into a separate file?
I don't know - I know GCC only as a dumb user
but shouldn't all polyfills be equivalent?
frankly that already sounds completely wrong as I'm saying it
@pesterhazy GCC will look at your code and add polyfills at the beginning of your output only for the constructs that you actually use (so for instance now with React I added a dummy (def ^:export polyfill-gen #js[(js/Map.) (js/Set.)])
@rauh you can force GCC to inject things, not sure there is an option for it in cljs yet
@thheller Yeah that's what I'm using. See: https://dev.clojure.org/jira/browse/CLJS-2026
Just spend a few hours trying to debug a problem with npm/yarn. Two different versions of yarn resulted in different yarn.lock files with vastly different behavior. One ended up including multiple versions of React in the bundle which I didn't know was possible.
@pesterhazy that’s interesting, at the top level? that said I’m not sure we can really do anything about stuff like that
@dnolen I should have mentioned, this was using webpack, not using npm-deps yet
so nothing for clojurescript to do. I don't think both versions were at the top level, actually I think that's impossible
but one dependency pulled in its own version, resulting in the dreaded Uncaught Error: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component’s render method, or you have multiple copies of React loaded
error
npm's dependency resolution scheme is way too complicated, if even different versions of yarn
cannot agree on how to resolve conflicts
it works in figwheel but the google closure compiler won't build
Jul 27, 2017 2:44:20 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /Users/laurent/dev/singulargarden/awkward-majine/src/cljs/awkward_majine/buffers.js:7: ERROR - this language feature is only supported in es6 mode: arrow function. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT to enable ES6 features.
const numberOfChannels = buffers.map(x => x.numberOfChannels)
...
ERROR: ES6_FEATURE. this language feature is only supported in es6 mode: const declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT to enable ES6 features. at /Users/laurent/dev/singulargarden/awkward-majine/src/cljs/awkward_majine/buffers.js line 42 : 4
@lsenta Yes, it should be documented on the cljs website (I'm too lazy to find the link)
see https://github.com/clojure/clojurescript/wiki/Compiler-Options#language-in-and-language-out
i know clojurescript doesn’t support resolve or intern, but is there a way to use the js environment to achieve the same effect?
for example, using a :preloads while building for dev
where my preload file might redefine a function implementation?
ClojureScript master now has resolve
https://clojurescript.org/news/2017-07-10-code-splitting
See the CLJS Loader
section
Just ran into this: https://gist.github.com/jeaye/3c8eebbe86f39c5989341b64feaa5bbe
@jeaye ^ this occurs in a plain-vanilla shipping Node ClojureScript REPL, but not with ClojureScript master
probably because of the tools reader upgrade / cljs.reader
revamp
that fixed a lot of lingering stuff, such as reading namespaced maps with cljs.reader
as well
survey has no entry for “I never used parinfer but coworker who used it kept breaking namespaces by letting it restructure other people’s badly indented code wrong”
cursive
it could have been a user error of course, it just repeatedly happend even after we discussed the issue
Thanks, that's good to know. (To contrast, in Atom, when you open a file that would have it's AST changed by Parinfer, you get a prompt to kind of minimally re-indent the file so that that doesn't happen. Maybe something to look into for the Cursive implementation.)
cool @U0567Q30W - you might be interested in this?
In theory Cursive does do that, in practice it’s flakey and I haven’t managed to figure out why.
(not that I’m defending the bug, but I’d hope everyone revises their changes before checking something in, too…)
yeah, that plus making sure the code in master has processed by cljfmt was a workable solution
if I had implemented git I would make the -p
arg to git add
the default, and require an explicit arg to turn that behavior off
Hey guys, I have been playing with :npm-deps
in “1.9.820”. And i have some questions 🙂 I added {:material-components-web "0.15.0"}
. This pulls a lot of @material.components
in the node_modules. What is the right way to require these components ? I tried
(ns foo (:require ["@material.component.foundation" :as c]))
and (ns foo (:require ["@material/component.foundation" :as c]))
but it doesn’t work... How can I properly require this ?Also is there a way to tell the compiler not to install npm dependencies every time it recompiles on file change ?
@jeremys I can help you require those namespaces but I need to know what the directory structure looks like
what is the directory called, and what is inside it
@anmonteiro you have for instance “node_modules/@material/textfield/foundation.js”
so that would be (:require ["@material/textfield/foundation"])
java.lang.AssertionError: Assert failed: cljs.analyzer/foreign-dep? expected symbol got "@material/textfield/foundation"
im trying to use an npm dependency, as per https://anmonteiro.com/2017/03/requiring-node-js-modules-from-clojurescript-namespaces/, i see cljsbuild print “Installing Node.js dependencies” but there’s no node_modules folder, and it stops the build becuase “No such namespace: left-pad, could not locate left_pad.cljs, left_pad.cljc, or Closure namespace “left-pad” in file src/engine/core.cljs”
@jeremys did you build CLJS from master?
@sh3rawi make sure you have a package.json
in your project’s directory
even if only with {}
as the contents
@anmonteiro thanks, but shouldn’t this be documented somewhere?
it’s an NPM idiosyncrasy
we still shell out to NPM
@sh3rawi I’ll collect this one in https://github.com/clojure/clojurescript-site/issues/124
@anmonteiro Yep I build it from master v1.9.820
that’s weird because we have tests for that
I am rebuilding. As an aside, can tell the compiler not to install npm deps when recompilling on every file change ?
@jeremys I think you wanna build from current master
and install the dependencies yourself
current master is probably 1.9.837 or something
you now need to opt-in for dependency installation (with a flag :install-deps
)
but you can just pass :npm-deps
and :install-deps false
(which is the default)
^ this means: “I will install my own dependencies, but be aware of them”
ok cool because it slows down the compillation and makes figwheels hot reaload a bit slow...
I think you don’t even need to provide :npm-deps
the compiler will index a top-level node_modules
installation if it finds one
we definitely want to make sure everything works as expected before releasing the next version
tests help, but people breaking stuff is a better method to ensuring that 🙂
Although it is nice to be able to declare npm deps from your project.clj without worrying about npm
Is it possible that lein cljsbuild doesn’t use my version of the compiler ? i still have the assert not passing...
@anmonteiro you’re welcome! good luck with the release
Compiling “js-release/cljs_engine_bare.js” failed. java.lang.RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. null Node(NAME Events): /Users/sh3rawi/workspace/jawaker/clj_engine/node_modules/backbone-events-standalone/backbone-events-standalone.js:85:23 var _ = miniscore(), Events; Parent(VAR): /Users/sh3rawi/workspace/jawaker/clj_engine/node_modules/backbone-events-standalone/backbone-events-standalone.js:85:2 var _ = miniscore(), Events;
@jeremys make a minimal repro that I can take a look
@sh3rawi that’s unfortunate. see https://github.com/google/closure-compiler/pull/2579
will have to wait until a version of Closure is released with this fix ^
@anmonteiro ok sorry for the delay it’s getting late on my side of the atlantic... https://github.com/JeremS/class-test-npm
thanks I’ll have a look later
@anmonteiro ok cool thanks