Summary:
Uglify@3.1.7 is causing some perf issues (more specifically, this commit: 5b4b07e9a7) that are impacting TTI on RN views and increased memory usage.
More specifically, code like:
```
function nonTrivialFn(pre) {
return pre + Math.random();
}
function hotFunctionCalledALotOfTimes(num) {
return nonTrivialFn(num + Math.random());
}
hotFunctionCalledALotOfTimes(3);
hotFunctionCalledALotOfTimes(5);
```
in v3.1.7 gets converted to:
```
function hotFunctionCalledALotOfTimes(num){
return function(pre) {
return pre + Math.random();
}(num + Math.random())
}
hotFunctionCalledALotOfTimes(3);
hotFunctionCalledALotOfTimes(5);
```
This causes a function creation each time `hotFunctionCalledALotOfTimes` is called.
By comparison, in v3.1.6, that previous code was converted to:
```
function nonTrivialFn(pre){
return pre + Math.random()
}
function hotFunctionCalledALotOfTimes(num){
return nonTrivialFn(num + Math.random())
}
hotFunctionCalledALotOfTimes(3);
hotFunctionCalledALotOfTimes(5);
```
Reviewed By: jeanlauliac, alexeylang
Differential Revision: D6296740
fbshipit-source-id: b3988d886e607103ec3ae6b9763b2f0411a8aa3c
Summary:
`metro-bundler` v0.21 contains a rewritten bundling mechanism, with simplified logic and much faster rebuild times, called delta bundler. This release contains a couple of breaking changes:
* Now, when using a custom transformer, the list of additional babel plugins to apply are passed to the `transform()` method. These are used in non-dev mode for optimization purposes (Check 367a5f5db8 (diff-40653f0c822ac59a5af13d5b4ab31d84) to see how to handle them from the transformer).
* Now, when using a custom transformer outputting `rawMappings`, the transformer does not need to call the `compactMappings` method before returning (check d74685fd1d (diff-40653f0c822ac59a5af13d5b4ab31d84) for more info).
* We've removed support for two config parameters: `postProcessModules` and `postProcessBundleSourcemap`.
Reviewed By: davidaurelio
Differential Revision: D6186035
fbshipit-source-id: 242c5c2a954c6b9b6f339d345f888eaa44704579
Summary:
**Summary**
Minification fails or minified bundle may crash due to uglify-es bugs which have been fixed recently. See https://github.com/facebook/react-native/issues/16689
**Test plan**
Try to production bundle a project using ex-navigation, which fails with:
```
Maximum call stack size exceeded
```
Use this patch and see that bundling suceeds. There are also minified runtime errors solved by this change, see https://github.com/facebook/react-native/issues/16689 for more information.
Closes https://github.com/facebook/metro-bundler/pull/85
Reviewed By: mjesun
Differential Revision: D6259177
Pulled By: rafeca
fbshipit-source-id: 55987eb338b06938181c0da74d104d23eeb135b6
Summary:
This diff migrates Metro Bundler from `worker-farm` to `jest-worker`:
* Fully removes the custom patched `worker-farm` fork.
* Removes //a lot// of non-clear Flow types used to cast functions from callbacks to promises.
* Reduces cyclomatic complexity of the `Transformer` class by using `async`/`await`.
* Cleans all additional methods inside `JSTransformer/index.js`, by moving them to a single class and properly scoping them.
**Note:** this diff does not still enable the ability to bind files to workers by using `computeWorkerKey`; this will come at a later stage.
Reviewed By: davidaurelio
Differential Revision: D6247532
fbshipit-source-id: 51259360a5c15117996777a3be74b73b583f595e
Summary:
The `formatBanner.js` file is requiring the `wordwrap` package, but it was not defined in the package.json. Somehow this was working before (maybe the package was being downloaded by another depdendency or maybe `formatBanner` was not used).
This fixes https://github.com/facebook/metro-bundler/issues/79
Reviewed By: mjesun
Differential Revision: D6136865
fbshipit-source-id: 722dd61cb936fca893453f4cfc3248718a329779
Summary: Upgrades uglify to version 3 with (experimental) ES6 support turned on.
Reviewed By: jeanlauliac
Differential Revision: D5842410
fbshipit-source-id: 1c8ccea15785bc5bb1c68d7a83b75881432d0ce2
Summary:
Adding a Babel plugin that will analyze the file looking for any potential candidate to use `regenerator-runtime`, and if so, will inject dynamically the module. The module is injected per file, so we avoid polluting the global environment. The plugin is also able to inject the `require` call beforehand, so that the inliner can pick them and inline them.
The Babel plugin is part of `react-native-babel-preset`, so as long as you are using this preset you are safe. If not, you should include the specific transformer into your list of plugins, as `react-native-babel-preset/transforms/transform-regenerator-runtime-insertion.js`.
Reviewed By: davidaurelio
Differential Revision: D5388655
fbshipit-source-id: dc403f3d5e2d807529eb8569a85c45fec36a6a3e
Summary: Bump dependencies to the same version that react native uses
Reviewed By: jeanlauliac
Differential Revision: D5364009
fbshipit-source-id: 302db951a5509584da13a18a7fab6965e0b1e394
Summary:
Remove our internal docbloc module and use `jest-docblock` instead.
The development server is using `jest-haste-map` exclusively, which in turn relies on `jest-docblock`, which differs slightly from our own docblock module.
Depending on only one version greatly reduces the number of edge cases
Reviewed By: cpojer
Differential Revision: D5328472
fbshipit-source-id: 4a31d8159519e01a83fda04b76e8f14f0beb16af
Summary:
We use custom npm scripts (`prepare-release`, `cleanup-release`) to
- move `src` to `src.orig`, and `build` to `src` before creating the tarball
- move everything back afterwards
We run these scripts with lerna before and after publishing. Custom hooks avoid problems with `prepublishOnly` and `postpublish` not being run at opportune times, `prepack` and `postpack` not being supported by npm v4 and yarn, and using `lerna run prepublishOnly` resulting in duplicated execution of the command.
This ensures that development is closer to what is pulled in from npm.
Reviewed By: jeanlauliac
Differential Revision: D5310133
fbshipit-source-id: 6b9885c88b936ef3fe5f1858738ad63d581a8731
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: Upgrades uglify to version 3 with (experimental) ES6 support turned on.
Reviewed By: cpojer
Differential Revision: D5227245
fbshipit-source-id: db8638eebe2daf40b60570cac34905e9a7288705
Summary: This allows us to get the new fix for recovery on duplicate modules.
Reviewed By: cpojer
Differential Revision: D5128975
fbshipit-source-id: 5a2b60430bbca1806a97798c482af8522366e071
Summary:
Pass `localPath` to transformers to allow usage of plugins like `transform-react-jsx-source` that don’t conflict with x-machine caches, e.g. Buck or our own global cache.
These caches don’t work properly if paths local to a specific machine are part of cached outputs.
Reviewed By: jeanlauliac
Differential Revision: D5044147
fbshipit-source-id: 1177afb48d6dd9351738fcd4da8f9f6357e25e81
Summary: The logic of the `inline` babel transform regarded identifiers as global if no binding exists for them. We extend that logic to also accept flow-declared variables.
Reviewed By: arcanis
Differential Revision: D4737620
fbshipit-source-id: e71cfdf77c7b7751265cfa4412430b4f29e9e853
Summary:
Moves stack trace symbolication to a worker process.
The worker process is spawned laziliy, and is treated as an exclusive resource (requests are queued).
This helps keeping the server process responsive when symbolicating.
Reviewed By: cpojer
Differential Revision: D4602722
fbshipit-source-id: 5da97e53afd9a1ab981c5ba4b02a7d1d869dee71