Skip to content

Commit a03e08e

Browse files
committed
fix: update
1 parent ae27923 commit a03e08e

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

lib/HardlinkPlugin.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
/** @typedef {import("./Resolver")} Resolver */
99
/** @typedef {import("./Resolver").FileSystem} FileSystem */
10+
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
1011
/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
1112

1213
/**
1314
* Per-filesystem inode cache. The cache lifetime is tied to the filesystem
1415
* object (same invariant as `_pathCacheByFs` in `Resolver.js`): when the
1516
* user swaps filesystems the entries become unreachable and get collected.
16-
* @type {WeakMap<FileSystem, Map<string, string>>}
17+
* @type {WeakMap<FileSystem, Map<string, ResolveRequest>>}
1718
*/
1819
const _inodeCacheByFs = new WeakMap();
1920

@@ -51,26 +52,19 @@ module.exports = class HardlinkPlugin {
5152
if (ino === 0) return callback();
5253

5354
const key = `${stat.dev}:${ino}`;
54-
const cachedPath = inodeCache.get(key);
55+
const cached = inodeCache.get(key);
5556

56-
if (cachedPath !== undefined) {
57-
if (cachedPath !== filePath) {
58-
// Only request.path is updated; description-file
59-
// metadata (descriptionFileRoot, descriptionFilePath,
60-
// descriptionFileData, relativePath) still reflects
61-
// the original path. For the primary use case
62-
// (bundler module identity) only path matters, and
63-
// for pnpm hardlinks the description-file content is
64-
// identical across copies.
65-
request.path = cachedPath;
57+
if (cached !== undefined) {
58+
if (cached.path !== filePath) {
6659
if (resolveContext.log) {
6760
resolveContext.log(
68-
`deduplicated hardlink ${filePath} to ${cachedPath}`,
61+
`deduplicated hardlink ${filePath} to ${cached.path}`,
6962
);
7063
}
64+
return callback(null, cached);
7165
}
7266
} else {
73-
inodeCache.set(key, filePath);
67+
inodeCache.set(key, { ...request });
7468
}
7569
callback();
7670
});

0 commit comments

Comments
 (0)