@pnpm/hooks.pnpmfile 1100.0.25 → 1100.0.27

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @pnpm/pnpmfile
2
2
 
3
+ ## 1100.0.27
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/error@1100.1.2
9
+ - @pnpm/store.controller-types@1101.1.1
10
+
11
+ ## 1100.0.26
12
+
13
+ ### Patch Changes
14
+
15
+ - Fixed pnpm failing to start under asynchronous Node.js module loaders when no `.pnpmfile.mjs` exists [pnpm/pnpm#11701](https://github.com/pnpm/pnpm/issues/11701).
16
+
3
17
  ## 1100.0.25
4
18
 
5
19
  ### Patch Changes
@@ -16,6 +16,13 @@ export interface CookedHooks {
16
16
  customResolvers?: CustomResolver[];
17
17
  customFetchers?: CustomFetcher[];
18
18
  calculatePnpmfileChecksum?: () => Promise<string>;
19
+ /**
20
+ * Whether a `readPackage` hook came from a pnpmfile the checksum does not
21
+ * cover (the global pnpmfile) — its drift is invisible to
22
+ * `pnpmfileChecksum` comparisons, so nothing downstream may treat the
23
+ * checksum as proof the hooks are unchanged.
24
+ */
25
+ hasUntrackedReadPackageHook?: boolean;
19
26
  }
20
27
  export interface RequireHooksResult {
21
28
  hooks: CookedHooks;
@@ -73,6 +73,7 @@ export async function requireHooks(prefix, opts) {
73
73
  filterLog: [],
74
74
  updateConfig: [],
75
75
  };
76
+ cookedHooks.hasUntrackedReadPackageHook = entries.some((entry) => entry.hooks?.readPackage != null && !entry.includeInChecksum);
76
77
  // calculate combined checksum for all included files
77
78
  if (entries.some((entry) => entry.hooks != null)) {
78
79
  cookedHooks.calculatePnpmfileChecksum = async () => {
@@ -76,16 +76,21 @@ export async function requirePnpmfile(pnpmFilePath, prefix) {
76
76
  console.error(err);
77
77
  process.exit(1);
78
78
  }
79
- if (!util.types.isNativeError(err)) {
80
- throw new PnpmFileFailError(pnpmFilePath, toError(err));
79
+ if (isModuleNotFoundError(err) && !pnpmFileExistsSync(pnpmFilePath)) {
80
+ return undefined;
81
81
  }
82
- if (!('code' in err && (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_MODULE_NOT_FOUND')) ||
83
- pnpmFileExistsSync(pnpmFilePath)) {
84
- throw new PnpmFileFailError(pnpmFilePath, err);
85
- }
86
- return undefined;
82
+ throw new PnpmFileFailError(pnpmFilePath, toError(err));
87
83
  }
88
84
  }
85
+ /**
86
+ * Errors are matched by shape, not by class, because asynchronous module customization
87
+ * hooks forward them from their own realm, where `util.types.isNativeError()` returns false.
88
+ * See https://github.com/pnpm/pnpm/issues/11701
89
+ */
90
+ function isModuleNotFoundError(err) {
91
+ return typeof err === 'object' && err !== null && 'code' in err &&
92
+ (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_MODULE_NOT_FOUND');
93
+ }
89
94
  function pnpmFileExistsSync(pnpmFilePath) {
90
95
  const pnpmFileRealName = pnpmFilePath.endsWith('.cjs') || pnpmFilePath.endsWith('.mjs')
91
96
  ? pnpmFilePath
@@ -93,7 +98,7 @@ function pnpmFileExistsSync(pnpmFilePath) {
93
98
  return fs.existsSync(pnpmFileRealName);
94
99
  }
95
100
  function toError(err) {
96
- if (err instanceof Error)
101
+ if (util.types.isNativeError(err) || err instanceof Error)
97
102
  return err;
98
103
  try {
99
104
  return new Error(String(err), { cause: err });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/hooks.pnpmfile",
3
- "version": "1100.0.25",
3
+ "version": "1100.0.27",
4
4
  "description": "Reading a .pnpmfile.cjs",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -29,10 +29,10 @@
29
29
  "dependencies": {
30
30
  "@pnpm/core-loggers": "1100.3.2",
31
31
  "@pnpm/crypto.hash": "1100.0.2",
32
- "@pnpm/error": "1100.1.1",
32
+ "@pnpm/error": "1100.1.2",
33
33
  "@pnpm/hooks.types": "1100.2.6",
34
34
  "@pnpm/lockfile.types": "1100.0.19",
35
- "@pnpm/store.controller-types": "1101.1.0",
35
+ "@pnpm/store.controller-types": "1101.1.1",
36
36
  "@pnpm/types": "1101.9.0",
37
37
  "chalk": "^6.0.0",
38
38
  "path-absolute": "^2.0.0"
@@ -43,7 +43,7 @@
43
43
  "devDependencies": {
44
44
  "@jest/globals": "30.4.1",
45
45
  "@pnpm/fetching.fetcher-base": "1100.2.7",
46
- "@pnpm/hooks.pnpmfile": "1100.0.25",
46
+ "@pnpm/hooks.pnpmfile": "1100.0.27",
47
47
  "@pnpm/logger": "1100.0.0",
48
48
  "@pnpm/test-fixtures": "1100.0.1"
49
49
  },