react-native/jest
Rafael Oleza dd0900a03a Standarize options passed to the transformer
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
2018-08-23 15:48:03 -07:00
..
__tests__ Fix hasteImpl path checks on Windows machines 2018-07-17 16:33:56 -07:00
MockNativeMethods.js RN: Refactor `MockNativeMethods` in Jest 2018-05-09 01:16:11 -07:00
assetFileTransformer.js Fix jest snapshot testing on windows 2018-05-31 12:58:05 -07:00
hasteImpl.js Whitelist react-native-dom in haste/cli config defaults (#20393) 2018-07-25 17:47:42 -07:00
mockComponent.js Enforce component name 2018-06-26 07:47:11 -07:00
preprocessor.js Standarize options passed to the transformer 2018-08-23 15:48:03 -07:00
setup.js Require that JS defined Component Attributes match Native ones in dev 2018-08-23 13:01:41 -07:00