petehunt / generator-react-library

Yeoman generator for React components
Apache License 2.0
17 stars 5 forks source link

Simplified folder structure #14

Open chenglou opened 10 years ago

chenglou commented 10 years ago

@sdawson @petehunt one thing I forgot to talk about yesterday is how the folders look like here. I need feedback on this one (related to #13). I was testing a simpler folder structure:

├── README.md
├── build
│   └── static
│       └── Comp-MyComponent.css
├── package.json
├── src
│   └── index.js
├── static
│   └── MyComponent.css
└── test
    ├── entrypoint.js
    └── index.spec.js

I removed lib/ because in all use cases they've been only an intermediate step. There's an argument to be made for not requiring people to use JSX when they include our lib, but really, the odds that every single lib that person uses doesn't ship JSX is rather small (or maybe I shouldn't be talking about JSX at all since this is framework-agnostic? I'll start by making sharing React components easy though). Also moved the spec and entrypoint into test/, so that they can be npmignored. Build is generated of course. When a person installs the lib, he sees only this:

├── package.json
├── src
│   └── index.js
├── static
      └── MyComponent.css

which is as small a component can get.

petehunt commented 10 years ago

We need to check regular .js files into npm I think. The coffeescript people went through this battle and npm pretty firmly says to do this.

With that said I think that this package should encourage jsx. One thing we could do: have people write .jsx files in src/ that compile to .js files along side them (also in /src)

chenglou commented 10 years ago

Oh... Yeah I've gotten this before with CoffeeScript. An npm postinstall won't do?

petehunt commented 10 years ago

https://npmjs.org/doc/misc/npm-scripts.html

"NOTE: INSTALL SCRIPTS ARE AN ANTIPATTERN"

chenglou commented 10 years ago

How about npm prepublish, compile inside src/ like you said, and npmignore .jsx?

petehunt commented 10 years ago

sounds great!