Commit Graph

400 Commits

Author SHA1 Message Date
jsdevel d4cc5b53c7 Setting current working directory for dev server.
Summary:
* This allows `react-native` to work for users on fedora.
* `react-native run-android` was failing because the launch packager script was unable to find packager.sh (see `source` in `man bash`).
* This change sets cwd for the dev server when run with `run-android`.
Closes https://github.com/facebook/react-native/pull/7316

Differential Revision: D3255866

fb-gh-sync-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
fbshipit-source-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
2016-05-04 02:45:29 -07:00
Sawyer Hood 9425bcff8f Updated a warning string in upgrade.js
Summary:
I inserted an 'in' in the warning message that is displayed when the user's package.json file doesn't have a valid version number for react native.

Test plan
---------------
-run upgrade.js on a project with an invalid version number.
Closes https://github.com/facebook/react-native/pull/7314

Differential Revision: D3245839

fb-gh-sync-id: e38f3be0884d8c75f9610faced85d5c81c24a49e
fbshipit-source-id: e38f3be0884d8c75f9610faced85d5c81c24a49e
2016-04-30 18:21:17 -07:00
Janic Duplessis f8f9362c05 Reverted commit D3242754
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.

I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.

**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.

I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155

Differential Revision: D3242754

Pulled By: eczarny

fb-gh-sync-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
fbshipit-source-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
2016-04-30 16:54:31 -07:00
Janic Duplessis 19429f79b2 Use a separate babel config for the local-cli and the packager
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.

I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.

**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.

I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155

Differential Revision: D3242754

Pulled By: davidaurelio

fb-gh-sync-id: 02880c841c10562d5f107e1c975d668e55cc619f
fbshipit-source-id: 02880c841c10562d5f107e1c975d668e55cc619f
2016-04-30 16:25:24 -07:00
David Aurelio 34dd17cae5 Add encoding/hash signature to JS files
Reviewed By: tadeuzagallo

Differential Revision: D3241028

fb-gh-sync-id: 737ae64cf3a3f4f121076dbfe933d5fe71e07817
fbshipit-source-id: 737ae64cf3a3f4f121076dbfe933d5fe71e07817
2016-04-30 09:44:23 -07:00
Mark Oswald 90f9f48498 add reset-cache command to bundle
Summary:
Currently the `react-native bundle` has no option to reset the file cache. For example changing the .babelrc has no effect on the bundling process. `react-native start` has it already implemented, so this is just a small addition.

**Test plan (required)**

the issue:

- `react-native init` a new project
- run `react-native bundle` (should work as expected)
- create `.babelrc` with empty object ```{}```
- rerun `react-native bundle`
- should fail now with `Unexptected token` (no babel plugins configured)
 - if not failing, your cache already hit (clear $TMPDIR to get the error)
- delete .babelrc and rerun `bundle`
- still failing, but it should went back to normal
- delete your $TMPDIR contents
- works again

The option `--reset-cache` should fix that
Closes https://github.com/facebook/react-native/pull/7297

Differential Revision: D3241259

Pulled By: davidaurelio

fb-gh-sync-id: 0ed5b58aa1f021d72021f4c80fbc57d2e7e8181f
fbshipit-source-id: 0ed5b58aa1f021d72021f4c80fbc57d2e7e8181f
2016-04-29 10:38:29 -07:00
David Aurelio cccb8db175 Unify source map approach for RA bundles on iOS/Android
Reviewed By: javache

Differential Revision: D3229780

fb-gh-sync-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
fbshipit-source-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
2016-04-29 10:16:22 -07:00
Shawn Wilsher 856f9e9fed Add `--version` to `local-cli/cli.js`
Summary:
[Buck](https://buckbuild.com) has a concept of a versioned tool.  In order to
properly use RN with Buck, the `cli.js` script should return the proper version
when passed `--version`.

Reviewed By: astreet

Differential Revision: D3197207

fb-gh-sync-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0
fbshipit-source-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0
2016-04-29 09:25:32 -07:00
Martin Konicek 12caa363a1 Remove 'react-native link'
Summary:
`react-native link` was an early experiment, [rnpm](https://github.com/rnpm/rnpm) does this much better. After merging this PR we should merge rnpm so that `react-native link` works again :)

grabbou Kureev Just making some space here :)

This reverts 4e5a2bc079.

**Test Plan**

e2e tests on Travis and CircleCI
Closes https://github.com/facebook/react-native/pull/7290

Differential Revision: D3240702

Pulled By: mkonicek

fb-gh-sync-id: 6aac83fac599ba3db0dd0a7ac48653ebabd93491
fbshipit-source-id: 6aac83fac599ba3db0dd0a7ac48653ebabd93491
2016-04-29 05:27:28 -07:00
Jagdeep Nagpal 3d0d426d46 Renamed --flavor to --variant
Summary:
This small update to runAndroid.js which renames --flavor to --variant.
~~`react-native run-android --flavor=staging`~~

~~doesn't work as it needs build type as well~~

~~so at present it needs to be like this~~

~~`react-native run-android --flavor=stagingDebug`~~

~~it looks messy, instead if we want to use the original spec then Debug must be concatenated to the end all the time as run-android was speced to trigger only debug builds~~
Closes https://github.com/facebook/react-native/pull/7036

Differential Revision: D3240692

Pulled By: mkonicek

fb-gh-sync-id: ef4570797b53ac8f76d0b86a263916ac5bdb0581
fbshipit-source-id: ef4570797b53ac8f76d0b86a263916ac5bdb0581
2016-04-29 05:18:24 -07:00
Janic Duplessis 891b87e7fb Launch the packager with `react-native run-android` on Windows
Summary:
Adds support for launching the packager in a new window on Windows.

**Test plan (required)**

Tested that the packager is launched in a completely independent process. This means that exiting the `react-native run-android` command should not close the packager window and it should exit properly when completed even if the packager window is still opened. Pretty much made sure it behaves exactly like on mac.

Also tested that an error in the packager will not close the window immediately to show the error stack trace.
Closes https://github.com/facebook/react-native/pull/7129

Differential Revision: D3240628

Pulled By: mkonicek

fb-gh-sync-id: 007582250536481d2b2376f9a201f8f415fc1080
fbshipit-source-id: 007582250536481d2b2376f9a201f8f415fc1080
2016-04-29 04:14:22 -07:00
David Aurelio e3c18c3990 Upgrade to node-haste@2.10.0 and allow to specify extra node modules
Summary: This upgrades to node-haste@2.10.0 and allows to expose folders as additional node modules from rn-cli.config.js

Reviewed By: bestander

Differential Revision: D3232595

fb-gh-sync-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
fbshipit-source-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
2016-04-28 06:33:27 -07:00
Alex Kotliarskyi 8295d27a90 Fix usage of react-native cli inside package.json scripts
Summary:
IIRC we made `wrong-react-native` to warn people in case they installed `react-native` globally (instead of `react-native-cli` what the guide suggests). To do that we added `bin` entry to React Native's `package.json` that points to `local-cli/wrong-react-native.js`

However, this means that if we have a project that uses `react-native` package and has call to `react-native` CLI inside its package.json, npm will execute *local* override (which just prints a confusing in this context error message).

In fact, the template we generate with `react-native init` has `react-native start` as `start` script, which makes it useless. Let's fix it by making `wrong-react-native` script smarter – it can detect that it has been executed from local `node_modules` and run the actual CLI.

cc vjeux ide
Closes https://github.com/facebook/react-native/pull/7243

Differential Revision: D3226645

Pulled By: frantic

fb-gh-sync-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
fbshipit-source-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
2016-04-26 15:42:35 -07:00
James Ide 6fac6db4d4 Use xcodebuild and delete "Framework Search Paths" for Xcode 7.3 to un-stall the tests
Summary:The Obj-C tests were stalling when we updated TravisCI to use the OS X image with Xcode 7.3 and iOS 9.3.

On my own MBP with Xcode 7.3 the tests stall as well. Running `./scripts/objc-test.sh` prints out a warning near the end, which says `ld` couldn't find a Frameworks folder under the iPhoneSimulator9.3 SDK directory. Indeed, this directory doesn't exist on my computer. When creating a brand new project with unit tests and UI tests, both test targets don't specify "Framework Search Paths" so I don't think we need to specify it anymore.
Closes https://github.com/facebook/react-native/pull/7168

Differential Revision: D3216524

fb-gh-sync-id: 3097bda98d78289ecdba86801bcd461f3311ac47
fbshipit-source-id: 3097bda98d78289ecdba86801bcd461f3311ac47
2016-04-22 23:04:19 -07:00
Alexey Lang 8aa82d3b33 Add flag "-lc++" for all checked-in projects
Reviewed By: bestander

Differential Revision: D3214654

fb-gh-sync-id: cb07b439156ab5ff1f909f69c766c09da2a027c6
fbshipit-source-id: cb07b439156ab5ff1f909f69c766c09da2a027c6
2016-04-22 16:23:18 -07:00
Raul Ascencio 44d36f7c5f removing xterm from linux spawn
Summary:Simply removing the xterm spawn from android packager, since you can archive exactly the same results using the standard shell 😄
Closes https://github.com/facebook/react-native/pull/7077

Differential Revision: D3212548

Pulled By: mkonicek

fb-gh-sync-id: 8cc03d2708614f64e1394ca738e5de0ba631deb9
fbshipit-source-id: 8cc03d2708614f64e1394ca738e5de0ba631deb9
2016-04-22 09:01:22 -07:00
Mike Grabowski d9349a7b79 Update imports in generated projects
Summary:Fixes warnings when React API is used by requiring 'react-native'.
Closes https://github.com/facebook/react-native/pull/7060

Differential Revision: D3196109

Pulled By: mkonicek

fb-gh-sync-id: b47afc138cd7909ad53c0d67a65e3a124b87134b
fbshipit-source-id: b47afc138cd7909ad53c0d67a65e3a124b87134b
2016-04-19 05:11:27 -07:00
Leland Richardson e9398c7926 Whitelist the 'pdf' extension in the packager
Summary:The WebView component in iOS currently does not support displaying PDFs without providing a remote URI or manually including the assets in the xcodeproj itself. This is because the packager has not whitelisted the 'pdf' extension.

I've gone ahead and whitelisted the 'pdf extension according to the recommendation by nicklockwood

GH comment: https://github.com/facebook/react-native/issues/1846#issuecomment-199302488
Closes https://github.com/facebook/react-native/pull/7004

Differential Revision: D3196019

Pulled By: nicklockwood

fb-gh-sync-id: 10a86a9232095f98f277506141de0b8af5b21ab4
fbshipit-source-id: 10a86a9232095f98f277506141de0b8af5b21ab4
2016-04-19 03:52:27 -07:00
Konstantin Raev 59a11995b3 increased timeout for ios e2e test and fixed --js e2e after ios e2e
Summary:Packager usually builds within 250 seconds and sometimes misses test timeout.
Also added non-persistent option to make it build faster.
Should be fine because we don't test live reloading in ios
Closes https://github.com/facebook/react-native/pull/6974

Differential Revision: D3178884

fb-gh-sync-id: e9bf75456f1cf480ffea6aa2c769550b40eb3d32
fbshipit-source-id: e9bf75456f1cf480ffea6aa2c769550b40eb3d32
2016-04-14 04:30:00 -07:00
Konstantin Raev f9bd789206 E2e android
Summary:- converted shell script `scripts/e2e-test.sh` into JS script to have more programming flexibility
- using appium execute 2 tests after a fresh React Native app installation: check HMR and that debugging mode does not crash the app
- made sure tests can be stable on limited CI systems and added ways to debug any problems in the future

Using appium we can now interact with Android app and test its state.
As a follow up i am planning to write a blog post on how to use appium with android and ios for e2e testing.
Closes https://github.com/facebook/react-native/pull/6840

Differential Revision: D3173635

Pulled By: mkonicek

fb-gh-sync-id: 3cf044bc9f64d1a842ae4589dd1bcab76de3d66a
fbshipit-source-id: 3cf044bc9f64d1a842ae4589dd1bcab76de3d66a
2016-04-13 08:20:05 -07:00
Sam Swarr 6b61e5927c Transform packager src files in cli entry point
Reviewed By: bestander

Differential Revision: D3163457

fb-gh-sync-id: 15cafcf39b2a463d1200f3dddf025b1375b1e1d3
fbshipit-source-id: 15cafcf39b2a463d1200f3dddf025b1375b1e1d3
2016-04-11 12:43:25 -07:00
Sam Swarr a35ef6c745 Remove socket interface from dependencies command
Reviewed By: davidaurelio

Differential Revision: D3136438

fb-gh-sync-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
fbshipit-source-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
2016-04-11 09:23:29 -07:00
Sam Swarr bc81cc4073 Remove socket interface from buildBundle command
Reviewed By: davidaurelio

Differential Revision: D3137070

fb-gh-sync-id: 8f3bb4af597bf509d16e5ce26f31fe1646acbc57
fbshipit-source-id: 8f3bb4af597bf509d16e5ce26f31fe1646acbc57
2016-04-11 09:23:29 -07:00
Sam Swarr 66d5529ea4 Have parseCommandLine use a new instance of optimist for each run
Reviewed By: mjmahone

Differential Revision: D3156730

fb-gh-sync-id: 0a55d0c231a93a6c590bd8c4a6eb793eda66f32f
fbshipit-source-id: 0a55d0c231a93a6c590bd8c4a6eb793eda66f32f
2016-04-08 12:09:22 -07:00
digeff 4c8a9f0d00 Added support for JavaScript third-party debuggers
Summary:* Add ability to configure the app that should open when starting debugging

axemclion discussed this feature with tadeuzagallo and martinbigio on: https://github.com/facebook/react-native/issues/5051
Closes https://github.com/facebook/react-native/pull/5683

Reviewed By: martinbigio

Differential Revision: D2971497

Pulled By: mkonicek

fb-gh-sync-id: 91c3ce68feed989658124bb96cb61d03dd032599
fbshipit-source-id: 91c3ce68feed989658124bb96cb61d03dd032599
2016-04-07 13:15:58 -07:00
Martin Konicek e4865a5609 Clean up after removing the Stetho dependency from open source React Native
Summary:We've removed the Stetho dependency from open source React Native, removing stuff that's not needed anymore.
Closes https://github.com/facebook/react-native/pull/6864

Differential Revision: D3150758

Pulled By: mkonicek

fb-gh-sync-id: fad4408df16f52914357dc474eb1d8d965cfac60
fbshipit-source-id: fad4408df16f52914357dc474eb1d8d965cfac60
2016-04-07 10:18:22 -07:00
David Aurelio 817ec2d756 wait for bundle save, don't silence errors
Summary:The logic when saving a bundle was flawed: we didn?t wait for promises returned by the `save` operation.
That would silence all errors from `save`.

Reviewed By: andreicoman11

Differential Revision: D3150363

fb-gh-sync-id: cdabf6f0e171aece5bd1fcb59654fa7c147988ba
fbshipit-source-id: cdabf6f0e171aece5bd1fcb59654fa7c147988ba
2016-04-07 08:58:23 -07:00
David Aurelio b8da6a2963 Wait for the modules directory to be created before writing module files
Summary: Typo: the operation of writing module files to a common sub-directory didn?t wait until that directory was created, because `Promise.all` was invoked directly as argument to `.then()`, rather than putting it in a lambda function.

Reviewed By: andreicoman11

Differential Revision: D3150338

fb-gh-sync-id: c65270b1757a248993048b039f5ebadb281b2eea
fbshipit-source-id: c65270b1757a248993048b039f5ebadb281b2eea
2016-04-07 08:26:26 -07:00
Chris Liu a1e105eea5 react app root path can be override by env var 'react_native_app_root'
Summary:This PR is to solve app build issue when node_modules is a symlink by providing an environmental variable to override the current *smart* guessing of app root path.
I met this issue when I tried to setup a shared incremental node_modules directory to speed our react-native app build speed in CI. But the build crashed in step 'bundleReleaseJsAndAssets' with error messages like:
> :app:bundleReleaseJsAndAssets
> bundle: Created ReactPackager
> uncaught error Error: NotFoundError: Cannot find entry file index.android.js in any of the roots:["/home/jenkins/shared_data"]

The build is fixed by applying this patch and adding 'export react_native_app_root=${WORKSPACE}' before './gradlew assembleRelease' in build script.

**Test plan**
1. react-native init demo # init a demo app from scratch
2. cd demo/android && ./gradlew assembleRelease # build works fine
3. mkdir ~/shared_data && mv ../node_modules ~/shared_data && cd .. && ln -s ~/shared_data/node_modules . # create symlink for node_modules in shared d
Closes https://github.com/facebook/react-native/pull/6859

Differential Revision: D3150341

fb-gh-sync-id: efbe19b7f6b3053f18d8e568deb75d24861c27ff
fbshipit-source-id: efbe19b7f6b3053f18d8e568deb75d24861c27ff
2016-04-07 07:39:22 -07:00
James Ide c30d125050 Honor the version of "react" under peerDeps when setting up a new project
Summary:We need this since React 15.0.0 is coming and will break `react-native init`, which currently installs the latest version of React. We'll need some changes to React Native to support 15 that Sebastian is actively working on, but till that lands we want `react-native init` to continue working.
Closes https://github.com/facebook/react-native/pull/6846

Differential Revision: D3148182

Pulled By: sebmarkbage

fb-gh-sync-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b
fbshipit-source-id: 3df5bc184c0b82d2c9c320c620256c7c8568d90b
2016-04-07 00:07:21 -07:00
Adam Miskiewicz 8200041694 Pass transformOptions to getShallowDependencies.
Summary:We weren't passing `transformOptions` to `getShallowDependencies`, and therefore, when this method was called on a module, it would bust the cache and cause a retransform of the file. This was resulting in a complete retransforming of all files when the HMR Client connected to the packager.
Closes https://github.com/facebook/react-native/pull/6843

Differential Revision: D3145306

Pulled By: martinbigio

fb-gh-sync-id: 3619c27801b2fc07b758fafed47fcc892bb8e6db
fbshipit-source-id: 3619c27801b2fc07b758fafed47fcc892bb8e6db
2016-04-06 11:38:27 -07:00
Nick 2a03182b1c CHORE - Remove Trailing Spaces
Summary:Remove Trailing Spaces.

Why:
Sometimes there are conflicts with trailing spaces
Saves space
Those whose tools automatically delete them will have their pr watered down with trailing space removal
Closes https://github.com/facebook/react-native/pull/6787

Differential Revision: D3144704

fb-gh-sync-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8
fbshipit-source-id: d8a62f115a3f8a8a49d5b07f56c540a02af38cf8
2016-04-06 09:21:53 -07:00
Konstantin Raev ce1261a3dd Added BUCK to generated app with react-native-cli init
Summary:BUCK is faster than Gradle.
For example `gradle app:installDebug` vs `buck install app` is ~7 seconds vs ~2 seconds with warm caches.
This is just the beginning to allow people to become familiar with BUCK.
It is enough for running the app locally and testing on a device.

Gradle is still used for dependency resolution.
Closes https://github.com/facebook/react-native/pull/6733

Differential Revision: D3126328

Pulled By: bestander

fb-gh-sync-id: 56aad276036c029af7e0e23d60c46ba2f77b3d2c
fbshipit-source-id: 56aad276036c029af7e0e23d60c46ba2f77b3d2c
2016-04-01 08:54:19 -07:00
Mark Oswald dac028d496 Make iOS project path configurable by parameter in run-ios cli command
Summary:In projects where you have multiple apps or a different structure (ios is not the directory containing the xcode project) it would be helpful to have the option to configure the directory containing the xcode project when doing "react-native run-ios"

As my PR does not change and does not affect UI it's hard to show a video ;-) Steps to reproduce are:

1. checkout facebook/react-native
2. run 'react-native run-ios' (it will fail)
3. npm link react-native (with my PR)
4. re-run 'react-native run-ios --ios-project-path Examples/Movies/

Now the simulator should open the Movies example app
Closes https://github.com/facebook/react-native/pull/6134

Differential Revision: D3035188

fb-gh-sync-id: edb924ce3cca4e82161cdce3d25f321b03abc765
fbshipit-source-id: edb924ce3cca4e82161cdce3d25f321b03abc765
2016-04-01 08:03:20 -07:00
Satyajit Sahoo a7cde8045b Apply react.gradle from node_modules/react-native
Summary:The goal is to minimize the number of files we need to bootstrap. This allows us to make the upgrade process smoother for everyone.

If someone needs to customize the file, we already provide some config options. The ability to copy the file and modify it is always there for those few who need it.

**Test plan**

Generate a new project with the updated template.  The app should build and run fine both in debug and production mode.

Related #6292
Closes https://github.com/facebook/react-native/pull/6610

Differential Revision: D3109099

Pulled By: foghina

fb-gh-sync-id: 13fc89e60daed30bf6349e532a140c1b6f8f053a
fbshipit-source-id: 13fc89e60daed30bf6349e532a140c1b6f8f053a
2016-03-29 07:39:21 -07:00
Martín Bigio 8edc35004c Move preloaded modules to startup code section
Summary:We found that moving the preloaded modules to the startup section of the RAM Bundle improves TTI quite a bit by saving lots of through the bridge calls and injecting multiple modules at once on JSC. However, doing this on a non hacky way required a lot of work. The main changes this diff does are:
  - Add to `BundleBase` additional bundling options. This options are fetched based on the entry file we're building by invoking a module that exports a function (`getBundleOptionsModulePath`).
  - Implement `BundleOptions` module to include the `numPreloadedModules` attribute as a bundle additional option. This value is computed by getting the dependencies the entry file has and looking for the first module that exports a module we don't want to preload. The `numPreloadedModules` attribute is then used to decide where to splice the array of modules.
- Additional kung fu to make sure sourcemaps work for both preloaded and non preloaded modules.

Reviewed By: davidaurelio

Differential Revision: D3046534

fb-gh-sync-id: 80b676222ca3bb8b9eecc912a7963be94d3dee1a
shipit-source-id: 80b676222ca3bb8b9eecc912a7963be94d3dee1a
2016-03-23 09:28:31 -07:00
Martín Bigio 1ef9e4dc59 Make HMR compatible with numeric IDs
Summary:We recently refactor the packager to transform the module names into numeric IDs but we forgot to update the HMR call site. As a consequence, HMR doesn't work the first time a file is saved but the second one.

This is affecting master as of 3/20. If we don't land this before v0.23 is cut we'll have to cherry pick it. This rev does *not* need to be picked on v0.22.

Reviewed By: bestander

Differential Revision: D3075192

fb-gh-sync-id: 410e4bf8f937c0cdb8f2b462dd36f928a24e8aa8
shipit-source-id: 410e4bf8f937c0cdb8f2b462dd36f928a24e8aa8
2016-03-21 15:51:24 -07:00
David Aurelio 5b5a89aefa Add sourcemap support for asset-based random access bundles
Summary:This adds support for source maps that can be used for “random access modules” / “unbundles”

- source maps contain an extra custom field: `x_facebook_offsets`
- this field maps module IDs to line offsets
- the source map is built as if all files were concatenated

Decoding/symbolication works as follows:
- when decoding a stack trace, and a stack frame comes from a filename that contains only numbers and ends with `.js`, look up the additionally needed line offset in the offset map and add it to the original line of the stack frame.
- consume the source map as usual

Reviewed By: martinbigio

Differential Revision: D3072426

fb-gh-sync-id: 827e6dc13b1959f02903baafa7f9e4fc2e0d4bb9
shipit-source-id: 827e6dc13b1959f02903baafa7f9e4fc2e0d4bb9
2016-03-21 12:32:22 -07:00
farwayer dcf4600a7c Using local-cli in gradle
Summary:Same as d87d127 but for gradle. It will help to prevent installing global `react-native-cli` (more simple CI server configuration for ex.)
Tested on Linux and Windows.
Closes https://github.com/facebook/react-native/pull/6272

Differential Revision: D3076101

Pulled By: foghina

fb-gh-sync-id: 89c3870536b1ce3fdbb909909b887f3ce68b2951
shipit-source-id: 89c3870536b1ce3fdbb909909b887f3ce68b2951
2016-03-21 09:21:26 -07:00
Kyle Corbitt 322f210e64 flowconfig adds flow/ folder
Summary:This change adds the `flow/` folder to the generated `.flowconfig` in new/upgraded projects. The absence of this folder was causing flow bugs to appear in projects consuming react-native that weren't visible in react-native itself. By including the same definition in consuming projects these errors disappear. Fixes https://github.com/facebook/react-native/issues/6428.

**Test plan (required)**

Tested `react-native upgrade` with this change and ensured that the generated `.flowconfig` works and didn't throw flow errors.
Closes https://github.com/facebook/react-native/pull/6430

Differential Revision: D3071701

fb-gh-sync-id: f28f4d8f7e63669386766b6f226144adeda32c85
shipit-source-id: f28f4d8f7e63669386766b6f226144adeda32c85
2016-03-21 06:26:34 -07:00
Janic Duplessis 4807290442 Fix cli config file on Windows
Summary:The local-cli didn't pickup the `rn-cli.config.js` file on Windows because the root of a path is not 1 character long since it is 'C:/' and broke the path operations. This just substrings the root length instead of hard coding 1.

Also fix a lint warning in the file about path concatenation but using string interpolation.

Fixes  #5686

**Test plan (required)**

Tested that the `findParentDirectory` function returns the path of `rn-cli.config.js` if present or null if not on both windows and mac.
Closes https://github.com/facebook/react-native/pull/6553

Differential Revision: D3075196

Pulled By: mkonicek

fb-gh-sync-id: a19ab4030ec22d85bef40d7d91de53bc1da072ca
shipit-source-id: a19ab4030ec22d85bef40d7d91de53bc1da072ca
2016-03-20 18:09:20 -07:00
Sam Swarr fa44607bf6 Add packager worker for Buck
Reviewed By: martinbigio

Differential Revision: D3051886

fb-gh-sync-id: da19ee987c0ec04cde550147d57bd90d98712e14
shipit-source-id: da19ee987c0ec04cde550147d57bd90d98712e14
2016-03-18 12:45:29 -07:00
Martin Bigio d0caf7e48b Fix HMR variable namings
Reviewed By: sam-swarr

Differential Revision: D3065862

fb-gh-sync-id: b7be3187bbc5d659e863d19071cb6d13a7d8199d
shipit-source-id: b7be3187bbc5d659e863d19071cb6d13a7d8199d
2016-03-17 15:06:26 -07:00
Martín Bigio dd2415df73 seek & read RAM Bundle
Summary: For RAM bundling we don't want to hold the entire bundle in memory as that approach doesn't scale. Instead we want to seek and read individual sections as they're required. This rev does that by detecting the type of bundle we're dealing with by reading the first 4 bytes of it. If we're dealing with a RAM Bundle we bail loading.

Reviewed By: javache

Differential Revision: D3026205

fb-gh-sync-id: dc4c745d6f00aa7241203899e5ba136915efa6fe
shipit-source-id: dc4c745d6f00aa7241203899e5ba136915efa6fe
2016-03-17 10:35:28 -07:00
Sam Swarr d5445d5fbc Add ability to silence packager logs to stdout
Summary:We use a few different modules to output logs to stdout when building a bundle with the packager:
- ##js/react-native-github/packager/react-packager/src/Activity/index.js##
- ##js/react-native-github/local-cli/util/log.js##
- ##https://www.npmjs.com/package/progress##

This diff also adds a ##silent## option to the packager ##Server##, which, when ##true##, will not create a ##progress## instance for the transformer.

Reviewed By: martinbigio

Differential Revision: D3048739

fb-gh-sync-id: a4c6caf36f5127946593f4a0a349fa145ad0d4e6
shipit-source-id: a4c6caf36f5127946593f4a0a349fa145ad0d4e6
2016-03-15 12:10:31 -07:00
David Aurelio bff0b1f9d6 Use numeric module IDs for iOS RA-bundles
Summary:Use the new numeric module IDs for indexed-file random access bundles, rather than string-based module names

This still uses those IDs as strings in the table, to make this bundle format work again.

Reviewed By: martinbigio

Differential Revision: D3050337

fb-gh-sync-id: f8da69cdbafd1b093a71474698796be5d21fc4f6
shipit-source-id: f8da69cdbafd1b093a71474698796be5d21fc4f6
2016-03-14 17:21:19 -07:00
David Aurelio 06b5bda349 Bring back "Use numeric identifiers when building a bundle"
Summary:This brings back "Use numeric identifiers when building a bundle", previously backed out.
This version passes on the correct entry module name to code that decides transform options.

Original Description:
Since the combination of node and haste modules (and modules that can be required as both node and haste module) can lead to situations where it’s impossible to decide an unambiguous module identifier, this diff switches all module ids to integers. Each integer maps to an absolute path to a JS file on disk.

We also had a problem, where haste modules outside and inside node_modules could end up with the same module identifier.

This problem has not manifested yet, because the last definition of a module wins. It becomes a problem when writing file-based unbundle modules to disk: the same file might be written to concurrently, leading to invalid code.

Using indexed modules will also help indexed file unbundles, as we can encode module IDs as integers rather than scanning string IDs.

Reviewed By: martinbigio

Differential Revision: D2855202

fb-gh-sync-id: 9a011bc403690e1522b723e5742bef148a9efb52
shipit-source-id: 9a011bc403690e1522b723e5742bef148a9efb52
2016-03-14 16:17:20 -07:00
David Aurelio 9d33905786 Move name resolution of inversed dependencies to HMR server
Summary:Name resolution of inversed dependencies used to happen in node-haste, but that makes it difficult switiching to numeric module IDs.
This moves the name resolution to the HMR server in order to be able to change the logic more easily.

node-haste 2.9.0 provides a `Map` of modules to `Set`s that contain the modules that depend on the key.

Reviewed By: martinbigio

Differential Revision: D3047414

fb-gh-sync-id: b98accea901d4da209dc4434ab111eb07ce9e2a0
shipit-source-id: b98accea901d4da209dc4434ab111eb07ce9e2a0
2016-03-14 08:56:28 -07:00
Martín Bigio f99468de65 Sourcemaps support for RAM
Summary:This rev adds support for production sourcemaps on RAM.

When we inject a module into JSC we use the original `sourceURL` and specify the `startingLineNumber` of the module relative to a "regular" bundle. By doing so, when an error is thrown, JSC will include the provided `sourceURL` as the filename and will use the indicated `startingLineNumber` to figure out on which line the error actually occurred.

To make things a bit simpler and avoid having to deal with columns, we tweak the generated bundle so that each module starts on a new line. Since we cannot assure that each module's code will be on a single line as the minifier might break it on multiple (UglifyJS does so due to a bug on old versions of Chrome), we include on the index the line number that should be used when invoking `JSEvaluateScript`. Since the module length was not being used we replaced the placeholder we have there for the line number.

Reviewed By: javache

Differential Revision: D2997520

fb-gh-sync-id: 3243a489cbb5b48a963f4ccdd98ba63b30f53f3f
shipit-source-id: 3243a489cbb5b48a963f4ccdd98ba63b30f53f3f
2016-03-13 11:14:32 -07:00
Martín Bigio 972395a7c9 Unbreak HMR listener
Reviewed By: sam-swarr

Differential Revision: D3042801

fb-gh-sync-id: 2f06f2efbdf3d04ce4db0cf847ebe76d05fb109f
shipit-source-id: 2f06f2efbdf3d04ce4db0cf847ebe76d05fb109f
2016-03-12 17:33:21 -08:00
Martín Bigio e82a7a8649 Avoid hardcoding platform on blacklist
Reviewed By: davidaurelio

Differential Revision: D3042906

fb-gh-sync-id: 4a424ef1012d75d06c830b284806aefd1556ff74
shipit-source-id: 4a424ef1012d75d06c830b284806aefd1556ff74
2016-03-12 10:59:26 -08:00
Martín Bigio 780a513b7b HMR nits detected by the linter
Reviewed By: davidaurelio

Differential Revision: D3042850

fb-gh-sync-id: 03fd239b0dea2d7d4ef778e2d07d41af84fe310d
shipit-source-id: 03fd239b0dea2d7d4ef778e2d07d41af84fe310d
2016-03-11 16:16:27 -08:00
Marc Horowitz 2c6a81d445 Don't send bogus values to the app
Reviewed By: tadeuzagallo

Differential Revision: D3035881

fb-gh-sync-id: 6dc0018cd78195b34a782c21294f339026018ea6
shipit-source-id: 6dc0018cd78195b34a782c21294f339026018ea6
2016-03-11 04:35:24 -08:00
Martín Bigio a1821ae523 Blacklist modules from being how swapped
Reviewed By: frantic

Differential Revision: D3007480

fb-gh-sync-id: b563a9839c37110f7639b3f1db80ac2663d560ba
shipit-source-id: b563a9839c37110f7639b3f1db80ac2663d560ba
2016-03-09 11:50:28 -08:00
Kureev Alexey db3a00d58c Replace underscore by lodash
Summary:As far as we agreed to merge `rnpm` into react-native core, we need to align our dependencies to exclude duplications. One of the steps forward would be to use the same utilities library. According to the thread on fb, everybody is fine with replacing underscore by lodash (which we use internally for rnpm).

So, here we go!

cc mkonicek davidaurelio grabbou

**Test plan**
```
$ npm test
```
![image](https://cloud.githubusercontent.com/assets/2273613/13173972/ee34c922-d700-11e5-971b-68ff7322b6d6.png)

**Code formatting**

Changes are aligned with the current [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide).
Closes https://github.com/facebook/react-native/pull/6030

Differential Revision: D3016271

Pulled By: davidaurelio

fb-gh-sync-id: c4f6776a7de7470283d3ca5a8b56e423247f5e45
shipit-source-id: c4f6776a7de7470283d3ca5a8b56e423247f5e45
2016-03-09 03:09:44 -08:00
Jim Cummins 10ad47a711 Fix run-android to execute app on all connected devices
Summary:**EDIT: **

This has been updated to simply fix the `run-android` command so that it runs on all connected devices instead of throwing an error.

**Original PR description:**

This adds a new command to the react-native CLI. When executed this command will install and successfully execute your app on all connected Android devices:

`react-native run-android-all`

Closes #5901

**Note:** I wasn't sure how to approach this API since it seems a bit like a flag, but I didn't see any other flags implemented in the cli so it seems like the current trend is to keep all commands to a single phrase. I am open to changing this if need be.
Closes https://github.com/facebook/react-native/pull/5902

Differential Revision: D2976580

Pulled By: mkonicek

fb-gh-sync-id: e7f734478f719cf59e0192b5f4be3f6408c31964
shipit-source-id: e7f734478f719cf59e0192b5f4be3f6408c31964
2016-03-08 12:12:30 -08:00
David Aurelio 9d09efdd53 transform before extracting dependencies
Summary:Make packager transform files before extracting their dependencies.

This allows us to extract dependencies added by transforms (and to avoid including them manually).

It also allows for better optimization and to get rid of the “whole program optimization” step:
This diff utilizes the new worker introduced in D2976677 / d94a567 – that means that minified builds inline the following variables:

- `__DEV__` → `false`
- `process.env.NODE_ENV` → `'production'`
- `Platform.OS` / `React.Platform.OS` → `'android'` / `'ios'`

and eliminates branches of conditionals with constant conditions. Dependency extraction happens only after that step, which means that production bundles don’t include any modules that are not used.

Fixes #4185

Reviewed By: martinbigio

Differential Revision: D2977169

fb-gh-sync-id: e6ce8dd29d1b49aec49b309201141f5b2709da1d
shipit-source-id: e6ce8dd29d1b49aec49b309201141f5b2709da1d
2016-03-08 09:51:26 -08:00
Mark Rickert 62788a15f9 Allows a user to specify an xcode scheme name.
Summary:When running `react-native run-ios`, this feature allows a user to specify which scheme to run.

My project's scheme name is not the same as the xcode project name. Running `react-native run-ios` would error with the following:

```
± |master ↓95 ✓| → react-native run-ios
Found Xcode workspace Poot.xcworkspace
Launching iPhone 6 (9.2)...
Building using "xcodebuild -workspace Poot.xcworkspace -scheme Poot -destination id=2B3E8AAC-DD61-414C-95BD-F4829A8F7CE6 -derivedDataPath build"
User defaults from command line:
    IDEDerivedDataPathOverride = /Users/mrickert/Documents/project/ios/build

xcodebuild: error: The workspace named "Poot" does not contain a scheme named "Poot". The "-list" option can be used to find the names of the schemes in the workspace.
Installing build/Build/Products/Debug-iphonesimulator/Poot.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was n
Closes https://github.com/facebook/react-native/pull/6157

Differential Revision: D3020313

Pulled By: frantic

fb-gh-sync-id: 9d99fa382b3f50045759acea18eff418b15d511d
shipit-source-id: 9d99fa382b3f50045759acea18eff418b15d511d
2016-03-07 14:26:25 -08:00
Henry Zhu 89a486eb3b Fix: cli.js - use var instead of const
Summary:Explain the **motivation** for making this change. What existing problem does the pull request solve?

Fixes https://github.com/facebook/react-native/issues/6203

> SyntaxError: Use of const in strict mode.

- The rest of the file isn't using es6 anyway and babel-register is run on the file it's included in

**Test plan (required)**

Shouldn't have issues replacing it since it's used right after one time.
Closes https://github.com/facebook/react-native/pull/6329

Differential Revision: D3017697

Pulled By: martinbigio

fb-gh-sync-id: 42ee011d032a4bae3409b8e7793c9eb508719964
shipit-source-id: 42ee011d032a4bae3409b8e7793c9eb508719964
2016-03-06 18:56:27 -08:00
Vsevolod Ivanov 081a413340 Deleted unnecessary 'use strict' in new project templates
Summary:Hello there!

Since React Native generates `index.*.js` files with usage of ES6 modules, `'use strict'` became unnecessary.

http://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-code
> Module code is always strict mode code.
Closes https://github.com/facebook/react-native/pull/6322

Differential Revision: D3017181

Pulled By: vjeux

fb-gh-sync-id: 39e0fe703b8d8a0093b952f2c18a36d0d28e1020
shipit-source-id: 39e0fe703b8d8a0093b952f2c18a36d0d28e1020
2016-03-06 09:01:24 -08:00
nmccready 970782d147 run-android Chose your Term for OSX, and Linux
Summary:Main goal is to get this passed for OSX. I assume this works for linux; please verify. Also if specs need to be added, please suggest
an implementation as there is no __test__ dir for andriod.

using yargs (already a dependency) to allow other terminals besides OSX crummy default terminal. Like (iterm) :)

main use case:

` react-native run-android --open iterm`

The nice thing about this in ITERM is it opens another tab by default which is way less intrusive then OSX default term.
Closes https://github.com/facebook/react-native/pull/5232

Differential Revision: D3011590

Pulled By: mkonicek

fb-gh-sync-id: 7e2a004b3018b4d70aafadf4e9be9682561d7919
shipit-source-id: 7e2a004b3018b4d70aafadf4e9be9682561d7919
2016-03-04 21:55:27 -08:00
Alexandr Pantyuhov 46422ddd99 Ability to supply product flavor for `react-native run-android` command
Summary:This small update to runAndroid.js allows to specify product flavor as optional argument, like that:
`react-native run-android --option-flavor=staging`

This option is useful when developing complex applications that require some flavor-specific functionality. More information about productFlavors can be found here: http://developer.android.com/intl/ru/tools/building/configuring-gradle.html
Closes https://github.com/facebook/react-native/pull/6010

Differential Revision: D3011662

Pulled By: mkonicek

fb-gh-sync-id: ce730a17340c1f21b5d75f28a784db4d6fd99725
shipit-source-id: ce730a17340c1f21b5d75f28a784db4d6fd99725
2016-03-04 20:27:23 -08:00
Shayne Sweeney ab61a1fbac Sanitize lineNumber in launchEditor
Summary:Shelling out on win32 does not properly escape the command due to c3bb4b1aa5/lib/child_

This patch ensures a proper lineNumber before continuing, similar to how we check that the fileName passed exists.

**Test plan**

On platform `win32` or given appropriate testing changes to `launchEditor.js`...

With the following `request-bad` file:
```
GET /open-stack-frame HTTP/1.1
Host: 127.0.0.1:8081
Proxy-Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Content-Length: 64

{"file":"C:\\Windows\\system.ini","lineNumber":"123\" && calc"}
```

`$ nc localhost 8081 < request-bad`

Observe that before this patch `calc` would launch and afte
Closes https://github.com/facebook/react-native/pull/6299

Differential Revision: D3012074

Pulled By: davidaurelio

fb-gh-sync-id: cbc7b6e5c60529a289c0989a95593a322333ba5d
shipit-source-id: cbc7b6e5c60529a289c0989a95593a322333ba5d
2016-03-04 12:07:02 -08:00
Martín Bigio d5d9c5a7c6 Tweak HMR updates order
Reviewed By: sam-swarr

Differential Revision: D3007914

fb-gh-sync-id: efceeeafdaaf82e47ee2d2e8a313b64694988b5c
shipit-source-id: efceeeafdaaf82e47ee2d2e8a313b64694988b5c
2016-03-03 16:07:38 -08:00
Martín Bigio 436db67126 Allow parents to accept children modules
Summary:In order to be able to Hot Load Redux stores and modules that export functions, we need to build infrastructure to bubble up the HMR updates similar to how webpack does: https://webpack.github.io/docs/hot-module-replacement-with-webpack.html.

In here we introduce the minimum of this infrastructure we need to make this work. The Packager server needs to send the inverse dependencies to the HMR runtime that runs on the client so that it can bubble up the patches if they cannot be self accepted by the module that was changed.

This diff relies on https://github.com/facebook/node-haste/pull/40/files which adds support for getting the inverse dependencies.

Reviewed By: davidaurelio

Differential Revision: D2950662

fb-gh-sync-id: 26dcd4aa15da76a727026a9d7ee06e7ae4d22eaa
shipit-source-id: 26dcd4aa15da76a727026a9d7ee06e7ae4d22eaa
2016-02-26 15:17:43 -08:00
Adam Miskiewicz b2b41da37f Don't hardcode 'localhost:8081' as the _hmrURL in the Bundler
Summary:martinbigio this fixes your TODO. 🚀 🚀 🚀
Closes https://github.com/facebook/react-native/pull/5827

Differential Revision: D2932188

Pulled By: martinbigio

fb-gh-sync-id: 8c8caf0782f05b51c90c8d09fdb743ddd3e6f97e
shipit-source-id: 8c8caf0782f05b51c90c8d09fdb743ddd3e6f97e
2016-02-26 09:15:56 -08:00
Martín Bigio 20588a6bf8 Log HMR events
Summary:We've received reports saying that sometimes HRM updates take a couple of seconds to get applied. The feature is very optimized so that it takes around 100ms for most common type of changes. Only changes that require rebuilding caches could take longer than that, maybe up to 1 second.

We think the problem is that watchman delays sending the file change notification because the system is under heavy use. It worth mentioning this is not a watchman issue!. This could happen for instance if flow is enabled. So, to better understand what's going on lets log when a file is changed and just before sending the HMR update to the client. The client codepath is extremelly fast so no need to log any of that.

Reviewed By: davidaurelio

Differential Revision: D2978694

fb-gh-sync-id: abd3b473d0b7ac7cd4461effce9813ccfda32c2b
shipit-source-id: abd3b473d0b7ac7cd4461effce9813ccfda32c2b
2016-02-26 08:52:32 -08:00
Walter Luh c377f2a163 Add message channel to packager for sending commands to bridge (2/N)
Reviewed By: frantic

Differential Revision: D2957599

fb-gh-sync-id: 0d3f39bb5757c7af8ee6d178f4839af81928b8de
shipit-source-id: 0d3f39bb5757c7af8ee6d178f4839af81928b8de
2016-02-25 18:15:53 -08:00
Levy Klots 7eb7b947d7 fix resources build variable name
Summary:If jsBundleDir variable was defined, then RN image assets would be
thrown into the assets folder along with the js bundle. This is a
bug. Image assets should be published into a different folder than the
js bundle.

A new variable resourcesDir is defined where RN image assets and the
like should be published into.
Closes https://github.com/facebook/react-native/pull/5828

Differential Revision: D2980235

Pulled By: mkonicek

fb-gh-sync-id: af913814e2fcce42aaa1fbed2a68fd719198f306
shipit-source-id: af913814e2fcce42aaa1fbed2a68fd719198f306
2016-02-25 17:21:30 -08:00
Geoffrey Goh 9ae3714f4b Create offline package if not running in "Debug" config
Summary:**Problem**: As seen in https://github.com/facebook/react-native/issues/5820, many devs are confused by the fact that the offline bundle is not generated when running against the simulator, even when running in the "Release" configuration which is supposed to mimic "production" scenarios.

This pull request is a small change that fixes https://github.com/facebook/react-native/issues/5820 by updating the `react-native-xcode.sh` shell script to still generate the ofline bundle during Release configuration. It also updates `AppDelegate.m` to better document this behaviour in the comments so as to avoid any surprises.

**Test plan**: This is a simple change, the two tests done were
1. In a new React Native project, verify that an offline build is not generated when running against the simulator in "Debug" configuration as per normal.
2. Change to a "Release" configuration via Product > Scheme > Edit Scheme in XCode, then verify that the project runs with the offline build generated.

![screen shot 2016-02
Closes https://github.com/facebook/react-native/pull/6119

Differential Revision: D2970755

Pulled By: javache

fb-gh-sync-id: 64f658512869c73aa19286ca1e3dc6e31b5ac617
shipit-source-id: 64f658512869c73aa19286ca1e3dc6e31b5ac617
2016-02-24 03:11:38 -08:00
djhi b9ed72a043 Added a `root` option to the `run-android` command
Summary:Added a `root` option to the `run-android` command allowing to run it from a parent directory.

Use case: project is organized like this
```
- api
- apps
---- web
---- react-native
- package.json
```
You can use the root option on `react-native start` but not on `run-android`. This pr fixes that.
Closes https://github.com/facebook/react-native/pull/5597

Differential Revision: D2959523

Pulled By: mkonicek

fb-gh-sync-id: 03fb74b201fe9e89bf6fab80c9a98ca708464261
shipit-source-id: 03fb74b201fe9e89bf6fab80c9a98ca708464261
2016-02-21 16:53:32 -08:00
Martin Konicek eab211b1ec Fix comment in open source MainActivity
Reviewed By: mkonicek

Differential Revision:D2923275
Ninja: ninja

fb-gh-sync-id: 1a6700853a1b292c3ae3dd17f2b3e8ce4a2755cf
shipit-source-id: 1a6700853a1b292c3ae3dd17f2b3e8ce4a2755cf
2016-02-10 12:54:20 -08:00
Adam Miskiewicz 9f01f96770 Move `react` to peerDependencies
Summary:
This PR moves `react` from dependencies to peerDependencies.

In general, this would have only been important for those people using packages that depend on `react` and were using npm@2...npm@3 would automatically de-dupe.

However, when #5812 gets merged, dependencies will be scoped to react-native (on both npm@2 & npm@3), thus breaking projects that are using a package like `react-redux` for example, which depends on `react`. There would be two copies of React installed, and due to the use of haste modules in `react`, this would break the packager and cause naming collisions.

This PR does three things -

1. Moves the dependency from dependencies to peerDependencies
2. Updates the local-cli to run `npm install react --save` when a new project is initialized.
3. Updates `react-native upgrade` to warn if `react` is not listed in the package.json's dependencies.

**Note: This will require a shrinkwrap update.**
Closes https://github.com/facebook/react-native/pull/5813

Reviewed By: svcscm

Differential Revision: D2918380

Pulled By: androidtrunkagent

fb-gh-sync-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486
shipit-source-id: 6e4234a45284be2fdf6fedf29e70b2d2d0262486
2016-02-09 15:38:37 -08:00
Martin Konicek 702f999b05 Consume Android artifacts from npm
Summary:
This lets us say goodbye to Maven Central. This will greatly simplify
and speed up the release process as releasing Android artifacts to
Maven Central adds a lot of [complexity](https://github.com/facebook/react-native/blob/master/Releases-publish.md)
and delays the whole release by several hours when we have to wait
for the artifacts to propagate.

This diff assumes there's a local Maven repo at
`node_modules/react-native/android`.

The second part once this lands is to change our `release.sh` script to
output the artifacts under `react-native/android` before publishing to
npm.

This adds 3.7MB to the size of `node_modules` of any app. However,
we just download eagerly what we'd normally download later via Gradle.

**Test plan**

Released RN including a local Maven repo into Sinopia:

    $ cd react-native
    # Updated version in gradle.properties to 0.21.0
    $ ./gradlew ReactAndroid:installArchives
    # Moved everything in .m2/repository/com/facebook/react to react-native/android
    $ ls react-native/android
    com/facebook/react/react-native/0.21.0/react-native-0.21.0.aar
    com/facebook/react/react-native/0.21.0/react-native-0.21.0.pom
    com/facebook/react/react-native/maven-metadata.xml
    ...

    # Set version in package.json to 0.21.0
    $ npm set registry http://localhost:4873/
    $ npm publish

Created and ran an app:

   $ cd /tmp
   $ react-native init AndroidNpm
   $ cd AndroidNpm
   $ react-native run-android

It worked.

Checked that we're using the artifacts from node_modules/react-native/android:

    $ cd android
    $ ./gradlew app:dependencies
    compile - Classpath for compiling the main sources.
    +--- com.android.support:appcompat-v7:23.0.1
    |    \--- com.android.support:support-v4:23.0.1
    |         \--- com.android.support:support-annotations:23.0.1
    \--- com.facebook.react:react-native:+ -> 0.21.0
         +--- com.google.code.findbugs:jsr305:3.0.0
         +--- com.facebook.stetho:stetho-okhttp:1.2.0
    ...

Checked that Android Studio can find the source jars (you can navigate to RN sources in Android Studio). Opened the new project as described in the [docs](https://facebook.github.io/react-native/docs/android-setup.html#editing-your-app-s-java-code-in-android-studio).

public

Reviewed By: bestander

Differential Revision: D2912557

fb-gh-sync-id: 251c180518a3fb9bb8e80963b236e982d65533be
shipit-source-id: 251c180518a3fb9bb8e80963b236e982d65533be
2016-02-09 06:37:34 -08:00
Martin Konicek abdca047b0 Add a note about Android Studio to docs, fix formatting
Summary:
We should use 4 spaces of indentation in the MainActivity template as this
is the most common setting outside fb.

public

Reviewed By: bestander

Differential Revision: D2911952

fb-gh-sync-id: 3b5285945f0033d7342348b7a7cbafa32809f7dc
shipit-source-id: 3b5285945f0033d7342348b7a7cbafa32809f7dc
2016-02-08 15:25:32 -08:00
David Aurelio 6b74535e97 Clean up Bundler
Summary:
The bundler class had duplicated code and parts that were hard to follow, because functions accepted heterogenous arguments, leading to a lot of conditionals.

This commit tries to remove duplication between build steps of different type of bundles, and by accepting less different types of arguments. These differences are now handled further up the call stack.

public

Reviewed By: sebmarkbage

Differential Revision: D2905807

fb-gh-sync-id: ef85ea0d461a9a06a4a64480e014a5324c4ef532
2016-02-08 11:19:31 -08:00
Jagdeep Nagpal 1cf605dda3 Fix Product Flavour builds
Summary:
- Capitalise productFlavorName for target path
- Capitalise buildType in sourceName when flavour exists
- Fix the path the assets are added.
- Backward compatibility with bundleIn(buildTypeName) when flavours are added
Closes https://github.com/facebook/react-native/pull/5580

Reviewed By: svcscm

Differential Revision: D2911735

Pulled By: mkonicek

fb-gh-sync-id: 6fb391a12ee27ee2a503961d8779a85d31cf5367
2016-02-08 09:05:31 -08:00
Konstantin Raev 3c74a2595a Disable proguard
Summary:
until we have an automated test in CI
Closes https://github.com/facebook/react-native/pull/5775

Reviewed By: svcscm

Differential Revision: D2911639

Pulled By: mkonicek

fb-gh-sync-id: 26d8194dd5a6fd7210f4b014787e6847217dd7f1
2016-02-08 08:15:37 -08:00
Konstantin Raev 8c4f644385 Change ulimit to 2048 for non root Mac users
Reviewed By: vjeux

Differential Revision: D2905603

fb-gh-sync-id: 929e1ff562f6a4903bce55a5255c61c407fa8ad9
2016-02-06 11:45:37 -08:00
Alex Kotliarskyi 64d56f34b7 Improve Chrome debugger
Summary:
`debugger.html` contained a ton of hacky code that was needed to ensure we have a clean JS runtime every time a client RN app connects. That was needed because we used the page's global environment as runtime. Some time ago WebWorker support was added and now we run RN code inside an isolated WebWorker instance, and we can safely get rid of all these hacks.

This has a bunch of nice side-effects: debug reload works faster, `console.log`s are preserved, `debuggerWorker.js` selection doesn't change.

Made sure the debugging (breakpoints, etc.) still works as before.

Small demo
![](http://g.recordit.co/FPdVHLHPUW.gif)
Closes https://github.com/facebook/react-native/pull/5715

Reviewed By: svcscm

Differential Revision: D2906602

Pulled By: frantic

fb-gh-sync-id: 1a6ab9a5655d7c32ddd23619564e59c377b53a35
2016-02-05 15:17:33 -08:00
Janic Duplessis 10c0758906 Fix proguard template for ReactProp and ReactPropGroup
Summary:
ReactProp and ReactPropGroup were moved in the annotations package but the proguard file was not updated accordingly. This caused apps to crash when built in release using proguard.

Fixes #5655
Closes https://github.com/facebook/react-native/pull/5717

Reviewed By: svcscm

Differential Revision: D2905573

Pulled By: lexs

fb-gh-sync-id: 29ab14bacda7254d9896ff3991bf17d7fdfd6ea9
2016-02-05 05:20:35 -08:00
Christopher Chedeau 184c708b14 Remove React dev tools upsell
Summary:
React dev tools have been broken since we moved to web worker but we had a gigantic upsell for them. This must be a very frustrating experience for people just starting to use react native to be told to use something and see that it doesn't work.

Removing that upsell until it works again

<img width="1090" alt="screen shot 2016-02-04 at 2 00 37 pm" src="https://cloud.githubusercontent.com/assets/197597/12831501/8eba3f4e-cb49-11e5-8bdc-84f902053321.png">
Closes https://github.com/facebook/react-native/pull/5768

Reviewed By: svcscm

Differential Revision: D2903017

Pulled By: vjeux

fb-gh-sync-id: 731c5fefbef1a5249d632fc62ca36813533f2639
2016-02-04 15:37:35 -08:00
Christopher Chedeau e1f04bf2e3 Quit early if node < 4
Summary:
Before we would display this warning at the top and have the packager throw thousands of lines of errors because of es6 syntax.

Before:

<img width="602" alt="screen shot 2016-02-04 at 1 49 27 pm" src="https://cloud.githubusercontent.com/assets/197597/12831357/a72bdc0a-cb48-11e5-9b81-dde895eaf113.png">

After:

<img width="1440" alt="screen shot 2016-02-04 at 2 04 50 pm" src="https://cloud.githubusercontent.com/assets/197597/12831364/af1c16a0-cb48-11e5-949c-c470938f8b49.png">
Closes https://github.com/facebook/react-native/pull/5767

Reviewed By: svcscm

Differential Revision: D2902978

Pulled By: androidtrunkagent

fb-gh-sync-id: c0193c3b1e36778d61aa9013f0c294f8c3475442
2016-02-04 15:23:57 -08:00
Nick Lockwood 81fb985335 Support non-image assets in packager
Summary:
public
The packager currently assumes that all assets that are not JSON or JS files must be images. Although it is possible to add other extension types, they crash the packager if you try to require them, because it attempts to get their dimensions, assuming that they are an image.

This is a crude workaround for that problem, which skips the image-specific processing for non-image assets, but really it would be better if the packager was properly aware of different asset types and treated them differently (e.g. for sounds it could include the duration, for HTML pages it could parse and include linked CSS files, etc).

I've also added an example of using `require('...')` to load a packager-managed HTML page in the UIExplorer WebView example. In future I anticipate that all static asset types (sounds, fonts, etc.) could be handled in this way, which allows them to be edited or added/removed on the fly instead of needing to restart the app.

Reviewed By: martinbigio

Differential Revision: D2895619

fb-gh-sync-id: cd93794ca66bad838621cd7df3ff3c62b5645e85
2016-02-03 17:30:39 -08:00
Martín Bigio 36efbc341d Hot Loading Indicators
Summary:
public

Introduce a header bar similar to the one shown when loading the bundle to indicate that the packager server is processing an HMR update. Hook into HMR events to show this bar when appropriate.

Reviewed By: javache

Differential Revision: D2873521

fb-gh-sync-id: a77cbb2368b75b045aa8c6ababce2f731baf514b
2016-02-01 12:42:33 -08:00
Martín Bigio 68f71dab4c Make HMR faster (2)
Summary:
public

The HMR listener needs to be invoked on the non debounced callback to avoid loosing updates if 2 files are updated within the debounce configured time.

Also, improve the time it takes to send HMR updates by avoiding rebuilding the bundle when the listener is defined. Instead just invalidate the bundles cache so that if the user reloads or disables Hot Loading the packager rebuilds the requested bundle.

Reviewed By: davidaurelio

Differential Revision: D2863141

fb-gh-sync-id: 3ab500eacbd4a2e4b63619755e5eabf8afdd1db9
2016-01-29 10:15:41 -08:00
Martín Bigio 65b8ff17f3 Make HMR faster
Summary:
public

At the moment, when the user changes a file we end up pulling the dependencies of the entry point to build the bundle. This could take a long time if the bundle is big. To avoid it, lets introduce a new parameter to `getDependencies` to be able to avoid processing the modules recursively and reuse the resolution responseto build the bundle.

Reviewed By: davidaurelio

Differential Revision: D2862850

fb-gh-sync-id: b8ae2b811a8ae9aec5612f9655d1c762671ce730
2016-01-29 10:15:36 -08:00
Martín Bigio c56f280af2 Disable Flow on Packager
Reviewed By: frantic

Differential Revision: D2870105

fb-gh-sync-id: c95db83e40b3558c53614b08240a5361c14e0e6c
2016-01-27 15:33:31 -08:00
Martín Bigio f2438b440d Hot Loading Sourcemaps
Summary:
public

To make sourcemaps work on Hot Loading work, we'll need to be able to serve them for each module that is dynamically replaced. To do so we introduced a new parameter to the bundler, namely `entryModuleOnly` to decide whether or not to process the full dependency tree or just the module associated to the entry file. Also we need to add `//sourceMappingURL` to the HMR updates so that in case of an error the runtime retrieves the sourcemaps for the file on which an error occurred from the server.

Finally, we need to refactor a bit how we load the HMR updates into JSC. Unfortunately, if the code is eval'ed when an error is thrown, the line and column number are missing. This is a bug/missing feature in JSC. To walkaround the issue we need to eval the code on native. This adds a bit of complexity to HMR as for both platforms we'll have to have a thin module to inject code but I don't see any other alternative. when debugging this is not needed as Chrome supports sourceMappingURLs on eval'ed code

Reviewed By: javache

Differential Revision: D2841788

fb-gh-sync-id: ad9370d26894527a151cea722463e694c670227e
2016-01-27 14:55:36 -08:00
Alex Kotliarskyi d3e44143f6 Improve react-native-xcode.sh integration
Summary:
Inspired by conversation in https://github.com/facebook/react-native/pull/5374, this PR improves `react-native-xcode.sh`:

* No longer depends on global `react-native` binary
* Gracefully handles missing `node` dependency and adds a new way to configure the path to `node` in non-standard installation environments

This is how the error looks like:
![image](https://cloud.githubusercontent.com/assets/192222/12538882/3f9b5c3e-c29a-11e5-84fc-c7ccedf1c46a.png)
Closes https://github.com/facebook/react-native/pull/5518

Reviewed By: svcscm

Differential Revision: D2861116

Pulled By: frantic

fb-gh-sync-id: 9a80eda6c844d066e34369b1cda503955171485b
2016-01-25 12:36:33 -08:00
David Aurelio 17e1ceb543 Add ability to load “unbundles” to android
Summary:
public

This adds the ability to load “unbundles” in RN android apps. Unbundles are created by invoking the packager with the `unbundle` command rather than `bundle`.

The code detects usage of an “unbundle” by checking for the existence of a specific asset.

Reviewed By: astreet

Differential Revision: D2739596

fb-gh-sync-id: d0813c003fe0fa7b47798b970f56707079bfa5d7
2016-01-21 14:13:50 -08:00
David Aurelio 2902701566 Remove now unnecessary tweaking of global
Summary:
public

When we were debugging in the main window JS context in Chrome, the global environment had to be tweaked so that DOM features wouldn’t be detected.

Since we switched to debugging within a web worker, we don’t need to do this tweaks any more.

Reviewed By: bestander

Differential Revision: D2850239

fb-gh-sync-id: 886f2f7ac5c579c3fd4a424d5341bc6bc0432c0d
2016-01-21 10:26:33 -08:00
Martin Konicek 342a7630f1 When using split builds, don't generate universal APK
Summary:
Closes https://github.com/facebook/react-native/issues/5452

public

Reviewed By: foghina

Differential Revision: D2849769

fb-gh-sync-id: 93a53b05dc39560529a916fbeeb74efa761a7d7e
2016-01-21 04:22:35 -08:00
Martín Bigio 4afeb4310b Simplify HMR codepath
Reviewed By: davidaurelio

Differential Revision: D2839590

fb-gh-sync-id: 9bb14cafc69eec7d7a8712b60435e29f2ba48d3c
2016-01-20 07:14:33 -08:00
DengYun d4f6e447d2 add host argument for packager.
Summary:
Now packager only listen to "::", which is IPv6 "Any address".
It failed to run in IPv4 Environment.

defaults to undefined or empty string will fix this.

And I think it's necessary to let user define host by cli argument.

It's also for security reason. When working on a public network, it's much safer to listen with localhost instead of ::, which may let everyone in same network be able to get your code from debugger-ui.

recommit for #1918, fixes #2441
Closes https://github.com/facebook/react-native/pull/5377

Reviewed By: svcscm

Differential Revision: D2842594

Pulled By: martinbigio

fb-gh-sync-id: 575944c5469dac80e99136a7903ea99f5339dba1
2016-01-19 16:47:33 -08:00
Maksim Ryzhikov 182e97a62c chore: remove extra require
Summary:
We already have require fs [here](https://github.com/maksimr/react-native/blob/patch-cli/local-cli/cli.js#L34)
Closes https://github.com/facebook/react-native/pull/5352

Reviewed By: svcscm

Differential Revision: D2838334

Pulled By: martinbigio

fb-gh-sync-id: 96942b862fee925006687cfba3ad9185a2377a8a
2016-01-17 18:17:39 -08:00
Martín Bigio c9f274c02d Send assets updates through HRM interface
Reviewed By: frantic

Differential Revision: D2832693

fb-gh-sync-id: 816a01fa2f1f7cc8ca218de86b3e2e847ee005c9
2016-01-15 10:52:31 -08:00
Martín Bigio bba35f0415 Make Hot Loading work on OSS
Summary:
public

- Tweak OSS server to enable the HMR connection
- Remove client gating code.
- Resolve internal transforms plugins

After this diff, Hot Loading should work on OSS.

Reviewed By: javache

Differential Revision: D2803620

fb-gh-sync-id: b678180c884d2bfaf454edf9e7abe6b3b3b32ebe
2016-01-14 19:33:42 -08:00
Adam Miskiewicz 00659864bc Fixing CLI to pass "sourcemap-output" option to bundler.
Summary:
Currently, the CLI is not passing the sourceMapURL option to the bundler, so source maps are output as "null".
Closes https://github.com/facebook/react-native/pull/5288

Reviewed By: svcscm

Differential Revision: D2828092

Pulled By: androidtrunkagent

fb-gh-sync-id: 2e464ddf65f0d4fcbff3c50281391cb30b5c799c
2016-01-13 12:53:35 -08:00
Martín Bigio 97dcc66e7a Use same options on dependencies and bundle commands
Reviewed By: sam-swarr

Differential Revision: D2821362

fb-gh-sync-id: c07c2f74f237ab95ad4f4a89b7e35af4ca9e8c6b
2016-01-11 15:31:33 -08:00
Janic Duplessis e08a7f3587 Fix launching text editor from a redbox stacktrace on windows
Summary:
Launch the editor with cmd on windows.
Closes https://github.com/facebook/react-native/pull/5238

Reviewed By: svcscm

Differential Revision: D2819943

Pulled By: pcottle

fb-gh-sync-id: a38f88bb9be72871cc3a37367973371176799d9e
2016-01-11 13:27:31 -08:00
Andrew Jack bd7d10e5aa Add support for Build Variants to react.gradle
Summary:
This PR adds support for Android Gradle [Build Variants](https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Build-Variants) when generating the JS bundle.

**Before**: only supported "bundleDebugJsAndAssets" and "bundleReleaseJsAndAssets"

**Now**: all variants are supported
Examples: "bundleDevDebugJsAndAssets", "bundleStageAlphaJsAndAssets", or "bundleBetaJsAndAssets"

The Gradle script will automatically create bundle tasks for each build variant found in a project.
Closes https://github.com/facebook/react-native/pull/4686

Reviewed By: svcscm

Differential Revision: D2815856

Pulled By: foghina

fb-gh-sync-id: 4518de70d178205bc3e5044d2446b56c40298da2
2016-01-08 12:12:30 -08:00
Martín Bigio 8604bd1812 Add option to disable internal transforms
Reviewed By: davidaurelio

Differential Revision: D2815307

fb-gh-sync-id: 17ed8f13de7b4c41111efa4a5f2af5283e6ef3e0
2016-01-08 11:10:29 -08:00
Martín Bigio fe77ce1c62 Show red boxes on HL mode
Summary:
public

We should further improve this on the future by showing the actual stacktrace instead of the `HMRClient` one. Also, we need to integrate this with the dev plugin that opens in the default editor the file/line the user clicks on.

Reviewed By: vjeux

Differential Revision: D2798889

fb-gh-sync-id: 2392966908c493e86e11b0d024e7b68156c9066c
2016-01-07 13:15:28 -08:00
Martin Konicek e46736219c Tweak formatting in Android template
Reviewed By: mkonicek

Differential Revision:D2812482
Ninja: Doesn't affect any fb apps or code, purely for open source

fb-gh-sync-id: 4d190354112e3f002405686769dcc409e3394c3c
2016-01-07 12:36:07 -08:00
Martín Bigio b9c5f753aa Fixes Hot Loading re-loading bug
Summary:
public

Fixes a terrible bug due to which when Hot Loading enabled when the user reloads we'll serve them the first `hot` bundle he requested. This happened because when HMR enabled we bailed out after sending the HMR updates and didn't rebuild any of the bundles the user requested before. As a consequence, when they reload we'd sent him the first and only one we ever built.

The fix is to tweak the hmr listener to return a promise. This way we can run the remaining code on the file change listener just after the HMR stuff finishes. We need to do it this way to avoid the remaining stuff to compete for CPU with the HMR one and give the best possible experience when HMR is enabled.

Reviewed By: davidaurelio

Differential Revision: D2811382

fb-gh-sync-id: 906932d71f35467485cf8a865a8d59f4d2ff41a0
2016-01-07 12:03:58 -08:00
Martin Konicek abb81eb270 Add support for split build per architecture
Summary:
This allows everyone to deploy significantly smaller APKs to they Play Store by building separate APKs for ARM, x86 architectures.

For a simple app, a release APK minified with Produard:
- Universal APK is **7MB**
- x86 APK is **4.6MB** (34% reduction)
- ARM APK is **3.7MB** (47% reduction)

Created a sample project, uncommented `// include "armeabi-v7a", 'x86'`:

    cd android
    ./gradlew assembleDebug

Three APKs were created, unzipped each: one has only x86 binaries,
one has ARM binaries, one has both.

    ./gradlew assembleRelease

Three APKs were created, JS bundle is correcly added to assets.

    react-native run-android

The correct APK is installed on the emulator and the app runs fine
(Gradle output: "Installing APK 'app-x86-debug.apk'").

With the line commented out the behavior is exactly the same as before,
only one universal APK is built.

Checked that version codes are set correctly as described in
http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
http://developer.android.com/intl/ru/google/play/publishing/multiple-apks.html

Closes https://github.com/facebook/react-native/pull/5160

Reviewed By: svcscm

Differential Revision: D2811443

Pulled By: mkonicek

fb-gh-sync-id: 97b22b9cd567e53b8adac36669b90768458b7a55
2016-01-07 12:03:06 -08:00
Martín Bigio 2b09614068 Skip file removal on HMR interface
Summary:
public

We're not planning to accept file removals in the short term on the HMR interface so lets bail when a file is removed (before this this we were throwing when trying to get the shallow dependencies).

Reviewed By: yungsters

Differential Revision: D2810534

fb-gh-sync-id: f2733382f4a2619e22bdf1163aa4180694fff9f8
2016-01-07 12:02:47 -08:00
tdzl2003 5f3d08d524 Fix build error and runtime error after proguard enabled.
Summary:
Fix:
1. :app:packageRelease FAILED caused by proguard exception: `java.io.IOException: Please correct the above warnings first.`
2. Fix runtime exception
```
java.lang.ExceptionInInitializerError
   at com.facebook.react.ReactInstanceManagerImpl.recreateReactContextInBackgroundFromBundleFile(ReactInstanceManagerImpl.java:308)
```
Closes https://github.com/facebook/react-native/pull/5146

Reviewed By: svcscm

Differential Revision: D2807252

Pulled By: mkonicek

fb-gh-sync-id: 03d004405c7cca14a71230086b95351cfacbc055
2016-01-07 12:02:27 -08:00
Martín Bigio bdbadfd966 Make sure client is still connected while computing HMR update
Reviewed By: vjeux

Differential Revision: D2803506

fb-gh-sync-id: a182343947d52724e48709a8114fa48e8c97a7e2
2016-01-06 13:29:38 -08:00
Martín Bigio 51d8ed92d5 Move HMR to internal transform
Summary:
public

We want to support Hot Loading on the packager itself instead of on the transformer. This will allow us to enable it on OSS (and for any scripting language, yay!).

For now to enable Hot Loading the packager's internals transforms need to be manually enabled (start packager with `--enable-internal-transforms`). I think the internal pipeline should always be enabled as it doesn't affect performance if there're no transforms and the user can disable Hot Loading through the setting on the app though. I'll tweak this on a follow up commit.

Reviewed By: vjeux

Differential Revision: D2801343

fb-gh-sync-id: 563984d77b10c3925fda6fd5616b814cdbea2c66
2016-01-06 09:47:39 -08:00
Martín Bigio d875aac3c8 Resolve requires on HMR
Summary:
public

Requires are transformed when building the bundle but we forgot doing so when building the HMR one.

Reviewed By: vjeux

Differential Revision: D2801319

fb-gh-sync-id: ae70612945ab81a05154b14d6b756ef390770542
2016-01-06 09:47:31 -08:00
Geoffrey Goh e730a9fdd0 Load assets from same folder as JSbundle (Android)
Summary:
https://github.com/facebook/react-native/issues/3679 was only partially fixed as the behaviour only works on iOS. This implements the same behaviour for Android. If the JSBundle was loaded from the assets folder, this will load images from the built-in resources. Else, load the image from the same folder as the JS bundle.

EDIT: For added clarity:

On iOS,
Bundle Location: 'file:///Path/To/Sample.app/main.bundle'
httpServerLocation: '/assets/module/a/'
Name: 'logo'
type: 'png'
**Resolved Asset location: '/Path/To/Sample.app/assets/module/a/logo.png'**

On Android,
Bundle Location: 'file:///sdcard/Path/To/main.bundle'
httpServerLocation: '/assets/module/a/',
name: 'logo'
type: 'png'
**Resolved Asset location: 'file:///sdcard/Path/To/drawable_mdpi/module_a_logo.png'**
Closes https://github.com/facebook/react-native/pull/4527

Reviewed By: svcscm

Differential Revision: D2788005

Pulled By: mkonicek

fb-gh-sync-id: 3f6462a7ee6370a92dd6727ac422c5de346c3ff1
2016-01-06 08:46:35 -08:00
Alex Kotliarskyi 9490c2c759 Added `react-native run-ios`
Summary:
Works the same way as `react-native run-android`, but targets iOS simulator instead. Under the hood, it uses `xcodebuild` to compile the app and store it in `ios/build` folder, then triggers `instruments` and `simctl` to install and launch the app on simulator.

Since Facebook relies on BUCK to build and run iOS app, we probably won't use `run-ios` internally. That's why I'm putting this as public PR instead of internal diff.

To test this, I hacked global `react-native` script to install react native from my local checkout instead of from npm, cd into the folder and ran `react-native run-ios`.
Closes https://github.com/facebook/react-native/pull/5119

Reviewed By: svcscm

Differential Revision: D2805199

Pulled By: frantic

fb-gh-sync-id: 423a45ba885cb5e48a16ac22095d757d8cca7e37
2016-01-05 17:18:49 -08:00
Alex Kotliarskyi ec76271715 Return non-zero exit code from wrong-react-native
Summary:
When used in automation, `wrong-react-native` can cause problems because it does not
report the issue via exit code.
Closes https://github.com/facebook/react-native/pull/5114

Reviewed By: svcscm

Differential Revision: D2799995

Pulled By: frantic

fb-gh-sync-id: 23c32dac9b0fcdbeaf48b94e9cb220c6c1b344aa
2016-01-05 15:22:59 -08:00
Satyajit Sahoo 80bf431f98 Add warnings while upgrading RN with `react-native upgrade`
Summary: Closes https://github.com/facebook/react-native/pull/4854

Reviewed By: svcscm

Differential Revision: D2803252

Pulled By: foghina

fb-gh-sync-id: e6b05b19cf45773d7683ae8ae35643f400e51692
2016-01-05 09:58:28 -08:00
Martín Bigio f2bdb79782 Make HMR server send full list modules that changed
Summary:
public

Before this diff we were only accepting the module that was modified but the user. This works fine as long as the user doesn't modify the dependencies a module has but once he starts doing so the HMR runtime may fail when updating modules' code because they might might a few dependencies. For instance, if the user changes the `src` a `Image` has to reference an image (using the new asset system) that wasn't on the original bundle the user will get a red box. This diff addresses this by diffing the modules the app currently has with the new ones it should have and including all of them on the HMR update. Note this diffing is only done when the we realize the module that was modified changed it's dependencies so there's no additional overhead on this change.

Reviewed By: vjeux

Differential Revision: D2796325

fb-gh-sync-id: cac95f2e995310634c221bbbb09d9f3e7bc03e8d
2016-01-04 13:02:27 -08:00
Martín Bigio 8c9c7e6286 Introduce transforms pipeline
Summary:
public

This diff introduces an internal transforms pipeline that integrates with the external one. This has been a feature we've been looking to implement for a long time to use babel instead of `replace` with regexps on many parts of the packager.

Also, to split the bundle we'll need to run one transform. Internally for Facebook we can run the system-import transform altogether withe the other ones. For OSS we offer `transformer.js` which people can use out of the box if they're writing ES6 code. For those people, `transformer.js` will also run the internal transforms`. However they might want to tune the transforms, or even write the code on another language that compiles to Javascript and use a complete different transformer. On those cases we'll need to run the external transforms first and pipe the output through the internal transforms. Note that the order it's important as the internal transforms assume the code is written in JS, though the original code could be on other scripting languages (CoffeeScript, TypeScript, etc).

Reviewed By: davidaurelio

Differential Revision: D2725109

fb-gh-sync-id: d764e209c78743419c4cb97068495c771372ab90
2016-01-04 11:32:42 -08:00
Satyajit Sahoo f93cf6ca19 Fix android activity template. Fixes #5030
Summary: Closes https://github.com/facebook/react-native/pull/5033

Reviewed By: svcscm

Differential Revision: D2794157

Pulled By: androidtrunkagent

fb-gh-sync-id: 9d30b3a661b18be31d246dc3f55c429cc4b51a8a
2015-12-30 13:23:31 -08:00
Martín Bigio e75e861116 Make Hot Loading faster
Summary:
public

Before this this when a file was changed besides sending the HMR update we rebuild every single bundle that the packager had build (to serve it faster when the user hit cmd+r). Since when hot loading is enabled we don't do cmd+r all this work was pointless (except for when you're developing multiple apps using the same packager instance at the same time, which we can assume is very uncommon). As a consequence, the HMR update was competing with the rebundling job making HMR quite slow (i.e.: on one huge internal app it took up to 6s for the HMR changes to get applied).

So, this diff tweaks the file change listener so that we don't rebundle nor invoke the fileWatchers (use for live reload which is also useless when hot load is enabled) when hot loading is enabled. Also, it makes the HMR listener more high pri than the other listeners so that the HMR dev experience is as good as it can get.

Reviewed By: vjeux

Differential Revision: D2793827

fb-gh-sync-id: 724930db9f44974c15ad3f562910b0885e44efde
2015-12-29 18:25:40 -08:00
Martín Bigio b5081abae3 Send HMR updates only for files on the bundle
Summary:
public

Compute the dependencies of the bundle entry file just before sending HMR updates. In case the file that was changed doesn't belong to the bundle bail.

Reviewed By: vjeux

Differential Revision: D2793736

fb-gh-sync-id: f858e71b0dd5fe4f5b2307a22c6cef627eb66a22
2015-12-29 18:25:35 -08:00
Martín Bigio 5f850fbede Pipe `platform` and `bundleEntry` through WebSocket connection
Reviewed By: vjeux

Differential Revision: D2793572

fb-gh-sync-id: 6ce2467b8d528d1a91c1b4fc51741f2502674022
2015-12-29 18:25:28 -08:00
Martín Bigio 4ffb241647 Hot Loading E2E basic flow
Summary:
public

Implement all the necessary glue code for several diffs submitted before to get Hot Loading work end to end:

- Simplify `HMRClient`: we don't need to make it stateful allowing to enable and disable it because both when we enable and disable the interface we need to reload the bundle.
- On the native side we introduced a singleton to process the bundle URL. This new class might alter the url to include the `hot` attribute. I'm not 100% sure this is the best way to implement this but we cannot use `CTLSettings` for this as it's are not available on oss and I didn't want to contaminate `RCTBridge` with something specific to hot loading. Also, we could potentially use this processor for other things in the future. Please let me know if you don't like this approach or you have a better idea :).
- Use this processor to alter the default bundle URL and request a `hot` bundle when hot loading is enabled. Also make sure to enable the HMR interface when the client activates it on the dev menu.
- Add packager `hot` option.
- Include gaeron's `react-transform` on Facebook's JS transformer.

The current implementation couples a bit React Native to this feature because `react-transform-hmr` is required on `InitializeJavaScriptAppEngine`. Ideally, the packager should accept an additional list of requires and include them on the bundle among all their dependencies. Note this is not the same as the option `runBeforeMainModule` as that one only adds a require to the provided module but doesn't include all the dependencies that module amy have that the entry point doesn't. I'll address this in a follow up task to enable asap hot loading (9536142)

I had to remove 2 `.babelrc` files from `react-proxy` and `react-deep-force-update`. There's an internal task for fixing the underlaying issue to avoid doing this horrible hack (t9515889).

Reviewed By: vjeux

Differential Revision: D2790806

fb-gh-sync-id: d4b78a2acfa071d6b3accc2e6716ef5611ad4fda
2015-12-28 16:44:59 -08:00
Martín Bigio ac9c3c548d Make Packager send fresh modules through HMR interface
Reviewed By: frantic

Differential Revision: D2787951

fb-gh-sync-id: 63c04710b60d99b5161ef9a40b116ba2f72df745
2015-12-28 16:44:38 -08:00
Martín Bigio 90781d3067 Introduce Packager and App HMR WebSocket connection
Summary:
public

This diff adds infra to both the Packager and the running app to have a WebSocket based connection between them. This connection is toggled by a new dev menu item, namely `Enable/Disable Hot Loading`.

Reviewed By: vjeux

Differential Revision: D2787621

fb-gh-sync-id: d1dee769348e4830c28782e7b650d025f2b3a786
2015-12-28 16:44:32 -08:00
Patrick Puritscher bde2f30474 Update templates to ES2015
Summary:
I don't know the reasons, why the templates are written with the `react.createClass`method. Today I see lot's of examples using the **ES6 way**. In my own projects I'm using this way, too.

I removed `use strict`, since *Module code is always strict mode code*, according to the [spec](http://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-code).

Maybe we should **discuss** the usage of ES6 in the templates.
Closes https://github.com/facebook/react-native/pull/4891

Reviewed By: svcscm

Differential Revision: D2789493

Pulled By: androidtrunkagent

fb-gh-sync-id: 90e70f787017c61dc64cbc9f0beb02331fa749ec
2015-12-25 02:17:30 -08:00
Bhuwan Khattar 7035fbc58d getTransformOptionsModulePath
Summary:
Passing around a `getTransformOptions` function doesn't really work with the CLI utils, so I'm changing this to `getTransformOptionsModulePath` instead, which can easily be injected in through `rn-cli.config.js`.

public

Reviewed By: martinbigio

Differential Revision: D2785789

fb-gh-sync-id: c9fdc358cb5d0db27e0d02496e44c013c77f3d5f
2015-12-24 01:02:30 -08:00
Philipp von Weitershausen 1b80007236 Improvements to the packager for very large projects
Summary:
Here are some small fixes for issues we've encountered with very large RN projects (mostly huge dependency trees in `node_modules`).

cc amasad martinbigio
Closes https://github.com/facebook/react-native/pull/4880

Reviewed By: svcscm

Differential Revision: D2782834

Pulled By: mkonicek

fb-gh-sync-id: e316a62b84ba796b80ac819431414ebf27f7b566
2015-12-23 10:08:24 -08:00
David Aurelio c866a0a6d0 use a filename for the magic unbundle file that will end up in the apk
Reviewed By: martinbigio

Differential Revision: D2774022

fb-gh-sync-id: 5ccafe606e586c55213a10e00013c6feecc9dbcd
2015-12-23 10:07:47 -08:00
Satyajit Sahoo 935cbb76c0 Add a base activity for React Native apps. Fixes #4043
Summary:
Having a base activity allows us to add new features and fixes without having to change the generated `MainActivity` file.

cc mkonicek arbesfeld
Closes https://github.com/facebook/react-native/pull/4827

Reviewed By: bestander

Differential Revision: D2783527

Pulled By: mkonicek

fb-gh-sync-id: 707b82839809ca2e1775f5d3ac022a6d00bcac5a
2015-12-23 10:07:42 -08:00
David Aurelio dfdafdb733 Add magic indicator file to FS unbundles
Reviewed By: tadeuzagallo

Differential Revision: D2773427

fb-gh-sync-id: 8724f5c6e300f456e5a9c434c14e8e74b2792cf9
2015-12-18 06:37:16 -08:00
David Aurelio 12778f3bc6 fork unbundle output format per platform
Summary:
We decided to use different storage formats for android and ios. This diff changes the output format to asset files if the platform is `'android'`.

public

Reviewed By: martinbigio

Differential Revision: D2764739

fb-gh-sync-id: 4a5ac13ba7978112e9424573643e90cef2a1b75f
2015-12-16 12:01:17 -08:00
Sebastian Markbage 8d397b4cbc Decouple Module System from Native Calls
Summary:
The JavaScript ecosystem doesn't have the notion of a built-in native module loader. Even Node is decoupled from its module loader. The module loader system is just JS that runs on top of the global `process` object which has all the built-in goodies.

Additionally there is no such thing as a global require. That is something unique to our providesModule system. In other module systems such as node, every require is contextual. Even registered npm names are localized by version.

The only global namespace that is accessible to the host environment is the global object. Normally module systems attaches itself onto the hooks provided by the host environment on the global object.

Currently, we have two forms of dispatch that reaches directly into the module system. executeJSCall which reaches directly into require. Everything now calls through the BatchedBridge module (except one RCTLog edge case that I will fix). I propose that the executors calls directly onto `BatchedBridge` through an instance on the global so that everything is guaranteed to go through it. It becomes the main communication hub.

I also propose that we drop the dynamic requires inside of MessageQueue/BatchBridge and instead have the modules register themselves with the bridge.

executeJSCall was originally modeled after the XHP equivalent. The XHP equivalent was designed that way because the act of doing the call was the thing that defined a dependency on the module from the page. However, that is not how React Native works.

The JS side is driving the dependencies by virtue of requiring new modules and frameworks and the existence of dependencies is driven by the JS side, so this design doesn't make as much sense.

The main driver for this is to be able to introduce a new module system like Prepack's module system. However, it also unlocks the possibility to do dead module elimination even in our current module system. It is currently not possible because we don't know which module might be called from native.

Since the module system now becomes decoupled we could publish all our providesModule modules as npm/CommonJS modules using a rewrite script. That's what React Core does.

That way people could use any CommonJS bundler such as Webpack, Closure Compiler, Rollup or some new innovation to create a JS bundle.

This diff expands the executeJSCalls to the BatchedBridge's three individual pieces to make them first class instead of being dynamic. This removes one layer of abstraction. Hopefully we can also remove more of the things that register themselves with the BatchedBridge (various EventEmitters) and instead have everything go through the public protocol. ReactMethod/RCT_EXPORT_METHOD.

public

Reviewed By: vjeux

Differential Revision: D2717535

fb-gh-sync-id: 70114f05483124f5ac5c4570422bb91a60a727f6
2015-12-08 16:03:37 -08:00
David Aurelio d013554083 Prepend magic number to unbundle files
Summary:
In order to be able to reliable identify unbundles when loading files, prepend a magic number (0xFB0BD1E5)
public

Reviewed By: martinbigio

Differential Revision: D2734359

fb-gh-sync-id: b469e26459234e7f6270fffa0b872a93d137381d
2015-12-08 11:03:25 -08:00
Sam Swarr 61272e69e9 Fix race condition in packager list dependencies
Reviewed By: martinbigio

Differential Revision: D2732655

fb-gh-sync-id: 6d3d730b499c183d3f6977a30ec37a799cc17c33
2015-12-07 19:26:28 -08:00
Christopher Dro 802aef9509 Update argument passed for assetRoots.
Summary:
Fixes #4388
Closes https://github.com/facebook/react-native/pull/4431

Reviewed By: svcscm

Differential Revision: D2704076

Pulled By: mkonicek

fb-gh-sync-id: 2b788eb15787334bf7309fde730566092ff63832
2015-12-02 05:55:26 -08:00
David Aurelio cc4a5d39db Add unbundling to packager
Reviewed By: tadeuzagallo

Differential Revision: D2707409

fb-gh-sync-id: 30216c36066dae68d83622dba2d598e9dc0a29db
2015-12-01 08:48:30 -08:00
David Aurelio 32fa0b7fa1 Move bundle output formats to their own files
Reviewed By: tadeuzagallo

Differential Revision: D2702834

fb-gh-sync-id: fca308c5078a11924e071077822fb77d762bd564
2015-11-30 09:31:27 -08:00
Bram 710b443af1 bugfix #3997: react-native bundle not working on windows 10
Summary: fixes https://github.com/facebook/react-native/issues/3997

the root cause is in

Mon, 09 Nov 2015 13:22:47 GMT ReactNativePackager:SocketServer uncaught error Error: listen EACCES C:\Users\donald\AppData\Local\Temp\react-packager-9248a9803ac72b509b389b456696850d

This means that the socket server cannot create the socket.

cfr https://gist.github.com/domenic/2790533 the socket name is not a valid windows socket name.
Closes https://github.com/facebook/react-native/pull/4071

Reviewed By: mkonicek

Differential Revision: D2699546

Pulled By: davidaurelio

fb-gh-sync-id: 6c6494c14c42bb17506b8559001419c9f85e91e3
2015-11-27 08:22:29 -08:00
Christopher Dro cfd9f65cfe Add space after url. Fixes #4292
Summary: Closes https://github.com/facebook/react-native/pull/4297

Reviewed By: svcscm

Differential Revision: D2686725

Pulled By: foghina

fb-gh-sync-id: 3679c7e8d9b3e4c12ef42628e348c6a6d5cc32d7
2015-11-23 12:31:30 -08:00
Sebastian Markbage 43f18ffd08 Add infra for Prepack build option
Summary: This adds a build option for using Prepack (an experimental packager) to
build a bundle. It doesn't actually take on the npm package dependency
because it's not published/open source (yet).

This will be used while we experiment and should be maintained as the
build system changes so that we can continue getting fresh builds.

I found that saveBundleAndMap and processBundle were over abstracted and
got in my way so I inlined it and removed the unit tests because the unit
test was testing trivial code that is likely to change interface.

I went with a separate build phase and a separate Bundle class even though
there are a lot of commonalities. I imagine that the requirements for
Prepack will continue to diverge. Especially for source maps but a larger
refactor could try to unify these a bit more. The fact that modules are
wrapped before the write phase seems to be an unfortunate architecture
that makes this difficult.
Closes https://github.com/facebook/react-native/pull/4226

Reviewed By: amasad

Differential Revision: D2673760

Pulled By: sebmarkbage

fb-gh-sync-id: 299ccc42e4be1d9dee19ade443ea3388db2e39a8
2015-11-20 20:19:25 -08:00
DengYun 6124298dd7 bugfix part 1 for #4124: react.gradle cause a error on windows when building release apk.
Summary: ```
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> A problem occurred starting process 'command 'react-native''
```

Can be solved by this patch.
Closes https://github.com/facebook/react-native/pull/4209

Reviewed By: svcscm

Differential Revision: D2669661

Pulled By: foghina

fb-gh-sync-id: 951b7eb9dd3121de607cf5eb3dfb3af44cdf5994
2015-11-18 12:23:28 -08:00
James Ide b838b4617c Compress HTTP responses from the packager
Summary: The packager was adding compression middleware too late in the stack. This makes things a little faster especially if you're loading through dynamic DNS for example.
Closes https://github.com/facebook/react-native/pull/4121

Reviewed By: svcscm

Differential Revision: D2664373

Pulled By: frantic

fb-gh-sync-id: 46cce81ff6d9e4e71e1718d7e96b58449c248bc1
2015-11-17 12:22:29 -08:00
Pasindu Perera 83c9741dc9 Fixed Typo
Summary: Closes https://github.com/facebook/react-native/pull/4160

Reviewed By: svcscm

Differential Revision: D2663767

Pulled By: mkonicek

fb-gh-sync-id: 1e61c9a96247eec0cb22523989a31b2ad2de0827
2015-11-17 09:49:27 -08:00
Tadeu Zagallo 0b46a0c13b Add a naive WPO implementation
Summary: public

RFC: The minifier haven't been stripping dead-code, and it also can't kill unused
modules, so as a temporary solution this inlines `__DEV__`, kill dead branches
and kill dead modules. For now I'm just white-listing the dev variable, but we
could definitely do better than that, but as a temporary fix this should be
helpful.

I also intend to kill some dead variables, so we can kill unused requires,
although inline-requires can also fix it.

Reviewed By: vjeux

Differential Revision: D2605454

fb-gh-sync-id: 50acb9dcbded07a43080b93ac826a5ceda695936
2015-11-17 03:39:28 -08:00
Tadeu Zagallo 136d79f4d6 Fix set log block in template
Summary: public

The log register function was updated, but the test example wasn't.

Reviewed By: javache

Differential Revision: D2658417

fb-gh-sync-id: 9ad27ec02eb437e0262e71897ff1a58a97e88b6d
2015-11-16 10:08:08 -08:00
James Ide 88a92f8f52 Add back projectRoots option to packager CLI command
Summary: Adding this to the CLI again (like: 8e7cfcd053 (diff-75e3fc051b7c5100b4681e8a8f62615bL45))

Fix #2390
Closes https://github.com/facebook/react-native/pull/4065

Reviewed By: svcscm

Differential Revision: D2652032

Pulled By: mkonicek

fb-gh-sync-id: 7162983c24f6e08ecc8f7f410e9b756471d88631
2015-11-13 08:00:29 -08:00
Martin Konicek 2681200ed6 More descriptive comment in default.config.js
Reviewed By: foghina

Differential Revision: D2575388

fb-gh-sync-id: b28e9ccd7a89409d4d755cfb8d771e5a9e1981b9
2015-11-12 07:43:25 -08:00
Tadeu Zagallo 6766d5ed54 Temporarily disable cli tests
Summary: public

The tests are failing, disable it temporarily until it's fixed.

Reviewed By: mkonicek

Differential Revision: D2641730

fb-gh-sync-id: e8e2a8f3e67df197570484d6a8b1d16be08ce1d7
2015-11-12 07:05:01 -08:00
Alex Kotliarskyi a710eb3292 Try to guess user's editor
Summary: public

Currently works only on OSX and supports Sublime (2/3) and Atom.

The idea is to get the list of running processes and try to find some well-known
editors there.

Reviewed By: vjeux

Differential Revision: D2642865

fb-gh-sync-id: d346902662354b2f633651a9bc54368146133651
2015-11-11 13:47:34 -08:00
Tadeu Zagallo b907f40957 Fix breakages when upgrading to babel 6
Reviewed By: vjeux

Differential Revision: D2628092

fb-gh-sync-id: 077a3572fe8b261d390be2bdc32d9d06c2b80a01
2015-11-10 10:56:48 -08:00
Felix Oghina 96b76fc85f fix run-android looking for packager in wrong place
Summary: Possibly leftover from the CLI migration.

public

Reviewed By: vjeux

Differential Revision: D2626589

fb-gh-sync-id: 22e44b7276bca136cde375a6d6d5af3bf0811767
2015-11-06 12:05:28 -08:00
Satyajit Sahoo 6c11d18360 Prevent destroying activity on runtime changes
Summary: From http://developer.android.com/guide/topics/resources/runtime-changes.html

> Some device configurations can change during runtime (such as screen orientation, keyboard availability, and language). When such a change occurs, Android restarts the running Activity (onDestroy() is called, followed by onCreate()). The restart behavior is designed to help your application adapt to new configurations by automatically reloading your application with alternative resources that match the new device configuration.

However, in a React Native app, there is only a single activity for the entire app, unlike a single activity per screen in Android, and resources are not specific to orientation etc. Destroying activity means reloading the entire app. Most of the time, this is not the intended behaviour, and can cause data loss for the user if the developer doesn't disable it explicitly. I'm proposing to disable it by default.
Closes https://github.com/facebook/react-native/pull/3813

Reviewed By: svcscm

Differential Revision: D2616083

Pulled By: foghina

fb-gh-sync-id: 8794e436f61581ff0bf569b1b112845cae77b688
2015-11-04 10:47:30 -08:00
Kai Wood 635edd9ccc Support line number arguments for RubyMine
Summary: RubyMine's command line launcher `mine` supports the same syntax as `mate` for jumping to line numbers. This patch adds it to the list.
Closes https://github.com/facebook/react-native/pull/3883

Reviewed By: svcscm

Differential Revision: D2615422

Pulled By: pcottle

fb-gh-sync-id: 79a70f524f852ba8eb4803e6abc6970abbf02b61
2015-11-04 07:56:27 -08:00
Martín Bigio eed38e9163 Retry landing D2590327
Reviewed By: swarr

Differential Revision: D2613446

fb-gh-sync-id: d38ad4e7cf66d25c69f92b330dd0feed0eeb23df
2015-11-03 17:45:28 -08:00
Jan Kassens 2519d25992 Fix undefined var exception
Summary: This check to see if `require` exists was bad as it throws an error for an
undefined reference in case it doesn't exist.
Closes https://github.com/facebook/react-native/pull/3845

Reviewed By: svcscm

Differential Revision: D2613368

Pulled By: martinbigio

fb-gh-sync-id: 7b1d0f38e4af9bce81356a613d6105f2c00c7ed7
2015-11-03 17:11:29 -08:00
Martin Konicek 441c464c2b Make it clear Android emulator is the quickest way to get started
Summary: A lot of people try to use a device as the very first thing when trying
out React Native. I've observed this at the developer workshop in Prague
and on Twitter.

However, developing on pre-API 21 devices is quite involved:
https://facebook.github.io/react-native/docs/running-on-device-android.html

I'm thinking we could recommend installing Android together with Android
studio. Android studio installs HAXM for you (hardware acceleration, without
this Google emulators are useless) and also creates and starts emulators.
So it would be quite a smooth experience similar to pressing 'Run' in Xcode.

We'd just need to integrate with Gradle so that installing the app also starts
the packager. I think that's something we should do in any case.

Probably an even better option is to build a React Native-specific tool that
lets you do everything you need: opens the Android SDK Manager, creates and
starts emulators, detects whether you have Genymotion and opens it, upgrades
node and npm etc.

public

Reviewed By: vjeux

Differential Revision: D2604774

fb-gh-sync-id: c7ffb701b4e5209815faf652926937c22943be95
2015-11-03 04:05:27 -08:00
Martin Konicek 4411ad49a4 More descriptive error message when Gradle build/install fails
Summary: Inspired by: https://twitter.com/geirmanc/status/660275638637477889

There are many reasons why the Gradle build could fail and the best
thing to do is to read the error message.

We can provide some hints in the most common cases though.

public

Reviewed By: vjeux

Differential Revision: D2604747

fb-gh-sync-id: 1aa83abb9ec823c03814dcc31d630a8f1914cf5c
2015-11-03 03:48:26 -08:00
Chris Geirman b752d79838 update pro tip to clarify how to configure zsh shell
Summary: Thanks to alex_frantic for helping me solve this problem...
https://twitter.com/alex_frantic/status/657276624220659712
Closes https://github.com/facebook/react-native/pull/3853

Reviewed By: svcscm

Differential Revision: D2609728

Pulled By: pcottle

fb-gh-sync-id: edb20fcbaff0289a2363eedebd84d20c2d3b39aa
2015-11-02 21:33:31 -08:00
Tadeu Zagallo ccd90e25c1 Convert remaining uses of alloc] init] to new]
Summary: public

We moved to using `new` instead of `alloc] init` but there was still some calls
left.

Reviewed By: javache

Differential Revision: D2604679

fb-gh-sync-id: ff7300ecbedb55dd5e93873592598810c9b87808
2015-11-02 08:03:17 -08:00
Aaron Chiu c4d780d904 fix packager compilation error
Differential Revision: D2604171

fb-gh-sync-id: 11decf6c8b689b903bd9c4fd9aca2ea626cc1d43
2015-10-31 06:14:26 -07:00
Tadeu Zagallo 010380cca6 Fix CPU profiler upload
Summary: public

Changes were made on the packager that broke the CPU profile upload route,
fix it.

Reviewed By: martinbigio

Differential Revision: D2585184

fb-gh-sync-id: 206744f92d403d6851a69891dfac0c4c11bf1b7e
2015-10-30 14:46:00 -07:00
Adrov Igor 95972cfd08 fix error handling in packager
Summary: Currently on error I have following output:
```
 ERROR  Packager can't listen on port 8081
Most likely another process is already using this port
Run the following command to find out which process:

   lsof -n -i4TCP:8081

You can either shut down the other process:

   kill -9 <PID>

or run packager on different port.

See http://facebook.github.io/react-native/docs/troubleshooting.html
for common problems and solutions.
/Users/nucleartux/Work/projects/react-native/local-cli/server/server.js:90
    if (error.code === 'EADDRINUSE') {
             ^

TypeError: Cannot read property 'code' of undefined
    at process.<anonymous> (/Users/nucleartux/Work/projects/react-native/local-cli/server/server.js:104:14)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)
    at process._fatalException (node.js:211:26)
```
Closes https://github.com/facebook/react-native/pull/3765

Reviewed By: svcscm

Differential Revision: D2595537

Pulled By: martinbigio

fb-gh-sync-id: e11ec2e6e8794bf5fe7570e27cd327777d8b300c
2015-10-29 08:59:02 -07:00
Martín Bigio 89f1e6732e Fix comments on .bat file 2015-10-28 21:36:07 -04:00
Martín Bigio 15006cf0b4 Add option to indicate bundle encoding
Summary: public

To improve cold start performance we want to be able to avoid decoding the bundle at all. To make that happen we need to be able to generate a bundle encoded on `ucs2`. This diff adds support for indicating the encoding the Packager should use for bundling.

Reviewed By: davidaurelio

Differential Revision: D2582365

fb-gh-sync-id: 905384272a668910c57a1a2ca6d1b723c39233f8
2015-10-28 13:20:28 -07:00
Martín Bigio 44af0d3dec Infer platform from extension
Summary: public
Aparently this used to work on 0.11, lets fix it :)

Reviewed By: foghina

Differential Revision: D2557719

fb-gh-sync-id: dcbca077431c1356c89dfc55b71eecff64c7ad3d
2015-10-27 17:47:28 -07:00
Martin Konicek 4e5a2bc079 Introduce react-native link
Reviewed By: martinbigio

Differential Revision: D2575858

fb-gh-sync-id: 13be5a0411db5cd753ebbac3799a7a0139c0f952
2015-10-27 11:22:28 -07:00
Martin Konicek 3c730b1ce2 Revert "Add folders to attempt to unblock sync"
We don't need these files anymore, the sync from the internal
fb repo to github is working now.

This reverts commit 746ebc6a79.
2015-10-26 22:48:10 +00:00
Martín Bigio bcf762af60 Move files from `packager/` to `local-cli`
Summary: public

This is not only to put the files on a place where it makes more sense but also to allow to use ES6 features on them as `/packager` is not whitelisted on `babel`.

Reviewed By: mkonicek

Differential Revision: D2577267

fb-gh-sync-id: b69a17c0aad349a3eda987e33d1778d97a8e1549
2015-10-26 15:38:14 -07:00
Martín Bigio 2856be9a07 Bring back global cli module check
Summary: public

This was introduced by vjeux on 0a5967d and removed on 0686b01. I guess it was removed accidentally as this this is a nice warning to have that should prevent n00bs from commiting a common mistake

Reviewed By: frantic

Differential Revision: D2563885

fb-gh-sync-id: 9fae145bbec587514f118d1d28d076b1d82f0630
2015-10-26 15:36:29 -07:00
Martín Bigio 849aa4dae6 Move `private-cli` commands to `local-cli`
Summary: public

We cannot remove `local-cli` because is referenced by the global cli explicitly. If we do so, people would have to upgrate this global thin cli which will cause some pain. So, lets move `private-cli` commands into `local-cli` instead.

Reviewed By: frantic

Differential Revision: D2571983

fb-gh-sync-id: 712c29430203660fb6f0d5f23813cb2a7156ee48
2015-10-26 15:36:04 -07:00
Martin Konicek 746ebc6a79 Add folders to attempt to unblock sync 2015-10-26 17:22:39 +00:00
Martin Bigio 47926abca9 Use default asset roots on `default.config.js`
Summary: We need to cherry pick this one as well.

cc ide
Closes https://github.com/facebook/react-native/pull/3640

Reviewed By: svcscm

Differential Revision: D2577961

Pulled By: mkonicek

fb-gh-sync-id: 3368fc02a931e0f259f3baa6706bd7d8586b0fbf
2015-10-23 18:49:25 -07:00
Felix Oghină 7e53ee1095 add upgrade cli command
Reviewed By: mkonicek

Differential Revision: D2559885

fb-gh-sync-id: 785bd6ad855da30c00b170e737a7dd0f3e756430
2015-10-23 03:37:28 -07:00
Martín Bigio 32aeeea313 Fix cli entry points
Reviewed By: frantic

Differential Revision: D2565954

fb-gh-sync-id: 6fde9e1dbefd71944e8f857e9a40619bf599ef75
2015-10-22 10:13:13 -07:00
Alex Kotliarskyi be70e32de2 Generate bundle and assets when building via Xcode
Summary: This integrates React Native into Xcode's build process, which lets us automatically handle bundling and packaging image assets.

Tested the script via https://github.com/frantic/ReactNativeAssetsExample

Loaded from packager:
<img width="432" alt="screen shot 2015-10-19 at 3 11 12 pm" src="https://cloud.githubusercontent.com/assets/192222/10593447/be5bc7e8-7678-11e5-8c70-ecc2a1ee24fc.png">

Loaded from offline bundle:
<img width="432" alt="screen shot 2015-10-19 at 3 10 58 pm" src="https://cloud.githubusercontent.com/assets/192222/10593448/be5d5194-7678-11e5-8b02-d492a26cfb81.png">

Android:
<img width="639" alt="screen shot 2015-10-19 at 3 11 20 pm" src="https://cloud.githubusercontent.com/assets/192222/10593449/be5de2d0-7678-11e5-8d3c-0378fc447f15.png">
Closes https://github.com/facebook/react-native/pull/3523

Reviewed By: mkonicek

Differential Revision: D2557923

Pulled By: frantic

fb-gh-sync-id: 19957e255993696e793b0162662772efd89f5c1a
2015-10-21 18:44:27 -07:00
Martín Bigio c6c97cbd9d Introduce default config
Reviewed By: frantic

Differential Revision: D2561344

fb-gh-sync-id: 651b8a199069f78e1ace2897ba4c0352aab7e3ea
2015-10-21 03:04:04 -07:00
Martín Bigio 8e7cfcd053 Kill unused files
Reviewed By: frantic

Differential Revision: D2561113

fb-gh-sync-id: a81fece0a948485e12bff7ec146e39d890664887
2015-10-21 03:04:01 -07:00
Martín Bigio 088c193a22 Start packager through cli
Reviewed By: frantic

Differential Revision: D2561066

fb-gh-sync-id: 1743153a84947da5d0e54aca7e1919cf5df3a965
2015-10-21 03:03:59 -07:00
Martín Bigio 5c4bb894bf Clean up cli.js
Reviewed By: frantic

Differential Revision: D2546201

fb-gh-sync-id: 214a12213674749e1b7270ccbe90fd3330c9cb1e
2015-10-21 03:03:57 -07:00
Felix Oghină 71adc24974 Revert "Update rn-cli.config.js"
This reverts commit 8d592650c9.
2015-10-21 11:02:08 +01:00
Martín Bigio 02e39719c2 Move `run-android` to `private-cli`
Reviewed By: mkonicek

Differential Revision: D2544567

fb-gh-sync-id: 3c62f6c30b5be7f480d8f44a48fb551fc30d477e
2015-10-20 11:48:29 -07:00
Martin Konicek 4ac3c4a853 Make 'npm start' an alias for 'packager.sh', don't silently no-op on Windows
Reviewed By: martinbigio

Differential Revision: D2559772

fb-gh-sync-id: d1cd2874c32459d6e1f0af7d084c3559ebc145aa
2015-10-20 10:15:22 -07:00
Martin Konicek e612690413 Add license headers to local-cli
Reviewed By: martinbigio

Differential Revision: D2559969

fb-gh-sync-id: d8cd52435213729ff73a1f039eb0378b28f8d10e
2015-10-20 09:55:21 -07:00
Martín Bigio 8d592650c9 Update rn-cli.config.js 2015-10-19 19:07:34 -04:00
Felix Oghină 9dc036d2b9 add gradle tasks for bundling js and assets in template
Summary: This adds gradle tasks that call `react-native bundle` with the correct args to bundle dev/release JS and assets. The dev task is disabled by default, as in dev mode people only use reload JS in most cases.

Submitting this as a pull request to have community visibility, although we have this code internally as well now and this will require an import.

* generate a project with `react-native init`, add some assets, run `./gradlew assembleRelease`, sign & zipalign generated APK, run it -> works
* enable dev bundling task, run `./gradlew installDebug` (not `react-native run-android` so as to not start the packager) -> works

Reviewed By: svcscm

Differential Revision: D2555071

Pulled By: foghina

fb-gh-sync-id: c3d9fcd4c77862e6a4db4e4d8d8cc39ee9dff3ab
2015-10-19 06:33:22 -07:00
Martín Bigio 8bff2d30ab Use `private-cli`'s server instead of `packager.js`
Reviewed By: vjeux

Differential Revision: D2542027

fb-gh-sync-id: e59f3be17590c1e256a903e04f2f0359c835c8b5
2015-10-16 15:01:23 -07:00
Martín Bigio 5977f494fc Allow user to configure transformer through cl argument
Reviewed By: frantic

Differential Revision: D2547435

fb-gh-sync-id: 77016ee5beba854a4cb58e9ac04b91a7dd76cf3e
2015-10-16 13:26:22 -07:00
Martin Bigio c0b5e6ed67 [react-native-cli] Move `new-library` command to `private-cli` 2015-10-16 11:20:29 -04:00
Pieter De Baets 74002b784b Fixes broken link to running on device
Summary: Closes https://github.com/facebook/react-native/pull/2420

@​public

Reviewed By: @majak

Differential Revision: D2549685

fb-gh-sync-id: 8ce3c9aa242cd65e8efc2bdd0065f9e20de8240d
2015-10-16 03:41:21 -07:00
Martín Bigio 36697ae6a1 Move android generator to private-cli
Summary: @​public

Lets also make this more generic to allow to generate the template for any platform code.

Reviewed By: @vjeux

Differential Revision: D2536821

fb-gh-sync-id: 6fb99c6dc546b8e1f9839c96a473dc08b0f5285c
2015-10-16 03:40:48 -07:00
Martín Bigio a21e226b68 Remove `install` command
Summary: @​public

The implementation wasn't working. Lets remove this for now and revisit if we trully want to support this.

Reviewed By: @frantic

Differential Revision: D2536442

fb-gh-sync-id: 4aca2d1d2584cd15ac855d69e6e9a5a08abf778e
2015-10-13 12:08:22 -07:00
Martín Bigio a102e6f587 Breaking change: Move `bundle` to `private-cli`
Summary: @​public

We need to start using the `private-cli` for the new asset system. Note this is a breaking change! People will have to upgrade their workflows/scripts to start using the new cli. Otherwise we'd need to build a thin adapter that is aware of both APIs which is something we;d like to avoid. The major API changes are:
  - API is now `entry-file` based instead of `url` based.
  - /s/--out/--bundle-output
  - /s/--out/--sourcemap-output

Also these parameters have no longer default values, you need to specify them. For instance, if you want to generate the sourcemaps you need to pass in the `--sourcemap-output` option

Lastly, additional project roots or asset roots need to be specified on the `rn-cli.config.js`.

Reviewed By: @frantic

Differential Revision: D2533877

fb-gh-sync-id: a45f9095fdf9442a9106ea7bb6a6b7f651d25273
2015-10-13 11:48:30 -07:00
Martín Bigio 144f8598c2 Introduce configuration template
Summary: @​public

We're rolling out a replacement for `local-cli`. As part of the process we moved many hardcoded values into a JS based configuration file.

Reviewed By: @vjeux

Differential Revision: D2533111

fb-gh-sync-id: 7250bddee9989b089ded409104e098ef15d79498
2015-10-13 06:44:14 -07:00
Felix Oghină aa63636512 [cli] suppress yeoman create output in init 2015-10-12 16:10:18 +01:00
Martin Konicek a7b23df510 [Android] Add default Proguard config 2015-10-09 17:13:46 +01:00
Martin Konicek c740edaf03 Add a comment to CLI's init 2015-10-08 17:49:05 +01:00
Nick Simmons 8d3bbdf8e6 [cli] make init backwards-compatible for real 2015-10-07 17:39:22 -04:00
Ben Vinegar a16d0e46d8 Add --write-sourcemap option to 'bundle' cli command (fixes GH-3202) 2015-10-02 16:01:18 -07:00
Felix Oghină 046d8d2dee [cli] make init backwards-compatible 2015-10-02 14:44:20 +01:00