ds300/react-native-typescript-transformer

Remove the CLI config file

orta opened this issue ยท 3 comments

orta commented

๐Ÿ‘‹ - I was looking at updating the docs for RN around the cli-config.js file, and in digging around in the RN source code, I noticed that we might not need to do that anymore.

Basically, we added the cli-config to ensure that this code could resolve to this dep.

But passing in

yarn start --transformer "node_modules/react-native-typescript-transformer/index.js" --sourceExts "ts"

should also work, and in an ideal case support in RN could be improved to handle

yarn start --transformer "react-native-typescript-transformer" --sourceExts "ts"

Meaning a bit less process, it's a trade-off, and not one I'm sure I want to recommend yet - but worth noting

--transformer "react-native-typescript-transformer" looks for transformer in root instead of node_modules. Full transformer path is required otherwise it throws the error below.

ENOENT: no such file or directory, open '/MY_PATH/react-native-typescript-transformer'

The second problem is extensions also need tsx, without tsx it won't find any TypeScript component.

So, the right command would be

yarn start --transformer "node_modules/react-native-typescript-transformer/index.js" --sourceExts "ts,tsx"
ds300 commented

Good point. My thinking behind recommending the rn-cli.config.js file is that there are a bunch of ways to run the packager. e.g. react-native run-android, react-native run-ios, react-native bundle, etc. All of these would require the extra config to be passed. So having a central config file reduces the burden of duplication in your package.json scripts entry. But also it lets people use the react-native cli directly, which should cause less friction for people following tutorials?

So yeah, I'm not crazy about the proliferation of config files, but not sure that getting rid of this one would help anyone ๐Ÿคทโ€โ™€๏ธ

orta commented

Yeah, I agree, I don't see much value also - I went and documented this file a bit on the site facebook/react-native-website#462