Guest User

Untitled

a guest
Feb 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. const typescript = require('typescript');
  2. const babelJest = require('babel-jest');
  3. const path = require('path');
  4.  
  5. const tsConfigPath = path.resolve(__dirname, '../', 'tsconfig.json');
  6.  
  7. const tsConfig = require(tsConfigPath);
  8. console.log('test');
  9. module.exports = {
  10. process(src, path, config,...rest) {
  11. const isTypeScript = path.endsWith('.ts') || path.endsWith('.tsx');
  12. const isJavaScript = path.endsWith('.js') || path.endsWith('.jsx');
  13.  
  14. if (isTypeScript) {
  15. src = typescript.transpile(src, tsConfig.compilerOptions, path, []);
  16. }
  17.  
  18. if (isJavaScript || isTypeScript) {
  19. // babel-jest hack for transpile src without file
  20. const fileName = isJavaScript
  21. ? path
  22. : 'file.js';
  23. src = babelJest.process(src, fileName, config,...rest);
  24. }
  25.  
  26. return src;
  27. },
  28. getCacheKey(fileData, filename) {
  29. // The output is always the same.
  30. return new Date().getTime() + 'test123';
  31. }
  32. };
Add Comment
Please, Sign In to add comment