mirror of https://github.com/status-im/metro.git
packager: Module: remove dead cacheTransformResults option
Reviewed By: davidaurelio Differential Revision: D4884343 fbshipit-source-id: ae29757690d9b56d6f166bc86573aca9b1b6b65c
This commit is contained in:
parent
edcaf438a7
commit
781b3b9bb7
|
@ -69,7 +69,6 @@ class Resolver {
|
|||
(opts.blacklistRE != null && opts.blacklistRE.test(filepath));
|
||||
},
|
||||
moduleOptions: {
|
||||
cacheTransformResults: true,
|
||||
hasteImpl: opts.hasteImpl,
|
||||
resetCache: opts.resetCache,
|
||||
},
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue