Commit Graph

277 Commits

Author SHA1 Message Date
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