From 781b3b9bb72a21be4d0ff8d7bd3539366551fb1a Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Tue, 18 Apr 2017 09:26:58 -0700 Subject: [PATCH] packager: Module: remove dead cacheTransformResults option Reviewed By: davidaurelio Differential Revision: D4884343 fbshipit-source-id: ae29757690d9b56d6f166bc86573aca9b1b6b65c --- packages/metro-bundler/src/Resolver/index.js | 1 - .../metro-bundler/src/node-haste/Module.js | 14 ++--------- .../__tests__/DependencyGraph-test.js | 2 +- .../src/node-haste/__tests__/Module-test.js | 24 +------------------ 4 files changed, 4 insertions(+), 37 deletions(-) diff --git a/packages/metro-bundler/src/Resolver/index.js b/packages/metro-bundler/src/Resolver/index.js index fac3b892..8b10acba 100644 --- a/packages/metro-bundler/src/Resolver/index.js +++ b/packages/metro-bundler/src/Resolver/index.js @@ -69,7 +69,6 @@ class Resolver { (opts.blacklistRE != null && opts.blacklistRE.test(filepath)); }, moduleOptions: { - cacheTransformResults: true, hasteImpl: opts.hasteImpl, resetCache: opts.resetCache, }, diff --git a/packages/metro-bundler/src/node-haste/Module.js b/packages/metro-bundler/src/node-haste/Module.js index 4b13979d..2a5a7957 100644 --- a/packages/metro-bundler/src/node-haste/Module.js +++ b/packages/metro-bundler/src/node-haste/Module.js @@ -61,7 +61,6 @@ export type HasteImpl = { }; export type Options = { - cacheTransformResults?: boolean, hasteImpl?: HasteImpl, resetCache?: boolean, }; @@ -246,17 +245,8 @@ class Module { /** * To what we read from the cache or worker, we need to add id and source. */ - _finalizeReadResult( - source: string, - result: TransformedCode, - ): ReadResult { - const id = this._getHasteName(); - if (this._options.cacheTransformResults === false) { - const {dependencies} = result; - /* $FlowFixMe: this code path is dead, remove. */ - return {dependencies}; - } - return {...result, id, source}; + _finalizeReadResult(source: string, result: TransformedCode): ReadResult { + return {...result, id: this._getHasteName(), source}; } _transformCodeForCallback( diff --git a/packages/metro-bundler/src/node-haste/__tests__/DependencyGraph-test.js b/packages/metro-bundler/src/node-haste/__tests__/DependencyGraph-test.js index 569c23f9..23629ee0 100644 --- a/packages/metro-bundler/src/node-haste/__tests__/DependencyGraph-test.js +++ b/packages/metro-bundler/src/node-haste/__tests__/DependencyGraph-test.js @@ -76,7 +76,7 @@ describe('DependencyGraph', function() { useWatchman: false, ignoreFilePath: () => false, maxWorkerCount: 1, - moduleOptions: {cacheTransformResults: true}, + moduleOptions: {}, resetCache: true, transformCode: (module, sourceCode, transformOptions) => { return new Promise(resolve => { diff --git a/packages/metro-bundler/src/node-haste/__tests__/Module-test.js b/packages/metro-bundler/src/node-haste/__tests__/Module-test.js index 78b475d5..e4aca77e 100644 --- a/packages/metro-bundler/src/node-haste/__tests__/Module-test.js +++ b/packages/metro-bundler/src/node-haste/__tests__/Module-test.js @@ -60,9 +60,7 @@ describe('Module', () => { let transformCacheKey; const createModule = options => new Module({ - options: { - cacheTransformResults: true, - }, + options: {}, transformCode: (module, sourceCode, transformOptions) => { return Promise.resolve({code: sourceCode}); }, @@ -258,26 +256,6 @@ describe('Module', () => { }); }); - it('only stores dependencies if `cacheTransformResults` option is disabled', () => { - transformResult = { - code: exampleCode, - arbitrary: 'arbitrary', - dependencies: ['foo', 'bar'], - dependencyOffsets: [12, 764], - map: {version: 3}, - subObject: {foo: 'bar'}, - }; - const module = createModule({transformCode, options: { - cacheTransformResults: false, - }}); - - return module.read().then(result => { - expect(result).toEqual({ - dependencies: ['foo', 'bar'], - }); - }); - }); - it('stores all things if options is undefined', () => { transformResult = { code: exampleCode,