diff --git a/.yarn/versions/56678543.yml b/.yarn/versions/56678543.yml new file mode 100644 index 000000000000..2d6a48f178d8 --- /dev/null +++ b/.yarn/versions/56678543.yml @@ -0,0 +1,34 @@ +releases: + "@yarnpkg/cli": patch + "@yarnpkg/core": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-http" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm" + - "@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/doctor" + - "@yarnpkg/extensions" + - "@yarnpkg/nm" + - "@yarnpkg/pnpify" + - "@yarnpkg/sdks" diff --git a/packages/acceptance-tests/pkg-tests-core/sources/utils/makeTemporaryEnv.ts b/packages/acceptance-tests/pkg-tests-core/sources/utils/makeTemporaryEnv.ts index 971c4b5de7d7..730bfe2fa2b0 100644 --- a/packages/acceptance-tests/pkg-tests-core/sources/utils/makeTemporaryEnv.ts +++ b/packages/acceptance-tests/pkg-tests-core/sources/utils/makeTemporaryEnv.ts @@ -58,6 +58,8 @@ const mte = generatePkgDriver({ [`YARN_ENABLE_GLOBAL_CACHE`]: `false`, // Older versions of Windows need this set to not have node throw an error [`NODE_SKIP_PLATFORM_CHECK`]: `1`, + // We don't want the PnP runtime to be accidentally injected + [`NODE_OPTIONS`]: ``, ...rcEnv, ...env, }, diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts index 5fe8d7692f40..70438674d170 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts @@ -107,6 +107,23 @@ describe(`Commands`, () => { await expect(run(`constraints`)).rejects.toThrow(/This should fail/); })); + it(`should allow requiring dependencies from the yarn.config.cjs file`, makeTemporaryEnv({ + dependencies: { + [`no-deps`]: `1.0.0`, + }, + }, async ({path, run, source}) => { + await run(`install`); + + await writeFile(ppath.join(path, `yarn.config.cjs`), ` + require('no-deps'); + + exports.constraints = ({Yarn}) => { + }; + `); + + await run(`constraints`); + })); + it(`shouldn't report errors when comparing identical objects`, makeTemporaryEnv({ foo: { ok: true, diff --git a/packages/yarnpkg-core/sources/Project.ts b/packages/yarnpkg-core/sources/Project.ts index 57ba94dd4288..a2201624c2c8 100644 --- a/packages/yarnpkg-core/sources/Project.ts +++ b/packages/yarnpkg-core/sources/Project.ts @@ -711,6 +711,14 @@ export class Project { } async loadUserConfig() { + // TODO: We're injecting the .pnp.cjs in the environment, so that it's + // able to required the project dependencies. It's not ideal to hardcode + // this logic here, but I'm not quite sure yet what would be a better place. + // + const pnpPath = ppath.join(this.cwd, `.pnp.cjs`); + if (await xfs.existsPromise(pnpPath)) + miscUtils.dynamicRequire(pnpPath).setup(); + const configPath = ppath.join(this.cwd, `yarn.config.cjs`); if (!await xfs.existsPromise(configPath)) return null;