move patching of RN packager into a separate command 'enable-source-maps'

- patching the packager in 'upgrade' command is a bit too intrusive, this can be done optionally only when source maps are actually needed.
This commit is contained in:
Artur Girenko 2016-02-06 16:00:09 +01:00
parent b274e92275
commit c4113aea85
2 changed files with 14 additions and 9 deletions

View File

@ -33,7 +33,7 @@ Contributions are welcome.
- Simultaneous development of iOS and Android apps is supported
- You can reload app any time, no problem.
- Custom react-native components are supported (with re-natal use-component <name>)
- Source maps are available when you "Debug in Chrome"
- Source maps are available when you "Debug in Chrome" (with re-natal enable-source-maps)
- Optimizations :simple is used to compile "production" index.ios.js and index.android.js
- [Unified way of using static images of rn 0.14+](https://facebook.github.io/react-native/docs/images.html) works
- Works on Linux and Windows (Android only)
@ -272,13 +272,16 @@ To upgrade React Native to newer version please follow the official
[Upgrading](https://facebook.github.io/react-native/docs/upgrading.html) guide of React Native.
Re-Natal makes almost no changes to the files generated by react-native so the official guide should be valid.
### Changes Re-Natal does to original RN application
It would be perfect not to do any changes there, but...
* To make source maps available in "Debug in Chrome" mode re-natal patches
### Enabling source maps when debugging in chrome
To make source maps available in "Debug in Chrome" mode re-natal patches
the react native packager to serve \*.map files from file system and generate only index.\*.map file.
To achieve this [this line](https://github.com/facebook/react-native/blob/master/packager/react-packager/src/Server/index.js#L408)
To achieve this [this line](https://github.com/facebook/react-native/blob/master/packager/react-packager/src/Server/index.js#L413)
of file "node_modules/react-native/packager/react-packager/src/Server/index.js" is modified to match only index.\*.map
To do this run: `re-natal enable-source-maps` and restart packager.
You can undo this any time by deleting `node_modules` and running `re-natal deps`
## Example Apps
* [Luno](https://github.com/alwx/luno-react-native) is a demo mobile application written in ClojureScript.

View File

@ -230,6 +230,7 @@ updateGitIgnore = () ->
fs.appendFileSync(".gitignore", "\n# Figwheel\n#\nfigwheel_server.log")
patchReactNativePackager = () ->
ckDeps.sync {install: true, verbose: false}
log "Patching react-native packager to serve *.map files"
edit "node_modules/react-native/packager/react-packager/src/Server/index.js",
[[/match.*\.map\$\/\)/m, "match(/index\\..*\\.map$/)"]]
@ -428,10 +429,6 @@ doUpgrade = (config) ->
projNameHyph = projName.replace(camelRx, '$1-$2').toLowerCase()
projNameUs = toUnderscored projName
ckDeps.sync {install: true, verbose: false}
patchReactNativePackager()
copyDevEnvironmentFiles(projNameHyph, projName, "localhost")
copyProdEnvironmentFiles(projNameHyph, projName)
log 'upgraded files in env/'
@ -517,6 +514,11 @@ cli.command 'use-component <name>'
.action (name) ->
useComponent(name)
cli.command 'enable-source-maps'
.description 'patches RN packager to server *.map files from filesystem, so that chrome can download them.'
.action () ->
patchReactNativePackager()
cli.command 'copy-figwheel-bridge'
.description 'copy figwheel-bridge.js into project'
.action () ->