title: Error when uglifying webpack bundles
body: <p>We used to have a single bundle generated by Webpack in our application (we are using Angular 1.5~ to build the UI), however due to the single file being a bit bulky and many things were only required in specific areas of the application, I decided to separate my application in multiple bundles, i.e.:</p>
  
  <pre><code>app.bundle.js
  trade.bundle.js
  analysis.bundle.js
  ... and so on
  </code></pre>
  
  <p>On the development environment it worked flawlessly, however, when I tried to build it for production, which the only main difference is that we use the UglifyJS Plugin, to minify the bundles.</p>
  
  <p>And now it doesn't work, the console displays an error "Could not set BrV of undefined", and then tons of other errors due to Angular being unable to load a module and nothing works.</p>
  
  <p>BrV is a third-party plugin I am using for some input validations.</p>
  
  <p>Having separated bundles minified seems to break some scripts which ends up breaking the whole application.</p>
  
  <p>Here is my webpack conf (only the exports section)</p>
  
  <pre><code>// configuration.js
  module.exports = {
      WEBCONTENT_FOLDER: '../WebContent/',
      PATH_TO_OUTPUT: '../WebContent/js/',
      ENTRIES: {
          app: '../WebContent/js/app.js',
          trade: '../WebContent/js/src/trade.js',
          reports: '../WebContent/js/src/reports.js',
          analysis: '../WebContent/js/src/analysis.js',
          wordpress: '../WebContent/js/src/wordpress.js'
      }
  };
  
  // common.js
  module.exports = {
    entry: config.ENTRIES,
  
    module: {
        rules: [
            {
                test: require.resolve(path.resolve(config.WEBCONTENT_FOLDER, 'js/forms')),
                use: 'exports-loader?addNavigation,ajaxCall,isChecked'
            }
        ]
    },
  
    resolve: {
      modules: [
          path.resolve(__dirname)
      ],
  
      alias: {
        ThirdParty: path.resolve(config.WEBCONTENT_FOLDER, 'js/third-party'),
        App: path.resolve(config.WEBCONTENT_FOLDER, 'js/myApp'),
        JS: path.resolve(config.WEBCONTENT_FOLDER, 'js'),
        JSP: path.resolve(config.WEBCONTENT_FOLDER, 'jsp')
      }
    },
  
    plugins: [
      new CleanWebpackPlugin(['dist']),
      new webpack.ProvidePlugin({
          addNavigation: [path.resolve(config.WEBCONTENT_FOLDER, 'js/forms'), 'addNavigation'],
          ajaxCall: [path.resolve(config.WEBCONTENT_FOLDER, 'js/forms'), 'ajaxCall']
      })
    ],
  
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(config.PATH_TO_OUTPUT, 'dist')
    },
  
    externals: {
        'angular': 'angular',
        'jquery': 'jQuery'
    }
  };
  
  // prod.js
  module.exports = merge(common, {
      devtool: 'source-map',
      module: {
            rules: [
                {
                    test: /\.js$/,
                    use: [
                        { loader: 'ifdef-loader', options: opts}
                    ]
                }
            ]
      },
  
      plugins: [
          new ngAnnotatePlugin({
              add: true,
          }),
          // I wasn't passing this object before, but I was trying to make it work, so I added this, mainly for the keep_fnames, which didn't do a thing though...
          new UglifyJSPlugin({
              parallel: 4,
              sourceMap: true,
              uglifyOptions: {
                  ie8: false,
                  mangle: {
                      keep_fnames: true
                  }
              }
          }),
          new MergeIntoSingleFilePlugin({
              files: {
                  'vendor.js': [
                      path.resolve(config.WEBCONTENT_FOLDER, 'js/third-party/dropzone/dropzone.js'),
                      path.resolve(config.WEBCONTENT_FOLDER, 'js/forms.js'),
                      path.resolve(config.WEBCONTENT_FOLDER, 'js//app/app.i18n.js'),
                  ]
              },
              transform: {
                  'vendor.js': code =&gt; require('uglify-js').minify(code).code
              }
          }),
          new webpack.DefinePlugin({
              'ENV': 'prod'
          })
      ]
  });
  </code></pre>
  
  <p>Does anyone have a clue on what might be happening? I can provide more info if needed. Thanks for the help.</p>
  
  <p>Kind regards.</p>
  
  <p><strong>EDIT - Solution</strong></p>
  
  <p><em>Turns out the error was due to faulty code on the BrV plugin indeed. I thought that it was just because it was the first library being loaded, and that even if I fixed this, I'd have trouble with lots of other plugins, but in the end, I fixed the code and everything worked. Thanks.</em></p>