forked from htmlburger/carbon-fields
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-packages.js
55 lines (49 loc) · 1.22 KB
/
wp-packages.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
/**
* The WordPress packages used across the code and exposed globally on `cf.vendor` variable.
*
* @type {string[]}
*/
module.exports.packages = [
'@wordpress/compose',
'@wordpress/element',
'@wordpress/hooks',
'@wordpress/data',
'@wordpress/i18n'
];
/**
* Get the packages as an external configuration.
*
* @type {string[]}
*/
module.exports.externals = module.exports.packages.reduce( ( externals, package ) => {
externals[ package ] = [
'wp',
package.replace( '@wordpress/', '' )
];
return externals;
}, {} );
/**
* Get the packages as an external configuration.
* This variant is useful for the classic bundles where we
* provide those dependencies manually.
*
* @type {string[]}
*/
module.exports.proxyExternals = module.exports.packages.reduce( ( externals, package ) => {
externals[ package ] = [
'cf',
'vendor',
package
];
return externals;
}, {} );
/**
* Get the packages as a provider configuration.
* The providers should be used in combination with `proxyExternals` configuration.
*
* @type {Object}
*/
module.exports.providers = module.exports.packages.reduce( ( providers, package ) => {
providers[ module.exports.externals[ package ].join( '.' ) ] = package;
return providers;
}, {} );