/**
 * Base webpack config used across other specific configs
 */

import _ from 'lodash';
import path from 'path';
import { dependencies as externals } from './app/package.json';
import { optionalDependencies as additionalExternals } from './app/package.json';

export default {
  module: {
    rules: [{
      test: /\.jsx?$/,
      use: [{
        loader: 'babel-loader'
      }],
      exclude: /node_modules\/(?!open)/
    }]
  },

  output: {
    path: path.join(__dirname, 'app'),
    filename: 'bundle.js',

    // https://github.com/webpack/webpack/issues/1114
    libraryTarget: 'commonjs2'
  },

  /**
   * Determine the array of extensions that should be used to resolve modules.
   */
  resolve: {
    extensions: ['.js', '.jsx', '.json'],
    mainFields: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'],
    alias: {
      superagent: 'superagent/lib/client.js',
      emitter: 'component-emitter',
      reduce  : 'reduce-component'
    }
  },
  resolveLoader: { },

  plugins: [],

  externals: _.keys(_.merge({}, externals, additionalExternals) || {})
};

/**
 * Base webpack config used across other specific configs
 */

import _ from 'lodash';
import path from 'path';
import { dependencies as externals } from './app/package.json';
import { optionalDependencies as additionalExternals } from './app/package.json';

export default {
  module: {
    rules: [{
      test: /\.jsx?$/,
      use: [{
        loader: 'babel-loader'
      }],
      exclude: /node_modules/
    }]
  },

  output: {
    path: path.join(__dirname, 'app'),
    filename: 'bundle.js',

    // https://github.com/webpack/webpack/issues/1114
    libraryTarget: 'commonjs2'
  },

  /**
   * Determine the array of extensions that should be used to resolve modules.
   */
  resolve: {
    extensions: ['.js', '.jsx', '.json'],
    mainFields: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'],
    alias: {
      superagent: 'superagent/lib/client.js',
      emitter: 'component-emitter',
      reduce  : 'reduce-component'
    }
  },
  resolveLoader: { },

  plugins: [],

  externals: _.keys(_.merge({}, externals, additionalExternals) || {})
};

Revert "don't exclude open dependency from babel-loader, as it contains ES6 spread operator"
Revert "don't exclude open dependency from babel-loader, as it contains ES6 spread operator"

This reverts commit 06a4956dc1535e2e7f31373af69bd805dfa4fca1.
