const vm = require('vm');
const mapValues = require('lodash.mapvalues');
const webpack = require('webpack');
const {normalizeFilePath} = require('../models/Paths');

function getWebpackConfigStubPlugin(name) {
  class WebpackConfigStubPlugin {
    constructor(...args) {
      this.plugin = name;
      this.args = args;
    }
  }
  return WebpackConfigStubPlugin;
}

const WebpackConfigRequire = (name) => ({
  webpack: webpack,
  path: {
    join: (...pieces) => normalizeFilePath(pieces.join('/'))
  }
})[name];

WebpackConfigRequire.resolve = (name) => null;

const WebpackConfigContext = {
  RegExp: RegExp,
  __dirname: '/',
  require: WebpackConfigRequire,
  module: {}
};

function getWebpackConfig(buffer) {
  let ctx = Object.assign({}, WebpackConfigContext);
  vm.runInNewContext(buffer.toString(), ctx);
  return  ctx.module.exports;
}

module.exports = getWebpackConfig;
@@ -23,55 +23,8 @@
 ');%0A
-const mapValues = require('lodash.mapvalues');%0A
 cons
@@ -116,210 +116,8 @@
 );%0A%0A
-function getWebpackConfigStubPlugin(name) %7B%0A  class WebpackConfigStubPlugin %7B%0A    constructor(...args) %7B%0A      this.plugin = name;%0A      this.args = args;%0A    %7D%0A  %7D%0A  return WebpackConfigStubPlugin;%0A%7D%0A%0A
 cons

Drop older environment code.