Summary:
We can keep the `searchQueue` cleaner by using `this._fastfs.dirExists` on the potential `node_modules` directory. In addition to avoiding useless lookups, this also makes the error message provided by #9832 much more understandable.
/cc davidaurelio
Closes https://github.com/facebook/react-native/pull/9973
Differential Revision: D3887053
Pulled By: davidaurelio
fbshipit-source-id: 6a5a488bb4217dd0f9db1c9c9f988b498c746ca9
Summary:
Hi,
This PR fixes the problem described by chrisnojima in https://github.com/facebook/react-native/issues/9581#issuecomment-243766310
**Test plan**
In development mode,
- Run an app with an image: `<Image source={ require('./logo.png') }/>`
- Notice that you see the following in packager console:
```txt
6:46:42 PM] <START> processing asset request logo.png
[6:46:42 PM] <END> processing asset request logo.png (1ms)
```
- Reload the app, or navigate to another page of the app with the same image
- Notice that you see again:
```txt
6:47:23 PM] <START> processing asset request logo.png
[6:47:23 PM] <END> processing asset request logo.png (1ms)
```
Now wih the fix applied,
notice that you only see `logo.png` fetched once, even if you reload or show the same image in a different part of the app.
Let me know what you think.
Closes https://github.com/facebook/react-native/pull/9795
Differential Revision: D3876945
Pulled By: davidaurelio
fbshipit-source-id: f41f4719e87644692a690123fd6e54eead9cc87d
Summary:
The introduction of groups for random access bundles broke hot module reloading, because HMR uses a different Bundle class. And that didn’t have the `setRamGroups()` method.
This just adds an empty method on the base class.
**Test plan (required)**
I ran `node scripts/run-ci-e2e-tests.js --android`
Closes https://github.com/facebook/react-native/pull/9982
Differential Revision: D3886096
Pulled By: bestander
fbshipit-source-id: 46e6183607b0275d3cfe0d892360248b7b2154e9
Summary:
Adds the possibility to specify an array of files (group roots) that are used to bundle modules outside of the “startup section” into bigger groups by colocating their code.
A require call for any grouped module will load all modules in that group.
Files contained by multiple groups are deoptimized (i.e. bundled as individual script)
Reviewed By: martinbigio
Differential Revision: D3841780
fbshipit-source-id: 8d37782792efd66b5f557c7567489f68c9b229d8
Summary:
This adds support for `false` values in `package.json` `"browser"` and `"react-native"` mappings.
All `false` values are not longer silently ignored, but redirected to an empty file.
Fixes#9854#9518
Reviewed By: bestander
Differential Revision: D3876521
fbshipit-source-id: 96d1ba03518812bc88c51672c374956eabd40c9b
Summary:
For example, I could have a root named `random` and another root named `randomColor`.
A child of `randomColor` would **incorrectly** pass as a descendant of `random`.
So this commit changes `isDescendant` to do 2 things:
- check for exact matches (eg: the path is a root)
- call `startsWith` like before, but append `path.sep` to avoid false positives
Closes https://github.com/facebook/react-native/pull/9831
Differential Revision: D3864968
fbshipit-source-id: 7fe04913579aa0741840fc925216283304ae3433
Summary:
This piece of code can assemble all transitive dependencies of a set of entry modules. It is supposed to replace `ResolutionRequest.getOrderedDependencies`.
It has the following advantages:
- has minimal API surface to other components of the system (uses two functions, exposes one function)
- allows to separate concerns into loading + transforming files, resolving dependencies, gathering all modules belonging to a bundle (this code), and bundling
- allows to specify multiple entry points
- allows to use any kind of dependency ID as entry point (haste IDs, node module IDs, relative paths, absolute paths – depends on the resolver)
- allows to skip files, which allows callers to incrementally update previously retrieved collections of modules
Reviewed By: cpojer
Differential Revision: D3627346
fbshipit-source-id: 84b7aa693ca6e89ba3c1ab2af9a004e2e0aaed3d
Summary: This makes the `hash` property of asset data depend on asset file contents rather than modification time of files. That means that bundles will be consistent across different checkouts.
Reviewed By: martinbigio
Differential Revision: D3856815
fbshipit-source-id: 8bfea4e0a714f48fc6a4ae5ed2a1426dc8d5868e
Summary:
I'm not sure if this was actually breaking anything, but I don't think `new` before `Promise.race()` is conventional.
Closes https://github.com/facebook/react-native/pull/9817
Differential Revision: D3836814
Pulled By: javache
fbshipit-source-id: 3bde46dca3760c3f7f3427f6346dd5f16f8ac011
Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?
Fix issue with browser and react-native module mappings in node-haste when running the packager from Windows.
**Test plan (required)**
Tested on the NPM package uuid, which has a browser mapping, and it worked.
Fixes#9570
Closes https://github.com/facebook/react-native/pull/9572
Differential Revision: D3821761
Pulled By: davidaurelio
fbshipit-source-id: ebbd91f9e3215385afe3b81a97a962b45a6286f9
Summary:
When I use local static files as Image resources, it will occur a 404 error if the image file's name contains some non-latin letters.
The reason is that the request's url will be encoded if it contains some non-latin letters.
Closes https://github.com/facebook/react-native/pull/9604
Differential Revision: D3821328
Pulled By: javache
fbshipit-source-id: bfdc7f71517b5d4ba9e0a013979e5dcf6c31a237
Summary: Activity events now have a `silent` boolean option that specifies whether or not the event phases are to be logged to the console. Defaults to `false`, preserving current behaviour for events that do not explicitly have this option set.
Reviewed By: davidaurelio
Differential Revision: D3810802
fbshipit-source-id: 38d14b9e6c6502fbc73eece9466f20b60d19965e
Summary:
When bringing back `node-haste` to React Native, I left an `fdescribe` in a test that led to ~70 tests being skipped.
This re-enables these tests, and fixes test failures
Reviewed By: cpojer
Differential Revision: D3811225
fbshipit-source-id: 67a16f385759bb829f1f3f559862eab7e78f2097
Summary: Updating an existing bundle is now logged as a telemetric event.
Reviewed By: davidaurelio
Differential Revision: D3804754
fbshipit-source-id: adab3b054a161bd9535ad01d52573fb7bb177d43
Summary:
Revised the Activity implementation
- added flow annotations
- fixed some lint warnings
- added event `options`, specifically a `telemetric` option which indicates that events tagged in this manner are relevant for telemetry. The duration of these events is now highlighted in the Activity log
Reviewed By: bestander, kentaromiura
Differential Revision: D3770753
fbshipit-source-id: 6976535fd3bf5269c6263d825d657ab0805ecaad
Summary: The logic of assigning module IDs to the initial require calls of a bundle was faulty, counting up from -1 instead of counting down. This change ensures that IDs are -1, -2, ...
Reviewed By: matryoshcow
Differential Revision: D3735560
fbshipit-source-id: 89efa3e73b39c2f8bfed8a6a30487733d1a8b145
Summary: If a bundle failed to build, a file change would trigger the *update bundle* path, without ever being able to resolve the bundle. If a bundle can't be updated, we evict it from the cache.
Reviewed By: cpojer
Differential Revision: D3726567
fbshipit-source-id: a342f00c5a41364551194c33082718e5483fd7a4
Summary: Rejected promises in the cache would prevent the cache from persisting. This removes rejected promises from the cache, so that subsequent successful cache updates can be persisted.
Reviewed By: cpojer
Differential Revision: D3726691
fbshipit-source-id: ddec03676a7a89264fe64b4af4b183cbead638fb
Summary:
This clears the packager server cache for potential changes of module resolutions.
We will make this a lot better in the future, but for now this crude mechanism will have to do.
Reviewed By: cpojer
Differential Revision: D3713143
fbshipit-source-id: 7c81f40e8ec71404c3369211b29f63928d6634b9
Summary:
This is a very hacky solution to make reloads from packager faster for simple file changes.
Simple means that no dependencies have changed, otherwise packager will abort the attempt to update and fall back to the usual rebuilding method.
In principle, this change avoids re-walking and analyzing the whole dependency tree, and just updates modules in existing bundles.
Reviewed By: bestander
Differential Revision: D3713704
fbshipit-source-id: ba182325c4f4003c0a7402ea87444a94c75ebaf8
Summary:
This is a very hacky solution to make reloads from packager faster for simple file changes.
Simple means that no dependencies have changed, otherwise packager will abort the attempt to update and fall back to the usual rebuilding method.
In principle, this change avoids re-walking and analyzing the whole dependency tree, and just updates modules in existing bundles.
Reviewed By: bestander
Differential Revision: D3703896
fbshipit-source-id: abc2a41144536baf969d346522a17044c1c9558b
Summary:
This is a very hacky solution to make reloads from packager faster for simple file changes.
Simple means that no dependencies have changed, otherwise packager will abort the attempt to update and fall back to the usual rebuilding method.
In principle, this change avoids re-walking and analyzing the whole dependency tree, and just updates modules in existing bundles.
Reviewed By: bestander
Differential Revision: D3703896
fbshipit-source-id: 671206618dc093965822aed7161e3a99db69a529
Summary:
We have a weak build machine for React Native app: a poor Mac Book Air with HDD, which is very slow.
So, fs operations sometimes fail because of timeout.
We likely don't care about build time, but it's pretty annoying to restart builds sometimes.
In this PR I make timeout injectable via environment variable.
__USAGE__:
export this variable into environment. It's measured in miliseconds.
Example, for 1 minute timeout:
`export REACT_NATIVE_FSOP_TIMEOUT=60000`
If you don't specify it, it will remain default value: `15000`
This should not break anything, but repair slow builds.
Related to : #9373 , #8794 (I think so)
This PR should handle case of issue and close#9373
Closes https://github.com/facebook/react-native/pull/9374
Differential Revision: D3709325
Pulled By: bestander
fbshipit-source-id: b00c89e10d05362314546faea7a4524f3d327c97
Summary: This removes asset data that is not used at runtime from the bundle.
Reviewed By: javache
Differential Revision: D3628486
fbshipit-source-id: 33cd579c904e0b0e29502df39a4ff92cad43367c
Summary:
https://github.com/facebook/react-native/pull/8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets.
**Test plan (required)**
Try the test in the original pull request for range requests: https://github.com/facebook/react-native/pull/8219
Closes https://github.com/facebook/react-native/pull/9254
Differential Revision: D3680070
fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
Summary: Looks like react-addons-perf is sometimes missing entries. This prevents it from crashing.
Reviewed By: davidaurelio
Differential Revision: D3669007
fbshipit-source-id: 18a1102b5ad8dcfd9b80d39e1172ba85ad0e9dd2
Summary:
Since jest stopped using node-haste a while ago, we are the only client left.
This brings back node-haste back to fbsource to allow us to iterate faster.
Reviewed By: bestander
Differential Revision: D3641341
fbshipit-source-id: a859f8834765723a3515e2cf265581b9dd83997c
Summary: This shows at max 5 progress updates per second on the terminal, which results in a minor speedup of reloads.
Reviewed By: bestander
Differential Revision: D3620164
fbshipit-source-id: d1a30f2f29f7088602d276b8ad3fc8ff1b74c79d
Summary:
This changes the jest preprocessor so that files targetet at node.js will be run with the node-specific transform.
It also adapts tests that relied on inline requires.
Benefit: packager tests run faster now.
Reviewed By: cpojer
Differential Revision: D3562007
fbshipit-source-id: e06c86d545926a5c546458025f505dca115e7ea8
Summary:
This PR solves a problem when video assets are used from third-party React Native components (e.g. [react-native-video](https://github.com/brentvatne/react-native-video). The video will not work while the assets are served from the react native packager because the used video component (iOS) relies on HTTP range requests.
I added a small fix that allows ranged requests (e.g. mp4) to be served in ranges.
To test this:
1. make new react native project
1. add [react-native-video](https://github.com/brentvatne/react-native-video) to xcode project
1. add video component to your project
```
import Video from 'react-native-video';
var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
/* ... /*
render() {
let source = resolveAssetSource(require('./someVideoFile.mp4')) || {};
return <Video /*....*/ source={source} />;
}
```
That should not work (if video is smaller than a few megabytes, open app a few times). Then add my fix, that should do the trick.
Closes https://github.com/facebook/react-native/pull/8219
Reviewed By: davidaurelio
Differential Revision: D3542485
Pulled By: frantic
fbshipit-source-id: e4f2e4d3aaafa8445e965259bf04ad107dba8a4f
Summary:
This pull request fixes a small typo when a module fails being transformed through the React Packager.
Closes https://github.com/facebook/react-native/pull/8596
Differential Revision: D3522272
Pulled By: mkonicek
fbshipit-source-id: e117a26bab5a99573ac68fb0e7618df0a14325a4
Summary:
Looks like spaces in function names can happen, but the lib we use for parsing stacktraces doesn't support that. As result, when error is thrown in global scope, new JSC puts "global code" as function name, our parser chokes on it and thinks "global code@http://...." is a file name and sends it to packager. The packager can't resolve that URL and fails the whole symbolication request.
Longer term fix here: https://github.com/errwischt/stacktrace-parser/pull/5
Reviewed By: astreet
Differential Revision: D3516741
fbshipit-source-id: 7f14b52a50a118dc95a3463aee842941e904e984
Summary:
Looks like spaces in function names can happen, but the lib we use for parsing stacktraces doesn't support that. As result, when error is thrown in global scope, new JSC puts "global code" as function name, our parser chokes on it and thinks "global code@http://...." is a file name and sends it to packager. The packager can't resolve that URL and fails the whole symbolication request.
Longer term fix here: https://github.com/errwischt/stacktrace-parser/pull/5
Reviewed By: astreet
Differential Revision: D3516741
fbshipit-source-id: 4f2bb70084437ed9d37495cd775622a8c981fad1
Summary: This removes `node_modules/react` from the list of directories that are used for haste module resolutions. Modules required from React are now imported with `require('react/lib/…')`.
Reviewed By: astreet
Differential Revision: D3509863
fbshipit-source-id: 32cd34e2b8496f0a6676dbe6bb1eacc18124c01e
Summary:
* Next version of Jest doesn't allow non test files in __tests__ folders.
* I'm trying to switch all tests off of jsdom on react-native. This should save 500ms of time when running a single test because jsdom is slow to load and react-native is also not supposed to run in a DOM environment, so let's not pretend we are providing the DOM in tests.
* Make the bridge config configurable so that when we disable automocking and we reset the registry we can redefine the value.
Oh also, stop using lodash in Server.js. First off, lodash 3 doesn't work in Jest's node env because it does some crazy stuff, second because we don't need to load all of lodash for debounce.
Reviewed By: davidaurelio
Differential Revision: D3502886
fbshipit-source-id: 1da1cfba9ed12264d81945b702e7a429d5f84424
Summary:
When an asset is included in a module, and the directory for that asset can't be found in any of the roots, it is hard to debug that, because the error message contains neither the name of the requested file, the sub directory it is located in, nor the roots that have been searched for it. It becomes more difficult, because that exception is created asynchronously. It contains the calling promise code.
This diff makes the error message more useful by including the name of the file, the sub directory, and the roots.
Reviewed By: bestander
Differential Revision: D3456738
fbshipit-source-id: 60b81f04626ad386f7120247c5f5361c81c52968
Summary:
This makes sure that `getModuleId` is called on modules in the order returned by `node-haste`, rather than waiting for a couple of promises to resolve before calling the function.
Related: #7758
Reviewed By: frantic
Differential Revision: D3450853
fbshipit-source-id: 7f26590b39b94ade32c73a8db9fd31d283d57549