@dr.pogodin/react-utils 1.8.5 → 1.10.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/bin/build.js +0 -129
- package/bin/release.sh +1 -1
- package/bin/setup.js +0 -44
- package/build/development/client/index.js +0 -6
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +3 -1
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +14 -19
- package/build/development/index.js.map +1 -1
- package/build/development/server/index.js +1 -51
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +10 -4
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +1 -1
- package/build/development/server/utils/errors.js +3 -3
- package/build/development/shared/components/Button/index.js +7 -42
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +7 -14
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/CodeSplit/index.js +9 -66
- package/build/development/shared/components/CodeSplit/index.js.map +1 -1
- package/build/development/shared/components/Dropdown/index.js +9 -35
- package/build/development/shared/components/Dropdown/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +1 -23
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +6 -19
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/MetaTags.js +0 -21
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +5 -39
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +0 -10
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +6 -31
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/ScalableRect/index.js +2 -8
- package/build/development/shared/components/ScalableRect/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +10 -22
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +7 -13
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +9 -15
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +18 -18
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/utils/config.js +0 -22
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/index.js +11 -29
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy.js +3 -44
- package/build/development/shared/utils/isomorphy.js.map +1 -1
- package/build/development/shared/utils/jest.js +12 -126
- package/build/development/shared/utils/jest.js.map +1 -1
- package/build/development/shared/utils/url.js +1 -1
- package/build/development/shared/utils/webpack.js +0 -4
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/development/style.css +149 -149
- package/build/development/web.bundle.js +33 -33
- package/build/production/client/index.js +0 -6
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js +2 -1
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js +2 -11
- package/build/production/index.js.map +1 -1
- package/build/production/server/index.js +1 -49
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +2 -2
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +1 -1
- package/build/production/server/utils/errors.js +1 -1
- package/build/production/shared/components/Button/index.js +2 -37
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +2 -9
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/CodeSplit/index.js +2 -65
- package/build/production/shared/components/CodeSplit/index.js.map +1 -1
- package/build/production/shared/components/Dropdown/index.js +2 -24
- package/build/production/shared/components/Dropdown/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +1 -23
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +2 -13
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/MetaTags.js +0 -21
- package/build/production/shared/components/MetaTags.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +2 -34
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +1 -10
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +2 -25
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/ScalableRect/index.js +1 -7
- package/build/production/shared/components/ScalableRect/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -13
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +1 -7
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +1 -7
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/utils/config.js +1 -21
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/index.js +1 -20
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy.js +1 -40
- package/build/production/shared/utils/isomorphy.js.map +1 -1
- package/build/production/shared/utils/jest.js +2 -112
- package/build/production/shared/utils/jest.js.map +1 -1
- package/build/production/shared/utils/url.js +1 -1
- package/build/production/shared/utils/webpack.js +0 -4
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/production/style.css +1 -1
- package/build/production/style.css.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/config/babel/node-ssr.js +1 -8
- package/config/babel/webpack.js +1 -8
- package/config/jest/default.js +0 -34
- package/config/shared/utils.js +9 -100
- package/config/stylelint/default.js +2 -19
- package/config/webpack/app-base.js +3 -6
- package/config/webpack/app-development.js +0 -23
- package/config/webpack/app-production.js +0 -20
- package/config/webpack/lib-base.js +3 -66
- package/config/webpack/lib-development.js +0 -10
- package/config/webpack/lib-production.js +0 -9
- package/index.js +21 -10
- package/package.json +34 -36
- package/src/index.js +6 -61
- package/src/styles/_mixins/fonts.scss +4 -4
- package/src/styles/mixins.scss +1 -1
- package/build/development/styles/global-docs.js +0 -29
- package/build/development/styles/global-docs.js.map +0 -1
- package/build/development/styles/mixins.js +0 -103
- package/build/development/styles/mixins.js.map +0 -1
- package/build/production/styles/global-docs.js +0 -28
- package/build/production/styles/global-docs.js.map +0 -1
- package/build/production/styles/mixins.js +0 -101
- package/build/production/styles/mixins.js.map +0 -1
- package/config/eslint/docs.js +0 -40
- package/config/jsdoc/config.js +0 -34
- package/src/README.md +0 -130
package/config/babel/webpack.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @module babel/webpack
|
|
4
|
-
* @desc [Babel](https://babeljs.io/) preset for Webpack builds.
|
|
2
|
+
* [Babel](https://babeljs.io/) preset for Webpack builds.
|
|
5
3
|
*
|
|
6
4
|
* To include it into a Babel configuration:
|
|
7
5
|
* ```json
|
|
@@ -139,11 +137,6 @@ function addStyling(config, env) {
|
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
/**
|
|
142
|
-
* @static
|
|
143
|
-
* @desc
|
|
144
|
-
* ```js
|
|
145
|
-
* import getPreset from '@dr.pogodin/react-utils/config/babel/webpack';
|
|
146
|
-
* ```
|
|
147
140
|
* Generates Babel preset for Webpack.
|
|
148
141
|
* @param {object} babel Babel compiler.
|
|
149
142
|
* @param {object} [ops] Preset options.
|
package/config/jest/default.js
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @category Configs
|
|
3
|
-
* @module jest
|
|
4
|
-
* @desc Configuration for [Jest](https://facebook.github.io/jest/)
|
|
5
|
-
* (JavaScript testing framework).
|
|
6
|
-
*
|
|
7
|
-
* **Beware:** It assumes you use recommended code structure in the project
|
|
8
|
-
* using it: Jest configs in `config/jest` folder, the source code in `src`
|
|
9
|
-
* folder, the build outputs in `build` folder, _etc._ With a different
|
|
10
|
-
* project structure, it might be easier to compose necessary Jest config
|
|
11
|
-
* from scratch.
|
|
12
|
-
*
|
|
13
|
-
* To set up create these two files in `config/jest` folder of your project:
|
|
14
|
-
* ```js
|
|
15
|
-
* // config/jest/config.js
|
|
16
|
-
*
|
|
17
|
-
* const config = require('@dr.pogodin/react-utils/config/jest/default');
|
|
18
|
-
* // You can tune config as necessary here.
|
|
19
|
-
* module.exports = config;
|
|
20
|
-
* ```
|
|
21
|
-
* ```js
|
|
22
|
-
* // config/jest/setup.js
|
|
23
|
-
*
|
|
24
|
-
* import '@dr.pogodin/react-utils/config/jest/setup';
|
|
25
|
-
* ```
|
|
26
|
-
* Then point that config in Jest command, like so:
|
|
27
|
-
* ```
|
|
28
|
-
* jest --config config/jest/config.js
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* The current Jest environment setup script provided by `react-utils`
|
|
32
|
-
* only loads `raf/polyfill`, required by React.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
1
|
const path = require('path');
|
|
36
2
|
|
|
37
3
|
const globalLibDir = path.resolve(process.execPath, '../../lib/node_modules');
|
package/config/shared/utils.js
CHANGED
|
@@ -1,111 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Misc utilities reusable in different JS-format config files.
|
|
3
3
|
*/
|
|
4
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const {
|
|
6
|
+
generateScopedNameFactory,
|
|
7
|
+
} = require('@dr.pogodin/babel-plugin-react-css-modules/utils');
|
|
9
8
|
|
|
10
|
-
const
|
|
9
|
+
const generateScopedNameDev = generateScopedNameFactory(
|
|
10
|
+
'[package]___[path][name]___[local]___[hash:base64:6]',
|
|
11
|
+
);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param {string} file
|
|
16
|
-
* @return {string}
|
|
17
|
-
*/
|
|
18
|
-
function normalizePath(file) {
|
|
19
|
-
return path.sep === '\\' ? file.replace(/\\/g, '/') : file;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// eslint-disable-next-line no-control-regex
|
|
23
|
-
const filenameReservedRegex = /[<>:"/\\|?*]/g;
|
|
24
|
-
// eslint-disable-next-line no-control-regex
|
|
25
|
-
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g;
|
|
26
|
-
|
|
27
|
-
function escapeLocalident(localident) {
|
|
28
|
-
return cssesc(
|
|
29
|
-
localident
|
|
30
|
-
// For `[hash]` placeholder
|
|
31
|
-
.replace(/^((-?[0-9])|--)/, '_$1')
|
|
32
|
-
.replace(filenameReservedRegex, '-')
|
|
33
|
-
.replace(reControlChars, '-')
|
|
34
|
-
.replace(/\./g, '-'),
|
|
35
|
-
{ isIdentifier: true },
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Returns the name of package containing the folder; i.e. it recursively looks
|
|
41
|
-
* up from the folder for the closest package.json file, and returns the name in
|
|
42
|
-
* that file. It also caches the results from previously fisited folders.
|
|
43
|
-
* @ignore
|
|
44
|
-
* @param {string} folder
|
|
45
|
-
* @return {string}
|
|
46
|
-
*/
|
|
47
|
-
function getPackageInfo(folder) {
|
|
48
|
-
let res = getPackageInfo.cache[folder];
|
|
49
|
-
if (!res) {
|
|
50
|
-
const p = path.resolve(folder, 'package.json');
|
|
51
|
-
/* eslint-disable global-require, import/no-dynamic-require */
|
|
52
|
-
res = fs.existsSync(p) ? {
|
|
53
|
-
name: require(p).name,
|
|
54
|
-
root: folder,
|
|
55
|
-
} : getPackageInfo(path.resolve(folder, '..'));
|
|
56
|
-
/* eslint-enable global-require, import/no-dynamic-require */
|
|
57
|
-
getPackageInfo.cache[folder] = res;
|
|
58
|
-
}
|
|
59
|
-
return res;
|
|
60
|
-
}
|
|
61
|
-
getPackageInfo.cache = {};
|
|
62
|
-
|
|
63
|
-
function getLocalIdent(
|
|
64
|
-
{ resourcePath },
|
|
65
|
-
localIdentName,
|
|
66
|
-
localName,
|
|
67
|
-
options = {},
|
|
68
|
-
) {
|
|
69
|
-
const packageInfo = getPackageInfo(path.dirname(resourcePath));
|
|
70
|
-
const request = normalizePath(path.relative(packageInfo.root, resourcePath));
|
|
71
|
-
return interpolateName({
|
|
72
|
-
resourcePath,
|
|
73
|
-
}, localIdentName, {
|
|
74
|
-
...options,
|
|
75
|
-
content: `${packageInfo.name + request}\x00${localName}`,
|
|
76
|
-
context: packageInfo.root,
|
|
77
|
-
}).replace(/\[package\]/gi, packageInfo.name)
|
|
78
|
-
.replace(/\[local\]/gi, localName)
|
|
79
|
-
.replace(/@/g, '-');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function generateScopedNameDev(localName, assetPath) {
|
|
83
|
-
// Mind: "css-loader" additionally escapes identifiers returned by
|
|
84
|
-
// getLocalIdent(); the babel plugins - don't, thus we need to escape
|
|
85
|
-
// ourselves.
|
|
86
|
-
return escapeLocalident(
|
|
87
|
-
getLocalIdent(
|
|
88
|
-
{ resourcePath: assetPath },
|
|
89
|
-
'[package]___[path][name]___[local]___[hash:base64:6]',
|
|
90
|
-
localName,
|
|
91
|
-
{},
|
|
92
|
-
),
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function generateScopedNameProd(localName, assetPath) {
|
|
97
|
-
return escapeLocalident(
|
|
98
|
-
getLocalIdent(
|
|
99
|
-
{ resourcePath: assetPath },
|
|
100
|
-
'[hash:base64:6]',
|
|
101
|
-
localName,
|
|
102
|
-
{},
|
|
103
|
-
),
|
|
104
|
-
);
|
|
105
|
-
}
|
|
13
|
+
const generateScopedNameProd = generateScopedNameFactory(
|
|
14
|
+
'[hash:base64:6]',
|
|
15
|
+
);
|
|
106
16
|
|
|
107
17
|
module.exports = {
|
|
108
18
|
generateScopedNameDev,
|
|
109
19
|
generateScopedNameProd,
|
|
110
|
-
getLocalIdent,
|
|
111
20
|
};
|
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @category Configs
|
|
3
|
-
* @module stylelint
|
|
4
|
-
* @desc
|
|
5
|
-
* Configuration for [Stylelint](https://stylelint.io) (SCSS code linter).
|
|
6
|
-
* At the moment a single Stylelint configuration is provided by `react-utils`,
|
|
7
|
-
* and it just matches the
|
|
8
|
-
* [standard Stylelint config](https://github.com/stylelint/stylelint-config-standard)
|
|
9
|
-
* with a few extra options to ignore some valid rules and selectors not known
|
|
10
|
-
* to Stylelint: `@content`, `@extend`, `@for`, `@include`, `@mixin`, `:global`.
|
|
11
|
-
*
|
|
12
|
-
* To use it, just create the following `.stylelintrc`:
|
|
13
|
-
* ```json
|
|
14
|
-
* {
|
|
15
|
-
* "extends": "./node_modules/@dr.pogodin/react-utils/config/stylelint/default"
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
1
|
module.exports = {
|
|
20
|
-
extends: 'stylelint-config-standard',
|
|
2
|
+
extends: 'stylelint-config-standard-scss',
|
|
21
3
|
rules: {
|
|
22
4
|
'at-rule-no-unknown': [true, {
|
|
23
5
|
ignoreAtRules: [
|
|
@@ -30,6 +12,7 @@ module.exports = {
|
|
|
30
12
|
'use',
|
|
31
13
|
],
|
|
32
14
|
}],
|
|
15
|
+
'selector-class-pattern': null,
|
|
33
16
|
'selector-pseudo-class-no-unknown': [
|
|
34
17
|
true, { ignorePseudoClasses: ['global'] },
|
|
35
18
|
],
|
|
@@ -15,14 +15,11 @@ const SM = require('sitemap');
|
|
|
15
15
|
const { DefinePlugin, ProgressPlugin } = require('webpack');
|
|
16
16
|
const WorkboxPlugin = require('workbox-webpack-plugin');
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
getLocalIdent,
|
|
20
|
+
} = require('@dr.pogodin/babel-plugin-react-css-modules/utils');
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
|
-
* @func configFactory
|
|
22
|
-
* @desc
|
|
23
|
-
* ```js
|
|
24
|
-
* const configFactory = require('@dr.pogodin/react-utils/config/webpack/app-base');
|
|
25
|
-
* ```
|
|
26
23
|
* Creates a new Webpack config object, and performs some auxiliary operations
|
|
27
24
|
* on the way.
|
|
28
25
|
* @param {object} ops Configuration params. This allows to modify some
|
|
@@ -13,29 +13,6 @@ const { merge } = require('webpack-merge');
|
|
|
13
13
|
|
|
14
14
|
const baseFactory = require('./app-base');
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* @func configFactory
|
|
18
|
-
* @desc
|
|
19
|
-
* ```js
|
|
20
|
-
* const configFactory = require('@dr.pogodin/react-utils/config/webpack/app-development');
|
|
21
|
-
* ```
|
|
22
|
-
* Creates development Webpack configuration for applications. It is based on
|
|
23
|
-
* {@link module:webpack/app-base webpack/app-base}, and differs form that in
|
|
24
|
-
* the following:
|
|
25
|
-
* - *development* Babel environment is enforced, and sets
|
|
26
|
-
* `[path][name]___[local]___[hash:base64:6]` as the default value of
|
|
27
|
-
* `cssLocalIdent` argument for the base config.
|
|
28
|
-
* - [`webpack-hot-middleware/client?reload=true`](https://github.com/glenjamin/webpack-hot-middleware)
|
|
29
|
-
* - Emulates the following environment variables:
|
|
30
|
-
* - **`BABEL_ENV`** — It is set to *development* to inform any
|
|
31
|
-
* interested code that it is running in dev mode;
|
|
32
|
-
* - **`NODE_ENV`** — It is set to *development*.
|
|
33
|
-
* - Adds the following plugins:
|
|
34
|
-
* - [HotModuleReplacementPlugin](https://webpack.js.org/plugins/hot-module-replacement-plugin/);
|
|
35
|
-
* - [NamedModulesPlugin](https://webpack.js.org/plugins/named-modules-plugin/).
|
|
36
|
-
* @param {object} ops Config options, the saeme options as in the base config
|
|
37
|
-
* are accepted.
|
|
38
|
-
*/
|
|
39
16
|
module.exports = function configFactory(ops) {
|
|
40
17
|
const o = _.defaults(_.clone(ops), {
|
|
41
18
|
cssLocalIdent: '[package]___[path][name]___[local]___[hash:base64:6]',
|
|
@@ -10,26 +10,6 @@ const webpack = require('webpack');
|
|
|
10
10
|
const { merge } = require('webpack-merge');
|
|
11
11
|
const baseFactory = require('./app-base');
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* @func factoryConfig
|
|
15
|
-
* @desc
|
|
16
|
-
* ```js
|
|
17
|
-
* const configFactory = require('@dr.pogodin/react-utils/config/webpack/app-production');
|
|
18
|
-
* ```
|
|
19
|
-
* Creates a new production Webpack config, and performs some auxiliary
|
|
20
|
-
* operations on the way. This configuration is based on
|
|
21
|
-
* {@link module:webpack/app-base webpack/app-base}
|
|
22
|
-
* and it differs from that in the following:
|
|
23
|
-
* - *production* Babel environment is enforced;
|
|
24
|
-
* - Emulates the following environment variables:
|
|
25
|
-
* - **`BABEL_ENV`** — It is set to *production*;
|
|
26
|
-
* - **`NODE_ENV`** — It is set to *production*.
|
|
27
|
-
* - Adds the following plugins:
|
|
28
|
-
* - [CSS Minimizer Webpack Plugin](https://www.npmjs.com/package/css-minimizer-webpack-plugin);
|
|
29
|
-
* - [UglifyJsPlugin](https://webpack.js.org/plugins/uglifyjs-webpack-plugin/).
|
|
30
|
-
* @param {object} ops Accepts same options as the base config.
|
|
31
|
-
* @return {object}
|
|
32
|
-
*/
|
|
33
13
|
module.exports = function configFactory(ops) {
|
|
34
14
|
const entry = [
|
|
35
15
|
'@dr.pogodin/react-utils/build/production/client/init',
|
|
@@ -9,73 +9,10 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const { ProgressPlugin } = require('webpack');
|
|
11
11
|
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
getLocalIdent,
|
|
14
|
+
} = require('@dr.pogodin/babel-plugin-react-css-modules/utils');
|
|
13
15
|
|
|
14
|
-
/**
|
|
15
|
-
* @func configFactory
|
|
16
|
-
* @desc
|
|
17
|
-
* ```js
|
|
18
|
-
* const configFactory = require('@dr.pogodin/react-utils/config/webpack/lib-base');
|
|
19
|
-
* ```
|
|
20
|
-
* Creates a new Webpack config object.
|
|
21
|
-
* @param {object} ops Configuration params. This allows to conveniently set
|
|
22
|
-
* options that should be customized for specific libraries.
|
|
23
|
-
* @param {string} ops.babelEnv Babel environment to use for Babel compilation
|
|
24
|
-
* step;
|
|
25
|
-
* @param {object} [ops.babelLoaderOptions] Overrides for default Babel options
|
|
26
|
-
* of JSX and SVG files loader.
|
|
27
|
-
* @param {string} ops.context Base URL for resolution of relative config paths.
|
|
28
|
-
* @param {string} [ops.cssLocalIdent=hash:base64:6] The template for CSS
|
|
29
|
-
* classnames generation by the Webpack's css-loader; it is passed into
|
|
30
|
-
* the localIdentName param of the loader. It should match the corresponding
|
|
31
|
-
* setting in the Babel config.
|
|
32
|
-
* @param {string|string[]} ops.entry Entry point(s). The config may prepend
|
|
33
|
-
* them by necessary polyfills.
|
|
34
|
-
* @param {string} ops.library Name of the library to be build. It is important
|
|
35
|
-
* for proper resolution of the library assets.
|
|
36
|
-
* @param {string} [ops.outputPath=build] Output path.
|
|
37
|
-
* @param {string} [ops.mode] [Webpack mode](https://webpack.js.org/concepts/mode/).
|
|
38
|
-
* @return {Object}
|
|
39
|
-
* - The generated config will opt to:
|
|
40
|
-
* - References to the font assets (EOF, OTF, SVG, TTF, WOFF, WOFF2 files from
|
|
41
|
-
* the `src/assets/fonts` folder of the library source code) will rewritten
|
|
42
|
-
* to `LIBRARY_NAME/src/assets/fonts/FILENAME.FILE_EXTENSION`
|
|
43
|
-
* so that the host package of the library will be able to find and bundle
|
|
44
|
-
* them;
|
|
45
|
-
* - Bundle SCSS files from any folder of your source code, beside
|
|
46
|
-
* `node_modules` and its subfolders. The files will be compiled,
|
|
47
|
-
* bundled and extracted into the `build/{type}/style.css`
|
|
48
|
-
* bundles;
|
|
49
|
-
* - Bundle JS, JSX, and SVG files; they will be compiled into the
|
|
50
|
-
* `build/{type}/web.bundle.js` bundles, using the Babel environment
|
|
51
|
-
* specified in the factory options, and
|
|
52
|
-
* [`config/babel/webpack`](./babel-config.js#webpack) config.
|
|
53
|
-
*
|
|
54
|
-
* - The following path aliases will be automatically set:
|
|
55
|
-
* - **`assets`** for `[CONTEXT]/src/assets`;
|
|
56
|
-
* - **`components`** for `[CONTEXT]/src/shared/components`;
|
|
57
|
-
* - **`fonts`** for `[CONTEXT]/src/assets/fonts`;
|
|
58
|
-
* - **`styles`** for `[CONTEXT]/src/styles`.
|
|
59
|
-
*
|
|
60
|
-
* Also `resolve.symlinks` Webpack option is set to *false* to avoid problems
|
|
61
|
-
* with resolution of assets from packages linked with `npm link`.
|
|
62
|
-
*
|
|
63
|
-
* - The following packages are declared as externals:
|
|
64
|
-
* - `@babel/runtime`
|
|
65
|
-
* - `@dr.pogodin/react-global-state`
|
|
66
|
-
* - `@dr.pogodin/react-themes`
|
|
67
|
-
* - `@dr.pogodin/react-utils`
|
|
68
|
-
* - `axios`
|
|
69
|
-
* - `dayjs`
|
|
70
|
-
* - `lodash`
|
|
71
|
-
* - `prop-types`
|
|
72
|
-
* - `react`
|
|
73
|
-
* - `react-dom`
|
|
74
|
-
* - `react-helmet`
|
|
75
|
-
* - `react-router-dom`
|
|
76
|
-
* - `shortid`
|
|
77
|
-
* - `url-parse`
|
|
78
|
-
*/
|
|
79
16
|
module.exports = function configFactory(ops) {
|
|
80
17
|
return {
|
|
81
18
|
context: ops.context,
|
|
@@ -11,16 +11,6 @@ const { merge } = require('webpack-merge');
|
|
|
11
11
|
|
|
12
12
|
const baseFactory = require('./lib-base');
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* @func configFactory
|
|
16
|
-
* @desc
|
|
17
|
-
* Extends and tunes {@link module:webpack/lib-development lib-development}
|
|
18
|
-
* to use *development* Babel environment, and sets
|
|
19
|
-
* `[path][name]___[local]___[hash:base64:6]`as
|
|
20
|
-
* the template for generated CSS classnames.
|
|
21
|
-
* @param {object} ops
|
|
22
|
-
* @return {object}
|
|
23
|
-
*/
|
|
24
14
|
module.exports = function configFactory(ops) {
|
|
25
15
|
return merge(
|
|
26
16
|
baseFactory({
|
|
@@ -12,15 +12,6 @@ const { merge } = require('webpack-merge');
|
|
|
12
12
|
|
|
13
13
|
const baseFactory = require('./lib-base');
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* @func configFactory
|
|
17
|
-
* @desc
|
|
18
|
-
* Extends and tunes {@link module:webpack/lib-production lib-production}
|
|
19
|
-
* to use *production* Babel environment, and sets `[hash:base64:6]` as
|
|
20
|
-
* the template for generated CSS classnames.
|
|
21
|
-
* @param {object} ops
|
|
22
|
-
* @return {object}
|
|
23
|
-
*/
|
|
24
15
|
module.exports = function configFactory(ops) {
|
|
25
16
|
const baseConfig = baseFactory({
|
|
26
17
|
...ops,
|
package/index.js
CHANGED
|
@@ -7,15 +7,26 @@
|
|
|
7
7
|
/* eslint-disable global-require, import/no-dynamic-require,
|
|
8
8
|
import/no-unresolved, no-eval */
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
&& process.versions && process.versions.node;
|
|
10
|
+
let lib;
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
try {
|
|
13
|
+
if (process.versions.node) {
|
|
14
|
+
lib = process.env.NODE_ENV === 'production'
|
|
15
|
+
? './build/production' : './build/development';
|
|
16
|
+
lib = eval('require')(lib);
|
|
17
|
+
}
|
|
18
|
+
} catch (error) {
|
|
19
|
+
lib = undefined;
|
|
21
20
|
}
|
|
21
|
+
|
|
22
|
+
if (!lib) {
|
|
23
|
+
// NOTE: process.env.NODE_ENV check must be done explicitly here to ensure
|
|
24
|
+
// that webpack is able to optimize out the unncessary branch.
|
|
25
|
+
if (process.env.NODE_ENV === 'production') {
|
|
26
|
+
lib = require('./build/production/web.bundle');
|
|
27
|
+
} else {
|
|
28
|
+
lib = require('./build/development/web.bundle');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = lib;
|
package/package.json
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@babel/runtime": "^7.15.4",
|
|
11
|
-
"@dr.pogodin/babel-plugin-react-css-modules": "^6.
|
|
12
|
-
"@dr.pogodin/react-global-state": "^0.6.
|
|
11
|
+
"@dr.pogodin/babel-plugin-react-css-modules": "^6.4.1",
|
|
12
|
+
"@dr.pogodin/react-global-state": "^0.6.4",
|
|
13
13
|
"@dr.pogodin/react-themes": "^1.3.3",
|
|
14
14
|
"autoprefix": "^1.0.1",
|
|
15
|
-
"axios": "^0.
|
|
16
|
-
"commander": "^8.
|
|
15
|
+
"axios": "^0.23.0",
|
|
16
|
+
"commander": "^8.3.0",
|
|
17
17
|
"compression": "^1.7.4",
|
|
18
18
|
"config": "^3.3.6",
|
|
19
19
|
"cookie-parser": "^1.4.5",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"react-router-dom": "^5.3.0",
|
|
36
36
|
"request-ip": "^2.1.3",
|
|
37
37
|
"rimraf": "^3.0.2",
|
|
38
|
+
"serialize-javascript": "^6.0.0",
|
|
38
39
|
"serve-favicon": "^2.5.0",
|
|
39
40
|
"source-map-support": "^0.5.20",
|
|
40
41
|
"url-parse": "^1.5.3",
|
|
@@ -43,58 +44,56 @@
|
|
|
43
44
|
},
|
|
44
45
|
"description": "Collection of generic ReactJS components and utils",
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@babel/cli": "^7.15.
|
|
47
|
-
"@babel/core": "^7.15.
|
|
48
|
-
"@babel/node": "^7.15.
|
|
47
|
+
"@babel/cli": "^7.15.7",
|
|
48
|
+
"@babel/core": "^7.15.8",
|
|
49
|
+
"@babel/node": "^7.15.8",
|
|
49
50
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
50
|
-
"@babel/plugin-transform-runtime": "^7.15.
|
|
51
|
-
"@babel/preset-env": "^7.15.
|
|
51
|
+
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
52
|
+
"@babel/preset-env": "^7.15.8",
|
|
52
53
|
"@babel/preset-react": "^7.14.5",
|
|
53
54
|
"@babel/types": "^7.15.6",
|
|
54
55
|
"@dr.pogodin/babel-plugin-css-modules-transform": "^1.10.0",
|
|
55
56
|
"@dr.pogodin/babel-plugin-transform-assets": "^1.1.1",
|
|
56
57
|
"@dr.pogodin/babel-preset-svgr": "^1.3.1",
|
|
57
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.
|
|
58
|
-
"autoprefixer": "^10.3.
|
|
58
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
59
|
+
"autoprefixer": "^10.3.7",
|
|
59
60
|
"babel-eslint": "^10.1.0",
|
|
60
|
-
"babel-jest": "^27.
|
|
61
|
-
"babel-loader": "^8.2.
|
|
61
|
+
"babel-jest": "^27.3.1",
|
|
62
|
+
"babel-loader": "^8.2.3",
|
|
62
63
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"css-
|
|
66
|
-
"css-minimizer-webpack-plugin": "^3.0.2",
|
|
64
|
+
"core-js": "^3.18.3",
|
|
65
|
+
"css-loader": "^6.4.0",
|
|
66
|
+
"css-minimizer-webpack-plugin": "^3.1.1",
|
|
67
67
|
"eslint": "^7.32.0",
|
|
68
68
|
"eslint-config-airbnb": "^18.2.1",
|
|
69
69
|
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
70
|
-
"eslint-plugin-import": "^2.
|
|
71
|
-
"eslint-plugin-jest": "^
|
|
70
|
+
"eslint-plugin-import": "^2.25.2",
|
|
71
|
+
"eslint-plugin-jest": "^25.2.2",
|
|
72
72
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
73
|
-
"eslint-plugin-react": "^7.
|
|
73
|
+
"eslint-plugin-react": "^7.26.1",
|
|
74
74
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
75
75
|
"identity-obj-proxy": "^3.0.0",
|
|
76
|
-
"jest": "^27.
|
|
77
|
-
"
|
|
78
|
-
"mini-css-extract-plugin": "^2.3.0",
|
|
76
|
+
"jest": "^27.3.1",
|
|
77
|
+
"mini-css-extract-plugin": "^2.4.3",
|
|
79
78
|
"mockdate": "^3.0.5",
|
|
80
79
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
81
|
-
"postcss": "^8.3.
|
|
82
|
-
"postcss-loader": "^6.
|
|
83
|
-
"postcss-scss": "^4.0.
|
|
80
|
+
"postcss": "^8.3.11",
|
|
81
|
+
"postcss-loader": "^6.2.0",
|
|
82
|
+
"postcss-scss": "^4.0.1",
|
|
84
83
|
"pretty": "^2.0.0",
|
|
85
84
|
"react-refresh": "^0.10.0",
|
|
86
85
|
"react-test-renderer": "^17.0.2",
|
|
87
86
|
"regenerator-runtime": "^0.13.9",
|
|
88
87
|
"resolve-url-loader": "^4.0.0",
|
|
89
|
-
"sass": "^1.
|
|
90
|
-
"sass-loader": "^12.
|
|
88
|
+
"sass": "^1.43.3",
|
|
89
|
+
"sass-loader": "^12.2.0",
|
|
91
90
|
"sitemap": "^7.0.0",
|
|
92
|
-
"stylelint": "^
|
|
93
|
-
"stylelint-config-standard": "^
|
|
91
|
+
"stylelint": "^14.0.0",
|
|
92
|
+
"stylelint-config-standard-scss": "^2.0.0",
|
|
94
93
|
"supertest": "^6.1.6",
|
|
95
|
-
"webpack": "^5.
|
|
96
|
-
"webpack-dev-middleware": "^5.1
|
|
97
|
-
"webpack-hot-middleware": "^2.25.
|
|
94
|
+
"webpack": "^5.59.1",
|
|
95
|
+
"webpack-dev-middleware": "^5.2.1",
|
|
96
|
+
"webpack-hot-middleware": "^2.25.1",
|
|
98
97
|
"webpack-merge": "^5.8.0",
|
|
99
98
|
"workbox-core": "^6.3.0",
|
|
100
99
|
"workbox-precaching": "^6.3.0",
|
|
@@ -126,12 +125,11 @@
|
|
|
126
125
|
},
|
|
127
126
|
"scripts": {
|
|
128
127
|
"build": "rimraf build && node bin/build -t development --lib && node bin/build -t production --lib",
|
|
129
|
-
"docs": "rimraf docs && jsdoc -c config/jsdoc/config.js",
|
|
130
128
|
"jest": "NODE_CONFIG_ENV=test jest --no-cache -w 1 --config config/jest/default.js",
|
|
131
129
|
"lint": "npm run lint:js && npm run lint:scss",
|
|
132
130
|
"lint:js": "eslint --ext .js,.jsx .",
|
|
133
|
-
"lint:scss": "stylelint -- **/*.{css,scss}
|
|
131
|
+
"lint:scss": "stylelint -- **/*.{css,scss}",
|
|
134
132
|
"test": "npm run lint && npm run jest"
|
|
135
133
|
},
|
|
136
|
-
"version": "1.
|
|
134
|
+
"version": "1.10.0"
|
|
137
135
|
}
|
package/src/index.js
CHANGED
|
@@ -4,73 +4,18 @@ import { isomorphy, webpack } from 'utils';
|
|
|
4
4
|
|
|
5
5
|
let server = null; // eslint-disable-line import/no-mutable-exports
|
|
6
6
|
if (isomorphy.IS_SERVER_SIDE) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
try {
|
|
8
|
+
const path = webpack.requireWeak('path');
|
|
9
|
+
server = webpack.requireWeak(path.resolve(__dirname, './server'));
|
|
10
|
+
} catch (error) {
|
|
11
|
+
server = null;
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
/**
|
|
12
|
-
* @category Utilities
|
|
13
|
-
* @module _
|
|
14
|
-
* @desc
|
|
15
|
-
* ```js
|
|
16
|
-
* import { _ } from '@dr.pogodin/react-utils';
|
|
17
|
-
* ```
|
|
18
|
-
* `_` is just an alias for [lodash](https://lodash.com/docs) library,
|
|
19
|
-
* which provides various generic JS helpers.
|
|
20
|
-
*/
|
|
21
15
|
export { default as _ } from 'lodash';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @category Utilities
|
|
25
|
-
* @module api
|
|
26
|
-
* @desc
|
|
27
|
-
* ```js
|
|
28
|
-
* import { api } from '@dr.pogodin/react-utils';
|
|
29
|
-
* ```
|
|
30
|
-
* `api` is just an alias for [`axios`](https://www.npmjs.com/package/axios)
|
|
31
|
-
* library, which provides a great HTTP(S) client.
|
|
32
|
-
*/
|
|
33
16
|
export { default as api } from 'axios';
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @category Utilities
|
|
37
|
-
* @module PT
|
|
38
|
-
* @desc
|
|
39
|
-
* ```js
|
|
40
|
-
* import { PT } from '@dr.pogodin/react-utils';
|
|
41
|
-
* ```
|
|
42
|
-
* `PT` (short for `prop-types`) is an alias for
|
|
43
|
-
* [prop-types](https://www.npmjs.com/package/prop-types) library,
|
|
44
|
-
* which facilitates runtime type checks for React.
|
|
45
|
-
*/
|
|
46
17
|
export * as PT from 'prop-types';
|
|
47
18
|
|
|
48
|
-
/**
|
|
49
|
-
* @category Utilities
|
|
50
|
-
* @module ReactGlobalState
|
|
51
|
-
* @desc
|
|
52
|
-
* ```jsx
|
|
53
|
-
* import {
|
|
54
|
-
* getGlobalState,
|
|
55
|
-
* GlobalStateProvider,
|
|
56
|
-
* useAsyncCollection,
|
|
57
|
-
* useAsyncData,
|
|
58
|
-
* useGlobalState,
|
|
59
|
-
* } from '@dr.pogodin/react-utils';
|
|
60
|
-
* ```
|
|
61
|
-
* For convenience, `react-utils` re-exports components and hooks provided by
|
|
62
|
-
* [react-global-state](https://dr.pogodin.studio/docs/react-global-state/index.html)
|
|
63
|
-
* library, which is a state of the art library for global state and
|
|
64
|
-
* asynchronous data managment in React applications, powered by hooks and
|
|
65
|
-
* Context API. It is simple, efficient, and with a full server-side rendering
|
|
66
|
-
* (SSR) support.
|
|
67
|
-
*
|
|
68
|
-
* The standard {@link client} and {@link server} automatically wrap your
|
|
69
|
-
* app into `<GlobalStateProvider>`, also `server` wires `react-global-state` to
|
|
70
|
-
* SSR setup, and also exposes the actual incoming HTTP request object via SSR
|
|
71
|
-
* context, to which it attaches it as `req` field.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
19
|
export {
|
|
75
20
|
getGlobalState,
|
|
76
21
|
GlobalStateProvider,
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
@mixin font-family($font-name, $font-weight, $font-style, $font-url, $font-file) {
|
|
14
14
|
@font-face {
|
|
15
|
-
font-family:
|
|
15
|
+
font-family: "#{$font-name}";
|
|
16
16
|
font-display: block;
|
|
17
17
|
font-weight: $font-weight;
|
|
18
18
|
font-style: $font-style;
|
|
19
|
-
src: url(
|
|
20
|
-
src: url(
|
|
19
|
+
src: url("#{$font-url}#{$font-file}.eot");
|
|
20
|
+
src: url("#{$font-url}#{$font-file}.eot?#iefix") format("embedded-opentype"), url("#{$font-url}#{$font-file}.woff") format("woff"), url("#{$font-url}#{$font-file}.ttf") format("truetype"), url("#{$font-url}#{$font-file}.svg##{$font-name}") format("svg");
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
font-display: block;
|
|
36
36
|
font-style: $font-style;
|
|
37
37
|
font-weight: $font-weight;
|
|
38
|
-
src: url(
|
|
38
|
+
src: url("#{$font-url}.ttf") format("truetype");
|
|
39
39
|
}
|
|
40
40
|
}
|