Summary:
Currently, DevTools only work under ios (although this is undocumented!), because the JavaScriptEngine initialization process skips setupDevTools() on android.
DevTools work fine with Android, as tested on 0.26, 0.27, and 0.28 using Nuclide's inspector.
For reference, [the relevant issue on react-devtools](https://github.com/facebook/react-devtools/issues/229).
Closes https://github.com/facebook/react-native/pull/8095
Reviewed By: bestander
Differential Revision: D3430206
Pulled By: javache
fbshipit-source-id: 826f0252fff3f0ec2c843149540a0109e34d1d18
Summary:
`polyfillLazyGlobal` used a top level this which get stripped by babel `transform-es2015-modules-commonjs` with the default config. This is mainly an issues for people not using the react native babel preset.
This also replaces a few GLOBAL with global for consistency with the rest of the file.
**Test plan**
Tested that there was an error when using `['transform-es2015-modules-commonjs', { strict: true, allowTopLevelThis: false }]` in the babel config and that it was fixed after applying my changes.
Fixes#7700
Closes https://github.com/facebook/react-native/pull/7971
Differential Revision: D3427675
Pulled By: javache
fbshipit-source-id: 48f258b0db1bf21185193bd56df453ced9242e64
Summary:
In several pervious diffs we have moved symbolication of JS stack traces
to the packeger. This lets us save a bunch of memory (~80MB) and CPU on device,
reduces dependency on JS after exception occured.
This diff cleans up a bunch of code that was used to do symbolication on client side.
Reviewed By: javache
Differential Revision: D3348676
fbshipit-source-id: 88baa5c502836c9ca892896e1ee5d83db37486d3
Summary:
Having a function that symbolicates any given stack trace
is convenient, e.g. in #7459
More cleanup to follow.
Reviewed By: davidaurelio
Differential Revision: D3348616
fbshipit-source-id: 6313ec837869c6080829c811345a06aa1b2dcd21
Summary:
Many RN devtools (inspector, source maps, etc.) rely on packager.
This refactors individual SourceCode.scriptURL parsing into one function
that will be easier to change in the future.
Reviewed By: javache
Differential Revision: D3348465
fbshipit-source-id: 5a55939ea59e1517cb63bcbe4963f57f02ab15f3
Summary: When we're profiling, we want to load Systrace immediately and profile all the startup and initial render code. The code here used to load Systrace during startup only if `__DEV__` but would always start profiling once Systrace was otherwise required. That seems pretty hard to reason about, so I'm switching to always requiring Systrace during the startup path and enabling profiling if appropriate. In actual production that'll always be false, of course.
Reviewed By: javache
Differential Revision: D3338216
fbshipit-source-id: f173e82f34e110d83e7ff04f11af9b302a54b859
Summary:
Reuses the original property descriptor when overwriting / polyfilling globals to ensure enumerability and writability are the same
Closes https://github.com/facebook/react-native/pull/7704
Differential Revision: D3338119
Pulled By: davidaurelio
fbshipit-source-id: ab456324a3346cd3ec8b2c3e3a2378408c92087c
Summary:
See "D3291793 Symbolicate JS stacktrace using RN Packager" for the background
of why this matters. TLDR - saving tons of memory by moving symbolication from
JSC into server and cleaning up old hacks.
Before this change: a redbox causes +73MB JSC size
{F60869250}
{F60869249}
After this change: a redbox causes +1MB JSC size
{F61005061}
{F61005062}
Next step – replace JS implementation by native to show better progress and
clean up even more old APIs (ExceptionsManager.updateExceptionMessage).
Reviewed By: davidaurelio
Differential Revision: D3319151
fbshipit-source-id: 48ff4df27642ea4e1bc2414f48a8dd4d32adee50
Summary:
This make the transform behave closer to the standard for modules.
This removes the few places that a top level this was used to refer to the global space. It also clean up the usage of `GLOBAL` to use `global` instead as this is what is used everywhere else in the code base. We still define `GLOBAL` for compatibility with other modules.
**Test plan**
Clear the packager cache to make sure the transforms run again. (node ./local-cli/cli.js start --reset-cache).
Run the Movies example (UIExplorer is broken atm) and make sure there are no errors.
Closes https://github.com/facebook/react-native/pull/6255
Differential Revision: D3037227
Pulled By: mkonicek
fb-gh-sync-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9
fbshipit-source-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9
Summary:
This avoids requiring things that may never be used at all by the application such as WebSocket or Geolocation. It also stops us from asking for native modules
before we actually start the application enabling us to potentially be more lazy in the future.
Reviewed By: davidaurelio
Differential Revision: D3212802
fb-gh-sync-id: 70cf0d1a85f39fedc47758e5eb5df789a511bc9b
fbshipit-source-id: 70cf0d1a85f39fedc47758e5eb5df789a511bc9b
Summary: Fixes#6227 as discussed in FB group, also a follow up to ide commit 6ec4d65aec
Differential Revision: D3041185
Pulled By: javache
fb-gh-sync-id: 544c55b14d238eb8bfed3ab1588c6e48d164943e
shipit-source-id: 544c55b14d238eb8bfed3ab1588c6e48d164943e
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
Summary:
At the moment we have to disable strict mode for the transform-es2015-modules-commonjs because strict mode leaks to the global scope and breaks the bridge. It was due to the way the polyfills were bundled in the package. To fix it, I wrapped the polyfill modules in an IIFE. Then when strict mode was enabled some polyfills were broken due to strict mode errors so that was fixed too. Also removed the IIFE from the polyfills that included one.
This diff doesn't enable the strict mode transform since some internal facebook modules depend on it not being enabled. When #5214 lands we could make the default babel config shipped with OSS react-native use strict mode modules and facebook could just modify the babel config to disable it if needed.
This will allow removing `"strict": false` from https://github.com/facebook/react-native/blob/master/packager/react-packager/.babelrc#L16Fixes#5316
Closes https://github.com/facebook/react-native/pull/5422
Reviewed By: svcscm
Differential Revision: D2846422
Pulled By: davidaurelio
fb-gh-sync-id: a3e2f8909aa87dabab2b872c61b887e80220fb56
Summary:
public
Map and Set are a standard JavaScript features, but are only supported in a subset of JSC versions that we target (e.g. iOS 7's JSC doesn't support Set).
The consequence of this is that failing to require('Set') before using it won't error during testing on a modern OS, but will fail on older OS versions. This diff makes the Map and Set polyfills available globally to all RN apps to avoid that problem.
Reviewed By: davidaurelio
Differential Revision: D2833997
fb-gh-sync-id: 713d8b69f6a1bce2472a1b2e6b84f69d75f30289
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
Summary:
Inline require `ExceptionsManager` dependencies which are eagerly loaded on app startup (via `setUpConsole()` which is called from `InitializeJavaScriptAppEngine.js`) even though it's necessary until an exception needs to be reported.
This can save about 30-40ms on an iOS device.
public
Reviewed By: nicklockwood, tadeuzagallo, jspahrsummers
Differential Revision: D2755161
fb-gh-sync-id: d4cbfebf04d861b3a70558346a395d3d3ee87cc6
Summary:
public
Rename the `BridgeProfiling` JS module to `Systrace`, since it's actually just
an API to Systrace markers.
This should make it clearer as we add more perf tooling.
Reviewed By: jspahrsummers
Differential Revision: D2734001
fb-gh-sync-id: 642848fa7340c545067f2a7cf5cef8af1c8a69a2
Summary: Fix for [Issue 1331](https://github.com/facebook/react-native/issues/1331). Sets navigator.product to ReactNative and navigator.productSub to the version string in package.json.
Note that the code requires package.json, which works fine in the RN packager, but webpack users will probably a need to configure a json loader in their config file.
Tested using UIExplorer and console.log printout of the product variables in xcode and Chrome debugger.
Closes https://github.com/facebook/react-native/pull/4083
Reviewed By: svcscm
Differential Revision: D2696881
Pulled By: vjeux
fb-gh-sync-id: 511446432dcd0ec658100715129c77153e743423
Summary: public
Dynamically profile events from RelayProfiler if available. This will expose time spent in Relay in the systraces.
Reviewed By: tadeuzagallo
Differential Revision: D2674215
fb-gh-sync-id: d5f9d529b86d267a80b0cda2223f6a28a08ac385
Summary: public
Make sure some modules that are only available in dev mode are only
included in dev bundles.
Depends on: D2663838
Reviewed By: davidaurelio
Differential Revision: D2663889
fb-gh-sync-id: 42be40b865ef305828b3519556125af090ec61f4
Summary: public
Call the native bindings explicitly from BridgeProfiling instead of polyfill'ing `console.profile` with
a function that has a different signature.
Reviewed By: vjeux
Differential Revision: D2602313
fb-gh-sync-id: 9295eff9458f2caa35b7e982c0f7c06dbe65fd09
Summary: Set up the polyfills for console and process before initializing other modules. Some modules do work (e.g. call `invariant`) when they are first required, so requiring the DefaultInjection module at the beginning ensures we have a consistent JS environment.
Closes https://github.com/facebook/react-native/pull/3526
Reviewed By: spicyj
Differential Revision: D2560340
Pulled By: frantic
fb-gh-sync-id: 44c743e3212ff1dcdbe0169041dfd3ea8f1a54f7
Summary: Partially fixes#3316 by addressing 16 linter warnings:
- Strings should be singlequote
- Missing semicolon
Travis build jobs 1.1 through 1.4 complete successfully. 1.5 fails through what appears to be an unrelated issue on master.
Closes https://github.com/facebook/react-native/pull/3332
Reviewed By: @svcscm
Differential Revision: D2531718
Pulled By: @javache
fb-gh-sync-id: ca22fbeac5fe3b4f725775a72f21b6dd7a75d94b
Summary: @public
jest is running the polyfill multiple times on the same environment (cc @cpojer, need to fix that!). By default jest doesn't have XMLHttpRequest polyfilled so it'll define a property with writable to be false. It'll fatal the second time it tries to override XMLHttpRequest.
The hacky workaround is to make properties that do not exist with writable: true. But the long term fix would be to make jest stop running the polyfill multiple times.
Reviewed By: @javache
Differential Revision: D2532019
fb-gh-sync-id: a82abf69541781a64a0744798c736f90833e28cb