text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const path_1 = require("path");
  var messages;
  (function (messages) {
      messages["compilationComplete"] = "Webpack compilation complete.";
      messages["startWatching"] = "Webpack compilation complete. Watching for file changes.";
      messages["changeDetected"] = "File change detected. Starting incremental webpack compilation...";
  })(messages = exports.messages || (exports.messages = {}));
  /**
   * This little plugin will report the webpack state through the console.
   * So the {N} CLI can get some idea when compilation completes.
   */
  class WatchStateLoggerPlugin {
      apply(compiler) {
          const plugin = this;
          compiler.hooks.watchRun.tapAsync("WatchStateLoggerPlugin", function (compiler, callback) {
              plugin.isRunningWatching = true;
              if (plugin.isRunningWatching) {
                  console.log(messages.changeDetected);
              }
              process.send && process.send(messages.changeDetected, error => null);
              callback();
          });
          compiler.hooks.afterEmit.tapAsync("WatchStateLoggerPlugin", function (compilation, callback) {
              callback();
              if (plugin.isRunningWatching) {
                  console.log(messages.startWatching);
              }
              else {
                  console.log(messages.compilationComplete);
              }
              const emittedFiles = Object
                  .keys(compilation.assets)
                  .filter(assetKey => compilation.assets[assetKey].emitted)
                  .map(file => path_1.join(compiler.context, file));
              process.send && process.send(messages.compilationComplete, error => null);
              // Send emitted files so they can be LiveSynced if need be
              process.send && process.send({ emittedFiles }, error => null);
          });
      }
  }
  exports.WatchStateLoggerPlugin = WatchStateLoggerPlugin;
  //# sourceMappingURL=WatchStateLoggerPlugin.js.map