-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-extensions.ts
More file actions
61 lines (56 loc) · 1.57 KB
/
package-extensions.ts
File metadata and controls
61 lines (56 loc) · 1.57 KB
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
/**
* @fileoverview Package extensions for compatibility adjustments.
*
* Package extensions allow modifying package.json fields of dependencies
* to fix compatibility issues, missing peer dependencies, etc.
*/
import * as yarnPkgExtensions from './external/@yarnpkg/extensions'
const { freeze: ObjectFreeze } = Object
type PackageExtension = readonly [string, Record<string, unknown>]
const packageExtensions = ObjectFreeze(
(
[
/* c8 ignore next - External @yarnpkg/extensions data */
...yarnPkgExtensions.packageExtensions,
[
'@yarnpkg/extensions@>=1.1.0',
{
// Properties with undefined values are omitted when saved as JSON.
peerDependencies: undefined,
},
],
[
'abab@>=2.0.0',
{
devDependencies: {
// Lower the Webpack from v4.x to one supported by abab's peers.
webpack: '^3.12.0',
},
},
],
[
'is-generator-function@>=1.0.7',
{
scripts: {
// Make the script a silent no-op.
'test:uglified': '',
},
},
],
] as PackageExtension[]
).sort((a_, b_) => {
const aIndex = a_[0].lastIndexOf('@')
const bIndex = b_[0].lastIndexOf('@')
const a = aIndex === -1 ? a_[0] : a_[0].slice(0, aIndex)
const b = bIndex === -1 ? b_[0] : b_[0].slice(0, bIndex)
// Simulate the default compareFn of String.prototype.sort.
if (a < b) {
return -1
}
if (a > b) {
return 1
}
return 0
}),
)
export { packageExtensions }