Skip to content

Commit

Permalink
Show sourcemap support in typescript example
Browse files Browse the repository at this point in the history
Addresses jestjs#5113
  • Loading branch information
felipeochoa authored Dec 18, 2017
1 parent cb98442 commit b2bb8f9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/typescript/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ const tsConfig = require('./tsconfig.json');
module.exports = {
process(src, path) {
if (path.endsWith('.ts') || path.endsWith('.tsx')) {
return tsc.transpile(src, tsConfig.compilerOptions, path, []);
const {outputText, sourceMapText} = tsc.transpileModule(src, {
compilerOptions: tsConfig.compilerOptions,
fileName: path,
reportDiagnostics: false,
});
// Transformers can return a string with the transformed source text
// or a {code, map} if source maps are available
return {code: outputText, map: sourceMapText}
}
return src;
},
Expand Down

0 comments on commit b2bb8f9

Please sign in to comment.