I never finished this post, but actually managed to make a different strategy work. Post to be revised later, but example working code in this repo.
Today's quest: I have a bunch of reagent projects that involve displaying tabular data. Reagent, for those not in the cool kid club, is a clojurescript wrapper for React. I just learned, thanks to HN, about this awesome-looking new React library (do we call them libraries in react-land? or just components?) to display a spreadsheet-like interface, https://github.com/nadbm/react-datasheet.
Aside: I don't think it's a coincidence that the languages I like most, Clojure and Python, both have a strong BDFL-figure to keep things relatively sane. As much as people often disagree with their decisions, I take it that if people felt the need to produce dozens of totally different third-party solutions to a basic language feature like a module system, either Rich or Guido would quickly step in, bring the best one into the language, and the culture would quickly coalesce around people damn well using that. It's truly ridiculous that you can have
pip install foo and
Ok, so anyway. I'm gonna try to do this thing. In roughly three steps:
The docs for React-Datasheet assume that you have some kind of compilation process, presumably the normal compilation process for React, so all they do is tell you to install it via NPM. Needless to say, I'm not using NPM.
lein new reagent-frontend reactinreagent
mkdir reactstuff cd reactstuff npm install react-datasheet --save
Not even gonna try to figure out what needs to happen to keep this stuff off github. Don't care, no struggs.
well, that threw a truly astonishing number of warnings and errors:
/Users/myuser ├── UNMET PEER DEPENDENCY react@~0.14.8 || ^15.0.0 ├── firstname.lastname@example.org └── UNMET PEER DEPENDENCY react-dom@~0.14.8 || ^15.0.0 npm WARN enoent ENOENT: no such file or directory, open '/Users/pauliglot/package.json' npm WARN email@example.com requires a peer of react@~0.14.8 || ^15.0.0 but none was installed. npm WARN firstname.lastname@example.org requires a peer of react-dom@~0.14.8 || ^15.0.0 but none was installed. npm WARN myuser No description npm WARN myuser No repository field. npm WARN myuser No README data npm WARN myuser No license field.
Ok, so I guess I need to install lots of other stuff to make this happen? I suppose installing all the react crap into this other directory won't pollute my clojurescript project, and hopefully it'll all come out right at the other end. Let's pray. (But now I definitely need to add this to the .gitignore). Let's see what happens.
npm install react --save npm install react --save npm WARN saveError ENOENT: no such file or directory, open '/Users/myuser/package.json' /Users/myuser ├─┬ email@example.com │ ├─┬ firstname.lastname@example.org │ │ ├── email@example.com │ │ ├─┬ firstname.lastname@example.org │ │ │ ├─┬ email@example.com │ │ │ │ ├─┬ firstname.lastname@example.org │ │ │ │ │ └── email@example.com │ │ │ │ └── firstname.lastname@example.org │ │ │ └── email@example.com │ │ ├─┬ firstname.lastname@example.org │ │ │ └── email@example.com │ │ ├── firstname.lastname@example.org │ │ └── email@example.com │ ├─┬ firstname.lastname@example.org │ │ └── email@example.com │ └── firstname.lastname@example.org └── UNMET PEER DEPENDENCY react-dom@~0.14.8 || ^15.0.0 npm WARN enoent ENOENT: no such file or directory, open '/Users/myuser/package.json' npm WARN email@example.com requires a peer of react-dom@~0.14.8 || ^15.0.0 but none was installed. npm WARN myuser No description npm WARN myuser No repository field. npm WARN myuser No README data npm WARN myuser No license field.
Ok, so that ain't working. Apparently I do need, like, an entire fucking react toolchain to use this component. Let's see what the react docs have to say about getting one, huh?
Ok, apparently I need to:
npm init npm install --save react react-dom
oh god, npm init is some silly walkthrough that asks you a bunch of questions to create a package.json. save me? I'm just taking all the defaults.
But ok! Now it'll let me install the things, with only one warning:
npm WARN firstname.lastname@example.org No repository field. — and I'm perfectly happy with this warning, since I don't feel the need for NPM to know where my repo is.
So, next thing, I guess the default for npm.init was to create an entry point at index.js, so I'll do that.
Hmm. I'm not actually sure where index.js goes in order to get this stuff to all compile. I guess I need to use webpack? But how do I get webpack and the npm stuff to play together? Here's a really fucking long tutorial for that, jesus.
cd .. rm -rf reactstuff mkdir reactstuff cd reactstuff npm install -g create-react-app create-react-app godhelpme cd godhelpme npm install react-datasheet --save