How to use babel-preset-react - 2 common examples

To help you get started, we’ve selected a few babel-preset-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jairajs89 / zerver / src / plugin / babel.js View on Github external
filename        : path.join(options.dir, pathname),
            filenameRelative: pathname,
            compact         : false,
            ast             : false,
            comments        : false,
            moduleIds       : true,
            plugins         : [
                babelModuleInner,
            ].concat(
                require('babel-preset-es2015').plugins
                    .filter(function (_, index, list) {
                        // Super dirty hack to remove commonjs module formatter
                        return index !== list.length - 2;
                    })
            ).concat(
                require('babel-preset-react').plugins
            ).concat([
                babelModuleOuter,
            ]),
        }).code;
        headers['Content-Type'] = 'application/javascript';
    } catch (err) {
        console.error('failed to compile JSX file, ' + pathname);
        console.error(err.stack || err.message || err.toString());
        if (options.production) {
            process.exit(1);
        }
    }
    callback(headers, body);
};
github systemjs / plugin-babel / build-babel / systemjs-babel.js View on Github external
};

import runtimeTransformPlugin from 'babel-plugin-transform-runtime';
export let runtimeTransform = {
  plugins: [[runtimeTransformPlugin, { polyfill: false }]]
};

import p1 from 'babel-preset-stage-1';
import p2 from 'babel-preset-stage-2';
import p3 from 'babel-preset-stage-3';
import pReact from 'babel-preset-react';

let pluginsStage1 = p1.plugins;
let pluginsStage2 = p2.plugins;
let pluginsStage3 = p3.plugins;
let pluginsReact  = pReact.plugins;

export { pluginsStage1, pluginsStage2, pluginsStage3, pluginsReact }

// ES2015 plugins to keep in sync with https://github.com/babel/babel/blob/master/packages/babel-preset-es2015/index.js
import templateLiterals from 'babel-plugin-transform-es2015-template-literals';
import literals from 'babel-plugin-transform-es2015-literals';
import functionName from 'babel-plugin-transform-es2015-function-name';
import arrowFunctions from 'babel-plugin-transform-es2015-arrow-functions';
import blockScopedFunctions from 'babel-plugin-transform-es2015-block-scoped-functions';
import classes from 'babel-plugin-transform-es2015-classes';
import objectSuper from 'babel-plugin-transform-es2015-object-super';
import shorthandProperties from 'babel-plugin-transform-es2015-shorthand-properties';
import computedProperties from 'babel-plugin-transform-es2015-computed-properties';
import forOf from 'babel-plugin-transform-es2015-for-of';
import stickyRegex from 'babel-plugin-transform-es2015-sticky-regex';
import unicodeRegex from 'babel-plugin-transform-es2015-unicode-regex';

babel-preset-react

Babel preset for all React plugins.

MIT
Latest version published 8 years ago

Package Health Score

85 / 100
Full package analysis

Popular babel-preset-react functions

Similar packages