"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _path = _interopRequireDefault(require("path"));

var _babelPresetReactOption = _interopRequireDefault(require("../babel/babel-option-utils/babel-preset-react-option"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

let getDevJsLoaders = options => {
  let {
    app: {
      disableES5Transpile,
      instrumentScript,
      devConsoleExculde
    },
    esLint: {
      enable: enableEslint
    }
  } = options;
  let loaders = [];

  if (instrumentScript) {
    loaders.push({
      loader: require.resolve('../loaders/scriptInstrumentLoader.js')
    });
  }

  loaders.push({
    loader: 'babel-loader',
    options: {
      presets: [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
        modules: false,
        useBuiltIns: 'usage',
        corejs: 3,
        targets: {
          browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions']
        }
      } : {
        modules: false
      }], (0, _babelPresetReactOption.default)({
        disableES5Transpile
      })],
      plugins: disableES5Transpile ? [require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), // require.resolve('@babel/plugin-proposal-object-rest-spread'),
      devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
        exclude: ['error', 'log']
      }] : null].filter(Boolean) : [require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('@babel/plugin-proposal-object-rest-spread'), devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
        exclude: ['error', 'log']
      }] : null].filter(Boolean),
      cacheDirectory: true
    }
  });

  if (enableEslint) {
    loaders.push({
      loader: 'eslint-loader',
      options: {
        emitError: true,
        emitWarning: true,
        configFile: _path.default.join(__dirname, '..', '..', '.eslintrc.js')
      }
    });
  }

  return loaders;
};

var _default = getDevJsLoaders;
exports.default = _default;