title: Configure Webpack, Node, and the Babel object rest spread transform
body: <p>I am building a Vue application with Vuex, and want to use the <code>...</code> operator to merge objects, but I can't seem to install the Babel transformer.</p>
  
  <p>Here's my configuration file.  It is the last <code>const</code> definition, and the last entry in the plugins array, that are problems.</p>
  
  <pre><code>const path = require('path');
  const CleanWebpackPlugin = require('clean-webpack-plugin');
  const ManifestPlugin = require('webpack-manifest-plugin');
  const ExtractTextPlugin = require('extract-text-webpack-plugin');
  const CopyWebpackPlugin = require('copy-webpack-plugin');
  
  /** here is where I load the object rest spread transformation **/
  const RestSpreadTransform = require('babel-plugin-transform-object-rest-spread');
  
  module.exports = {
      entry: {
          admin : './resources/assets/js/admin/admin.js',
          staff : './resources/assets/js/staff/staff.js'
  
      },
      watch: true,
      watchOptions: {
          aggregateTimeout: 300,
          poll: 1000
      },
      resolve: {
          alias: {
              'vue$': 'vue/dist/vue.esm.js'
          }
      },
      module: {
          rules : [
              {
                  test: /\.js$/,
                  exclude: /(node_modules|bower_components)/,
                  use: {
                      loader: 'babel-loader',
                      options: {
                          presets: ['env']
                      }
                  }
              },
              { test: /\.scss$/,
                  use: ExtractTextPlugin.extract({
                      fallback:'style-loader',
                      use:['css-loader','sass-loader'],
                  })
              },
              { test: /\.(svg|ttf|woff|woff2|eot)$/,
                  use: [{ loader: 'file-loader',
                      options: { outputPath: 'fonts', publicPath: '/dist/fonts'} }]
              },
              {
                  test: require.resolve("./bower_components/typeahead.js/dist/typeahead.jquery.js"),
                  use: "imports-loader?define=&gt;false"
              },
              {
                  test: require.resolve("./bower_components/typeahead.js/dist/bloodhound.js"),
                  use: "imports-loader?define=&gt;false"
              },
              {
                  test: /\.vue$/,
                  loader: 'vue-loader',
                  exclude: /bower_components/,
                  options: {
                      js: {
                          loader: 'babel-loader'
                      }
                  }
              }
          ]
      },
      plugins: [
          new CleanWebpackPlugin(['public/dist']),
          new ManifestPlugin({ fileName : 'mix-manifest.json' }),
          new ExtractTextPlugin({ filename: 'css/[name].css' }),
          new CopyWebpackPlugin([{from:'./resources/assets/images',to:'images'}]),
  
          /** Here is where I instantiate the object rest spread transformation  **/
          new RestSpreadTransform({})
      ],
      output: {
          path: path.resolve(__dirname, 'public/dist'),
          filename: 'js/[name].js'
      }
  };
  </code></pre>
  
  <p>I have installed the transformer with <code>npm install --save-dev babel-plugin-transform-object-rest-spread</code>, as per the instructions at <a href="https://babeljs.io/docs/plugins/transform-object-rest-spread/" rel="nofollow noreferrer">https://babeljs.io/docs/plugins/transform-object-rest-spread/</a></p>
  
  <p>When I try to build my project, it gives the following error:</p>
  
  <pre><code>TypeError: arguments[i].apply is not a function
      at Compiler.apply (/home/vagrant/Code/Client1/Project1/node_modules/tapable/lib/Tapable.js:375:16)
      at webpack (/home/vagrant/Code/Client1/Project1/node_modules/webpack/lib/webpack.js:33:19)
      at processOptions (/home/vagrant/Code/Client1/Project1/node_modules/webpack/bin/webpack.js:335:15)
      at yargs.parse (/home/vagrant/Code/Client1/Project1/node_modules/webpack/bin/webpack.js:397:2)
      at Object.Yargs.self.parse (/home/vagrant/Code/Client1/Project1/node_modules/webpack/node_modules/yargs/yargs.js:533:18)
      at Object.&lt;anonymous&gt; (/home/vagrant/Code/Client1/Project1/node_modules/webpack/bin/webpack.js:152:7)
      at Module._compile (module.js:643:30)
      at Object.Module._extensions..js (module.js:654:10)
      at Module.load (module.js:556:32)
      at tryModuleLoad (module.js:499:12)
      at Function.Module._load (module.js:491:3)
      at Function.Module.runMain (module.js:684:10)
      at startup (bootstrap_node.js:187:16)
      at bootstrap_node.js:608:3
  </code></pre>
  
  <p>Where am I going wrong?  As you can see, I have configured a number of other plugins with no problems.</p>