@lipemat/js-boilerplate 6.5.0 → 7.0.0-beta.1
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/README.md +24 -15
- package/config/postcss.config.js +21 -13
- package/config/webpack.dev.js +1 -2
- package/helpers/config.js +1 -4
- package/package.json +6 -7
- package/scripts/fix-pnp.js +24 -17
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# The Start Of A Beautiful JS App
|
|
2
2
|
|
|
3
3
|
<p>
|
|
4
4
|
<a href="https://www.npmjs.com/package/@lipemat/js-boilerplate">
|
|
@@ -10,12 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
A zero configuration starting point for a React or non React app.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## Installation
|
|
14
14
|
```bash
|
|
15
15
|
yarn add @lipemat/js-boilerplate
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
## Version 6
|
|
19
|
+
|
|
20
|
+
**Version 6 has many backward incompatibilities and should be updated with focus and thoroughness.**
|
|
21
|
+
|
|
22
|
+
[Migration instructions are here.](https://github.com/lipemat/js-boilerplate/wiki/Version-6-Migration)
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
19
25
|
Add the following to your package.json. (this may also be found in the `templates` directory.
|
|
20
26
|
|
|
21
27
|
```json
|
|
@@ -39,25 +45,17 @@ Add the following to your package.json. (this may also be found in the `template
|
|
|
39
45
|
|
|
40
46
|
**_You may adjust things as needed but be sure to leave the `scripts` as is._**
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
## Version 6
|
|
44
|
-
|
|
45
|
-
**Version 6 has many backward incompatibilities and should be updated with focus and thoroughness.**
|
|
46
|
-
|
|
47
|
-
[Migration instructions are here.](https://github.com/lipemat/js-boilerplate/wiki/Version-6-Migration)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### Code Completion In PHPStorm
|
|
48
|
+
## Code Completion In PHPStorm
|
|
51
49
|
Some `@types` have been specified in this library to assist with code completion and allow using the built-in TypeScript support. Unfortunately, some typescripts still send errors to PHPStorm like "Default export is not declared in an imported module". I've found that it's easier to just remove this warning by un-checking `Editor -> Inspections -> JavaScript -> General -> Validate Imports`. (this may not need to be un-checked if you enable the built-in TypeScript support).
|
|
52
50
|
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
## ESLint
|
|
55
53
|
To use the built-in eslint, copy the following items from `templates` into your project root:
|
|
56
54
|
1. `.eslintrc`
|
|
57
55
|
|
|
58
56
|
Now you may adjust the eslint configuration as desired and run the linter via `yarn run lint`.
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
## Browserslist
|
|
61
59
|
To retrieve a list of all currently targeted browsers, add the following to your `package.json`
|
|
62
60
|
and run `yarn browserslist`.
|
|
63
61
|
|
|
@@ -72,7 +70,7 @@ and run `yarn browserslist`.
|
|
|
72
70
|
The console will display a list of browsers targeted by your [browserslist configruation](https://github.com/browserslist/browserslist#config-file), or the defaults if no configuration is specified.
|
|
73
71
|
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
## TypeScript
|
|
76
74
|
To use the built-in TypeScript, copy the following items from `templates` into your project root:
|
|
77
75
|
1. `tsconfig.json`
|
|
78
76
|
|
|
@@ -139,3 +137,14 @@ in your `package.json` to have it transformed.
|
|
|
139
137
|
]
|
|
140
138
|
}
|
|
141
139
|
```
|
|
140
|
+
|
|
141
|
+
## Certificates
|
|
142
|
+
If you are using https in your local environment, you may point to the certificates in your package.json like so:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
"certificates": {
|
|
146
|
+
"cert": "<path to -crt.pem file>",
|
|
147
|
+
"key": "<path to -key.pem file>"
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
package/config/postcss.config.js
CHANGED
|
@@ -18,6 +18,27 @@ const presetEnv = {
|
|
|
18
18
|
path.resolve( packageConfig.workingDirectory, 'src/globals/pcss/variables.css' ),
|
|
19
19
|
path.resolve( packageConfig.workingDirectory, '../pcss/globals/variables.css' ),
|
|
20
20
|
].filter( filePath => fs.existsSync( filePath ) ),
|
|
21
|
+
|
|
22
|
+
features: {
|
|
23
|
+
/**
|
|
24
|
+
* Fixes `focus-visible` feature for CSS modules (included by preset-env anywhere
|
|
25
|
+
* Safari is supported).
|
|
26
|
+
*
|
|
27
|
+
* Requires `focus-visible` polyfill to be loaded externally to support Safari.
|
|
28
|
+
*
|
|
29
|
+
* @link https://caniuse.com/css-focus-visible
|
|
30
|
+
*
|
|
31
|
+
* May be imported directly into index.js for SPA or site which loads JS app
|
|
32
|
+
* on every page.
|
|
33
|
+
* @link https://github.com/WICG/focus-visible
|
|
34
|
+
*
|
|
35
|
+
* Most often will need it site wide on pages which do and don't use the JS app.
|
|
36
|
+
* @link https://unpkg.com/focus-visible@5.2.0/dist/focus-visible.min.js
|
|
37
|
+
*/
|
|
38
|
+
'focus-visible-pseudo-class': {
|
|
39
|
+
replaceWith: ':global(.focus-visible)',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
21
42
|
};
|
|
22
43
|
|
|
23
44
|
/**
|
|
@@ -39,19 +60,6 @@ const config = {
|
|
|
39
60
|
postcssPresetEnv( presetEnv ),
|
|
40
61
|
require( 'postcss-color-mod-function' ),
|
|
41
62
|
require( '@lipemat/css-mqpacker' ),
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Requires `focus-visible` polyfill to be loaded externally to support Safari.
|
|
45
|
-
*
|
|
46
|
-
* @link https://caniuse.com/css-focus-visible
|
|
47
|
-
*
|
|
48
|
-
* May be imported directly into index.js for SPA or site which load JS app on every page.
|
|
49
|
-
* @link https://github.com/WICG/focus-visible
|
|
50
|
-
*
|
|
51
|
-
* Most often will need it site wide on pages which do and don't us the JS app.
|
|
52
|
-
* @link https://unpkg.com/focus-visible@5.2.0/dist/focus-visible.min.js
|
|
53
|
-
*/
|
|
54
|
-
require( 'postcss-focus-visible' )( {replaceWith: ':global(.focus-visible)'} ),
|
|
55
63
|
],
|
|
56
64
|
parser: 'postcss-scss',
|
|
57
65
|
};
|
package/config/webpack.dev.js
CHANGED
|
@@ -15,7 +15,6 @@ const plugins = [
|
|
|
15
15
|
jQuery: 'jquery',
|
|
16
16
|
$: 'jquery',
|
|
17
17
|
} ),
|
|
18
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
19
18
|
];
|
|
20
19
|
|
|
21
20
|
// Loads a thread which verifies any TypeScripts on changes.
|
|
@@ -95,7 +94,7 @@ module.exports = {
|
|
|
95
94
|
options: {
|
|
96
95
|
importLoaders: 1,
|
|
97
96
|
modules: true,
|
|
98
|
-
localIdentName: 'Ⓜ[name]__[local]__[contenthash:base64:
|
|
97
|
+
localIdentName: 'Ⓜ[name]__[local]__[contenthash:base64:2]',
|
|
99
98
|
sourceMap: true,
|
|
100
99
|
url: false,
|
|
101
100
|
},
|
package/helpers/config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const packageConfig = require( './package-config' );
|
|
2
2
|
const path = require( 'path' );
|
|
3
|
-
const without = require( 'lodash/without' );
|
|
4
3
|
const once = require( 'lodash/once' );
|
|
5
4
|
const browserslist = require( 'browserslist' );
|
|
6
5
|
|
|
@@ -90,9 +89,7 @@ const getDefaultBrowsersList = once( () => {
|
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
if ( browserslist( browserslist.defaults ) === browserslist() ) {
|
|
93
|
-
|
|
94
|
-
browsers.push( 'not IE 11' );
|
|
95
|
-
return without( browsers, 'ie >= 11' );
|
|
92
|
+
return require( '@wordpress/browserslist-config' );
|
|
96
93
|
}
|
|
97
94
|
return false;
|
|
98
95
|
} );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lipemat/js-boilerplate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.1",
|
|
4
4
|
"description": "Dependencies and scripts for a no config JavaScript app",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.15.3"
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"@lipemat/postcss-loader": "^3.1.2",
|
|
41
41
|
"@lipemat/webpack-cleanup-plugin": "^1.0.0",
|
|
42
42
|
"@types/lipemat__js-boilerplate": "lipemat/types-js-boilerplate#semver:^1.3.0",
|
|
43
|
-
"@wordpress/browserslist-config": "^
|
|
43
|
+
"@wordpress/browserslist-config": "^4.1.0",
|
|
44
44
|
"are-you-es5": "^2.1.1",
|
|
45
45
|
"babel-jest": "^24.7.1",
|
|
46
|
-
"babel-loader": "^8.
|
|
47
|
-
"browserslist": "^4.
|
|
46
|
+
"babel-loader": "^8.2.2",
|
|
47
|
+
"browserslist": "^4.17.0",
|
|
48
48
|
"classnames": "^2.2.6",
|
|
49
49
|
"core-js": "^3.8.3",
|
|
50
50
|
"cross-spawn": "^6.0.5",
|
|
51
|
-
"css-loader": "2.
|
|
51
|
+
"css-loader": "6.2.0",
|
|
52
52
|
"enzyme": "^3.9.0",
|
|
53
53
|
"enzyme-adapter-react-16": "^1.12.1",
|
|
54
54
|
"enzyme-to-json": "^3.5.0",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"postcss-clean": "^1.1.0",
|
|
64
64
|
"postcss-color-mod-function": "^3.0.3",
|
|
65
65
|
"postcss-custom-media": "^6.0.0",
|
|
66
|
-
"postcss-focus-visible": "^5.0.0",
|
|
67
66
|
"postcss-import": "^12.0.1",
|
|
68
67
|
"postcss-nested": "^4.1.2",
|
|
69
68
|
"postcss-preset-env": "^6.6.0",
|
|
@@ -74,7 +73,7 @@
|
|
|
74
73
|
"react-hot-loader": "^4.8.3",
|
|
75
74
|
"react-test-renderer": "^16.5.2",
|
|
76
75
|
"react-transition-group": "^4.4.1",
|
|
77
|
-
"style-loader": "^2.
|
|
76
|
+
"style-loader": "^3.2.1",
|
|
78
77
|
"typescript": "^4.2.4",
|
|
79
78
|
"update-notifier": "^4.1.3",
|
|
80
79
|
"webpack": "^5.11.0",
|
package/scripts/fix-pnp.js
CHANGED
|
@@ -9,30 +9,37 @@
|
|
|
9
9
|
* all loose module warnings unless the environmental variable
|
|
10
10
|
* it set to display all warnings.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
12
|
+
* @example "scripts": {
|
|
13
13
|
"postinstall": "lipemat-js-boilerplate fix-pnp"
|
|
14
14
|
},
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
const fs = require( 'fs' );
|
|
19
|
-
const PNP_FILE = './.pnp.js';
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const PNP_FILES = [
|
|
21
|
+
'./.pnp.js',
|
|
22
|
+
'./.pnp.cjs',
|
|
23
|
+
];
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
PNP_FILES.forEach( PNP_FILE => {
|
|
26
|
+
if ( fs.existsSync( PNP_FILE ) ) {
|
|
27
|
+
fs.readFile( PNP_FILE, 'utf8', ( readError, data ) => {
|
|
28
|
+
if ( readError ) {
|
|
29
|
+
return console.log( readError );
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} );
|
|
36
|
-
} );
|
|
32
|
+
const result = data.replace( /if \(reference != null\) {/, '// # Warnings suppressed via @lipemat/js-boilerplate/fix-pnp script. \n' +
|
|
33
|
+
'if (! alwaysWarnOnFallback && reference != null) { \n' +
|
|
34
|
+
'dependencyReference = reference; \n' +
|
|
35
|
+
'} else if (alwaysWarnOnFallback && reference != null) {' );
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
fs.writeFile( PNP_FILE, result, 'utf8', writeError => {
|
|
38
|
+
if ( writeError ) {
|
|
39
|
+
return console.log( writeError );
|
|
40
|
+
}
|
|
41
|
+
console.log( `The ${PNP_FILE} file has been adjusted to no longer display warnings for loose modules.` );
|
|
42
|
+
} );
|
|
43
|
+
} );
|
|
44
|
+
}
|
|
45
|
+
} );
|