apply(resolver) {
		resolver.hooks.resolved.tapAsync("ResolvePackageFromRootPlugin", (originalResolved, _, callback) => {

			if (!nestedNodeModuleRegex.test(
				/** @type {string} */
				(originalResolved.path)
			) || !originalResolved.context || !
				(originalResolved.context).issuer) {
				return callback(null, originalResolved)
			}

			resolver.doResolve(resolver.hooks.resolve, {
				context: {},
				path: originalResolved.context.issuer,
				request: originalResolved.context.issuer
			}, `resolve issuer of ${originalResolved.path}`, {}, (err, issuer) => {
				if (err) {
					return callback(null, originalResolved);
				}

				const moduleRequestPath = /** @type {string} */ (originalResolved.path).replace(replaceNodeModuleRegex, "");

				resolver.doResolve(resolver.hooks.resolve, {
					context: {},
					path: this.rootPath,
					request: moduleRequestPath
				}, `resolve ${moduleRequestPath} in ${this.rootPath}`, {}, (err, _resolvedInParentContext) => {
					if (err) {
						return callback(null, originalResolved);
					}

					const resolvedInParentContext = /** @type {ResolveRequest} */ (_resolvedInParentContext);

					const packageName =
						/** @type {NonNullable<ResolveRequest["descriptionFileData"]>} */
						(resolvedInParentContext.descriptionFileData).name;
					const resolvedVersion =
						/** @type {NonNullable<ResolveRequest["descriptionFileData"]>} */
						(resolvedInParentContext.descriptionFileData).version;
					const wantedVersion =
						/** @type {{ dependencies: Record<string, string> }} */
						(
							/** @type {ResolveRequest} */
							(issuer).descriptionFileData
						).dependencies[
							/** @type {string} */
							(packageName)
						];

					if (resolvedVersion !== wantedVersion) {
						return callback(null, originalResolved);
					}

					return callback(null, resolvedInParentContext);
				});
			});
		})
	}
@param {Resolver & { hooks: { resolved: AsyncSeriesBailHook<[ResolveRequest & { context: { issuer: string } }, ResolveContext], null | ResolveRequest> } }} resolver resolver