mirror of
https://github.com/status-im/metro.git
synced 2025-02-06 00:03:30 +00:00
Tweaks to experimental caches
Reviewed By: jeanlauliac Differential Revision: D7123128 fbshipit-source-id: 2f838d66c51ef5faef261a6ad474cefd9ac7e8ad
This commit is contained in:
parent
3bd7ef1d74
commit
b7e3e046cd
@ -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 {
|
||||||
|
@ -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),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user