module.exports = (babel, userOptions) => {
  const env = babel.env()
  const defaultOptions = {
    lodash: true,
    loose: true,
    modules: env === 'cjs' || env === 'test' ? 'commonjs' : false,
    react: true,
    removePropTypes: env === 'production' ? 'remove' : 'unsafe-wrap',
    runtime: true,
    targets: {
      browsers: env === 'test' ? undefined : ['IE 11', 'Firefox ESR', 'last 2 Chrome versions'],
      node: env === 'test' || '10.0.0',
    },
    typescript: true,
    useBuiltIns: true,
  }
  const {
    lodash,
    loose,
    modules,
    react,
    removePropTypes,
    runtime,
    targets,
    typescript,
    useBuiltIns,
  } = Object.assign(defaultOptions, userOptions)

  const plugins = [
    [require('@babel/plugin-proposal-class-properties').default, {loose}],
    [require('@babel/plugin-proposal-export-namespace-from').default],
    [require('@babel/plugin-proposal-object-rest-spread').default, {loose, useBuiltIns}],
    [require('@babel/plugin-syntax-dynamic-import').default],
    lodash && [require('babel-plugin-lodash')],
    runtime && [
      require('@babel/plugin-transform-runtime').default,
      {regenerator: false, useESModules: !modules},
    ],
    removePropTypes && [
      require('babel-plugin-transform-react-remove-prop-types').default,
      {mode: removePropTypes, removeImport: removePropTypes === 'remove'},
    ],
  ].filter(Boolean)

  const presets = [
    [
      require('@babel/preset-env').default,
      {loose, modules, targets, corejs: 3, useBuiltIns: 'entry'},
    ],
    typescript && [
      require('@babel/preset-typescript').default,
      typeof typescript === 'object' ? typescript : {},
    ],
    react && [
      require('@babel/preset-react').default,
      typeof react === 'object' ? {useBuiltIns, ...react} : {useBuiltIns},
    ],
  ].filter(Boolean)

  return {plugins, presets}
}

@@ -18,21 +18,17 @@
 (babel, 
-userO
+o
 ptions) 
@@ -69,25 +69,8 @@
 onst
- defaultOptions =
  %7B%0A 
@@ -78,17 +78,18 @@
   lodash
-:
+ =
  true,%0A 
@@ -96,17 +96,18 @@
    loose
-:
+ =
  true,%0A 
@@ -116,17 +116,18 @@
  modules
-:
+ =
  env ===
@@ -182,17 +182,18 @@
    react
-:
+ =
  true,%0A 
@@ -210,17 +210,18 @@
 ropTypes
-:
+ =
  env ===
@@ -273,17 +273,18 @@
  runtime
-:
+ =
  true,%0A 
@@ -293,17 +293,18 @@
  targets
-:
+ =
  %7B%0A     
@@ -456,17 +456,18 @@
 pescript
-:
+ =
  true,%0A 
@@ -484,205 +484,30 @@
 tIns
-: true,%0A  %7D%0A  const %7B%0A    lodash,%0A    loose,%0A    modules,%0A    react,%0A    removePropTypes,%0A    runtime,%0A    targets,%0A    typescript,%0A    useBuiltIns,%0A  %7D = Object.assign(defaultOptions, userO
+ = true,%0A  %7D = o
 ptions
-)
 %0A%0A  

Simplify handling of option defaults