Fork me on GitHub
#reagent
<
2017-04-08
>
savelichalex10:04:14

Is it planned for add support new :npm-deps compiler option and use react dependency from npm?

pesterhazy11:04:13

why are they deprecating createClass? That's easiest to access from compile-to-js languages

savelichalex11:04:49

they move createClass into separate package AFAIK

juhoteperi14:04:08

@savelichalex For Reagent? (My opinion:) Yes and no, for default dependencies I want to support using Reagent without npm, but optionally it should be possible to use :npm-deps

savelichalex14:04:25

@juhoteperi what you mean by default dependencies?

juhoteperi14:04:56

@savelichalex When user just adds dependency on reagent and doesn't define any additional options, like npm-deps

juhoteperi14:04:20

@pesterhazy > This will enable future code size optimizations.

pesterhazy14:04:11

@juhoteperi interesting, maybe something to do with their use of rollup?

savelichalex14:04:27

@juhoteperi as I understand this, reagent can describe they own dependency on react in :npm-deps and then user just adds reagent as dependency, that's all. Npm install react as usual in js apps

pesterhazy14:04:04

we don't want to depend on npm by default, I don't think

juhoteperi14:04:11

As was mentioned on #cljs-dev, ES6 classes are compiled into just function + prototype declarations, and Cljs can emit those, so one option will be to replace createClass by creating function + prototypes

juhoteperi14:04:35

@savelichalex There is probably some (or even lots of) Cljs devs without npm

pesterhazy14:04:59

but optionally, as juho says, you can exclude the dependency, in which case reagent will just use js/window.React

pesterhazy14:04:47

there should be a cljs library for working with ES2015 classes

juhoteperi14:04:13

And this is something I want to improve, if using npm-deps they don't export windows.React because the code goes through optimizations

juhoteperi14:04:29

But I think we can improve Reagent React var detection to support npm-deps better

savelichalex14:04:17

this is looks like hack for me. Why I need make global variables? This is not user friendly in my opinion. I want :npm-deps because use third-party react components with reagent is pain right now

pesterhazy14:04:09

yeah Reagent's React var detection is a bit wonky

pesterhazy14:04:25

there should be a way to pass in React manually

pesterhazy14:04:53

I've thought about that. do you have an idea how to do that?

juhoteperi14:04:55

I guess it'd be possible to store the React value in atom or something, and provide side-effectful function to change value of that

juhoteperi14:04:25

I hope there is a better way

pesterhazy14:04:27

js/window.React is a bit like an atom 🙂

juhoteperi14:04:05

All the Cljs React wrappers have to same problems so luckily this needs to be solved only once and then everyone else can copy the solution 🙂

savelichalex14:04:42

how you guys use third-party components right now? maybe you have best practices for this?

pesterhazy14:04:34

sure, react-select, reat-datepicker

pesterhazy14:04:51

all available on cljsjs

savelichalex14:04:16

ok, got it) looks like cljsjs best solution right now. But this is pain anyway 🙂

pesterhazy14:04:40

if it's on cljsjs it's pretty sweet

savelichalex14:04:00

yeah, but if not...)

pesterhazy14:04:00

if it isn't (yet), it can be annoying if you need to add it yourself

pesterhazy14:04:12

on the plus side, everyone else benefits!

edannenberg16:04:12

@savelichalex for smaller 3rd party stuff it's also often surprisingly simple to just take a look at the js source and port it to cljs

savelichalex16:04:42

@edannenberg yeah, that's what I'm doing right now 😆