From e38b92865050314fb77ef5f4f79cdea3e0bbbf11 Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Thu, 23 Aug 2018 15:44:38 -0700 Subject: [PATCH] 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, 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 --- jest/preprocessor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest/preprocessor.js b/jest/preprocessor.js index 17838def4c2..c08d4a3cde7 100644 --- a/jest/preprocessor.js +++ b/jest/preprocessor.js @@ -54,6 +54,7 @@ module.exports = { ast: true, // needed for open source (?) https://github.com/facebook/react-native/commit/f8d6b97140cffe8d18b2558f94570c8d1b410d5c#r28647044 dev: true, inlineRequires: true, + minify: false, platform: '', projectRoot: '', retainLines: true,