Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2444,7 +2444,9 @@ function readPackageJsonPeerDependencies(packageJsonInfo: PackageJsonInfo, state
if (peerDependencies === undefined) return undefined;
if (state.traceEnabled) trace(state.host, Diagnostics.package_json_has_a_peerDependencies_field);
const packageDirectory = realPath(packageJsonInfo.packageDirectory, state.host, state.traceEnabled);
const nodeModules = packageDirectory.substring(0, packageDirectory.lastIndexOf("node_modules") + "node_modules".length) + directorySeparator;
const nodeModulesIndex = packageDirectory.lastIndexOf("node_modules");
if (nodeModulesIndex === -1) return undefined;
const nodeModules = packageDirectory.substring(0, nodeModulesIndex + "node_modules".length) + directorySeparator;
let result = "";
for (const key in peerDependencies) {
if (hasProperty(peerDependencies, key)) {
Expand Down
17 changes: 10 additions & 7 deletions src/server/moduleSpecifierCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ export function createModuleSpecifierCache(host: ModuleSpecifierResolutionCacheH
for (const p of modulePaths) {
if (p.isInNodeModules) {
// No trailing slash
const nodeModulesPath = p.path.substring(0, p.path.indexOf(nodeModulesPathPart) + nodeModulesPathPart.length - 1);
const key = host.toPath(nodeModulesPath);
if (!containedNodeModulesWatchers?.has(key)) {
(containedNodeModulesWatchers ||= new Map()).set(
key,
host.watchNodeModulesForPackageJsonChanges(nodeModulesPath),
);
const nodeModulesIndex = p.path.indexOf(nodeModulesPathPart);
if (nodeModulesIndex !== -1) {
const nodeModulesPath = p.path.substring(0, nodeModulesIndex + nodeModulesPathPart.length - 1);
const key = host.toPath(nodeModulesPath);
if (!containedNodeModulesWatchers?.has(key)) {
(containedNodeModulesWatchers ||= new Map()).set(
key,
host.watchNodeModulesForPackageJsonChanges(nodeModulesPath),
);
}
}
}
}
Expand Down