Files
react-apollo/preprocessor.js
David Glasser 8c44c430a7 Mostly fix npm test in Node 4
Fixes #246.

tsc.transpile ignores tsconfig.json so we have to specify the ES5 target
manually.
2016-10-06 19:07:12 -07:00

27 lines
641 B
JavaScript

// Copyright 2004-present Facebook. All Rights Reserved.
const tsc = require('typescript');
const babelJest = require('babel-jest');
const babelTransform = babelJest.createTransformer();
module.exports = {
process(src, path) {
if (path.endsWith('.ts') || path.endsWith('.tsx')) {
return tsc.transpile(
src,
{
module: tsc.ModuleKind.CommonJS,
jsx: tsc.JsxEmit.React,
target: tsc.ScriptTarget.ES5
},
path,
[]
);
}
if (path.endsWith('.js') || path.endsWith('.jsx')) {
return babelTransform.process(src, path);
}
return src;
},
};