This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-03
Channels
- # bangalore-clj (1)
- # beginners (104)
- # boot (30)
- # braveandtrue (1)
- # cider (6)
- # cljs-dev (95)
- # cljsjs (16)
- # cljsrn (3)
- # clojure (106)
- # clojure-italy (15)
- # clojure-nl (2)
- # clojure-norway (3)
- # clojure-russia (1)
- # clojure-spec (40)
- # clojure-uk (53)
- # clojure-ukraine (1)
- # clojurescript (200)
- # code-reviews (2)
- # cursive (1)
- # datascript (3)
- # datomic (32)
- # editors (28)
- # gorilla (6)
- # graphql (8)
- # hoplon (1)
- # jobs (8)
- # jobs-discuss (5)
- # jobs-rus (1)
- # keechma (13)
- # leiningen (5)
- # luminus (3)
- # lumo (53)
- # off-topic (5)
- # om (5)
- # om-next (1)
- # onyx (56)
- # parinfer (7)
- # protorepl (22)
- # re-frame (47)
- # reagent (37)
- # remote-jobs (1)
- # ring-swagger (9)
- # specter (7)
- # vim (14)
- # yada (30)
when using :exclusions
it can also be a good idea to explicitly add a dep for the version of the thing you want at the top level, before anything that depends on it
its weird tho, I hadn't made any dependency changes in the past 2 weeks then all the sudden today it stopped working, really confusing
Now, if someone can tell me how syntax quote works when expanding clojurescript macros, my day is made 🙂
What does (foo ...)
expand to when I use the same ns trick for macro and the matching cljs namespace has a foo function?
Can I rely on it being the foo from that ns, or should I always fully specify the ns in the macro?
In Clojure that's not an issue, because the macro usually lives and is evaluated in the same ns that houses the functions it references...
has anyone ever had an issue that appears only when code is optimized? I’m running into a weird issue with https://github.com/benhowell/reagent-quill that only happens when the code is optimized.
@mrchance think of how many clojure.core functions you use though - ` namespace qualifies things such that your code works even if the code using the macro has renamed or hidden parts of the other ns
@noisesmith yes, I understand why that is needed in general, I just want to know how it works in cljs. Not sure how your reply answers that, maybe I'm being daft 🙂
` qualifies the symbols, you shouldn't have to do it by hand
just be sure the cljs is requiring the right namespaces somewhere at runtime
Hm, so I had a foo.cljs
and a foo.clj
file, the cljs file required the clj one and referred the macro, which had a reference to a record in foo.cljs in it. This didn't work. For the functions in foo.cljs
however, it did. That's what confused me
Figwheel handled it pretty weirdly too, I got a very short popup that looked like an undefined var warning, which immediately disappeared and was replaced with the success badge Oo
@noisesmith I still don't understand how that works, if a macro does
`(foo x#)
how does it know what foo it should expand into? In Clojure, it's always the foo in the same scope as the macro, but in cljs those are different phases, I usually even can't require the file with the right foo because it will be a cljs fileit's the defining namespace that determines the expansion
oh, - good point, that means that auto-expanding to the right cljs namespace would be tricky in some cases
it's a decent reason to have stub clj namespaces with the same path as the cljs namespace you want to emit calls to
maybe
ah, that's not a problem, I usually have both anyway, since I like to be able to omit :require-macros and treat them transparently
But in theory it should work similarly for records, correct? Nothing different there?
sure - you can refer to records via the ns level vars that get created rather than the raw classes / methods sometimes as well
(that might make things simpler)
(ns foo.awesome)
(defmacro to-bar [x]
`(Bar. x))
will always expand to (foo.awesome/Bar. x)
?and the answer is yes, unless Bar is in scope referenced from some other ns
I should still qualify calls to other libraries though, and hope they have been required somewhere? e.g. cljs.core.async/chan
or something like that?
that seems reasonable
@lumpy http://squirrel.pl/blog/2013/03/28/two-ways-to-access-properties-in-clojurescript/
@mfikes simple-benchmark
is what I’m using, but I can’t explain why I’m seeing a lot more variability accross runs than with the same code on the jvm
@jfntn I've seen JavaScriptCore's FTL optimizer create mysterious variations https://github.com/mfikes/planck/issues/417
@U61HA86AG Hm, right. Should be it I suppose.
I think the hard part this this is that there is no browserified JS ready for this file
https://unpkg.com/[email protected]/test-utils.js is the CommonJS file https://unpkg.com/[email protected]/dist/ no dist file
@juhoteperi Yeah, couldn't find one. So I guess it should be browserified and added to the cljsjs repo?
If it is possible to browserify it, yes
It would make sense to package this to cljsjs/react-dom, similar to how it is included in same npm package, but not sure if I want to have browserify included in main React packaging script
I packaged React 16 beta 2 to Cljsjs: https://github.com/cljsjs/packages/commit/c49c89169b9bb7391508c5f5e19d35514feee283, seems to break some tests at Reagent at least
What would be the fastest implementation of a global key-value cache? Current status: (def cache (volatile! (transient {})))
@jfntn why not an atom
?
volatile!
does not have any atomicity guarantees though, so it's not thread safe. I believe it's intended for smaller scope changes in a single thread (like in stateful transducers).
@dnolen fwiw the issue from yesterday was a REPL environment one, a bug in a version of bignumber
(which web3
relied on) hangs in Safari / similar envs (React Native on iOS) but not in a Node REPL, fixed by depending on a separate version of bignumber
and doing arithmetic there
quite an interesting bug actually https://github.com/MikeMcl/bignumber.js/issues/120
@fabrao {:uk-accordion true}
?
Hi. I’m following https://clojurescript.org/guides/javascript-modules and trying to load a vendored JavaScript project with CommonJS modules. Requiring the namespace fails (“No such namespace”). Re: this sentence:
> Notice that a :foreign-libs entry may now specify a directory for :file. In this case, the ClojureScript compiler will recursively search this directory for .js files and automatically create the :foreign-libs entries for you with the supplied options.
Is there a way to get the cljs compiler to list the foreign-libs entries it has created to aid in debugging? Currently I have the following foreign-libs entry: :foreign-libs [{:file "vendor" :module-type :commonjs}]
; where “vendor” contains one directory, csp-report-norm, the contents of which are a local copy of this git repo: https://github.com/tollmanz/csp-report-norm
@lvh currently there is no way to do debug, though that’s a probably a good feature to add to :verbose
@lvh no one might have the time to look at this right now, so best thing to do is make a minimal case - zero tooling except Quick Start uberjar
(also hi @dnolen thanks for all the work you’ve been doing; I know it’s a team effort but so much cool stuff since I last touched CLJS :))
if you like add separate issue about dumping foreign libs, probably something we could add to cljs.build.api
I’ll look into it right now
@lvh we’ve been a lot better about adding test cases for all these different combos - so if there’s an issue we’ll try to make sure it doesn’t regress
@anmonteiro thanks
oh actually
I know what’s wrong
@lvh there’s no :provides
entry in your foreign-libs definition
hrm, that might not be needed
Ah. From that instructions page I liked, just after the part I quoted: > The :provides namespace for each entry will be automatically computed from the directory structure. … so I was also expecting that to work for my vendored repo.
so how are you requiring it?
(require [vendor.index])
should be how you require it
sorry
csp-report-norm.index
[:ul {:data-uk-accordion true}]
-> <ul data-reactroot="" data-uk-accordion="true" class="uk-accordion"></ul>
WTF !!!?
Ah; I was requiring it as [csp-reports-norm]
; not with index, I thought that was implicit. That made the compiler happy, but it still doesn’t appear to be copied into out/
; notably, when I try to run it with node, I get:
cspshovel/out/goog/base.js:1357
throw Error('Undefined nameToPath for ' + requireName);
^
Error: Undefined nameToPath for vendor.csp_reports_norm.index
... (stacktrace omitted for brevity)
… which is what I think that means@lvh works for me
the only problem I’m seeing is that the package has a validator
dependency
which you’re not honoring
I’ll try and create a minimal reproducer. Thanks @anmonteiro 🙂
@lvh is this with :target :nodejs
?
that might be your problem
1 sec
oh yeah
here’s the problem: we stopped converting modules entirely when target is nodejs cc @dnolen
but this is not a good assumption, and we should only do that for node modules
I can put together a patch today
should be an easy fix
welp, I’m glad my problem was interesting at least — does that mean you no longer need an issue from me @anmonteiro ?
no, I can create one
I’ll make sure to include a test so we don’t regress 🙂
cool; thanks 🙂 If I understand what you’re saying correctly, this wouldn’t be a problem if the dep was added in package.json instead of being vendored?
if you use npm-deps
you’ll be able to require it
@lvh also simply because we don’t even attempt to run those through Closure if your target is Node
there’s a native require
, we use that
I didn’t know about :npm-deps — is that equivalent to a package.json with the appropriate devRequirements for cljs and the dependency?
@lvh https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
let me know if you have further questions after reading that
I also wrote something even before we launched it officially: https://anmonteiro.com/2017/03/requiring-node-js-modules-from-clojurescript-namespaces/
@lvh @dnolen ticket + patch here https://dev.clojure.org/jira/browse/CLJS-2296
@fabrao i am writing a clojurescript + planck script to ping a server that requires two way ssl, without the help from the browser, i think i will need to establish the trust somehow myself. Do you happen to know an example how to do this on clojurescript? or am i misunderstanding something here ?
something like http-client + openssl package in chicken scheme, but i really want to stay clojurescript
@whou pink @mfikes whether planck
has a https client, otherwise you might want to try lumo
since that is node which has https
support
Yes, Planck has https support. You can, for example (planck.http/get "
It is based on libcurl
I’ve been using :npm-deps
for two days now, and I’ve already encountered two google closure compiler bugs. Do you have any work-around technique for those bugs, or do I have to wait for upstream fix? I’ve been trying to fork and patch affecting npm modules, but that’s dubious…
(FYI: I’m referring to https://github.com/google/closure-compiler/issues/2377 and https://github.com/google/closure-compiler/issues/2450)
@pawel.kapala 2560 has been fixed in master
@pawel.kapala I started keeping track of packages and their problems: https://github.com/cljsjs/packages/wiki/Closure-npm-Module-processing-status
@juhoteperi Thanks, I’ll have a look at the list. Regarding 2560, if it’s fixed in master. Silly question: how can I use it in lein project. Special dependency? SNAPSHOT?
run mvn -DskipTests
at Closure-compiler dir and replace closure dependency with version 1.0-SNAPSHOT
Anyone know the best library to draw on files?
@juhoteperi the @atlaskit/*
packages are fun too, eg @atlaskit/navigation
references a whole bunch of packages with fun wrappers
@thheller https://unpkg.com/@atlaskit/[email protected]/dist/bundle-cjs.js ? Closure has a test case for one webpack UMD wrapper, so mayber this works?
--- node_modules/@atlaskit/avatar/dist/bundle.js:2
The define function must be called as a top-level statement.
--- node_modules/@atlaskit/blanket/dist/bundle.js:2
The define function must be called as a top-level statement.
--- node_modules/@atlaskit/field-base/dist/bundle.js:2
The define function must be called as a top-level statement.
@juhoteperi @pawel.kapala FWIW the Closure Compiler team started publishing nightlies a while ago
so you can just add 1.0-SNAPSHOT
and it’ll download the nightly snapshot from Maven
no need to build it yourself
@anmonteiro Perfect! Thanks!
@thheller dist/bundle.js
looks like the browserified file, package.json webpack
property points to dist/bundle-cljs.js
^ the errors above are because you’re setting AMD -> CJS conversion to true
disabling that will either 1. produce a better error, 2. convert the file successfully (no guarantees about working at runtime)
I think JS build tools just add those properties when ever they feel like it
"main": "dist/bundle.js",
"webpack": "dist/bundle-cjs.js",
"jsnext:experimental:main": "dist/es/index.js",
"ak:webpack:raw": "src/index.jsx",
"types": "src/index.d.ts",
there's also a module
property you can add that will have webpack automatically pull in the ES6 version of a dependency if its defined
@anmonteiro's patch adds option to Closure to configure this, so it will be possible to set it to ["webpack", "browser", "main"]
or something in future
which is better for tree-shaking/dead code elimination
@chrisbroome yep, it’s awaiting internal submission: https://github.com/google/closure-compiler/pull/2598
Hmph, though ClojureScript side only uses browser
, and main
so not all fields will work automatically
@anmonteiro seems almost signed off?
yeah, I think it’s going in if it passes Google internal testing
I don’t think I’ll have time tomorrow to sort out our own Closure artifact, but it’s still high on my queue
AFAICT they run every commit through their distributed build of every internal project
might be completely off-topic, but has the clojure/clojurescript team thought about targeting WebAssembly as a platform?
@chrisbroome people ask us that all the time 🙂
yeah i haven't seen any mention of it
interesting
I was reading some about it the other day after webpack said that they got funding to make it a first class module target
it's also kinda cool that the textual representation uses s-expressions 🙂
good point