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:
This will allow consumers to supply their own transformer to all `react-native` cli commands by simply implementing `rn-cli.config.js` and overriding `getTransformModulePath()`. That way they don't have to fork various parts of the iOS and Android build system that React Native already provides just to add a `--transformer` command line argument.
**Test plan:** Applied this patch to the React Native version in my app, implemented `getTransformModulePath()` in my `rn-cli.config.js`, and verified that my custom transformer is invoked.
Closes https://github.com/facebook/react-native/pull/7961
Differential Revision: D3404201
Pulled By: foghina
fbshipit-source-id: c7eaa85de84d485d06d23a2ffea899821b2cf71c
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
Summary:
When trying to access the debug dependency graph through the `/debug/graph` endpoint of the packager server (documented in the packager README and listed as well when hitting the root `/debug` endpoint), all I am getting back is a nasty HTTP 500 error :'(
What triggers this HTTP 500 is a `TypeError` being thrown while trying to access a function that doesn't exists (anymore). Here is the error log of the packager when trying to access this endpoint :
```
TypeError: this._depGraph.getDebugInfo is not a function
at Resolver.getDebugInfo (index.js:270:27)
at Bundler.getGraphDebugInfo (index.js:575:27)
at Server._processDebugRequest (index.js:369:28)
at Server.processRequest (index.js:423:12)
at next (/Users/blemair/Code/DependencyGraphTest/node_modules/connect/lib/proto.js:174:15)
at Object.module.exports [as handle] (cpuProfilerMiddleware.js:17:5)
at next (/Users/blemair/Code/DependencyGraphTest/node_modules/connect/lib/proto.js:174:15)
at Object.module.exports [as
Closes https://github.com/facebook/react-native/pull/8117
Differential Revision: D3445582
fbshipit-source-id: cf5af8bbba293f39773f32814a3b388b7ff67bf7
Summary:
Implemented automatic IP detection for iOS, based on #6345 and #6362.
As the previous pull requests did, this works by writing the IP address of the host to a file.
Closes https://github.com/facebook/react-native/pull/8091
Differential Revision: D3427657
Pulled By: javache
fbshipit-source-id: 3f534c9b32c4d6fb9615fc2e2c3c3aef421454c5
Summary:
When remote debugging is enabled, stack traces start at `/debuggerWorker.js`. Since this is not a valid bundle URL, the packager fails to decipher it to find its sourcemap.
This changes the packager to skip the `/debuggerWorker.js` stack frame if one exists.
Reviewed By: frantic
Differential Revision: D3418341
fbshipit-source-id: 7434aa45dea7d120d9d77c060101dd9403989d0c
Summary: We are already inlining `Platform.OS`. This diff adds support to inline calls to `Platform.select` with an object literal as first argument. The transform will replace the call with the property value corresponding to the platform, or `undefined` if it does not exist.
Reviewed By: frantic
Differential Revision: D3385391
fbshipit-source-id: bb068d17948ed84e381707faeaa0450399c2f306
Summary:
`fbjs-scripts` 0.4.0 has Babel 5 as a dependency, which causes some amount of havoc when you're trying to use `react-native` in a project that's otherwise dependent on Babel 6 and using the flat-installing npm >=3.
Closes https://github.com/facebook/react-native/pull/7855
Reviewed By: frantic
Differential Revision: D3371679
Pulled By: steveluscher
fbshipit-source-id: 9f7643171d89da0de0492e7e97875f472725e990
Summary:
Update to node-haste 2.12.0 to support pass through configuration of supported platforms.
Closes https://github.com/facebook/react-native/pull/7660
Differential Revision: D3335034
Pulled By: mkonicek
fbshipit-source-id: d238b90a90d51654301d61251ceb26d183fef57a
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.
I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.
**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.
I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155
Reviewed By: bestander
Differential Revision: D3301008
Pulled By: davidaurelio
fbshipit-source-id: 504180d158a1e50bc03e28fb0d1e53d0731ce32f
Summary:
The way we currently symbolicate JS stack traces in RN during development time
(e.g. inside the RedBox) is the following: we download the source map from RN,
parse it and use `source-map` find original file/line numbers. All happens
inside running JSC VM in a simulator.
The problem with this approach is that the source map size is pretty big and it
is very expensive to load/parse.
Before we load sourcemaps:
{F60869250}
After we load sourcemaps:
{F60869249}
In the past it wasn't a big problem, however the sourcemap file is only getting
larger and soon we will be loading it for yellow boxes too: https://github.com/facebook/react-native/pull/7459
Moving stack trace symbolication to server side will let us:
- save a bunch of memory on device
- improve performance (no need to JSON serialize/deserialize and transfer sourcemap via HTTP and bridge)
- remove ugly workaround with `RCTExceptionsManager.updateExceptionMessage`
- we will be able to symbolicate from native by simply sending HTTP request, which means symbolication
can be more robust (no need to depend on crashed JS to do symbolication) and we can pause JSC to
avoid getting too many redboxes that hide original error.
- reduce the bundle by ~65KB (the size of source-map parsing library we ship, see SourceMap module)
Reviewed By: davidaurelio
Differential Revision: D3291793
fbshipit-source-id: 29dce5f40100259264f57254e6715ace8ea70174
Summary:
This pull request is a prerequisite to enabling the react-native-windows platform extension.
In the Resolver component, we need to add 'windows' to the list of platforms that are allowed in the DependencyGraph. We also need to add 'react-native-windows' (the name of the Windows platform extension NPM module) to the `providesModuleNodeModules` option. This allows the node_module folder check in the DependencyGraphHelper from node-haste to be bypassed for *.windows.js files in the Windows NPM package.
For good measure, I also included a change to blacklist.js to ensure .windows.js files are ignored when the packager is parameterized on a platform.
Closes https://github.com/facebook/react-native/pull/7639
Differential Revision: D3327771
Pulled By: mkonicek
fbshipit-source-id: d1080b045ff6aa0cbf05d8070ceb0eb4cdb6dceb
Summary:
Putting this up as request for comments.
The PR adds [transform-react-jsx-source](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx-source) to the list of plugins that come by default with the `react-native` preset. It will enable the use of a bunch of really cool tooling around JSX, however those are generally useful only in development mode. Is changing `react-native` preset the right thing to do in this case? Is there a way to enable this transform only in DEV? Should I add this somewhere else?
Closes https://github.com/facebook/react-native/pull/6351
Differential Revision: D3302906
Pulled By: frantic
fbshipit-source-id: 012d3a4142168f9f90d30d1686115d4dc3996eb9
Summary:
This got broken recently. As a result of this, when a module throws while being required, either by regular load or hot reload, the module object is marked as `hasError`. Form that point all subsequent HMR updates will fail because it will think the module failed while executing the factory but the failure could have been on an old run of an old factory.
The fix is very simple: just reset `hasError` to false when accepting a module.
Closes https://github.com/facebook/react-native/pull/7567
Differential Revision: D3310685
fbshipit-source-id: 2f0b48ab7432b7c221d0c88a019a28969a8862b2
Summary:
grabbou pointed out this issue.
We recently started cleaning out the factory function after module are required to save some memory. This broke HMR on some edge cases because sometimes the factory function may need to be re-executed. This PR just wraps the optimization into `__DEV__` to make sure we don't use it while developing.
Closes https://github.com/facebook/react-native/pull/7568
Differential Revision: D3305120
Pulled By: martinbigio
fbshipit-source-id: 741cffbb327d118f0bd0ec34dc1af53d4f94880e
Summary:
The code to require modules by their name (rather than their numeric ID) was buggy, because it didn’t check whether the module factory was already executed and the module already existed.
This diff checks the already loaded modules, too, when loading modules by name.
Reviewed By: lexs
Differential Revision: D3281350
fbshipit-source-id: cef236e152fe5484f21c877d6cee37433fa11c76
Summary:
This intends to make the devx story better after switching to numeric module IDs:
- `require('<verbose-name>)` works again for dev builds
- In dev builds, Systrace will use the verbose names of modules for markers
Reviewed By: bestander
Differential Revision: D3253318
fb-gh-sync-id: 3425d5086ce28634653a6c8c7f5f11afa1614902
fbshipit-source-id: 3425d5086ce28634653a6c8c7f5f11afa1614902
Summary:
* This allows `react-native` to work for users on fedora.
* `react-native run-android` was failing because the launch packager script was unable to find packager.sh (see `source` in `man bash`).
* This change sets cwd for the dev server when run with `run-android`.
Closes https://github.com/facebook/react-native/pull/7316
Differential Revision: D3255866
fb-gh-sync-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
fbshipit-source-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
Summary:
addition to #7297
When called from an upstarting app, the bundling process should always be called with a cleared cache. That avoids possible problems with cached files.
Closes https://github.com/facebook/react-native/pull/7324
Differential Revision: D3247420
fb-gh-sync-id: 503ad39cb36455512ccea1af7618e89a80942f0c
fbshipit-source-id: 503ad39cb36455512ccea1af7618e89a80942f0c
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.
I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.
**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.
I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155
Differential Revision: D3242754
Pulled By: eczarny
fb-gh-sync-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
fbshipit-source-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.
I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.
**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.
I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155
Differential Revision: D3242754
Pulled By: davidaurelio
fb-gh-sync-id: 02880c841c10562d5f107e1c975d668e55cc619f
fbshipit-source-id: 02880c841c10562d5f107e1c975d668e55cc619f
Summary:
Adds support for launching the packager in a new window on Windows.
**Test plan (required)**
Tested that the packager is launched in a completely independent process. This means that exiting the `react-native run-android` command should not close the packager window and it should exit properly when completed even if the packager window is still opened. Pretty much made sure it behaves exactly like on mac.
Also tested that an error in the packager will not close the window immediately to show the error stack trace.
Closes https://github.com/facebook/react-native/pull/7129
Differential Revision: D3240628
Pulled By: mkonicek
fb-gh-sync-id: 007582250536481d2b2376f9a201f8f415fc1080
fbshipit-source-id: 007582250536481d2b2376f9a201f8f415fc1080
Summary: Apparently what we're using for console.trace is not really the same as what Chrome does (we don't log a stacktrace). Add `console.debug` with the same functionality as `console.trace`, just so we don't crash between browser and local execution.
Reviewed By: davidaurelio
Differential Revision: D3235053
fb-gh-sync-id: 4bed17ac8aa4c8c100f15cf0aabbc25101c913c1
fbshipit-source-id: 4bed17ac8aa4c8c100f15cf0aabbc25101c913c1
Summary: This upgrades to node-haste@2.10.0 and allows to expose folders as additional node modules from rn-cli.config.js
Reviewed By: bestander
Differential Revision: D3232595
fb-gh-sync-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
fbshipit-source-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
Summary:This PR fixes a bug where when using relative roots for the packager server, asset paths would be deemed invalid by the recently introduced security check. Resolving the root to an absolute path fixes that problem.
I'd be happy to write a regression test for this but I had a hard time setting up a mock file system with relative paths. If it is required, some help would be appreciated...
Closes https://github.com/facebook/react-native/pull/7161
Differential Revision: D3214840
fb-gh-sync-id: 08e13fb9f94a98206fd2d090f74a8b63ba2bf80f
fbshipit-source-id: 08e13fb9f94a98206fd2d090f74a8b63ba2bf80f
Summary:Adding the react native renderer dependency and various fixes to support React 15.
Don't use dispatchID for touchableHandleResponderGrant
This callback argument was removed because "IDs" no longer exist. Instead, we'll
use the tag from the event target.
The corresponding PR on React Core is: https://github.com/facebook/react/pull/6338
Reviewed By: spicyj
Differential Revision: D3159788
fb-gh-sync-id: 60e5cd2aa0af69d83fcdac3dfde0a85a748cb7b9
fbshipit-source-id: 60e5cd2aa0af69d83fcdac3dfde0a85a748cb7b9
Summary:The require functions will keep the generate bytecode + lexical environment in
memory unnecessarily, since we can be sure that it will be executed at most once
Reviewed By: davidaurelio
Differential Revision: D3168257
fb-gh-sync-id: 038e1bc08abea94ee52d0390b6aced5fb652f493
fbshipit-source-id: 038e1bc08abea94ee52d0390b6aced5fb652f493
Summary:The WebView component in iOS currently does not support displaying PDFs without providing a remote URI or manually including the assets in the xcodeproj itself. This is because the packager has not whitelisted the 'pdf' extension.
I've gone ahead and whitelisted the 'pdf extension according to the recommendation by nicklockwood
GH comment: https://github.com/facebook/react-native/issues/1846#issuecomment-199302488
Closes https://github.com/facebook/react-native/pull/7004
Differential Revision: D3196019
Pulled By: nicklockwood
fb-gh-sync-id: 10a86a9232095f98f277506141de0b8af5b21ab4
fbshipit-source-id: 10a86a9232095f98f277506141de0b8af5b21ab4