Modernizr/Modernizr — pull request #958 by doctyper (2013-05-30 00:57:46+00:00)
Title: Making Modernizr friendlier for npm/cli

Related to #695.

I'm requesting a couple of small changes so that Modernizr and grunt-modernizr can better talk to each other. For the sake of clarity, I'll first detail my progress with porting the builder to explain my thought process.

I have a first draft available of a v3-friendly [grunt-modernizr](https://github.com/doctyper/grunt-modernizr/tree/feature/modernizr-3.0) here for those that are interested in taking a look.

It makes sense (to me anyway) to import Modernizr as an npm module dependency. Since your build tool is already doing most of the work, I'm focusing on handling file parsing and test detection.

I'm using your [metadata generator](https://github.com/Modernizr/Modernizr/blob/master/lib/generate-meta.js) to retrieve the classes and/or test names I need to begin. I then use that data to dig through the current project and start parsing for matches. Once matched, I write the culled list of tests and options back to your [`lib/config-all.json`](https://github.com/Modernizr/Modernizr/blob/master/lib/config-all.json) file, and run `grunt build` to generate a customized build. All this happens behind-the-scenes and is invisible to the developer.

This seems to work really well. There are just a couple of integration edits I'd like to make:

- First, I modified the meta generator to export its JSON rather than logging to console. This allows me to import the script as a module, instead of having to spawn a child task and having to capture stdout. Removing the log isn't necessary, but it does help to suppress a lot of white noise.
- Second, and most importantly, I've promoted the `devDependencies` to actual dependencies. The reason is because `npm install` ignores `devDependencies` when installing, meaning I would not be able to run `grunt build` within this context.
- Speaking of `grunt build`, I'm currently having to spawn a process to run the build task (I couldn't figure out how to weave the two grunt contexts together). This works, but is obviously not ideal. Has there been a thought to provide a programmatic API? The ideal scenario is to be able to run `require("modernizr").build()` and not have to worry about grunt context and the like.

Thanks, and please let me know your thoughts on this setup.