Fork me on GitHub
#cljs-dev
<
2017-04-08
>
slipset08:04:06

looking at the demunge function in cljs.core,

slipset08:04:01

I see there is a redundant call to (str name), is that worth fixing?

juhoteperi09:04:03

Looks like using React with module processing will get even more desirable in future, as createClass is being deprecated (and needs additional lib) and React-with-addons is discontinued, and addons need to be provided as separate libs: https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.createclass

juhoteperi09:04:46

My understanding is that all React wrappers for Cljs currently use createClass and Cljs can't emit JS classes?

favila13:04:21

@juhoteperi Can't emit the js "class" syntax directly, but that is just sugar for normal constructor + prototype pattern, which cljs can certainly do.

thheller16:04:15

the treasures one keeps finding in the Closure compiler are just amazing

thheller16:04:02

(.setStripTypePrefixes compiler-options #{"cljs.core.prn"}) .. strips every (prn ...) call when optimizing

thheller16:04:22

you can strip entire namespaces with this ...

anmonteiro17:04:42

It employs the strategy @favila described

thheller17:04:36

@anmonteiro I don't think that is what he meant

juhoteperi17:04:09

hmm, but I think it will solve the problem

anmonteiro17:04:47

He said all React wrappers use createClass

anmonteiro17:04:54

I'm giving an alternative

juhoteperi17:04:11

Reagent will just need some handling for reagent/create-class where all the lifecycle methods are described using a map

anmonteiro17:04:51

@juhoteperi doesn't seem hard to do either

juhoteperi17:04:21

Yeah something like reduce which extends the object for each kv or something

anmonteiro17:04:38

One cool thing to note there is extends React.Component just boils down to copy the prototype

anmonteiro17:04:19

@thheller that is really cool, does it just strip every call that starts with the prefix?

anmonteiro17:04:52

Which also means you can shoot yourself in the foot if not careful :-)

thheller17:04:19

yeah definitely very dangerous

thheller17:04:53

you can strip by prefix, suffix, property names

thheller17:04:13

or full types cljs.core.PersistentHashMap and poof 😛

thheller17:04:33

also strips all calls that where using it

juhoteperi17:04:22

@anmonteiro Btw. does Om have some logic to require React from Cljsjs or npm-deps? I guess not as it refers js/React

juhoteperi17:04:41

.... or does it work correctly with either when externs are provided

juhoteperi17:04:13

... I think I'm not being able to describe what I'm thinking 😄

anmonteiro17:04:24

@juhoteperi React is required from CLJSJS

juhoteperi17:04:48

What if user excludes cljsjs/react and uses npm-deps instead?

anmonteiro17:04:27

Then the user needs to (set! js/React)

juhoteperi17:04:56

And probably also (set! js/ReactDOM)?

anmonteiro17:04:19

Npm deps is so new that we haven't gotten around to make it work