[
  {
    "path": ".gitignore",
    "content": "node_modules\n.DS_Store\n"
  },
  {
    "path": "README.md",
    "content": "## A sister of [bundle-loader](https://github.com/webpack/bundle-loader) with promise API\r\n\r\n### Usage\r\n\r\n[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)\r\n\r\nThis is a ripoff of [bundle-loader](https://github.com/webpack/bundle-loader) that uses promises instead of callbacks.\r\nIt only implements so-called `lazy` `bundle-loader` mode—that is, `require` returns a function that, when invoked, returns a promise that resolves to the module.\r\n\r\n`require: (string) -> () -> Promise<module>`\r\n\r\nIt's up to you to specify your Promise library of choice as a parameter.\r\n\r\n``` javascript\r\n// Assuming you use Bluebird\r\nvar load = require(\"promise?bluebird!./file.js\");\r\n\r\n// The chunk is not requested until you call the load function\r\nload().then(function(file) {\r\n\r\n});\r\n```\r\n\r\nIf a promise library is already loaded externally you can specify 'global'.  \r\n\r\n\r\nYou can optionally specify [a name for your chunk](http://webpack.github.io/docs/code-splitting.html#named-chunks) after a comma:\r\n\r\n```javascript\r\nvar load = require(\"promise?bluebird,editor!./editor.js\");\r\n```\r\n\r\nThis can be useful for [single-page apps](http://webpack.github.io/docs/optimization.html#single-page-app) because you can later extract filenames from [Webpack-generated stats](https://github.com/webpack/docs/wiki/node.js-api#stats) and pre-load specific bundles if you know user's going to hit them.\r\n\r\nThe bundle name may include `[filename]`, which will be replaced with the filename, and `[name]`, which omits the extension. This is useful for when you want to configure loaders in Webpack configuration without specifying precise filenames—for example, by a suffix:\r\n\r\n```javascript\r\n{\r\n  test: /\\.i18n\\.json$/,\r\n  loader: 'promise?global,[name].i18n'\r\n}\r\n```\r\n\r\n### License\r\n\r\nMIT (http://www.opensource.org/licenses/mit-license.php)\r\n\r\n"
  },
  {
    "path": "index.js",
    "content": "/*\r\n MIT License http://www.opensource.org/licenses/mit-license.php\r\n Author Dan Abramov\r\n Shamelessly based on bundle-loader by Tobias Koppers @sokra\r\n */\r\n\r\n var path = require('path');\r\n\r\nmodule.exports = function () {};\r\nmodule.exports.pitch = function (remainingRequest) {\r\n  this.cacheable && this.cacheable();\r\n  var query = this.query.substring(1).split(','),\r\n    promiseLib = query[0],\r\n    bundleName = query[1] || '';\r\n  var filename = path.basename(remainingRequest);\r\n  var name = path.basename(remainingRequest, path.extname(filename));\r\n  \r\n  bundleName = bundleName.replace(/\\[filename\\]/g, filename).replace(/\\[name\\]/g, name);\r\n\r\n  if (!promiseLib) {\r\n    throw new Error('You need to specify your Promise library of choice, e.g. require(\"promise?bluebird!./file.js\")');\r\n  }\r\n\r\n  var result = [\r\n    (promiseLib !== 'global') ? 'var Promise = require(' + JSON.stringify(promiseLib) + ');\\n' : '',\r\n    'module.exports = function () {\\n',\r\n    '  return new Promise(function (resolve) {\\n',\r\n    '    require.ensure([], function (require) {\\n',\r\n    '      resolve(require(', JSON.stringify('!!' + remainingRequest), '));\\n',\r\n    '    }' + (bundleName && (', ' + JSON.stringify(bundleName))) + ');\\n',\r\n    '  });\\n',\r\n    '}'\r\n  ];\r\n\r\n  return result.join('');\r\n};\r\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"promise-loader\",\n  \"version\": \"1.0.0\",\n  \"author\": {\n    \"name\": \"Dan Abramov\"\n  },\n  \"description\": \"a webpack bundle-loader ripoff with promise interface\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/gaearon/promise-loader.git\"\n  },\n  \"licenses\": [\n    {\n      \"type\": \"MIT\",\n      \"url\": \"http://www.opensource.org/licenses/mit-license.php\"\n    }\n  ]\n}\n"
  }
]