-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
pnpmfile.js
67 lines (60 loc) · 2.3 KB
/
pnpmfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
/**
* When using the PNPM package manager, you can use pnpmfile.js to workaround
* dependencies that have mistakes in their package.json file. (This feature is
* functionally similar to Yarn's "resolutions".)
*
* For details, see the PNPM documentation:
* https://pnpm.js.org/docs/en/hooks.html
*
* IMPORTANT: SINCE THIS FILE CONTAINS EXECUTABLE CODE, MODIFYING IT IS LIKELY
* TO INVALIDATE ANY CACHED DEPENDENCY ANALYSIS. We recommend to run "rush update --full"
* after any modification to pnpmfile.js.
*
*/
module.exports = {
hooks: {
readPackage
}
};
/**
* This hook is invoked during installation before a package's dependencies
* are selected.
* The `packageJson` parameter is the deserialized package.json
* contents for the package that is about to be installed.
* The `context` parameter provides a log() function.
* The return value is the updated object.
*/
function readPackage(packageJson, context) {
if (packageJson.name === 'resemblejs' && packageJson.peerDependencies) {
// resemblejs requests canvas as a peer dependency, but our use case doesn't require canvas
// (and attempting to install it causes node-gyp build errors).
// So remove the peer dependency.
delete packageJson.peerDependencies['canvas'];
}
if (packageJson.name === 'awesome-typescript-loader') {
console.log(packageJson);
packageJson.dependencies['typescript'] = '^2 || ^3';
}
// TODO: temporary changes to test 3.5.0-rc. delete before fabric 7 release!
if (
packageJson.name === 'fork-ts-checker-webpack-plugin' ||
packageJson.name === 'riceburn' ||
packageJson.name === 'tslint-microsoft-contrib' ||
packageJson.name === 'tslint' ||
packageJson.name === 'tslint-react' ||
packageJson.name === 'tsutils'
) {
packageJson.dependencies['typescript'] = '3.5.0-dev.20190525';
}
// Example: Suppose the karma types have a missing dependency on typings from the log4js package.
// if (packageJson.name === '@types/karma') {
// context.log('Fixed up dependencies for @types/karma');
// packageJson.dependencies['log4js'] = '0.6.38';
// }
// Example: Suppose we want to replace the dependency `resolve`
// if (packageJson.dependencies.resolve) {
// packageJson.dependencies.resolve = 'zkochan/node-resolve'
// }
return packageJson;
}