{
  "name": "amd-config-builder",
  "version": "0.2.0",
  "description": "Builds amd config for a project from configs of its components",
  "main": "lib/config-builder.js",
  "scripts": {
    "test": "mocha"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/herby/amd-config-builder.git"
  },
  "keywords": [
    "AMD",
    "config",
    "build"
  ],
  "author": {
    "name": "Herbert Vojčík"
  },
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/herby/amd-config-builder/issues"
  },
  "engines": {
    "node": ">=0.8.0"
  },
  "dependencies": {
    "lodash": "~2.4.1",
    "findit": "~1.2.0"
  },
  "readme": "amd-config-builder [![Travis CI Status](https://secure.travis-ci.org/herby/amd-config-builder.png)](https://travis-ci.org/#!/herby/amd-config-builder)\n==================\n\nBuilds amd config for a project from configs of its components\n\n\nFor a bigger project, where you load modules using AMD< you face with the problem of building\na big `require.config` call encompassing all dependencies and shims. Whwnever you change something\nabout the structure of the project, this big structure inside the call need to be changed.\n\nAs an example: you use CodeMirror, a non-amd module in your project. You naturally use jQuery,\nthe AMD project with hardcoded id (because CodeMirror needs it). Plus, you have some more modules\n(like es5-shim) in you `bower_components`, and you have some modules in your own app.\n\nThe premise of this project is to be able to specify pieces of AMD to-be-passed-into-`require.config`\nobject per component, that is, if the project has this structure:\n\n\n```\n  . <root>\n  +-+ bower_components/\n  | +-+ jquery/\n  | | `-- jquery.min.js\n  | +-+ codemirror/\n  | | +-- codemirror.min.css\n  | | `-- codemirror.min.js\n  | `-+ require-css/\n  |   `-- require-css.min.js\n  +-- lib/\n  | `-- ... some files\n  `-- distinct-part/\n    +-- vendor/\n    | +-- foo/\n    | | `-- ... files of foo vendor lib\n    | `-- ... some other vendor libs\n    `-- ... some more files\n```\n\nThese files would be added:\n\n\n```js\n// <root>/local.amd.json\n{\n  \"paths\": {\n    \"my-app\": \"lib\"\n  }\n}\n```\n\n```js\n//<root>/jquery.amd.json\n{\n  \"paths\": {\n    \"jquery\": \"jquery.min\"\n  }\n}\n```\n\n```js\n//<root>/require-css.amd.json\n{\n  \"paths\": {\n    \"css\": \"require-css.min\"\n  }\n}\n```\n\n```js\n//<root>/codemirror.amd.json\n{\n  \"paths\": {\n    \"codemirror\": \".\"\n  },\n  \"shim\": {\n    \"codemirror/codemirror.min\": [ \"jquery\", \"css!codemirror/codemirror.min\" ]\n  }\n}\n```\n\n\n```js\n//<root>/distinct-part/local.amd.json\n{\n  \"paths\": {\n    \"my-distinct\": \".\"\n  },\n  \"shim\": {\n    \"my-distinct/vendor/foo\": [ \"codemirror/codemirror.min\" ]\n  }\n}\n```\n\nThe `local.amd.json` files describe the `require.config` part for the module at the directory where they are present, in this example for the `<root>` and `<root>/distinct-part`. The idea is, each library can supply its own `local.amd.json`, so the final config can be assembled. The `paths` part of `local.amd.json` is relative to the module it describes, that is, relative to its position.\n\nThe `name.amd.json` files describe the missing pieces of config for other dependencies, which do not supply their own one (or they do, but something should be added/overridden). The `name` is the name of the directory where the dependent library / module resides. Thus, `jquery.amd.json` describes config part of `<root>/bower_dependencies/jquery`, similarly for `codemirror.amd.json` and `require-css.amd.json`. Again, `paths` part is relative _to the module described_, that is, for `jquery.amd.json`, even if it is in `<root>`, the `pahts` part is resolved relative to `<root>/bower_components/jquery` directory.\n\nQ: \"What if there are more directories with name `name`?\n\nA: \"The one which is less deeper in the hierarchy wins. If there are more of them at the same depth, the result is undefined (probably on of them is used; maybe some hinting as to which one should be preferred can be added in the future).\"\n\nThe result should be to look for all `.amd.json` files in the project and assemble all these files into one big `require.config` call:\n\n```js\nrequire.config({\n  paths: {\n    \"my-app\": \"lib\",\n    \"my-distinct\": \"distinct-part\",\n    \"codemirror\": \"bower_components/codemirror\",\n    \"jquery\": \"bower_components/jquery/jquery.min\",\n    \"css\": \"bower_components/require-css/require-css.min\"\n  },\n  shim: {\n    \"my-distinct/vendor/foo\": [ \"codemirror/codemirror.min\" ],\n    \"codemirror/codemirror.min\": [ \"jquery\", \"css!codemirror/codemirror.min\" ]\n  }\n});\n```\n\nThis, saved to a file, can be used as-is as a script to set up requirejs (or other loader),\nand it can as well be used as `mainConfigFile` for the requirejs optimizer.\n\nAPI\n----\n\n**require('amd-config-builder').produceConfigObject(rootDir, function(err, result))**\n\nThis scans for the subtree of _rootDir_ and call the _callback_\nwith either the error or with _(null, configObject)_. The _configObject_\nis what you put into `require.config` call.\nAll paths in _configObject_'s paths section that were not absolute / uri,\nare relative to _rootDir_\n",
  "readmeFilename": "README.md",
  "homepage": "https://github.com/herby/amd-config-builder",
  "_id": "amd-config-builder@0.2.0",
  "_from": "amd-config-builder@^0.2.0"
}
