@yarnpkg/plugin-pnp 4.0.0-rc.4 → 4.0.0-rc.40

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.
@@ -6,6 +6,7 @@ import { PnpSettings } from '@yarnpkg/pnp';
6
6
  export declare class PnpLinker implements Linker {
7
7
  protected mode: string;
8
8
  private pnpCache;
9
+ getCustomDataKey(): string;
9
10
  supportsPackage(pkg: Package, opts: MinimalLinkOptions): boolean;
10
11
  findPackageLocation(locator: Locator, opts: LinkOptions): Promise<PortablePath>;
11
12
  findPackageLocator(location: PortablePath, opts: LinkOptions): Promise<Locator | null>;
@@ -20,7 +21,6 @@ export declare class PnpInstaller implements Installer {
20
21
  private readonly virtualTemplates;
21
22
  private isESMLoaderRequired;
22
23
  constructor(opts: LinkOptions);
23
- getCustomDataKey(): string;
24
24
  private customData;
25
25
  attachCustomData(customData: any): void;
26
26
  installPackage(pkg: Package, fetchResult: FetchResult, api: InstallPackageExtraApi): Promise<{
package/lib/PnpLinker.js CHANGED
@@ -11,19 +11,21 @@ const index_1 = require("./index");
11
11
  const jsInstallUtils = tslib_1.__importStar(require("./jsInstallUtils"));
12
12
  const pnpUtils = tslib_1.__importStar(require("./pnpUtils"));
13
13
  const FORCED_UNPLUG_PACKAGES = new Set([
14
- // Some packages do weird stuff and MUST be unplugged. I don't like them.
15
- core_1.structUtils.makeIdent(null, `nan`).identHash,
16
- core_1.structUtils.makeIdent(null, `node-gyp`).identHash,
17
- core_1.structUtils.makeIdent(null, `node-pre-gyp`).identHash,
18
- core_1.structUtils.makeIdent(null, `node-addon-api`).identHash,
19
- // Those ones contain native builds (*.node), and Node loads them through dlopen
20
- core_1.structUtils.makeIdent(null, `fsevents`).identHash,
14
+ // Contains native binaries
15
+ core_1.structUtils.makeIdent(null, `open`).identHash,
16
+ core_1.structUtils.makeIdent(null, `opn`).identHash,
21
17
  ]);
22
18
  class PnpLinker {
23
19
  constructor() {
24
20
  this.mode = `strict`;
25
21
  this.pnpCache = new Map();
26
22
  }
23
+ getCustomDataKey() {
24
+ return JSON.stringify({
25
+ name: `PnpLinker`,
26
+ version: 2,
27
+ });
28
+ }
27
29
  supportsPackage(pkg, opts) {
28
30
  return this.isEnabled(opts);
29
31
  }
@@ -82,12 +84,6 @@ class PnpInstaller {
82
84
  this.unpluggedPaths = new Set();
83
85
  this.opts = opts;
84
86
  }
85
- getCustomDataKey() {
86
- return JSON.stringify({
87
- name: `PnpInstaller`,
88
- version: 2,
89
- });
90
- }
91
87
  attachCustomData(customData) {
92
88
  this.customData = customData;
93
89
  }
@@ -186,16 +182,13 @@ class PnpInstaller {
186
182
  if (this.opts.project.configuration.get(`pnpMode`) !== this.mode)
187
183
  return undefined;
188
184
  const pnpPath = (0, index_1.getPnpPath)(this.opts.project);
189
- if (fslib_1.xfs.existsSync(pnpPath.cjsLegacy)) {
190
- this.opts.report.reportWarning(core_2.MessageName.UNNAMED, `Removing the old ${core_1.formatUtils.pretty(this.opts.project.configuration, fslib_1.Filename.pnpJs, core_1.formatUtils.Type.PATH)} file. You might need to manually update existing references to reference the new ${core_1.formatUtils.pretty(this.opts.project.configuration, fslib_1.Filename.pnpCjs, core_1.formatUtils.Type.PATH)} file. If you use Editor SDKs, you'll have to rerun ${core_1.formatUtils.pretty(this.opts.project.configuration, `yarn sdks`, core_1.formatUtils.Type.CODE)}.`);
191
- await fslib_1.xfs.removePromise(pnpPath.cjsLegacy);
192
- }
193
185
  if (!this.isEsmEnabled())
194
186
  await fslib_1.xfs.removePromise(pnpPath.esmLoader);
195
187
  if (this.opts.project.configuration.get(`nodeLinker`) !== `pnp`) {
196
188
  await fslib_1.xfs.removePromise(pnpPath.cjs);
197
- await fslib_1.xfs.removePromise(this.opts.project.configuration.get(`pnpDataPath`));
189
+ await fslib_1.xfs.removePromise(pnpPath.data);
198
190
  await fslib_1.xfs.removePromise(pnpPath.esmLoader);
191
+ await fslib_1.xfs.removePromise(this.opts.project.configuration.get(`pnpUnpluggedFolder`));
199
192
  return undefined;
200
193
  }
201
194
  for (const { locator, location } of this.virtualTemplates.values()) {
@@ -253,7 +246,6 @@ class PnpInstaller {
253
246
  }
254
247
  async finalizeInstallWithPnp(pnpSettings) {
255
248
  const pnpPath = (0, index_1.getPnpPath)(this.opts.project);
256
- const pnpDataPath = this.opts.project.configuration.get(`pnpDataPath`);
257
249
  const nodeModules = await this.locateNodeModules(pnpSettings.ignorePattern);
258
250
  if (nodeModules.length > 0) {
259
251
  this.opts.report.reportWarning(core_2.MessageName.DANGEROUS_NODE_MODULES, `One or more node_modules have been detected and will be removed. This operation may take some time.`);
@@ -268,16 +260,15 @@ class PnpInstaller {
268
260
  automaticNewlines: true,
269
261
  mode: 0o755,
270
262
  });
271
- await fslib_1.xfs.removePromise(pnpDataPath);
263
+ await fslib_1.xfs.removePromise(pnpPath.data);
272
264
  }
273
265
  else {
274
- const dataLocation = fslib_1.ppath.relative(fslib_1.ppath.dirname(pnpPath.cjs), pnpDataPath);
275
- const { dataFile, loaderFile } = (0, pnp_1.generateSplitScript)({ ...pnpSettings, dataLocation });
266
+ const { dataFile, loaderFile } = (0, pnp_1.generateSplitScript)(pnpSettings);
276
267
  await fslib_1.xfs.changeFilePromise(pnpPath.cjs, loaderFile, {
277
268
  automaticNewlines: true,
278
269
  mode: 0o755,
279
270
  });
280
- await fslib_1.xfs.changeFilePromise(pnpDataPath, dataFile, {
271
+ await fslib_1.xfs.changeFilePromise(pnpPath.data, dataFile, {
281
272
  automaticNewlines: true,
282
273
  mode: 0o644,
283
274
  });
@@ -7,5 +7,5 @@ export default class UnplugCommand extends BaseCommand {
7
7
  recursive: boolean;
8
8
  json: boolean;
9
9
  patterns: string[];
10
- execute(): Promise<1 | 0>;
10
+ execute(): Promise<0 | 1>;
11
11
  }
@@ -82,12 +82,8 @@ class UnplugCommand extends cli_1.BaseCommand {
82
82
  traverse(nextPkg, depth + 1);
83
83
  }
84
84
  };
85
- for (const workspace of roots) {
86
- const pkg = project.storedPackages.get(workspace.anchoredLocator.locatorHash);
87
- if (!pkg)
88
- throw new Error(`Assertion failed: The package should have been registered`);
89
- traverse(pkg, 0);
90
- }
85
+ for (const workspace of roots)
86
+ traverse(workspace.anchoredPackage, 0);
91
87
  return selection;
92
88
  };
93
89
  let selection;
@@ -136,7 +132,6 @@ class UnplugCommand extends cli_1.BaseCommand {
136
132
  return report.exitCode();
137
133
  }
138
134
  }
139
- exports.default = UnplugCommand;
140
135
  UnplugCommand.paths = [
141
136
  [`unplug`],
142
137
  ];
@@ -176,3 +171,4 @@ UnplugCommand.usage = clipanion_1.Command.Usage({
176
171
  `yarn unplug -R '*'`,
177
172
  ]],
178
173
  });
174
+ exports.default = UnplugCommand;
package/lib/index.d.ts CHANGED
@@ -1,19 +1,22 @@
1
1
  import { Hooks as CoreHooks, Plugin, Project } from '@yarnpkg/core';
2
2
  import { PortablePath } from '@yarnpkg/fslib';
3
3
  import { Hooks as StageHooks } from '@yarnpkg/plugin-stage';
4
+ import UnplugCommand from './commands/unplug';
4
5
  import * as jsInstallUtils from './jsInstallUtils';
5
6
  import * as pnpUtils from './pnpUtils';
7
+ export { UnplugCommand };
6
8
  export { jsInstallUtils };
7
9
  export { pnpUtils };
8
10
  export declare const getPnpPath: (project: Project) => {
9
11
  cjs: PortablePath;
10
- cjsLegacy: PortablePath;
12
+ data: PortablePath;
11
13
  esmLoader: PortablePath;
12
14
  };
13
15
  export declare const quotePathIfNeeded: (path: string) => string;
14
16
  declare module '@yarnpkg/core' {
15
17
  interface ConfigurationValueMap {
16
18
  nodeLinker: string;
19
+ winLinkType: string;
17
20
  pnpMode: string;
18
21
  pnpShebang: string;
19
22
  pnpIgnorePatterns: Array<string>;
@@ -21,7 +24,6 @@ declare module '@yarnpkg/core' {
21
24
  pnpEnableInlining: boolean;
22
25
  pnpFallbackMode: string;
23
26
  pnpUnpluggedFolder: PortablePath;
24
- pnpDataPath: PortablePath;
25
27
  }
26
28
  }
27
29
  declare const plugin: Plugin<CoreHooks & StageHooks>;
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PnpLinker = exports.PnpInstaller = exports.quotePathIfNeeded = exports.getPnpPath = exports.pnpUtils = exports.jsInstallUtils = void 0;
3
+ exports.PnpLinker = exports.PnpInstaller = exports.quotePathIfNeeded = exports.getPnpPath = exports.pnpUtils = exports.jsInstallUtils = exports.UnplugCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@yarnpkg/core");
6
6
  const fslib_1 = require("@yarnpkg/fslib");
@@ -8,6 +8,7 @@ const semver_1 = tslib_1.__importDefault(require("semver"));
8
8
  const url_1 = require("url");
9
9
  const PnpLinker_1 = require("./PnpLinker");
10
10
  const unplug_1 = tslib_1.__importDefault(require("./commands/unplug"));
11
+ exports.UnplugCommand = unplug_1.default;
11
12
  const jsInstallUtils = tslib_1.__importStar(require("./jsInstallUtils"));
12
13
  exports.jsInstallUtils = jsInstallUtils;
13
14
  const pnpUtils = tslib_1.__importStar(require("./pnpUtils"));
@@ -15,8 +16,8 @@ exports.pnpUtils = pnpUtils;
15
16
  const getPnpPath = (project) => {
16
17
  return {
17
18
  cjs: fslib_1.ppath.join(project.cwd, fslib_1.Filename.pnpCjs),
18
- cjsLegacy: fslib_1.ppath.join(project.cwd, fslib_1.Filename.pnpJs),
19
- esmLoader: fslib_1.ppath.join(project.cwd, `.pnp.loader.mjs`),
19
+ data: fslib_1.ppath.join(project.cwd, fslib_1.Filename.pnpData),
20
+ esmLoader: fslib_1.ppath.join(project.cwd, fslib_1.Filename.pnpEsmLoader),
20
21
  };
21
22
  };
22
23
  exports.getPnpPath = getPnpPath;
@@ -45,8 +46,8 @@ async function setupScriptEnvironment(project, env, makePathWrapper) {
45
46
  async function populateYarnPaths(project, definePath) {
46
47
  const pnpPath = (0, exports.getPnpPath)(project);
47
48
  definePath(pnpPath.cjs);
49
+ definePath(pnpPath.data);
48
50
  definePath(pnpPath.esmLoader);
49
- definePath(project.configuration.get(`pnpDataPath`));
50
51
  definePath(project.configuration.get(`pnpUnpluggedFolder`));
51
52
  }
52
53
  const plugin = {
@@ -60,6 +61,15 @@ const plugin = {
60
61
  type: core_1.SettingsType.STRING,
61
62
  default: `pnp`,
62
63
  },
64
+ winLinkType: {
65
+ description: `Whether Yarn should use Windows Junctions or symlinks when creating links on Windows.`,
66
+ type: core_1.SettingsType.STRING,
67
+ values: [
68
+ core_1.WindowsLinkType.JUNCTIONS,
69
+ core_1.WindowsLinkType.SYMLINKS,
70
+ ],
71
+ default: core_1.WindowsLinkType.JUNCTIONS,
72
+ },
63
73
  pnpMode: {
64
74
  description: `If 'strict', generates standard PnP maps. If 'loose', merges them with the n_m resolution.`,
65
75
  type: core_1.SettingsType.STRING,
@@ -96,11 +106,6 @@ const plugin = {
96
106
  type: core_1.SettingsType.ABSOLUTE_PATH,
97
107
  default: `./.yarn/unplugged`,
98
108
  },
99
- pnpDataPath: {
100
- description: `Path of the file where the PnP data (used by the loader) must be written`,
101
- type: core_1.SettingsType.ABSOLUTE_PATH,
102
- default: `./.pnp.data.json`,
103
- },
104
109
  },
105
110
  linkers: [
106
111
  PnpLinker_1.PnpLinker,
@@ -4,7 +4,7 @@ export declare function checkAndReportManifestCompatibility(pkg: Package, label:
4
4
  configuration: Configuration;
5
5
  report?: Report | null;
6
6
  }): boolean;
7
- export declare type ExtractBuildScriptDataRequirements = {
7
+ export type ExtractBuildScriptDataRequirements = {
8
8
  manifest: Pick<Manifest, 'scripts'>;
9
9
  misc: {
10
10
  hasBindingGyp: boolean;
package/package.json CHANGED
@@ -1,26 +1,31 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-pnp",
3
- "version": "4.0.0-rc.4",
3
+ "version": "4.0.0-rc.40",
4
+ "stableVersion": "3.2.7",
4
5
  "license": "BSD-2-Clause",
5
6
  "main": "./lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./package.json": "./package.json"
10
+ },
6
11
  "dependencies": {
7
12
  "@types/semver": "^7.1.0",
8
- "@yarnpkg/fslib": "^3.0.0-rc.4",
9
- "@yarnpkg/plugin-stage": "^4.0.0-rc.4",
10
- "@yarnpkg/pnp": "^4.0.0-rc.4",
13
+ "@yarnpkg/fslib": "^3.0.0-rc.40",
14
+ "@yarnpkg/plugin-stage": "^4.0.0-rc.40",
15
+ "@yarnpkg/pnp": "^4.0.0-rc.40",
11
16
  "clipanion": "^3.2.0-rc.10",
12
17
  "micromatch": "^4.0.2",
13
18
  "semver": "^7.1.2",
14
- "tslib": "^1.13.0"
19
+ "tslib": "^2.4.0"
15
20
  },
16
21
  "peerDependencies": {
17
- "@yarnpkg/cli": "^4.0.0-rc.4",
18
- "@yarnpkg/core": "^4.0.0-rc.4"
22
+ "@yarnpkg/cli": "^4.0.0-rc.40",
23
+ "@yarnpkg/core": "^4.0.0-rc.40"
19
24
  },
20
25
  "devDependencies": {
21
26
  "@types/micromatch": "^4.0.1",
22
- "@yarnpkg/cli": "^4.0.0-rc.4",
23
- "@yarnpkg/core": "^4.0.0-rc.4"
27
+ "@yarnpkg/cli": "^4.0.0-rc.40",
28
+ "@yarnpkg/core": "^4.0.0-rc.40"
24
29
  },
25
30
  "repository": {
26
31
  "type": "git",
@@ -33,14 +38,15 @@
33
38
  },
34
39
  "publishConfig": {
35
40
  "main": "./lib/index.js",
36
- "typings": "./lib/index.d.ts"
41
+ "exports": {
42
+ ".": "./lib/index.js",
43
+ "./package.json": "./package.json"
44
+ }
37
45
  },
38
46
  "files": [
39
47
  "/lib/**/*"
40
48
  ],
41
49
  "engines": {
42
50
  "node": ">=14.15.0"
43
- },
44
- "stableVersion": "3.2.0",
45
- "typings": "./lib/index.d.ts"
51
+ }
46
52
  }