Skip to content

Commit

Permalink
Update jest preprocessors to use the ast from the transformers
Browse files Browse the repository at this point in the history
Reviewed By: jeanlauliac

Differential Revision: D6390677

fbshipit-source-id: e023fc32188c2d601b35d7a2e3f0f6f8af067962
  • Loading branch information
rafeca authored and facebook-github-bot committed Nov 22, 2017
1 parent 7fd5aa8 commit 2ae255a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const babelRegisterOnly = require('metro-bundler/src/babelRegisterOnly');
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');
const generate = require('babel-generator').default;

const nodeFiles = RegExp([
'/local-cli/',
Expand All @@ -47,7 +48,7 @@ module.exports = {
).code;
}

return transformer.transform({
const {ast} = transformer.transform({
filename: file,
localPath: file,
options: {
Expand All @@ -58,7 +59,17 @@ module.exports = {
retainLines: true,
},
src,
}).code;
});

return generate(ast, {
code: true,
comments: false,
compact: false,
filename: file,
retainLines: true,
sourceFileName: file,
sourceMaps: true,
}, src).code;
},

getCacheKey: createCacheKeyFunction([
Expand Down

0 comments on commit 2ae255a

Please sign in to comment.