Hey Jonathan, TJ, Ian, etc. Great job so far, and news of version 1.0 is really exciting. I started a new job about 6 months ago, and the first thing I did was "npm install -g component". Out of all the JavaScript libraries/frameworks out there, I really think Component.io gets it right (Ian - thanks for showing me the light in #segmentio). For this reason, I obviously want to see higher adoption, so here's some input from my short time in the corporate world. Forgive me if I'm ignorant of existing solutions to these problems. I've done lots of searching, but haven't come up with much.
1. Better documentation for `component build`
I'm happy to see the builder2.js overhaul. We have a crazy Makefile (which can't even be run on Windows without first installing MingW or Cygwin). Only recently have I realized you can use `component build --use ...` to extend the build process, but the documentation is still really lacking. I think you should at least allude to `--use` in the component/component Readme and find some alternative to GNU make for all the UI developers (and coworkers) out there using Windows. Here are some of the things our current setup support:
- Building
- Converting all .html files in our component (sub)directories to .js
- Unit testing: make test
- Acceptance testing: karma start karma.conf.js (I'd like to use component for this, but can't. See node/npm require() below)
- Getting a list of third-party licenses for our legal department
- Copying files to our development box via SSH (we build our own NIC's, so virtualization is near impossible)
- Updating third-party components
2. Revision records
"which is why I think we need component pin, component update, and component outdated commands" - YES! It also made me really happy to see this, as I just recently incorporated component build into our CI system. As I'm sure you know, this isn't reliable without some record of versions/revisions. Ideally, I'd like to always stay at the latest versions of third-party dependencies, so I don't care so much about semver or pinning dependencies at
specific versions; however, I do need
some way to be consistent across all working copies of our code. I think
a simple lock file would be useful.
3. node/npm require()
I know the npm guys aren't budging on their current dependency resolver. Regardless, this causes a lot of confusion in the Component.io community I'm sure. At first glance, component seems like a way to run code in
either the browser or a server. In practice, this is tricky, and it all boils down to very subtle differences in the require() implementations of npm and component. Some clear documentation on these two common use cases would be really helpful: 1) Using components in node, 2) Using npm packages in the browser alongside components. In the case of 2, I think it's fine to say "you can't" as long as the answer is clear. As far as I know, the only solution is using a try/catch clause with different require()'s. A better solution might be to support an (optional) list of dependencies and their paths (I know you don't like this idea). Maybe
implement something like
RequireJS's shim, but discourage its use?
4. Lazy loading
`component build` outputs a single file - well, one JS, one CSS, etc. We're expected to simply include this one file in our HTML. I think all of us prefer this over loading multiple files for performance reasons; however, on a large project like mine, build.js can become pretty large. It would be nice to be able to lazy load these files only when they're needed. This is critical for
breaking the 1000ms mobile barrier. I consider this advanced, but I wanted to mention it anyways.
Again, thanks for devoting your time to such a great project. I've been contributing to some of the non-core libraries, and would love to help out more.