Summary: Since we started relying on NativeModules' getConstants() method to access constants, we need to update our jest mocks of these NativeModules, so that the tests still pass. I do that in this diff.
Reviewed By: fkgozali
Differential Revision: D13561376
fbshipit-source-id: eaef3de82d842fd97d04be741d55bdded73c6a11
Summary:
This diff removes the dependency of `metro` on `react-native` by using the newly created `metro-react-native-babel-transformer` package.
This package does not depend on any other internal metro logic and this will decouple RN from metro a bit more.
Reviewed By: cpojer
Differential Revision: D13434949
fbshipit-source-id: a02a3b327c71cef53111514b797f7d6bc9f9d71c
Summary: This removes the remaining references to `local-cli`. We already have a `cli.js` file on the root that was just forwarding to the local-cli folder, so I removed that. It also seems that `setupBabel.js` is no longer necessary in RN.
Reviewed By: TheSavior
Differential Revision: D13396218
fbshipit-source-id: a945cb91dae39c4b58c5cabcca6b0f0328fc4717
Summary:
This diff ignores the `react-native-local-cli` from being used internally.
Unfortunately, since `react-native-local-cli` has its own dependency on Metro, and using `yarn` selective resolutions causes some issues with `flow` rechecks that have not been resolved (https://fb.facebook.com/groups/flow/permalink/2220467474668522/), the easiest way to move forward is to just not install the `react-native-local-cli` package internally (we don't need it since we have our own cli).
Reviewed By: pvdz
Differential Revision: D13377495
fbshipit-source-id: 6d6edbd947104e050ad1c31a657fc21fe6848692
Summary: This module now lives outside of the React Native repo.
Reviewed By: TheSavior
Differential Revision: D13337412
fbshipit-source-id: 548868e5f1f3812574fda3d235eb9d47c81d6522
Summary:
Back it out again. This time really not sure why this is breaking, but it seems to be production only. The error seems to be "RCTSinglelineTextInputView" was not found in the UIManager" but the relavent logic is not changed in this diff, just moved around, so unclear why it would trigger a failure.
Reverting to be safe. When we re-apply the diff, we'll need to test a full OTA to prod to verify the fix.
Reviewed By: blairvanderhoof
Differential Revision: D13108463
fbshipit-source-id: 5f877a0c1a08dc114ce45921d6d92bf619575977
Summary: D10515754 reapplied by backing out D12989604 and then fixed by manually forwarding the instance methods to the host function instead of using `forwardRef`. This also removes the need for the $flowFixMe.
Reviewed By: TheSavior
Differential Revision: D13048482
fbshipit-source-id: ff2447aff123e0960eddaef645f7dc976a426e14
Summary:
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->
**Summary**
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
This is an updated followup from https://github.com/facebook/metro/pull/280, which we would still need to address the following assumptions about `/assets/`:
e7deea1900/packages/metro/src/Server.js (L332)e7deea1900/packages/metro/src/Server.js (L379)e7deea1900/packages/metro/src/Server.js (L385)
As pointed out by gdborton, there isn't currently a way to make this a configurable option. I am not certain how to find a proper workaround for `processRequest`.
We found a temporary solution to have our express app pick up serving the assets from a publicPath as a middleware. But the change in this PR is still necessary to get it working fully.
**Test plan**
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
- Will add tests once we figure out a comprehensive solution
Pull Request resolved: https://github.com/facebook/metro/pull/299
Reviewed By: rafeca
Differential Revision: D12939229
Pulled By: mjesun
fbshipit-source-id: 769c23468c5ac434f8319e5e7caaf46dd6453f2d
Summary:
This was failing due to issues with refs, which we were able to fix and then finally due to some jest tests that were failing due to things being null that shouldn't be which I couldn't easily figure out. Reverting the stack until we can actually solve it, hopefully with additional tests.
This was created by running:
```
$ hg backout c2fe2c46e538
fetching tree '' b9bbfc1925c6daf85ba3227d12f177aca9c0c054, based on 4257c76aefa84aaa17279e65aa7ca1174f4401e7, found via 02368b670953
connected to hg015.frc2.facebook.com
60 trees fetched over 2.91s
fetching tree '' c3c304df13399f0f1a29a668242da454fc1d8a97, based on b9bbfc1925c6daf85ba3227d12f177aca9c0c054, found via c2fe2c46e538
7 trees fetched over 0.03s
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
commit 4270328:50a65c5c2e27 backs out commit 4266783:c2fe2c46e538
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over 0.57s
[twsvcscm@sandcastle3265.ftw1 /data/sandcastle/boxes/instance-ide/xplat/js (50a65c5)]$ hg backout 02368b670953
fetching tree '' a46c8ca065f5b92cf375d7ed899fc5ca268ba4da, based on b9bbfc1925c6daf85ba3227d12f177aca9c0c054, found via bade4285eafb
connected to hg024.frc2.facebook.com
27 trees fetched over 3.21s
fetching tree '' 361548a090e81d18bab6f4fc16036c518cb4d7c1, based on a46c8ca065f5b92cf375d7ed899fc5ca268ba4da, found via bade4285eafb
41 trees fetched over 0.10s
merging react-native-github/Libraries/Components/TextInput/TextInput.js
8 files updated, 1 files merged, 0 files removed, 0 files unresolved
commit 4270329:dbaca0daf0ac backs out commit 4266782:02368b670953
14 files fetched over 7 fetches - (14 misses, 0.00% hit ratio) over 1.72s
[twsvcscm@sandcastle3265.ftw1 /data/sandcastle/boxes/instance-ide/xplat/js (dbaca0d)]$ hg backout bade4285eafb
connected to hg030.frc2.facebook.com
fetching tree '' 1b4a17164fdbfcad40139e46da4a9bfa8aa8def3, based on 361548a090e81d18bab6f4fc16036c518cb4d7c1, found via 5cfb25344385
7 trees fetched over 0.06s
merging react-native-github/Libraries/Components/TextInput/TextInput.js
20 files updated, 1 files merged, 0 files removed, 0 files unresolved
commit 4270330:2951740e5b32 backs out commit 4266781:bade4285eafb
33 files fetched over 14 fetches - (33 misses, 0.00% hit ratio) over 4.50s
[twsvcscm@sandcastle3265.ftw1 /data/sandcastle/boxes/instance-ide/xplat/js (2951740)]$ hg backout 5cfb25344385
connected to hg035.frc2.facebook.com
merging react-native-github/Libraries/Components/TextInput/TextInput.js
0 files updated, 1 files merged, 2 files removed, 0 files unresolved
commit 4270331:fffb4629a397 backs out commit 4266780:5cfb25344385
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over 4.03s
```
Reviewed By: yungsters
Differential Revision: D12989604
fbshipit-source-id: 703a7c9c1f5bdd710077e515bdff06fdb34502ec
Summary:
A while back Jest introduced `jest.requireActual` and `jest.requireMock` which are aliases to `require.requireActual` and `require.requireMock`. We believe that users should use official Jest API and are planning to deprecate the latter.
Pull Request resolved: https://github.com/facebook/react-native/pull/21849
Differential Revision: D10448849
Pulled By: TheSavior
fbshipit-source-id: 34fffde97f48c26098c74ee222a56d99071703a6
Summary:
Up until now the `enableBabelRuntime` option in the `metro-react-native-preset` package was hardcoded in the transformer: our internal transformer set it to `false` and the opensource one was `true`.
This diff now exposes this param out to the config of Metro (now that it's quite easy to expose things) so anybody can set it to false or true.
This allows our end to end tests to set it to false to not have to deal with requires to `babel/runtime`.
Reviewed By: davidaurelio
Differential Revision: D10123776
fbshipit-source-id: 97e744eeb567c8e86ab3c613ac71970d226ed2ca
Summary: Replaced each view manager access with a getViewManager() function call. This will later be used to lazily load view manager classes by allowing java to avoid sending the entire list of view managers to JS.
Reviewed By: QueryConnectionException
Differential Revision: D9695788
fbshipit-source-id: 949858aa2f0b0b00b68e260461ba8f1d085cf07f
Summary:
This PR is a WIP for adding tests for out-of-tree platform support. [I originally had issues](https://github.com/facebook/react-native/pull/20825#issuecomment-416433611) with this, so I want to give it a try in a separate pull request. None of these issues appear on my machine while running these tests as of this rebase - if everything seems okay on CircleCI after this rebase against `master`, I will ditch the [WIP] tag. Otherwise, I will see if I can find a way to make this work.
The bunch of JS files that will give this a "Large PR" tag are in `RNTester/js/OutOfTreeTestPlatform` - they are only used by the bundler and not executed at any point in time. So if another file needs to be added when React Native's module structure changes, you do not need to have a functional JS file in there as a stub. `module.exports` could be `null` if you wanted. I just had copied over stubs from `Libraries` because I wanted a non-trivial haste module map to be in the test.
Pull Request resolved: https://github.com/facebook/react-native/pull/20932
Reviewed By: axe-fb
Differential Revision: D9818112
Pulled By: hramos
fbshipit-source-id: 0b53359b84430fdefb972587c95d19f85773c5fa
Summary:
Follow up to 8932a9caa8
Babel helpers and regenerator runtime will be imported automatically from `babel/runtime`. We still need to add the global regeneratorRuntime for jest tests since we disable babel-runtime currently.
Pull Request resolved: https://github.com/facebook/react-native/pull/21283
Reviewed By: mjesun
Differential Revision: D10010963
Pulled By: rafeca
fbshipit-source-id: da5e23dd901f8f8940d46816b4fc9290d0e28c76
Summary:
Since the options that are passed to the `babelTransformer` are not exactly the same ones as the `transformer` receives, we need to have a specific object for them.
This allows us to make the transformer options object strict (since unfortunately the `babeltransformer` options object comes from many places and needs a bit of work to be able to be strict...
Reviewed By: mjesun
Differential Revision: D9309173
fbshipit-source-id: 0a92381968f17e5eb6c4740c1ca89580fa7ee4d3
Summary:
Up until now, transformers in Metro received the absolute path of a file, the relative path of a file and the projectRoot.
This diff gets rid of the absolute path sent to the worker, since by having the projectRoot and the relative path, the absolute path can be easily calculated.
This has been done to avoid having absolute paths as transform options, since we need to have custom logic to filter them out from the cache key generation, which is dangerous.
Reviewed By: mjesun
Differential Revision: D9195147
fbshipit-source-id: e95c5c29272eec7f1a48af7cede4c6d6b4a8ffb7
Summary:
**Summary**
The RN transformer currently relies on the enviroment providing babelHelpers and regeneratorRuntime as globals by using 'babel-external-helpers'. This wasn't really a problem before since helpers were stable and we could maintain our copy easily but it seems like there are more now with babel 7 and it makes sense to include only those used by the app.
This is exactly what babel/transform-runtime does. It will alias all helpers and calls to regeneratorRuntime to files in the babel/runtime package.
This will solve issues like this https://github.com/facebook/react-native/issues/20150 caused by missing babelHelpers. This solution also avoids bloating babelHelpers to fix OSS issues like the one linked before.
**Test plan**
- Updated tests so they all pass.
- Tested that it actually works by applying the changes locally in an RN app.
- Added a test for async functions, to make sure regenerator is aliased properly and doesn't depend on the global.
- Made sure require-test.js still fails if the require implementation contains babel helpers (by adding an empty class in the file).
Pull Request resolved: https://github.com/facebook/metro/pull/198
Reviewed By: mjesun
Differential Revision: D8833903
Pulled By: rafeca
fbshipit-source-id: 7081f769f288ab358ba89ae8ee72a513bb12e225
Summary: This change drops the year from the copyright headers and the LICENSE file.
Reviewed By: yungsters
Differential Revision: D9727774
fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
Summary:
This pull request adds the ability for a platform developer to provide a `"haste"` key under the `"rnpm"` key in their `package.json` which allows the packager to pick up that platform's javascript files. The intent is to remove the need to have custom platforms hardcoded in. This is inspired by the `"jest": { "haste": {} }` key used by jest.
For example, React Native Dom would have an entry like:
```json
{
"rnpm": {
"haste": {
"providesModuleNodeModules": [
"react-native-dom"
],
"platforms": [
"dom"
]
}
}
}
```
Support for more keys (path blacklists perhaps?) could be added in the future.
This succeeds #20662, as per a discussion I had with matthargett.
I've got an open discussion over here as well: https://github.com/react-native-community/discussions-and-proposals/issues/21
Pull Request resolved: https://github.com/facebook/react-native/pull/20825
Differential Revision: D9596429
Pulled By: hramos
fbshipit-source-id: a02f0da0bea8870bdc45d55e23da8ccbc36249f2
Summary: Apparently different apps have different implementations of view managers that support different props. This is a problem that we will need to address. Unfortunately, this means we can't have a static config defined in JS. We will need to find another approach to this problem.
Reviewed By: sahrens
Differential Revision: D9500178
fbshipit-source-id: b591559164fcf29f5fd43e13a0f2da15011491c6
Summary:
This is the first step to make transformers fully customizable (and not be tied to JS, or RN). In order to do that, I'm changing the signature of the transformers, which currently is:
```
function transformCode(
filename: string,
localPath: LocalPath,
transformerPath: string,
options: WorkerOptions,
assetExts: $ReadOnlyArray<string>,
assetRegistryPath: string,
minifierPath: string,
asyncRequireModulePath: string,
dynamicDepsInPackages: DynamicRequiresBehavior,
)
```
to be:
```
async function transformCode(
filename: string,
localPath: LocalPath,
options: WorkerOptions,
)
```
(so basically, all the RN-custom properties are moved to `WorkerOptions`, which in the future will be a generic to allow anybody pass any random option to their transformers).
In order to make all this work, I've had to get rid of the logic that calculates the base cache key hash based on a subset of worker options (the ones that Metro knows that are not going to change between runs).
This could potentially cause a perf regression (since we're now making the hash calculation a bit more costly), and in fact I could measure a ~400ms regression on the worse case scenario (which happens when restarting Metro and re-transforming a Wilde from a warm local cache).
I've benchmarked this regression and could find that it's caused by the array of `assetExtensions` (which is potentially large). I have a followup diff to improve this, which is able to remove the regression completely.
Reviewed By: pvdz
Differential Revision: D8695766
fbshipit-source-id: eccd18a4cbc91854f34d5c9ba7f95088f19483a1
Summary: As we move these configs to JS from native, until we have codegen that ensures everything stays up to date, this adds a dev mode check to ensure they are consistent.
Reviewed By: yungsters
Differential Revision: D9475011
fbshipit-source-id: 9d6f7b6c649229cae569d840eda3d5f7b7aa7cb2
Summary: Adds missing comma, following up on https://github.com/facebook/react-native/pull/20178. Thanks to LinusU for pointing out the error.
Reviewed By: TheSavior
Differential Revision: D9242887
fbshipit-source-id: 4b547396722d0e37dc5c8eb3439b9a441c3c0ac2
Summary: Doesn't look like this is used anymore.
Reviewed By: schwink
Differential Revision: D9032481
fbshipit-source-id: c35b7db07c068b6238bacc25183a468c9d62661d
Summary:
This adds `react-native-dom` to `hasteImpl.js` because it's not currently possible to configure it from an out of tree platform. Also adds the relevant `providesModuleNodeModules` and `platforms` values to the default RN CLI config. This should hopefully be able to be removed once better support for out of tree platforms is implemented.
Pull Request resolved: https://github.com/facebook/react-native/pull/20393
Differential Revision: D9007186
Pulled By: hramos
fbshipit-source-id: 67077860dc1fb191d80300fb980599ed76d5f91c
Summary:
Closes https://github.com/facebook/react-native/pull/20007
We removed support for providesModule annotations and maintained support for Haste names in installed modules via `providesModuleNodeModules`, but our default `hasteImpl` doesn't take them into account. We need to find a better way to override core components from plugins but meanwhile this adds an exception for react-native-windows in the default `hasteImpl` to unblock their upgrade to the latest RC.
Fixes https://github.com/facebook/metro/issues/188
Reviewed By: mjesun
Differential Revision: D8695207
fbshipit-source-id: 2ad6cb1e93e600880a148776ac45f6ebd7d205d3
Summary: When snapshotting, do not get affected by the building process.
Reviewed By: rafeca
Differential Revision: D8638527
fbshipit-source-id: 8335fc55c0c85f2ff110db338a5000c7af4b29aa
Summary: This is necessary to provide things like `Image.prefetch` in Jest tests. Previously this only gave access to propTypes.
Reviewed By: sahrens
Differential Revision: D8526494
fbshipit-source-id: 11d49d95d6edf3f75c90438e0b629f5345bc980d
Summary:
Fixes#19370
Applied changes to existing project that uses jest snapshot testing. Testing was broken before and now works.
To verify: Run any snapshot test containing an image reference on Windows before and after this PR.
[WINDOWS][BUGFIX][jest] - Fixed jest snapshot testing on windows
Closes https://github.com/facebook/react-native/pull/19496
Differential Revision: D8195947
Pulled By: hramos
fbshipit-source-id: 909b5fe7cfd8c6286baf161a227a359854a37603
Summary:
Upgrade Babel from beta.40 to beta.47
There are two important breaking changes here.
- If you want an AST from the Babel `transform` functions you must pass on `ast:true` in the options.
- The `sourceType` is now the only source of truth on whether to parse with the Script or Module goal. It defaults to `script` and can also be `module` or `unambiguous`. In the `unambiguous` case it will first try to parse with the Module goal and only if it crashes it will try again with the Script goal.
Beyond that there were some fixes and some smaller changes that may affect you. See the Babel changelogs for details (https://github.com/babel/babel/tags).
Also updated the way we generate the babel helpers file.
Reviewed By: rubennorte
Differential Revision: D8075280
fbshipit-source-id: 2bb902690e8a4b19d9cada2b7b0c94812b3d4f0f
Summary:
fix issue https://github.com/facebook/react-native/issues/11701.
Pass current ci
<!--
Does this PR require a documentation change?
Create a PR at https://github.com/facebook/react-native-website and add a link to it here.
-->
<!--
Required.
Help reviewers and the release process by writing your own release notes. See below for an example.
-->
[GENERAL] [BUGFIX] [JEST] - add missing jest mock in StatusBarManager
<!--
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAL ] [ BUGFIX ] [ {Component} ]
[ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/19017
Differential Revision: D8014888
Pulled By: hramos
fbshipit-source-id: 1be29f9643cf0faa53ad64f79e11d48b654a97b3
Summary:
This PR removes the need for having the `providesModule` tags in all the modules in the repository.
It configures Flow, Jest and Metro to get the module names from the filenames (`Libraries/Animated/src/nodes/AnimatedInterpolation.js` => `AnimatedInterpolation`)
* Checked the Flow configuration by running flow on the project root (no errors):
```
yarn flow
```
* Checked the Jest configuration by running the tests with a clean cache:
```
yarn jest --clearCache && yarn test
```
* Checked the Metro configuration by starting the server with a clean cache and requesting some bundles:
```
yarn run start --reset-cache
curl 'localhost:8081/IntegrationTests/AccessibilityManagerTest.bundle?platform=android'
curl 'localhost:8081/Libraries/Alert/Alert.bundle?platform=ios'
```
[INTERNAL] [FEATURE] [All] - Removed providesModule from all modules and configured tools.
Closes https://github.com/facebook/react-native/pull/18995
Reviewed By: mjesun
Differential Revision: D7729509
Pulled By: rubennorte
fbshipit-source-id: 892f760a05ce1fddb088ff0cd2e97e521fb8e825
Summary: Moves the implementation of Buck’s worker protocol into its own package and babelRegisterOnly for better reusability.
Reviewed By: rafeca
Differential Revision: D7666896
fbshipit-source-id: ae297494ced3b8dd1f9d90983a640643d6ce7896
Summary:
The `sourceType` option is a new mandatory option for Babel which determines whether to parse the file with the module or script goal. The value "disambiguous" determines this state by parsing.
See https://github.com/babel/babel/pull/7417
Reviewed By: mjesun
Differential Revision: D7685610
fbshipit-source-id: 3958c5ad396592bb1d790e2df4ce315737421a2f