@yarnpkg/plugin-pnp 4.0.0-rc.47 → 4.0.0-rc.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/PnpLinker.js CHANGED
@@ -335,7 +335,7 @@ class PnpInstaller {
335
335
  if (customPackageData.manifest.preferUnplugged !== null)
336
336
  return customPackageData.manifest.preferUnplugged;
337
337
  const buildRequest = jsInstallUtils.extractBuildRequest(pkg, customPackageData, dependencyMeta, { configuration: this.opts.project.configuration });
338
- if ((buildRequest === null || buildRequest === void 0 ? void 0 : buildRequest.skipped) === false || customPackageData.misc.extractHint)
338
+ if (buildRequest?.skipped === false || customPackageData.misc.extractHint)
339
339
  return true;
340
340
  return false;
341
341
  }
@@ -389,8 +389,7 @@ function normalizeDirectoryPath(root, folder) {
389
389
  return relativeFolder.replace(/\/?$/, `/`);
390
390
  }
391
391
  async function extractCustomPackageData(fetchResult) {
392
- var _a;
393
- const manifest = (_a = await core_2.Manifest.tryFind(fetchResult.prefixPath, { baseFs: fetchResult.packageFs })) !== null && _a !== void 0 ? _a : new core_2.Manifest();
392
+ const manifest = await core_2.Manifest.tryFind(fetchResult.prefixPath, { baseFs: fetchResult.packageFs }) ?? new core_2.Manifest();
394
393
  const preservedScripts = new Set([`preinstall`, `install`, `postinstall`]);
395
394
  for (const scriptName of manifest.scripts.keys())
396
395
  if (!preservedScripts.has(scriptName))
@@ -114,9 +114,8 @@ class UnplugCommand extends cli_1.BaseCommand {
114
114
  stdout: this.context.stdout,
115
115
  json: this.json,
116
116
  }, async (report) => {
117
- var _a;
118
117
  for (const pkg of selection) {
119
- const version = (_a = pkg.version) !== null && _a !== void 0 ? _a : `unknown`;
118
+ const version = pkg.version ?? `unknown`;
120
119
  const dependencyMeta = project.topLevelWorkspace.manifest.ensureDependencyMeta(core_2.structUtils.makeDescriptor(pkg, version));
121
120
  dependencyMeta.unplugged = true;
122
121
  report.reportInfo(core_1.MessageName.UNNAMED, `Will unpack ${core_2.structUtils.prettyLocator(configuration, pkg)} to ${core_1.formatUtils.pretty(configuration, pnpUtils.getUnpluggedPath(pkg, { configuration }), core_1.formatUtils.Type.PATH)}`);
package/lib/index.js CHANGED
@@ -4,7 +4,6 @@ exports.PnpLinker = exports.PnpInstaller = exports.quotePathIfNeeded = exports.g
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const fslib_1 = require("@yarnpkg/fslib");
7
- const semver_1 = tslib_1.__importDefault(require("semver"));
8
7
  const url_1 = require("url");
9
8
  const PnpLinker_1 = require("./PnpLinker");
10
9
  const unplug_1 = tslib_1.__importDefault(require("./commands/unplug"));
@@ -26,21 +25,27 @@ const quotePathIfNeeded = (path) => {
26
25
  };
27
26
  exports.quotePathIfNeeded = quotePathIfNeeded;
28
27
  async function setupScriptEnvironment(project, env, makePathWrapper) {
28
+ // We still support .pnp.js files to improve multi-project compatibility.
29
+ // TODO: Drop the question mark in the RegExp after .pnp.js files stop being used.
30
+ // TODO: Support `-r` as an alias for `--require` (in all packages)
31
+ const pnpRegularExpression = /\s*--require\s+\S*\.pnp\.c?js\s*/g;
32
+ const esmLoaderExpression = /\s*--experimental-loader\s+\S*\.pnp\.loader\.mjs\s*/;
33
+ const nodeOptions = (env.NODE_OPTIONS ?? ``)
34
+ .replace(pnpRegularExpression, ` `)
35
+ .replace(esmLoaderExpression, ` `)
36
+ .trim();
37
+ // We remove the PnP hook from NODE_OPTIONS because the process can have
38
+ // NODE_OPTIONS set while changing linkers, which affects build scripts.
39
+ if (project.configuration.get(`nodeLinker`) !== `pnp`) {
40
+ env.NODE_OPTIONS = nodeOptions;
41
+ return;
42
+ }
29
43
  const pnpPath = (0, exports.getPnpPath)(project);
30
44
  let pnpRequire = `--require ${(0, exports.quotePathIfNeeded)(fslib_1.npath.fromPortablePath(pnpPath.cjs))}`;
31
45
  if (fslib_1.xfs.existsSync(pnpPath.esmLoader))
32
46
  pnpRequire = `${pnpRequire} --experimental-loader ${(0, url_1.pathToFileURL)(fslib_1.npath.fromPortablePath(pnpPath.esmLoader)).href}`;
33
- if (pnpPath.cjs.includes(` `) && semver_1.default.lt(process.versions.node, `12.0.0`))
34
- throw new Error(`Expected the build location to not include spaces when using Node < 12.0.0 (${process.versions.node})`);
35
47
  if (fslib_1.xfs.existsSync(pnpPath.cjs)) {
36
- let nodeOptions = env.NODE_OPTIONS || ``;
37
- // We still support .pnp.js files to improve multi-project compatibility.
38
- // TODO: Drop the question mark in the RegExp after .pnp.js files stop being used.
39
- const pnpRegularExpression = /\s*--require\s+\S*\.pnp\.c?js\s*/g;
40
- const esmLoaderExpression = /\s*--experimental-loader\s+\S*\.pnp\.loader\.mjs\s*/;
41
- nodeOptions = nodeOptions.replace(pnpRegularExpression, ` `).replace(esmLoaderExpression, ` `).trim();
42
- nodeOptions = nodeOptions ? `${pnpRequire} ${nodeOptions}` : pnpRequire;
43
- env.NODE_OPTIONS = nodeOptions;
48
+ env.NODE_OPTIONS = nodeOptions ? `${pnpRequire} ${nodeOptions}` : pnpRequire;
44
49
  }
45
50
  }
46
51
  async function populateYarnPaths(project, definePath) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-pnp",
3
- "version": "4.0.0-rc.47",
4
- "stableVersion": "3.2.10",
3
+ "version": "4.0.0-rc.49",
4
+ "stableVersion": "3.2.11",
5
5
  "license": "BSD-2-Clause",
6
6
  "main": "./lib/index.js",
7
7
  "exports": {
@@ -9,23 +9,21 @@
9
9
  "./package.json": "./package.json"
10
10
  },
11
11
  "dependencies": {
12
- "@types/semver": "^7.1.0",
13
- "@yarnpkg/fslib": "^3.0.0-rc.47",
14
- "@yarnpkg/plugin-stage": "^4.0.0-rc.47",
15
- "@yarnpkg/pnp": "^4.0.0-rc.47",
16
- "clipanion": "^3.2.1",
12
+ "@yarnpkg/fslib": "^3.0.0-rc.49",
13
+ "@yarnpkg/plugin-stage": "^4.0.0-rc.49",
14
+ "@yarnpkg/pnp": "^4.0.0-rc.49",
15
+ "clipanion": "^4.0.0-rc.2",
17
16
  "micromatch": "^4.0.2",
18
- "semver": "^7.1.2",
19
17
  "tslib": "^2.4.0"
20
18
  },
21
19
  "peerDependencies": {
22
- "@yarnpkg/cli": "^4.0.0-rc.47",
23
- "@yarnpkg/core": "^4.0.0-rc.47"
20
+ "@yarnpkg/cli": "^4.0.0-rc.49",
21
+ "@yarnpkg/core": "^4.0.0-rc.49"
24
22
  },
25
23
  "devDependencies": {
26
24
  "@types/micromatch": "^4.0.1",
27
- "@yarnpkg/cli": "^4.0.0-rc.47",
28
- "@yarnpkg/core": "^4.0.0-rc.47"
25
+ "@yarnpkg/cli": "^4.0.0-rc.49",
26
+ "@yarnpkg/core": "^4.0.0-rc.49"
29
27
  },
30
28
  "repository": {
31
29
  "type": "git",