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'; 'use strict';
require('babel-polyfill');
var fs = require('fs');
var path = require('path');
var _only = []; 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) { module.exports = function(onlyList) {
_only = _only.concat(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, "retainLines": true,
"compact": true, "compact": true,
"comments": false, "comments": false,
"whitelist": [ "plugins": [
"es6.arrowFunctions", "syntax-async-functions",
"es6.blockScoping", "syntax-class-properties",
"es6.classes", "syntax-trailing-function-commas",
"es6.constants", "transform-es2015-arrow-functions",
"es6.destructuring", "transform-es2015-block-scoping",
"es6.modules", "transform-es2015-classes",
"es6.parameters", "transform-es2015-computed-properties",
"es6.properties.computed", "transform-es2015-constants",
"es6.properties.shorthand", "transform-es2015-destructuring",
"es6.spread", ["transform-es2015-modules-commonjs", {"strict": false, "allowTopLevelThis": true}],
"es6.templateLiterals", "transform-es2015-parameters",
"es7.asyncFunctions", "transform-es2015-shorthand-properties",
"es7.trailingFunctionCommas", "transform-es2015-spread",
"es7.objectRestSpread", "transform-es2015-template-literals",
"flow", "transform-class-properties",
"react", "transform-flow-strip-types",
"react.displayName", "transform-object-assign",
"regenerator" "transform-object-rest-spread",
"transform-react-display-name",
"transform-react-jsx",
"transform-regenerator"
], ],
"sourceMaps": false "sourceMaps": false
} }

View File

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