Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .yarn/versions/9aaf86c6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/plugin-nm": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,32 @@ describe(`Node_Modules`, () => {
),
);

it(`should only reinstall scoped dependencies deleted by the user on the next install`,
makeTemporaryEnv(
{
dependencies: {
[`@types/no-deps`]: `1.0.0`,
[`@types/is-number`]: `1.0.0`,
},
},
{
nodeLinker: `node-modules`,
},
async ({path, run}) => {
await run(`install`);

await xfs.removePromise(`${path}/node_modules/@types/is-number` as PortablePath);
const inode = (await xfs.statPromise(`${path}/node_modules/@types/no-deps/package.json` as PortablePath)).ino;

await run(`install`);
const nextInode = (await xfs.statPromise(`${path}/node_modules/@types/no-deps/package.json` as PortablePath)).ino;

await expect(xfs.existsPromise(`${path}/node_modules/@types/is-number` as PortablePath));
expect(nextInode).toEqual(inode);
},
),
);

it(`should support portals to external workspaces`,
makeTemporaryEnv(
{
Expand Down
14 changes: 7 additions & 7 deletions packages/plugin-nm/sources/NodeModulesLinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,12 @@ function syncPreinstallStateWithDisk(locationTree: LocationTree, binSymlinks: Bi
const locatorLocations = new Map();
let installChangedByUser = false;

const syncNodeWithDisk = (parentPath: PortablePath, entry: Filename, parentNode: LocationNode, refinedNode: LocationNode, nodeModulesDiskEntries: Set<Filename>) => {
const syncNodeWithDisk = (parentPath: PortablePath, entry: Filename, parentNode: LocationNode, refinedNode: LocationNode, parentDiskEntries: Set<Filename>) => {
let doesExistOnDisk = true;
const entryPath = ppath.join(parentPath, entry);
let childNodeModulesDiskEntries = new Set<Filename>();
let childDiskEntries = new Set<Filename>();

if (entry === NODE_MODULES) {
if (entry === NODE_MODULES || entry.startsWith(`@`)) {
let stats;
try {
stats = xfs.statSync(entryPath);
Expand All @@ -860,9 +860,9 @@ function syncPreinstallStateWithDisk(locationTree: LocationTree, binSymlinks: Bi
installChangedByUser = true;
} else if (stats.mtimeMs > stateMtimeMs) {
installChangedByUser = true;
childNodeModulesDiskEntries = new Set(xfs.readdirSync(entryPath));
childDiskEntries = new Set(xfs.readdirSync(entryPath));
} else {
childNodeModulesDiskEntries = new Set(parentNode.children.get(NODE_MODULES)!.children.keys());
childDiskEntries = new Set(parentNode.children.get(entry)!.children.keys());
}

const binarySymlinks = binSymlinks.get(parentPath);
Expand Down Expand Up @@ -893,7 +893,7 @@ function syncPreinstallStateWithDisk(locationTree: LocationTree, binSymlinks: Bi
}
}
} else {
doesExistOnDisk = nodeModulesDiskEntries.has(entry);
doesExistOnDisk = parentDiskEntries.has(entry);
}

const node = parentNode.children.get(entry)!;
Expand All @@ -908,7 +908,7 @@ function syncPreinstallStateWithDisk(locationTree: LocationTree, binSymlinks: Bi
}

for (const childEntry of node.children.keys()) {
syncNodeWithDisk(entryPath, childEntry, node, childRefinedNode, childNodeModulesDiskEntries);
syncNodeWithDisk(entryPath, childEntry, node, childRefinedNode, childDiskEntries);
}
} else if (node.locator) {
project.storedBuildState.delete(structUtils.parseLocator(node.locator).locatorHash);
Expand Down