mirror of
https://github.com/expo/react-apollo.git
synced 2026-11-15 09:08:06 -10:00
Fixes #246. tsc.transpile ignores tsconfig.json so we have to specify the ES5 target manually.
27 lines
641 B
JavaScript
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;
|
|
},
|
|
};
|