Fork me on GitHub
#clojurescript
<
2017-05-15
>
john04:05:23

what are the safest non-alphanumeric characters to use in keywords?

kauko05:05:23

Newest version of Clojurescript breaks code that uses Plumatic Schema https://groups.google.com/d/msg/clojure/In88wV63QyE/5daVkzxzBgAJ

adamvh05:05:50

question: what do y’all use for widget libraries?

john05:05:41

I think schema was depending on undocumented/unintended behavior.

adamvh05:05:42

also @john empirically i would guess hyphen 😛

john05:05:12

yeah, I'm using hyphens and plus signs. Trying to put a base64 string in the name of the keyword. Every once and awhile I get a reader failure. Not a lot of info in the error though.

adamvh05:05:20

the common lisp community usually responds to that sort of thing with a stern finger wagging

adamvh05:05:32

and tells you to rethink whatever you’re trying to do

adamvh05:05:45

why are you programmatically generating keywords? is it in a macro?

john05:05:11

namespaced message tags, of sorts

john05:05:41

objects that are programmatically generated at runtime. and the keys refer to the objects

john05:05:38

hmm

If -, + or . are the first character, the second character (if any) must be non-numeric.

john05:05:15

but, testing read-string on some of those in the repl seems to work fine

john05:05:19

and I'm just using pr-str and read-string atm

Oliver George06:05:23

@anmonteiro thanks for your patch on CLJS-2020 the performance numbers look fantastic.

anmonteiro14:05:12

@olivergeorge sure. Just looks like we forgot to port a patch over from Clojure

metametadata15:05:24

Hello. Is it possible to create tests in ClojureScript dynamically? I've found the approach which works in Clojure: https://gist.github.com/joelittlejohn/2ecc1256e5d184d78f30fd6c4641099e#file-test-clj-L7 But it will not work in CLJS because there's no intern.

dnolen15:05:55

@metametadata I don’t think it’s really posssible

darwin15:05:32

@metametadata data there is something called test-ns-hook in the sources, maybe you could hook into that and do your dynamic stuff there

metametadata15:05:17

@darwin thank you, I'll need to think about it!

adamtrilling18:05:49

n00b question: I'm trying to import an NPM module written in ES6 that isn't packaged for clojurescript. If I use (nodejs/require "uws"), it returns an object that I can call the functions on with no problem. If I add it to my build script in :npm_deps and try to require it, I get all sorts of errors about the clojurescript compiler not knowing what to do with ES6 and telling me to use --language_in=ECMASCRIPT6. Where do I put that flag, or is there another easy way to get it to use ES6 modules?

adamtrilling18:05:23

(I'm targeting node, not the browser)

richiardiandrea18:05:05

@adamtrilling I don't know if it is the problem, but make sure it is :npm-deps (dash)

adamtrilling18:05:26

Yeah it is. Should have copied and pasted from my code 🙂

anmonteiro18:05:26

@adamtrilling did you set :language-in :es6 in your compiler options?

adamtrilling18:05:16

That worked! Now it's having trouble with the module saying const http = require('http');

adamtrilling18:05:52

But that may have to do with the module itself

john18:05:32

So I halfway figured out my problem with keywords. I'm pr-string and read-stringing all over the place. And, in certain namespaces, some nameed things are getting ear-muffed with whitespace. It's as if in a particular context, the object printer is using println semantics, where spaces are interposed.

john19:05:57

And I have a logging macro that adds namespace data using ~(name cljs.analyzer/*cljs-ns*) and puts it in a ... " <" nspace ":" line-number ">" ... string. Sometimes it prints <my.nspace:56> and sometimes it prints < my.nspace :56>.

john19:05:34

and this expansion is apparently happening throughout other places as well, causing breakage randomly

john19:05:34

I was interposing whitespace in one of my functions, but I removed it and I'm not interposing anywhere else in the project.

john19:05:50

So, keywords like :kname are are getting whitespace earmuffed into : kname

john19:05:15

and then the reader fails. Has anyone else seen this behavior and tracked it down?

rohit19:05:02

@thheller: picking up from Google Groups - shouldn't it be possible to run Google Closure on the output of browserify without any issues?

thheller19:05:44

@rohit no, closure expects ONE global scope. but webpack&node create a scope per file

thheller19:05:29

so everything is wrapped in (function (exports, require, module, __filename, __dirname) { CODE });

thheller19:05:40

or similar for webpack/browserify

thheller19:05:46

closure doesn't handle that well

rohit19:05:42

ah ok. I see what you mean. I was able to use it for npm-module-example. GCC generated the minified file but it did complain.

thheller19:05:27

yeah I tried when you wrote the message

thheller19:05:39

but I have tried for ages using the JVM closure compiler so I didn't expect much

thheller19:05:45

the scope thing really is the problem

thheller19:05:25

passing everything into closure is the other solution (where :npm-deps is headed)

thheller19:05:41

currently I do not see this working properly in many cases so I dismissed it for now

thheller19:05:35

code splitting for closure also needs ONE shared scope but no JS tool supports that

ksmithbaylor19:05:10

Doesn't Rollbar do that?

ksmithbaylor19:05:24

Sorry, I meant Rollup

rohit19:05:13

I think even webpack supports code splitting.

rohit19:05:10

@thheller: I'm gonna investigate this.

tbaldridge19:05:35

ksmithbaylor: holy wall-of-text, batman! 🙂

ksmithbaylor19:05:14

haha, sorry. I pasted and hit enter before seeing how big the URL was 🙂

ksmithbaylor19:05:06

The variables from other scopes get renamed so they don't conflict with each other, but they all end up in the same scope in the final build.

thheller19:05:29

@ksmithbaylor interesting, didn't look at rollup yet

ksmithbaylor19:05:30

(I had to console.log each one since Rollup does some dead-code-elimination)

thheller19:05:44

@rohit I didn't investigate many JS options yet. I know the closure compiler inside-out but nothing else really

thheller19:05:07

could definitely use help from the JS front, like rollup which looks promising

rohit19:05:31

Sure. I don't think we are far from where we currently are.

rohit19:05:36

> Use webpack for apps, and Rollup for libraries

ksmithbaylor19:05:04

Yep! That's the general advice. Although for specific use-cases, it may make sense to use Rollup for apps. The main reason Webpack is a better option for apps is because of its rich plugin/loader system, which makes it really easy to load styles, images, and other assets directly in your source code. If you don't use those features (like if you only have a small portion of your app written in JS, and the rest in CLJS), then Rollup would be a perfect solution.

pesterhazy20:05:06

If there is src/foo/bar.cljs and dev/foo/bar.cljs, and you set your project.clj to :source-paths ["dev" "src"], which of the two files will take precedence with figwheel?

qqq20:05:48

I wonder if devs ever decide to f- wit people on these issues by having it pick a random one, based on the day of the month, i.e. "odd numbered day? take dev" "even numbered day? take src" -- this way, it's not obvious it's random (since it's constant for any given day), but causes a new eadache every day 🙂

pesterhazy20:05:11

funny you should mention that

pesterhazy20:05:34

I think it's actually random in my experience - sometimes figwheel picks dev, sometimes src

qqq20:05:01

or pick the one with the latest modification time, that'd be evil too and hard to debug 🙂

pesterhazy20:05:59

well I actually thought I was being clever by lettings developers in our team override a namespace by adding an overriding "dev" ns

pesterhazy20:05:35

correct me if I'm wrong but this kind of hack is pretty common in Clojure, where the classpath works reliably

qqq20:05:59

this is insane, people in clj dev purposely have overlapping names and predict which one the jvm picks to load ?

darwin20:05:02

@pesterhazy I used to do it by having dev and rel folders and same namespaces in them, but putting only one of them into :source-paths

darwin20:05:34

that always worked predictably, these days I prefer :preloads compiler option if possible

pesterhazy20:05:51

@darwin, that would require devs to change source-paths accordingly hm...

thheller20:05:46

@pesterhazy should be fairly simple, the jvm classpath decides. so in your example src wins

thheller20:05:09

but given that figwheel watches files, it may load the dev one after the fact

pesterhazy20:05:13

@thheller that's what I thought, but that's now how it works, at least with figwheel

thheller20:05:52

not sure which folders figwheel watches by default

thheller20:05:30

in shadow-devtools you actually get a warning for these things 😉

pesterhazy20:05:40

the whole point of this was to add a feature.cljs, which developers can keep outside revision control

pesterhazy20:05:55

so they can keep their personal copy of feature flags

pesterhazy20:05:17

if I ask developers to update project.clj to add a classpath, that sort of defeats the purpose of the exercise 🙂

darwin20:05:46

there is also :source-paths for clojure macros on project.clj root level, which might interfere with :source-paths on cljsbuild level (assuming lein), I guess

pesterhazy20:05:30

yes, using lein here

darwin20:05:58

@pesterhazy feature flags could easily be a file, you can load it as part of macro code and then decide which cljs code to emit based on it

pesterhazy20:05:52

so the problem is that you can't require a file but also ignore it if it doesn't exist

pesterhazy20:05:01

but a macro could do that

pesterhazy20:05:51

I'll try the macro route

pesterhazy21:05:07

@darwin, that worked, thanks!

Oliver George22:05:04

Just found one of those bugs where my view wouldn't update when a local state atom changed.

Oliver George22:05:39

Problem was my deref was inside a (for...) loop and so the lazy seq wasn't evaluated yet (so no deref happened).

Oliver George22:05:51

(into [:tbody]
  (for [id ids]
    (let [has-focus? (= id @focus-id)]
      [:tr "xxx"])))

Oliver George22:05:06

[:tbody
  (for [id ids]
    (let [has-focus? (= id @focus-id)]
      [:tr "xxx"]))]

Oliver George22:05:28

I wonder if re-frame could report a warning where lazy-seqs are returned from views.

Oliver George22:05:40

Or if I could pick it up with a spec.

thheller23:05:05

Too tired to make a proper announcement but I just pushed the first preview version of the shadow-cljs npm package.

thheller23:05:23

npm install -g shadow-cljs
shadow-cljs --once
node
var x = require("shadow-cljs/cljs.core");
x.enable_console_print_BANG_(); // oops
x.prn(x.assoc(null, "foo", "bar"));

thheller23:05:01

More tomorrow ... I need sleep. 😉