@lipemat/js-boilerplate 8.2.1 → 8.4.0
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/config/babel.config.js +1 -5
- package/helpers/config.js +35 -6
- package/package.json +4 -5
package/config/babel.config.js
CHANGED
|
@@ -9,10 +9,7 @@ const presetEnv = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* except for IE11 which we don't support by default.
|
|
14
|
-
*
|
|
15
|
-
* @link https://babeljs.io/docs/en/babel-preset-env#targets
|
|
12
|
+
* Use shared browserslist configurations.
|
|
16
13
|
*/
|
|
17
14
|
if ( getDefaultBrowsersList() ) {
|
|
18
15
|
presetEnv.targets = getDefaultBrowsersList();
|
|
@@ -30,4 +27,3 @@ module.exports = {
|
|
|
30
27
|
'react-hot-loader/babel',
|
|
31
28
|
],
|
|
32
29
|
};
|
|
33
|
-
|
package/helpers/config.js
CHANGED
|
@@ -8,7 +8,7 @@ const extensions = Object.keys( packageConfig.dependencies ).filter( name => nam
|
|
|
8
8
|
/**
|
|
9
9
|
* Check to see if a local config file exists.
|
|
10
10
|
*
|
|
11
|
-
* @param {string}
|
|
11
|
+
* @param {string} fileName
|
|
12
12
|
* @param {boolean} inWorkingDirectory - Look in working directory instead of their /config directory
|
|
13
13
|
*
|
|
14
14
|
* @return {boolean}
|
|
@@ -37,6 +37,22 @@ function hasLocalOverride( fileName, inWorkingDirectory = false ) {
|
|
|
37
37
|
* we will merge the contents with our config/babel.config.js in favor of whatever
|
|
38
38
|
* is specified with the project's file.
|
|
39
39
|
*
|
|
40
|
+
* If the `module.exports` are a function, the existing configuration will be passed
|
|
41
|
+
* as the only argument. Otherwise, standard `module.exports` are also supported.
|
|
42
|
+
*
|
|
43
|
+
* @example ```ts
|
|
44
|
+
* // standard
|
|
45
|
+
* module.export = {
|
|
46
|
+
* externals: {extra: 'Extra'}
|
|
47
|
+
* }
|
|
48
|
+
* // function
|
|
49
|
+
* module.exports = function( config ) {
|
|
50
|
+
* return {
|
|
51
|
+
* externals: {...config.externals, extra: 'Extra'}
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
40
56
|
* @param {string} $fileName
|
|
41
57
|
*
|
|
42
58
|
* @return {Object}
|
|
@@ -45,7 +61,11 @@ function getConfig( $fileName ) {
|
|
|
45
61
|
let config = {...require( '../config/' + $fileName ), ...getExtensionsConfig( $fileName )};
|
|
46
62
|
try {
|
|
47
63
|
const localConfig = require( path.resolve( packageConfig.packageDirectory + '/config', $fileName ) );
|
|
48
|
-
|
|
64
|
+
if ( 'function' === typeof localConfig ) {
|
|
65
|
+
config = {...config, ...localConfig( config )};
|
|
66
|
+
} else {
|
|
67
|
+
config = {...config, ...localConfig};
|
|
68
|
+
}
|
|
49
69
|
} catch ( e ) {
|
|
50
70
|
}
|
|
51
71
|
return config;
|
|
@@ -55,6 +75,8 @@ function getConfig( $fileName ) {
|
|
|
55
75
|
* Get a config from any existing extension's /config directories
|
|
56
76
|
* merged into one.
|
|
57
77
|
*
|
|
78
|
+
* @see getConfig
|
|
79
|
+
*
|
|
58
80
|
* @param {string} $fileName
|
|
59
81
|
*
|
|
60
82
|
* @return {Object}
|
|
@@ -64,7 +86,11 @@ function getExtensionsConfig( $fileName ) {
|
|
|
64
86
|
extensions.forEach( extension => {
|
|
65
87
|
try {
|
|
66
88
|
const extensionConfig = require( extension + '/config/' + $fileName );
|
|
67
|
-
|
|
89
|
+
if ( 'function' === typeof extensionConfig ) {
|
|
90
|
+
config = {...config, ...extensionConfig( config )};
|
|
91
|
+
} else {
|
|
92
|
+
config = {...config, ...extensionConfig};
|
|
93
|
+
}
|
|
68
94
|
} catch ( e ) {
|
|
69
95
|
}
|
|
70
96
|
} );
|
|
@@ -73,8 +99,8 @@ function getExtensionsConfig( $fileName ) {
|
|
|
73
99
|
}
|
|
74
100
|
|
|
75
101
|
/**
|
|
76
|
-
* If browserslist is not specified, we
|
|
77
|
-
* except for
|
|
102
|
+
* If browserslist is not specified, we fall back to WordPress defaults
|
|
103
|
+
* except for > 1% we don't support by default.
|
|
78
104
|
*
|
|
79
105
|
* Return false if a browserslist is specified in the current project.
|
|
80
106
|
*
|
|
@@ -89,7 +115,10 @@ const getDefaultBrowsersList = once( () => {
|
|
|
89
115
|
}
|
|
90
116
|
|
|
91
117
|
if ( browserslist( browserslist.defaults ) === browserslist() ) {
|
|
92
|
-
return require( '@wordpress/browserslist-config' )
|
|
118
|
+
return require( '@wordpress/browserslist-config' ).map( range => {
|
|
119
|
+
// Swap out "> 1%" for "> 2%".
|
|
120
|
+
return '> 1%' === range ? '> 2%' : range;
|
|
121
|
+
} );
|
|
93
122
|
}
|
|
94
123
|
return false;
|
|
95
124
|
} );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lipemat/js-boilerplate",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Dependencies and scripts for a no config JavaScript app",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.17.6"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@lipemat/postcss-loader": "^3.1.2",
|
|
42
42
|
"@lipemat/webpack-cleanup-plugin": "^1.0.0",
|
|
43
43
|
"@types/lipemat__js-boilerplate": "lipemat/types-js-boilerplate#semver:^1.3.0",
|
|
44
|
-
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.
|
|
44
|
+
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
|
|
45
45
|
"@wordpress/browserslist-config": "^4.1.0",
|
|
46
46
|
"are-you-es5": "^2.1.1",
|
|
47
47
|
"babel-jest": "^24.7.1",
|
|
@@ -67,14 +67,13 @@
|
|
|
67
67
|
"postcss-nested": "^4.1.2",
|
|
68
68
|
"postcss-preset-env": "^6.6.0",
|
|
69
69
|
"postcss-scss": "^2.0.0",
|
|
70
|
-
"prop-types": "^15.7.2",
|
|
71
70
|
"react": "^17.0.1",
|
|
72
71
|
"react-dom": "^17.0.1",
|
|
73
72
|
"react-hot-loader": "^4.8.3",
|
|
74
73
|
"react-test-renderer": "^17.0.2",
|
|
75
74
|
"react-transition-group": "^4.4.1",
|
|
76
75
|
"style-loader": "^3.2.1",
|
|
77
|
-
"typescript": "
|
|
76
|
+
"typescript": "^4.2.4",
|
|
78
77
|
"update-notifier": "^4.1.3",
|
|
79
78
|
"webpack": "^5.65.0",
|
|
80
79
|
"webpack-assets-manifest": "^5.0.6",
|
|
@@ -86,5 +85,5 @@
|
|
|
86
85
|
"url": "https://github.com/lipemat/js-boilerplate/issues"
|
|
87
86
|
},
|
|
88
87
|
"homepage": "https://github.com/lipemat/js-boilerplate#readme",
|
|
89
|
-
"packageManager": "yarn@3.
|
|
88
|
+
"packageManager": "yarn@3.2.0"
|
|
90
89
|
}
|