Tweaks to experimental caches

Reviewed By: jeanlauliac

Differential Revision: D7123128

fbshipit-source-id: 2f838d66c51ef5faef261a6ad474cefd9ac7e8ad
This commit is contained in:
Miguel Jimenez Esun 2018-03-05 03:59:14 -08:00 committed by Facebook Github Bot
parent 3bd7ef1d74
commit b7e3e046cd
2 changed files with 3 additions and 3 deletions

View File

@ -13,7 +13,6 @@
const fs = require('fs'); const fs = require('fs');
const mkdirp = require('mkdirp'); const mkdirp = require('mkdirp');
const path = require('path'); const path = require('path');
const serializer = require('jest-serializer');
import type {TransformedCode} from 'metro/src/JSTransformer/worker'; import type {TransformedCode} from 'metro/src/JSTransformer/worker';
@ -36,7 +35,7 @@ class FileStore {
get(key: Buffer): ?TransformedCode { get(key: Buffer): ?TransformedCode {
try { try {
return serializer.readFileSync(this._getFilePath(key)); return JSON.parse(fs.readFileSync(this._getFilePath(key), 'utf-8'));
} catch (err) { } catch (err) {
if (err.code === 'ENOENT') { if (err.code === 'ENOENT') {
return null; return null;
@ -47,7 +46,7 @@ class FileStore {
} }
set(key: Buffer, value: TransformedCode): void { set(key: Buffer, value: TransformedCode): void {
fs.writeFileSync(this._getFilePath(key), serializer.serialize(value)); fs.writeFileSync(this._getFilePath(key), JSON.stringify(value));
} }
_getFilePath(key: Buffer): string { _getFilePath(key: Buffer): string {

View File

@ -161,6 +161,7 @@ class ModuleCache {
/* $FlowFixMe: there are missing arguments. */ /* $FlowFixMe: there are missing arguments. */
return new Polyfill({ return new Polyfill({
depGraphHelpers: this._depGraphHelpers, depGraphHelpers: this._depGraphHelpers,
experimentalCaches: this._experimentalCaches,
file, file,
getTransformCacheKey: this._getTransformCacheKey, getTransformCacheKey: this._getTransformCacheKey,
localPath: toLocalPath(this._roots, file), localPath: toLocalPath(this._roots, file),