@yarnpkg/plugin-pnp 4.0.0-rc.2 → 4.0.0-rc.20

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
@@ -18,12 +18,21 @@ const FORCED_UNPLUG_PACKAGES = new Set([
18
18
  core_1.structUtils.makeIdent(null, `node-addon-api`).identHash,
19
19
  // Those ones contain native builds (*.node), and Node loads them through dlopen
20
20
  core_1.structUtils.makeIdent(null, `fsevents`).identHash,
21
+ // Contains native binaries
22
+ core_1.structUtils.makeIdent(null, `open`).identHash,
23
+ core_1.structUtils.makeIdent(null, `opn`).identHash,
21
24
  ]);
22
25
  class PnpLinker {
23
26
  constructor() {
24
27
  this.mode = `strict`;
25
28
  this.pnpCache = new Map();
26
29
  }
30
+ getCustomDataKey() {
31
+ return JSON.stringify({
32
+ name: `PnpLinker`,
33
+ version: 2,
34
+ });
35
+ }
27
36
  supportsPackage(pkg, opts) {
28
37
  return this.isEnabled(opts);
29
38
  }
@@ -82,12 +91,6 @@ class PnpInstaller {
82
91
  this.unpluggedPaths = new Set();
83
92
  this.opts = opts;
84
93
  }
85
- getCustomDataKey() {
86
- return JSON.stringify({
87
- name: `PnpInstaller`,
88
- version: 2,
89
- });
90
- }
91
94
  attachCustomData(customData) {
92
95
  this.customData = customData;
93
96
  }
@@ -186,16 +189,13 @@ class PnpInstaller {
186
189
  if (this.opts.project.configuration.get(`pnpMode`) !== this.mode)
187
190
  return undefined;
188
191
  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
192
  if (!this.isEsmEnabled())
194
193
  await fslib_1.xfs.removePromise(pnpPath.esmLoader);
195
194
  if (this.opts.project.configuration.get(`nodeLinker`) !== `pnp`) {
196
195
  await fslib_1.xfs.removePromise(pnpPath.cjs);
197
- await fslib_1.xfs.removePromise(this.opts.project.configuration.get(`pnpDataPath`));
196
+ await fslib_1.xfs.removePromise(pnpPath.data);
198
197
  await fslib_1.xfs.removePromise(pnpPath.esmLoader);
198
+ await fslib_1.xfs.removePromise(this.opts.project.configuration.get(`pnpUnpluggedFolder`));
199
199
  return undefined;
200
200
  }
201
201
  for (const { locator, location } of this.virtualTemplates.values()) {
@@ -253,7 +253,6 @@ class PnpInstaller {
253
253
  }
254
254
  async finalizeInstallWithPnp(pnpSettings) {
255
255
  const pnpPath = (0, index_1.getPnpPath)(this.opts.project);
256
- const pnpDataPath = this.opts.project.configuration.get(`pnpDataPath`);
257
256
  const nodeModules = await this.locateNodeModules(pnpSettings.ignorePattern);
258
257
  if (nodeModules.length > 0) {
259
258
  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 +267,15 @@ class PnpInstaller {
268
267
  automaticNewlines: true,
269
268
  mode: 0o755,
270
269
  });
271
- await fslib_1.xfs.removePromise(pnpDataPath);
270
+ await fslib_1.xfs.removePromise(pnpPath.data);
272
271
  }
273
272
  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 });
273
+ const { dataFile, loaderFile } = (0, pnp_1.generateSplitScript)(pnpSettings);
276
274
  await fslib_1.xfs.changeFilePromise(pnpPath.cjs, loaderFile, {
277
275
  automaticNewlines: true,
278
276
  mode: 0o755,
279
277
  });
280
- await fslib_1.xfs.changeFilePromise(pnpDataPath, dataFile, {
278
+ await fslib_1.xfs.changeFilePromise(pnpPath.data, dataFile, {
281
279
  automaticNewlines: true,
282
280
  mode: 0o644,
283
281
  });
package/lib/index.d.ts CHANGED
@@ -1,13 +1,15 @@
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;
@@ -21,7 +23,6 @@ declare module '@yarnpkg/core' {
21
23
  pnpEnableInlining: boolean;
22
24
  pnpFallbackMode: string;
23
25
  pnpUnpluggedFolder: PortablePath;
24
- pnpDataPath: PortablePath;
25
26
  }
26
27
  }
27
28
  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 = {
@@ -96,11 +97,6 @@ const plugin = {
96
97
  type: core_1.SettingsType.ABSOLUTE_PATH,
97
98
  default: `./.yarn/unplugged`,
98
99
  },
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
100
  },
105
101
  linkers: [
106
102
  PnpLinker_1.PnpLinker,
package/package.json CHANGED
@@ -1,26 +1,31 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-pnp",
3
- "version": "4.0.0-rc.2",
3
+ "version": "4.0.0-rc.20",
4
+ "stableVersion": "3.2.2",
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.2",
9
- "@yarnpkg/plugin-stage": "^4.0.0-rc.2",
10
- "@yarnpkg/pnp": "^4.0.0-rc.2",
13
+ "@yarnpkg/fslib": "^3.0.0-rc.20",
14
+ "@yarnpkg/plugin-stage": "^4.0.0-rc.20",
15
+ "@yarnpkg/pnp": "^4.0.0-rc.20",
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.2",
18
- "@yarnpkg/core": "^4.0.0-rc.2"
22
+ "@yarnpkg/cli": "^4.0.0-rc.20",
23
+ "@yarnpkg/core": "^4.0.0-rc.20"
19
24
  },
20
25
  "devDependencies": {
21
26
  "@types/micromatch": "^4.0.1",
22
- "@yarnpkg/cli": "^4.0.0-rc.2",
23
- "@yarnpkg/core": "^4.0.0-rc.2"
27
+ "@yarnpkg/cli": "^4.0.0-rc.20",
28
+ "@yarnpkg/core": "^4.0.0-rc.20"
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
  }