@@ -0,0 +1,1976 @@
+var path = require('path');%0Avar Promise = require('bluebird');%0A%0Avar Plugin = require('./Plugin');%0Avar HOOKS = require('../hooks');%0Avar readFile = require('../utils/readFile');%0A%0Avar fileCache = %7B%7D;%0Avar packageInfoCache = %7B%7D;%0A%0A%0Avar PackageInfoPlugin = Plugin.create();%0A%0APackageInfoPlugin.prototype.apply = function (compiler) %7B%0A  compiler.plugin('compilation', function (compilation) %7B%0A    compilation.plugin(HOOKS.SOURCE_CREATED, function (source, done) %7B%0A%0A      findFile('package.json', source.absolutePath).then(function (filepath) %7B%0A        if (filepath !== null) %7B%0A          readFile(filepath, compiler.inputFileSystem).then(function(contents) %7B%0A            source.packageInfo = JSON.parse(contents);%0A            done(null, source);%0A          %7D);%0A        %7D else %7B%0A          done(null, source);%0A        %7D%0A%0A      %7D);%0A%0A    %7D);%0A  %7D)%0A%7D;%0A%0Amodule.exports = PackageInfoPlugin;%0A%0A/**%0A * pathExists, splitPath, join and findFile is adapted from https://github.com/sindresorhus/find-up%0A * @see https://github.com/sindresorhus/find-up%0A */%0A%0A/**%0A * @param %7Bstring%7D filepath%0A * @param %7BCachedInputFileSystem%7D fs%0A * @returns %7BPromise%7D%0A */%0Afunction pathExists(filepath, fs) %7B%0A  var fs = fs %7C%7C require('fs');%0A%0A  return new Promise(function (resolve) %7B%0A    fs.stat(filepath, function (err) %7B%0A      resolve(err instanceof Error == false);%0A    %7D);%0A  %7D);%0A%7D%0A%0Afunction splitPath(x) %7B%0A  return path.resolve(x %7C%7C '').split(path.sep);%0A%7D%0A%0Afunction join(parts, filename) %7B%0A  return path.resolve(parts.join(path.sep) + path.sep, filename);%0A%7D%0A%0Afunction findFile(filename, opts) %7B%0A  opts = opts %7C%7C %7B%7D;%0A  var fs = opts.fs %7C%7C require('fs');%0A%0A  var parts = splitPath(opts.cwd);%0A%0A  return new Promise(function (resolve) %7B%0A    (function find() %7B%0A      var fp = join(parts, filename);%0A%0A      pathExists(fp, fs).then(function (exists) %7B%0A        if (exists) %7B%0A          resolve(fp);%0A        %7D else if (parts.pop()) %7B%0A          find();%0A        %7D else %7B%0A          resolve(null);%0A        %7D%0A      %7D);%0A    %7D)();%0A  %7D);%0A%7D

Update PackageInfoPlugin