Upgrade transformers to be compatible babel 6

Reviewed By: vjeux

Differential Revision: D2626155

fb-gh-sync-id: e919c8fb8bbf139bcd979ee2738c7ec4fc9eba74
This commit is contained in:
Tadeu Zagallo 2015-11-10 10:51:39 -08:00 committed by facebook-github-bot-2
parent 7e89bb9920
commit a88f69e482
3 changed files with 61 additions and 47 deletions

View File

@ -8,9 +8,22 @@
*/
'use strict';
require('babel-polyfill');
var fs = require('fs');
var path = require('path');
var _only = [];
function readBabelRC() {
var rcpath = path.join(__dirname, 'react-packager', '.babelrc');
var source = fs.readFileSync(rcpath).toString();
return JSON.parse(source);
}
module.exports = function(onlyList) {
_only = _only.concat(onlyList);
require('babel-core/register')({only: _only});
var config = readBabelRC();
config.only = _only;
require('babel-core/register')(config);
};

View File

@ -1,27 +1,29 @@
// Keep in sync with packager/transformer.js
{
"retainLines": true,
"compact": true,
"comments": false,
"whitelist": [
"es6.arrowFunctions",
"es6.blockScoping",
"es6.classes",
"es6.constants",
"es6.destructuring",
"es6.modules",
"es6.parameters",
"es6.properties.computed",
"es6.properties.shorthand",
"es6.spread",
"es6.templateLiterals",
"es7.asyncFunctions",
"es7.trailingFunctionCommas",
"es7.objectRestSpread",
"flow",
"react",
"react.displayName",
"regenerator"
"plugins": [
"syntax-async-functions",
"syntax-class-properties",
"syntax-trailing-function-commas",
"transform-es2015-arrow-functions",
"transform-es2015-block-scoping",
"transform-es2015-classes",
"transform-es2015-computed-properties",
"transform-es2015-constants",
"transform-es2015-destructuring",
["transform-es2015-modules-commonjs", {"strict": false, "allowTopLevelThis": true}],
"transform-es2015-parameters",
"transform-es2015-shorthand-properties",
"transform-es2015-spread",
"transform-es2015-template-literals",
"transform-class-properties",
"transform-flow-strip-types",
"transform-object-assign",
"transform-object-rest-spread",
"transform-react-display-name",
"transform-react-jsx",
"transform-regenerator"
],
"sourceMaps": false
}

View File

@ -18,10 +18,7 @@ function transform(src, filename, options) {
const plugins = [];
if (options.inlineRequires) {
plugins.push({
position: 'after',
transformer: inlineRequires,
});
plugins.push([inlineRequires]);
}
const result = babel.transform(src, {
@ -29,31 +26,33 @@ function transform(src, filename, options) {
compact: true,
comments: false,
filename,
whitelist: [
plugins: plugins.concat([
// Keep in sync with packager/react-packager/.babelrc
'es6.arrowFunctions',
'es6.blockScoping',
'es6.classes',
'es6.constants',
'es6.destructuring',
'es6.modules',
'es6.parameters',
'es6.properties.computed',
'es6.properties.shorthand',
'es6.spread',
'es6.templateLiterals',
'es7.asyncFunctions',
'es7.trailingFunctionCommas',
'es7.objectRestSpread',
'flow',
'react',
'react.displayName',
'regenerator',
],
plugins,
'syntax-async-functions',
'syntax-class-properties',
'syntax-jsx',
'syntax-trailing-function-commas',
'transform-class-properties',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-classes',
'transform-es2015-computed-properties',
'transform-es2015-constants',
'transform-es2015-destructuring',
['transform-es2015-modules-commonjs', {strict: false, allowTopLevelThis: true}],
'transform-es2015-parameters',
'transform-es2015-shorthand-properties',
'transform-es2015-spread',
'transform-es2015-template-literals',
'transform-flow-strip-types',
'transform-object-assign',
'transform-object-rest-spread',
'transform-react-display-name',
'transform-react-jsx',
'transform-regenerator',
]),
sourceFileName: filename,
sourceMaps: false,
extra: options || {},
});
return {