Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rush] Add warning when using globalIgnoredOptionalDependencies in < pnpm 9.0.0 #5001

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Add warning when using globalIgnoredOptionalDependencies in < pnpm 9.0.0",
witcher112 marked this conversation as resolved.
Show resolved Hide resolved
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
13 changes: 13 additions & 0 deletions libraries/rush-lib/src/logic/installManager/InstallHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type { PnpmOptionsConfiguration } from '../pnpm/PnpmOptionsConfiguration'
import { merge } from '../../utilities/objectUtilities';
import type { Subspace } from '../../api/Subspace';
import { RushConstants } from '../RushConstants';
import * as semver from 'semver';

interface ICommonPackageJson extends IPackageJson {
pnpm?: {
Expand Down Expand Up @@ -71,6 +72,18 @@ export class InstallHelpers {
}

if (pnpmOptions.globalIgnoredOptionalDependencies) {
if (rushConfiguration.rushConfigurationJson.pnpmVersion !== undefined && semver.lt(rushConfiguration.rushConfigurationJson.pnpmVersion, '9.0.0')) {
// eslint-disable-next-line no-console
console.warn(
iclanton marked this conversation as resolved.
Show resolved Hide resolved
Colorize.yellow(
`Your version of pnpm ${rushConfiguration.rushConfigurationJson.pnpmVersion} ` +
`doesn't support "globalIgnoredOptionalDependencies". Please consider upgrading the ` +
`"pnpmVersion" setting in ${RushConstants.rushJsonFilename} to 9.0.0 or higher ` +
Colorize.bold('(please note that pnpm 9+ is not officially supported yet at the moment)')
witcher112 marked this conversation as resolved.
Show resolved Hide resolved
)
);
}

commonPackageJson.pnpm.ignoredOptionalDependencies = pnpmOptions.globalIgnoredOptionalDependencies;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ export class PnpmOptionsConfiguration extends PackageManagerOptionsConfiguration
* dependencies. The settings are copied into the pnpm.ignoredOptionalDependencies field of the common/temp/package.json
* file that is generated by Rush during installation.
*
* (SUPPORTED ONLY IN PNPM 9.0.0 AND NEWER)
*
* PNPM documentation: https://pnpm.io/package_json#pnpmignoredoptionaldependencies
*/
public readonly globalIgnoredOptionalDependencies: string[] | undefined;
Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/schemas/pnpm-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
},

"globalIgnoredOptionalDependencies": {
"description": "This field allows you to skip the installation of specific optional dependencies. The listed packages will be treated as if they are not present in the dependency tree during installation, meaning they will not be installed even if required by other packages.",
"description": "This field allows you to skip the installation of specific optional dependencies. The listed packages will be treated as if they are not present in the dependency tree during installation, meaning they will not be installed even if required by other packages.\n\n(SUPPORTED ONLY IN PNPM 9.0.0 AND NEWER)\n\nPNPM documentation: https://pnpm.io/package_json#pnpmalloweddeprecatedversions",
"type": "array",
"items": {
"description": "Specify the package name of the optional dependency to be ignored.",
Expand Down
Loading