packager: Module: remove dead cacheTransformResults option
Reviewed By: davidaurelio Differential Revision: D4884343 fbshipit-source-id: ae29757690d9b56d6f166bc86573aca9b1b6b65c
This commit is contained in:
parent
a6828f2127
commit
1c53c9b20f
|
@ -69,7 +69,6 @@ class Resolver {
|
||||||
(opts.blacklistRE != null && opts.blacklistRE.test(filepath));
|
(opts.blacklistRE != null && opts.blacklistRE.test(filepath));
|
||||||
},
|
},
|
||||||
moduleOptions: {
|
moduleOptions: {
|
||||||
cacheTransformResults: true,
|
|
||||||
hasteImpl: opts.hasteImpl,
|
hasteImpl: opts.hasteImpl,
|
||||||
resetCache: opts.resetCache,
|
resetCache: opts.resetCache,
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,7 +61,6 @@ export type HasteImpl = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Options = {
|
export type Options = {
|
||||||
cacheTransformResults?: boolean,
|
|
||||||
hasteImpl?: HasteImpl,
|
hasteImpl?: HasteImpl,
|
||||||
resetCache?: boolean,
|
resetCache?: boolean,
|
||||||
};
|
};
|
||||||
|
@ -246,17 +245,8 @@ class Module {
|
||||||
/**
|
/**
|
||||||
* To what we read from the cache or worker, we need to add id and source.
|
* To what we read from the cache or worker, we need to add id and source.
|
||||||
*/
|
*/
|
||||||
_finalizeReadResult(
|
_finalizeReadResult(source: string, result: TransformedCode): ReadResult {
|
||||||
source: string,
|
return {...result, id: this._getHasteName(), source};
|
||||||
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};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_transformCodeForCallback(
|
_transformCodeForCallback(
|
||||||
|
|
|
@ -76,7 +76,7 @@ describe('DependencyGraph', function() {
|
||||||
useWatchman: false,
|
useWatchman: false,
|
||||||
ignoreFilePath: () => false,
|
ignoreFilePath: () => false,
|
||||||
maxWorkerCount: 1,
|
maxWorkerCount: 1,
|
||||||
moduleOptions: {cacheTransformResults: true},
|
moduleOptions: {},
|
||||||
resetCache: true,
|
resetCache: true,
|
||||||
transformCode: (module, sourceCode, transformOptions) => {
|
transformCode: (module, sourceCode, transformOptions) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
|
|
@ -60,9 +60,7 @@ describe('Module', () => {
|
||||||
let transformCacheKey;
|
let transformCacheKey;
|
||||||
const createModule = options =>
|
const createModule = options =>
|
||||||
new Module({
|
new Module({
|
||||||
options: {
|
options: {},
|
||||||
cacheTransformResults: true,
|
|
||||||
},
|
|
||||||
transformCode: (module, sourceCode, transformOptions) => {
|
transformCode: (module, sourceCode, transformOptions) => {
|
||||||
return Promise.resolve({code: sourceCode});
|
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', () => {
|
it('stores all things if options is undefined', () => {
|
||||||
transformResult = {
|
transformResult = {
|
||||||
code: exampleCode,
|
code: exampleCode,
|
||||||
|
|
Loading…
Reference in New Issue