Skip to content

Commit 3a8f9e1

Browse files
voideanvaluefacebook-github-bot-8
authored andcommitted
split transformers
Reviewed By: martinbigio Differential Revision: D2567545 fb-gh-sync-id: 2e6a341885c701c6a7da35830227dbff7705255c
1 parent 54b1402 commit 3a8f9e1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

jestSupport/preprocessor.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ module.exports = {
1717
// Don't transform node_modules, except react-tools which includes the
1818
// untransformed copy of React
1919
if (
20-
file.match(/node_modules\/(?!react-tools\/)/) ||
21-
// (TODO: balpert, cpojer): Remove this once react is updated to 0.14
22-
file.endsWith('performanceNow.js')
20+
file.match(/node_modules\/(?!react-tools\/)/)
2321
) {
2422
return src;
2523
}
2624

27-
return transformer.transform(src, file).code;
25+
return transformer.transform(src, file, {inlineRequires: true}).code;
2826
},
2927

3028
getCacheKey: createCacheKeyFunction([

packager/transformer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ const babel = require('babel-core');
1414
const inlineRequires = require('fbjs-scripts/babel/inline-requires');
1515

1616
function transform(src, filename, options) {
17+
options = options || {};
1718
const plugins = [];
1819

19-
if (process.env.NODE_ENV === 'test') {
20+
if (
21+
options.inlineRequires &&
22+
// (TODO: balpert, cpojer): Remove this once react is updated to 0.14
23+
!filename.endsWith('performanceNow.js')
24+
) {
2025
plugins.push({
2126
position: 'after',
2227
transformer: inlineRequires,
@@ -63,7 +68,7 @@ function transform(src, filename, options) {
6368
module.exports = function(data, callback) {
6469
let result;
6570
try {
66-
result = transform(data.sourceCode, data.filename);
71+
result = transform(data.sourceCode, data.filename, data.options);
6772
} catch (e) {
6873
callback(e);
6974
return;

0 commit comments

Comments
 (0)