ds300/react-native-typescript-transformer

react-native bundle?

ajcrites opened this issue ยท 9 comments

I'm trying to create a complete build to generate .ipa / .apk files.

The README specifies that tsc will not actually generate a build. I believe this is probably because of the noEmit rule in tsconfig.json.

I'm trying to use --transformer as well which appears to be an undocumented flag for build, but then I get this output:

Unable to resolve module `./src/App` from `/Users/acrites/projects/personal/rnts3/index.js`: The module `./src/App` could not be found from `/Users/acrites/projects/personal/rnts3/index.js`. Indeed, none of these files exist:

  * `/Users/acrites/projects/personal/rnts3/src/App(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
  * `/Users/acrites/projects/personal/rnts3/src/App/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`

--sourceExts is not a flag for build.

Is there any way to generate a bundle with a react-native TypeScript project using this transformer? If so, should this be documented in the README?

ds300 commented

HI! :)

I'm not sure what this build command you're mentioning is, could you elaborate?

--sourceExts and --transformer are for the react-native bundle command, but I don't think it should be necessary to use that directly for most situations. Maybe those flags are not supported directly any more, in which case it seems you can still use the --config flag to specify which rn-cli.config.js to use

Thanks, I should have said bundle, not build. My bad.

Yes, --sourceExts is not supported by bundle (I suppose anymore). --transformer is supported, but it seems to be undocumented. Using rn-cli.config.js does work though (but is also undocumented). I was able to get it to work just using rn-cli.config.js, but it seems a sketchy that you don't have direct control over this for the builds without changing base configuration.

We ran into the same issue when trying to produce an offline bundle for distribution. The transformer works great in tandem with the RN packager's start process, but not with bundle. It's unclear whether rn-cli.config.js is getting picked up by the packager (is this even supported anymore? we're on RN 0.48.1) so we are using the CLI approach with --transfomer and --sourceExts flags for development, but these flags don't seem to work (--sourceExts specifically) with RN's bundle command.

Is it possible for this transformer to work with bundle?

ds300 commented

@petekp yeah it should work. I tested just now and, bundle works with the --config option, which you can use to specify an absolute path to your rn-cli.config.js file.

@ds300 Yep, the --config option did the trick. Thanks!

I haven't had to use --config with rn-cli.config.js at the root of the repository.

@ajcrites Curious which version of RN you're running. I'm on 0.48.1 and the packager doesn't appear to pick up rn-cli.config.js in root. Have had to use the command line approach.

Oh, I'm on version 53 which may make a difference there.

ds300 commented

I added a note about the --config option to the readme, so will close this issue for now. Please feel free to open it again if you're still having troubles.