Closed ds300 closed 6 years ago
Configuration for running jest tests described in https://github.com/ds300/react-native-typescript-transformer/issues/21#issuecomment-330148700 also doesn't work with 0.52
It is failing with error:
● Test suite failed to run
TypeError: Jest: a transform's `process` function must return a string, or an object with `code` key containing this string.
at ScriptTransformer.transformSource (node_modules/jest-runtime/build/script_transformer.js:238:15)
Ah yes, that makes sense. Thanks for the heads-up! I'm going to try duplicating the old upstream transformer locally.
Another thing I'm trying is traversing the ast and updating its mappings in place. Seems doable so far.
Jest tests are still failing with the same error as mentioned in my previous comment :|
Ah yes. I should have made another issue for that
@dluksza you can do this for now:
var tsTransformer = require('react-native-typescript-transformer')
var rnTransformer = require('react-native/jest/preprocessor')
var generate = require('babel-generator')
var preprocessor = Object.assign({}, rnTransformer, {
process (src, file) {
const {ast} = tsTransformer.transform({
filename: file,
localPath: file,
options: {
dev: true,
platform: '',
projectRoot: '',
},
src,
})
return generate.default(ast, {
filename: file,
retainLines: true
}, src)
},
})
module.exports = preprocessor
It doesn't do source mapping, but then neither did the original version.
@ds300 thank you that works! :D
following discussion from from #37