Skip to content

Commit 9e0776d

Browse files
committed
Use absolute path as the key
1 parent 90cba37 commit 9e0776d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/react-fs/src/ReactFilesystem.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {Wakeable, Thenable} from 'shared/ReactTypes';
1111

1212
import {unstable_getCacheForType} from 'react';
1313
import * as fs from 'fs/promises';
14+
import {resolve} from 'path';
1415

1516
const Pending = 0;
1617
const Resolved = 1;
@@ -85,11 +86,12 @@ export function readFile(
8586
},
8687
): string | Buffer {
8788
const map = unstable_getCacheForType(createReadFileCache);
88-
let entry = map.get(path);
89+
const resolvedPath = resolve(path);
90+
let entry = map.get(resolvedPath);
8991
if (!entry) {
90-
const thenable = fs.readFile(path);
92+
const thenable = fs.readFile(resolvedPath);
9193
entry = toResult(thenable);
92-
map.set(path, entry);
94+
map.set(resolvedPath, entry);
9395
}
9496
const result: Buffer = readResult(entry);
9597
if (!options) {

scripts/rollup/bundles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const bundles = [
168168
moduleType: ISOMORPHIC,
169169
entry: 'react-fs/index.node',
170170
global: 'ReactFilesystem',
171-
externals: ['react', 'fs/promises'],
171+
externals: ['react', 'fs/promises', 'path'],
172172
},
173173

174174
/******* React PG Browser (experimental, new) *******/

0 commit comments

Comments
 (0)