Unbreak jest tests (and travis e2e tests)

Reviewed By: mkonicek

Differential Revision: D2652002

fb-gh-sync-id: 8aab8da47dd737acc4ee9acddc484bd3bbdf1184
This commit is contained in:
David Aurelio 2015-11-14 03:23:46 -08:00 committed by facebook-github-bot-4
parent 48ffe711f8
commit b7df3ca666
2 changed files with 20 additions and 38 deletions

View File

@ -6,6 +6,7 @@
"syntax-async-functions", "syntax-async-functions",
"syntax-class-properties", "syntax-class-properties",
"syntax-trailing-function-commas", "syntax-trailing-function-commas",
"transform-class-properties",
"transform-es2015-arrow-functions", "transform-es2015-arrow-functions",
"transform-es2015-block-scoping", "transform-es2015-block-scoping",
"transform-es2015-classes", "transform-es2015-classes",
@ -17,7 +18,6 @@
"transform-es2015-shorthand-properties", "transform-es2015-shorthand-properties",
"transform-es2015-spread", "transform-es2015-spread",
"transform-es2015-template-literals", "transform-es2015-template-literals",
"transform-class-properties",
"transform-flow-strip-types", "transform-flow-strip-types",
"transform-object-assign", "transform-object-assign",
"transform-object-rest-spread", "transform-object-rest-spread",

View File

@ -11,51 +11,33 @@
'use strict'; 'use strict';
const babel = require('babel-core'); const babel = require('babel-core');
const fs = require('fs');
const inlineRequires = require('fbjs-scripts/babel-6/inline-requires'); const inlineRequires = require('fbjs-scripts/babel-6/inline-requires');
const json5 = require('json5');
const path = require('path');
const babelRC =
json5.parse(
fs.readFileSync(
path.resolve(__dirname, 'react-packager', '.babelrc')));
function transform(src, filename, options) { function transform(src, filename, options) {
options = options || {}; options = options || {};
const plugins = [];
const extraPlugins = ['external-helpers-2'];
const extraConfig = {
filename,
sourceFileName: filename,
};
const config = Object.assign({}, babelRC, extraConfig);
if (options.inlineRequires) { if (options.inlineRequires) {
plugins.push([inlineRequires]); extraPlugins.push(inlineRequires);
} }
config.plugins = extraPlugins.concat(config.plugins);
const result = babel.transform(src, { const result = babel.transform(src, Object.assign({}, babelRC, config));
retainLines: true,
compact: true,
comments: false,
filename,
plugins: plugins.concat([
// Keep in sync with packager/react-packager/.babelrc
'external-helpers-2',
'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-object-assign',
'transform-react-display-name',
'transform-react-jsx',
'transform-regenerator',
]),
sourceFileName: filename,
sourceMaps: false,
});
return { return {
code: result.code code: result.code