Skip to content

Commit 60b1b7a

Browse files
robhoganfacebook-github-bot
authored andcommitted
Replace metro-memory-fs dependency in tests with OSS memfs (#52572)
Summary: Pull Request resolved: #52572 We'd like to stop supporting `metro-memory-fs` - there are better alternatives out there. This replaces the one usage of `metro-memory-fs` in `react-native` with `memfs`, and swaps the dependency. Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D78161921 fbshipit-source-id: 139233adac413a4f47a0d56d9e08ec841abaf47c
1 parent 42ea4bc commit 60b1b7a

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
"jest-snapshot": "^29.7.0",
9494
"markdownlint-cli2": "^0.17.2",
9595
"markdownlint-rule-relative-links": "^3.0.0",
96+
"memfs": "^4.7.7",
9697
"metro-babel-register": "^0.82.5",
97-
"metro-memory-fs": "^0.82.5",
9898
"metro-transform-plugins": "^0.82.5",
9999
"micromatch": "^4.0.4",
100100
"node-fetch": "^2.2.0",

packages/react-native/scripts/hermes/__tests__/hermes-utils-test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @format
99
*/
1010

11+
import typeof FS from 'fs';
12+
1113
import * as path from 'path';
1214

1315
const {
@@ -25,9 +27,12 @@ const {
2527
setHermesTag,
2628
shouldUsePrebuiltHermesC,
2729
} = require('../hermes-utils');
28-
const MemoryFs = require('metro-memory-fs');
2930
const os = require('os');
3031

32+
// $FlowFixMe[untyped-import] (OSS) memfs
33+
// $FlowFixMe[cannot-resolve-module] (Meta) memfs
34+
const {memfs} = require('memfs') as {memfs: () => {fs: FS}};
35+
3136
const hermesTag =
3237
'hermes-2022-04-28-RNv0.69.0-15d07c2edd29a4ea0b8f15ab0588a0c1adb1200f';
3338
const tarballContents = 'dummy string';
@@ -147,16 +152,8 @@ describe('hermes-utils', () => {
147152
beforeEach(() => {
148153
jest.resetModules();
149154

150-
jest.mock(
151-
'fs',
152-
() =>
153-
new MemoryFs({
154-
platform: process.platform === 'win32' ? 'win32' : 'posix',
155-
}),
156-
);
155+
jest.mock('fs', () => memfs().fs);
157156
fs = require('fs');
158-
// $FlowFixMe[prop-missing]
159-
fs.reset();
160157

161158
populateMockFilesystemWithHermesBuildScripts();
162159

yarn.lock

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6823,6 +6823,13 @@ memfs-or-file-map-to-github-branch@^1.3.0:
68236823
dependencies:
68246824
"@octokit/rest" "*"
68256825

6826+
memfs@^4.7.7:
6827+
version "4.7.7"
6828+
resolved "https://registry.yarnpkg.com/memfs/-/memfs-4.7.7.tgz#bcf09cab1646d655f659e7cf832dfc75ccb95b2d"
6829+
integrity sha512-x9qc6k88J/VVwnfTkJV8pRRswJ2156Rc4w5rciRqKceFDZ0y1MqsNL9pkg5sE0GOcDzZYbonreALhaHzg1siFw==
6830+
dependencies:
6831+
tslib "^2.0.0"
6832+
68266833
memoize-one@^5.0.0:
68276834
version "5.2.1"
68286835
resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.2.1.tgz#8337aa3c4335581839ec01c3d594090cebe8f00e"
@@ -6920,13 +6927,6 @@ [email protected]:
69206927
nullthrows "^1.1.1"
69216928
walker "^1.0.7"
69226929

6923-
metro-memory-fs@^0.82.5:
6924-
version "0.82.5"
6925-
resolved "https://registry.yarnpkg.com/metro-memory-fs/-/metro-memory-fs-0.82.5.tgz#ae6c4c251cd6dc9cf44540c3b1356cff54db875e"
6926-
integrity sha512-yMYtBwDtG84vnDfQDEGZ3EUYbHng4dMZX2AKSQFQOMdd34lyQcD1yV5yrrUTG/DqMKDxJGqmxDkeyqTlKwwuUA==
6927-
dependencies:
6928-
flow-enums-runtime "^0.0.6"
6929-
69306930
69316931
version "0.82.5"
69326932
resolved "https://registry.yarnpkg.com/metro-minify-terser/-/metro-minify-terser-0.82.5.tgz#5dc77d53b6ef4079bd9c752ae046d557df4ae584"
@@ -9191,6 +9191,11 @@ tslib@^1.8.1, tslib@^1.9.0:
91919191
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
91929192
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
91939193

9194+
tslib@^2.0.0:
9195+
version "2.8.1"
9196+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
9197+
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
9198+
91949199
tslib@^2.1.0:
91959200
version "2.7.0"
91969201
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01"

0 commit comments

Comments
 (0)