Summary:
The HMR logic used to try to calculate the dependencies of every new added (or modified) file, including assets. This resulted in a TransformError.
This commit adds a check that stops the HMR bundling once it finds out that the updated file is an asset
Reviewed By: cpojer
Differential Revision: D5697391
fbshipit-source-id: faf7ccad76ac4922b70ed1c7ce8ce32b03c4e8ee
Summary:
This diff builds on top of the refactor to use `async/await` and adds multi-client support to Hot Module Reloading.
Thanks to async/await it's been quite straightforward to add this logic, since the only thing that I've had to do is to create a `Set` with the currently connected clients and passed the specified client to each method that was using the global client before.
This closes https://github.com/facebook/react-native/issues/14334
Reviewed By: davidaurelio
Differential Revision: D5611176
fbshipit-source-id: ec29438887342877c372b61132efada16af58fa5
Summary: makes flow typing for the entry point more sound and fixes two issues
Reviewed By: BYK
Differential Revision: D5507650
fbshipit-source-id: 6b03f7de792ffcece4d0d61950e136a61ea7db2e
Summary:
This adds support to RN's configuration file to let people turn off Babel's behavior of looking up .babelrc files. Most of the support for this feature is in Metro (https://github.com/facebook/metro-bundler/pull/31).
Closes https://github.com/facebook/react-native/pull/15136
Differential Revision: D5483241
Pulled By: jeanlauliac
fbshipit-source-id: c78096c1574c9f844c9f34aff73e6f97cb0b5e45
Summary: Move the returned type of `getPolyfills` from a standard `Array` to a read-only one, so that we make sure the array is not modified once created. Also, refactor the list of polyfills included by default to a generic, central file, then require it both from the CLI utils as well as the development server.
Reviewed By: jeanlauliac
Differential Revision: D5406553
fbshipit-source-id: ab980288bb1c625338de469da77dd6fc70bcedbc
Summary:
<details>
Thanks for submitting a PR! Please read these instructions carefully:
- [ ] Explain the **motivation** for making this change.
- [ ] Provide a **test plan** demonstrating that the code is solid.
- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.
Please read the [Contribution Guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md) to learn more about contributing to React Native.
</details>
_What existing problem does the pull request solve?_
On Linux, the packager caught an "Google Chrome exited with error: { Error: spawn google-chrome ENOENT}" when trying to launch the devTools because google-chrome is not installed but chromium is.
Thus, this pull request maps the platform Linux with chromium for launching the debugger automatically in the packager
_A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI or updates the website._
- enter on terminal
> react-native start
- launch the app in dev mode with "Debug JS remotely" enabled
- the packager prints "Launching Dev Tools..." and launch chromium with the debugger
![screenshot](https://user-images.githubusercontent.com/13065528/27481217-ceaf5e58-581b-11e7-976f-75c107596ad3.png)
Closes https://github.com/facebook/react-native/pull/14696
Differential Revision: D5398564
Pulled By: hramos
fbshipit-source-id: 151f83b549492c8716a248eb16f7e24c5658b32e
Summary:
React Native bundler (aka Metro Bundler) was splitted from the main codebase some time ago (now it lives [[https://github.com/facebook/metro-bundler|here]]). To make it more agnostic, polyfills will be moved out from it, so people who doesn't need them does not include them. However, RN will still need them, so the first step is to copy them back to RN so that we can provide them to Metro Bundler later.
We also include a way of passing the list of polyfills to include, as an `Array<string>`. The field is called `polyfills`, and defaults to the traditional list that is currently included in the package manager [see here](be1843cddc/packages/metro-bundler/src/defaults.js (L27-L37)).
In future commits, `metro-bundler` will be able to manage the `polyfills` array passed to it, and use it, instead of the pre-defined ones.
Reviewed By: davidaurelio
Differential Revision: D5381614
fbshipit-source-id: 749d536b781843ecb3067803e44398cd6df941f1
Summary:
Since copy to clipboard functionality is now available in Linux, the comment above `copyToClipboard` function has been updated.
Closes https://github.com/facebook/react-native/pull/14773
Differential Revision: D5392372
Pulled By: hramos
fbshipit-source-id: 6e2668e1a89d37f9d5707fa36b3639895cd5bffd
Summary: Upgrade metro-bundler to v0.9.0. This version has no functional change. The only change is that the structure of the npm package reflects the structure of the source code.
Reviewed By: bestander
Differential Revision: D5315651
fbshipit-source-id: 3a69337106d4ccf708823c80d304941973360e8e
Summary:
The React Native Remote Debugger page (`debugger.html`) contains an embedded silent sound file to maintain tab priority in Google Chrome.
This revision simply replaces the existing one with a better one that has the following characteristics:
- 1s Duration
- 10Hz Frequency
- -48dBFS Amplitude
- Fades in/out to reduce audible clicks on loop.
- 44.1kHz @ 16bit to maximimize compatibility.
- Smaller size.
Much thanks to Stephane Pigeon (http://stephanepigeon.com/) for designing the sound file specifically for this use case.
Reviewed By: mmmulani
Differential Revision: D5273591
fbshipit-source-id: 81668cc0a829e008263907fc1fa7150b72691371
Summary:
This diff cleans up some cruft and adds some features:
* It removes the usage of an env variable to control workers.
* It removes the lazy and handwavy calculation on how many workers to use for jest-haste-map. Jest itself uses the maximum amount of workers available and it has never been reported as an issue – especially since it is a one-time startup cost of about 3 seconds on a cold cache only.
* It adds a `--max-workers` flag to replace the env variable. This one is able to control both the number of workers for `jest-haste-map` as well as the transformers.
* It makes the transformers run in the parent process if 1 or fewer workers are are specified. This should help with debugging.
Once you approve this diff, I will publish a new version of metro to npm and update the version used in RN and remove the use of the env variable altogether: https://our.intern.facebook.com/intern/biggrep/?corpus=xplat&filename=&case=false&view=default&extre=&s=REACT_NATIVE_MAX_WORKERS&engine=apr_strmatch&context=false&filter[uninteresting]=false&filter[intern]=false&filter[test]=false&grep_regex=
Note: the process of adding a CLI option is really broken. Commander also has a weird API. We should consider building a better public API for Metro and then consider how to build a new CLI on top of it and simplify our internal integration. I really don't like how Metro is integrated across pieces of the RN cli in ways that is hard to manage. But that is a larger task for another time :)
Reviewed By: jeanlauliac
Differential Revision: D5217726
fbshipit-source-id: 74efddbb87755a9e744c816fbc62efa21f6a79bf
Summary:
* Internally, we already set up babel before calling into metro-bundler.
* Externally, I moved the setup calls to outside the packager/ folder.
If somebody has a custom integration with RN, they would need to setup babel themselves up until we make the open source split. By the time this is released in open source, an npm version of metro-bundler will be available for use.
Next step: also do this for the worker and remove setupBabel from the metro repo.
Reviewed By: davidaurelio
Differential Revision: D5121429
fbshipit-source-id: e77c6ccc23bef1d13fd74c4727be2d7e09d2d0ca
Summary:
After examining how React Native sets up `process.env.NODE_ENV` using `global.__DEV__` from `prelude_dev.js` or `prelude.js` by treating them like polyfills I decided to use the same approach for environment variables. I setup my own rn-project.config.js file like so:
```
const blacklist = require('react-native/packager/blacklist');
const pathJoin = require('path').join;
module.exports = {
getBlacklistRE: function() {
return blacklist([/build\/.*/, /app\/assets\/webpack.*/]);
},
polyfillModuleNames: [pathJoin(__dirname, 'globals.js')]
};
```
I ran the packaging server using:
`react-native start --config=config/react-native/rn-project.config.js --reset-cache`
I expected my polyfillModuleNames to be passed into the Packager properly and be handled the same way the built-in polyfills worked. Unfortunately I noticed the Packager wasn't actually getting `opt.polyfillModuleNames`. Digging into the code a bit, it seems the local-cli wasn't passing the polyfillModuleNames from the config.
There are no specs for runServer.js but this change can be tested by using a config that contains polyfillModuleNames. Sample config and run command provided above simple `global.js` provided below:
```
global.process = global.process ? global.process : {};
global.process.env = global.process.env ? global.process.env : {};
global.process.env['PROJECT_ENV'] = 'staging';
```
Closes https://github.com/facebook/react-native/pull/13725
Differential Revision: D5077615
Pulled By: jeanlauliac
fbshipit-source-id: f66a8a8bda2702cd9a4e5b92f5335f43ab2f9089
Summary: I'd like to start typing the front-end so that it's easier to track adding new options, etc.
Reviewed By: davidaurelio
Differential Revision: D5069868
fbshipit-source-id: 9a18dca52efd486ca18f17d0ec434a5ec1c1649c
Summary: This makes it easier to verify correctness when adding new config/args.
Reviewed By: davidaurelio
Differential Revision: D5069537
fbshipit-source-id: 4d8058851900b23163d0f2744e91dd14dfcdd461
Summary: I've been confused for a long time by this, and I think it's better late than never. I propose we rename that file to make it more explicit where that class lives, and so that it's consistent with the test file, name `DependencyGraph-test.js`
Reviewed By: davidaurelio
Differential Revision: D5020556
fbshipit-source-id: d54a501c3995f3fea16a5bfc6ca72993f73c4873
Summary:
Existing instructions are a bit misleading, as Chrome extension is not supposed to work, but there is still a supported way to run them.
Closes https://github.com/facebook/react-native/pull/13707
Differential Revision: D5010169
Pulled By: gaearon
fbshipit-source-id: f9558c9ccb04196854b2eef6ff40a998350b65db
Summary:
`declareOpts` prevents strong Flow typing, and promotes default values, that may be different from a function to another (my goal is to remove defaults from the whole codebase except perhaps the public API). This changeset replaces it by Flow types and fixes callsites to be explicit on values.
This is the last callsite of `declareOpts` so I'll remove it, in a separate diff.
Reviewed By: cpojer
Differential Revision: D4970650
fbshipit-source-id: e5ea2e06febde892d28c9dc59dc2920d4033bb01