Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix source mapping in react-native 0.52 #39

Closed
ds300 opened this issue Jan 9, 2018 · 7 comments
Closed

Fix source mapping in react-native 0.52 #39

ds300 opened this issue Jan 9, 2018 · 7 comments

Comments

@ds300
Copy link
Owner

ds300 commented Jan 9, 2018

following discussion from from #37

@dluksza
Copy link

dluksza commented Jan 9, 2018

Configuration for running jest tests described in #21 (comment) 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)

@ds300
Copy link
Owner Author

ds300 commented Jan 9, 2018

Ah yes, that makes sense. Thanks for the heads-up! I'm going to try duplicating the old upstream transformer locally.

@ds300
Copy link
Owner Author

ds300 commented Jan 9, 2018

Another thing I'm trying is traversing the ast and updating its mappings in place. Seems doable so far.

@ds300 ds300 closed this as completed in b2adc0f Jan 10, 2018
@dluksza
Copy link

dluksza commented Jan 10, 2018

Jest tests are still failing with the same error as mentioned in my previous comment :|

@ds300 ds300 reopened this Jan 10, 2018
@ds300
Copy link
Owner Author

ds300 commented Jan 10, 2018

Ah yes. I should have made another issue for that

@ds300
Copy link
Owner Author

ds300 commented Jan 10, 2018

@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.

@dluksza
Copy link

dluksza commented Jan 11, 2018

@ds300 thank you that works! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants