mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-17 00:34:47 -05:00
When installing unrelated package inside scoped packages dont invalidate resolutions from everything in the scoped package (#53873)
This commit is contained in:
@@ -1889,7 +1889,7 @@ export function pathContainsNodeModules(path: string): boolean {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function parseNodeModuleFromPath(resolved: string): string | undefined {
|
||||
export function parseNodeModuleFromPath(resolved: string, isFolder?: boolean): string | undefined {
|
||||
const path = normalizePath(resolved);
|
||||
const idx = path.lastIndexOf(nodeModulesPathPart);
|
||||
if (idx === -1) {
|
||||
@@ -1897,16 +1897,16 @@ export function parseNodeModuleFromPath(resolved: string): string | undefined {
|
||||
}
|
||||
|
||||
const indexAfterNodeModules = idx + nodeModulesPathPart.length;
|
||||
let indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
|
||||
let indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules, isFolder);
|
||||
if (path.charCodeAt(indexAfterNodeModules) === CharacterCodes.at) {
|
||||
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
|
||||
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName, isFolder);
|
||||
}
|
||||
return path.slice(0, indexAfterPackageName);
|
||||
}
|
||||
|
||||
function moveToNextDirectorySeparatorIfAvailable(path: string, prevSeparatorIndex: number): number {
|
||||
function moveToNextDirectorySeparatorIfAvailable(path: string, prevSeparatorIndex: number, isFolder: boolean | undefined): number {
|
||||
const nextSeparatorIndex = path.indexOf(directorySeparator, prevSeparatorIndex + 1);
|
||||
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
|
||||
return nextSeparatorIndex === -1 ? isFolder ? path.length : prevSeparatorIndex : nextSeparatorIndex;
|
||||
}
|
||||
|
||||
function loadModuleFromFileNoPackageId(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): Resolved | undefined {
|
||||
|
||||
Reference in New Issue
Block a user