split transformers

Reviewed By: martinbigio

Differential Revision: D2567545

fb-gh-sync-id: 2e6a341885c701c6a7da35830227dbff7705255c
This commit is contained in:
Bhuwan Khattar 2015-10-21 16:25:24 -07:00 committed by facebook-github-bot-8
parent 54b1402c43
commit 3a8f9e1080
2 changed files with 9 additions and 6 deletions

View File

@ -17,14 +17,12 @@ module.exports = {
// Don't transform node_modules, except react-tools which includes the // Don't transform node_modules, except react-tools which includes the
// untransformed copy of React // untransformed copy of React
if ( if (
file.match(/node_modules\/(?!react-tools\/)/) || file.match(/node_modules\/(?!react-tools\/)/)
// (TODO: balpert, cpojer): Remove this once react is updated to 0.14
file.endsWith('performanceNow.js')
) { ) {
return src; return src;
} }
return transformer.transform(src, file).code; return transformer.transform(src, file, {inlineRequires: true}).code;
}, },
getCacheKey: createCacheKeyFunction([ getCacheKey: createCacheKeyFunction([

View File

@ -14,9 +14,14 @@ const babel = require('babel-core');
const inlineRequires = require('fbjs-scripts/babel/inline-requires'); const inlineRequires = require('fbjs-scripts/babel/inline-requires');
function transform(src, filename, options) { function transform(src, filename, options) {
options = options || {};
const plugins = []; const plugins = [];
if (process.env.NODE_ENV === 'test') { if (
options.inlineRequires &&
// (TODO: balpert, cpojer): Remove this once react is updated to 0.14
!filename.endsWith('performanceNow.js')
) {
plugins.push({ plugins.push({
position: 'after', position: 'after',
transformer: inlineRequires, transformer: inlineRequires,
@ -63,7 +68,7 @@ function transform(src, filename, options) {
module.exports = function(data, callback) { module.exports = function(data, callback) {
let result; let result;
try { try {
result = transform(data.sourceCode, data.filename); result = transform(data.sourceCode, data.filename, data.options);
} catch (e) { } catch (e) {
callback(e); callback(e);
return; return;