
module.exports = function createOpts(env, react) {
    const flowOrReactPreset = react ? 'react' : 'flow';
    const production = !env.endsWith('-dev');

    if (!production) {
        env = env.slice(0, -4);
    }

    if (env === 'doc') {
        return {
            presets: ['es2015', flowOrReactPreset, 'stage-1'],
            plugins: ['add-jsdoc-annotations']
        };
    }

    let presets;
    let browser;

    switch (env) {
        case 'es5':
            presets = ['es2015', flowOrReactPreset, 'stage-1'];
            browser = false;
            break;

        case 'test':
        case 'node6':
            presets = ['es2015-node6/object-rest', flowOrReactPreset, 'stage-1'];
            browser = false;
            break;

        case 'webpack':
            presets = ['es2015-webpack', flowOrReactPreset, 'stage-1'];
            browser = true;
            break;

        case 'webpack-modern-browsers':
            presets = ['modern-browsers/webpack2', flowOrReactPreset, 'modern-browsers-stage-1'];
            browser = true;
            break;

        default:
            throw new Error(`Unsupported env ${env}`);

    }

    return {
        presets: presets,
        plugins: [
            react && 'react-require',
            !production && 'typecheck',
            ['defines', { 'PRODUCTION': production, 'BROWSER': browser, 'SERVER': !browser }],
            'remove-dead-code',
            ['discard-module-references', { 'targets': [], 'unusedWhitelist': ['react']  }]
        ].filter(Boolean)
    };
};

@@ -1243,24 +1243,88 @@
 t-require',%0A
+            !production && react && 'transform-react-jsx-self',%0A
             

add jsx-self