@dr.pogodin/react-utils 1.14.3 → 1.15.2

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.
Files changed (45) hide show
  1. package/bin/release.sh +1 -0
  2. package/build/development/shared/components/Button/index.js +1 -1
  3. package/build/development/shared/components/Checkbox/index.js +1 -1
  4. package/build/development/shared/components/CodeSplit/ClientSide.js +5 -4
  5. package/build/development/shared/components/CodeSplit/ClientSide.js.map +1 -1
  6. package/build/development/shared/components/Dropdown/index.js +1 -1
  7. package/build/development/shared/components/Input/index.js +1 -1
  8. package/build/development/shared/components/Modal/index.js +1 -1
  9. package/build/development/shared/components/PageLayout/index.js +1 -1
  10. package/build/development/shared/components/Throbber/index.js +1 -1
  11. package/build/development/shared/components/WithTooltip/index.js +1 -1
  12. package/build/development/shared/components/YouTubeVideo/index.js +2 -2
  13. package/build/development/web.bundle.js +5 -5
  14. package/build/production/shared/components/Button/index.js +1 -1
  15. package/build/production/shared/components/Button/index.js.map +1 -1
  16. package/build/production/shared/components/Checkbox/index.js +1 -1
  17. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  18. package/build/production/shared/components/CodeSplit/ClientSide.js +2 -2
  19. package/build/production/shared/components/CodeSplit/ClientSide.js.map +1 -1
  20. package/build/production/shared/components/Dropdown/index.js +1 -1
  21. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  22. package/build/production/shared/components/Input/index.js +1 -1
  23. package/build/production/shared/components/Input/index.js.map +1 -1
  24. package/build/production/shared/components/Modal/index.js +1 -1
  25. package/build/production/shared/components/Modal/index.js.map +1 -1
  26. package/build/production/shared/components/PageLayout/index.js +1 -1
  27. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  28. package/build/production/shared/components/Throbber/index.js +1 -1
  29. package/build/production/shared/components/Throbber/index.js.map +1 -1
  30. package/build/production/shared/components/WithTooltip/index.js +1 -1
  31. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  32. package/build/production/shared/components/YouTubeVideo/index.js +1 -1
  33. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  34. package/build/production/web.bundle.js +1 -1
  35. package/build/production/web.bundle.js.map +1 -1
  36. package/config/babel/node-ssr.js +5 -67
  37. package/config/babel/webpack.js +10 -53
  38. package/node-entry.js +5 -0
  39. package/null.js +0 -0
  40. package/package.json +44 -20
  41. package/config/shared/utils.js +0 -20
  42. package/dev-styles.js +0 -7
  43. package/index.js +0 -32
  44. package/mixins.scss +0 -1
  45. package/prod-styles.js +0 -7
@@ -1,55 +1,8 @@
1
- /**
2
- * [Babel](https://babeljs.io/) preset for NodeJS builds & server-side
3
- * execution.
4
- *
5
- * To include it into a Babel configuration:
6
- * ```json
7
- * {
8
- * "presets": ["@dr.pogodin/react-utils/config/babel/node-ssr"]
9
- * }
10
- * ```
11
- *
12
- * To provide additional preset options (for supported options see
13
- * documentation for _ops_ argument of
14
- * {@link module:babel/node.getConfig getConfig()} method below):
15
- * ```json
16
- * {
17
- * "presets": [
18
- * ["@dr.pogodin/react-utils/config/babel/node-ssr", {
19
- * "someOption": "someValue"
20
- * }]
21
- * ]
22
- * }
23
- * ```
24
- *
25
- * This preset builds on top of {@link module:babel/webpack babel/webpack}
26
- * preset: it performs all the same setups, then on top of it does
27
- * the following:
28
- *
29
- * - Sets up [babel-plugin-css-modules-transform](https://www.npmjs.com/package/babel-plugin-css-modules-transform),
30
- * which transforms (S)CSS imports into JS objects mapping original (S)CSS
31
- * class names into transformed class names emitted into CSS bundle (thus,
32
- * matching (S)CSS transformations done by
33
- * `@dr.pogodin/babel-plugin-react-css-modules` plugin on (S)CSS code.
34
- *
35
- * - Sets up [babel-plugin-tranform-assets](https://www.npmjs.com/package/@dr.pogodin/babel-plugin-transform-assets)
36
- * to convert GIF, JPEG, JPG, and PNG imports into emitted asset paths, like
37
- * `/images/[FILE_HASH].[FILE_EXTENSION]`. The `baseAssetsOutputPath` preset
38
- * option allows to add custom prefix to these paths.
39
- *
40
- * - In _development_ environment it removes `react-refresh/babel`.
41
- */
42
1
  /* eslint-disable import/no-extraneous-dependencies */
43
2
 
44
3
  const { pick, pull } = require('lodash');
45
- const postcssScss = require('postcss-scss');
46
4
  const getWebpackBabelConfig = require('./webpack');
47
5
 
48
- const {
49
- generateScopedNameDev,
50
- generateScopedNameProd,
51
- } = require('../shared/utils');
52
-
53
6
  /**
54
7
  * Creates a new base config.
55
8
  * @param {object} babel Babel compiler.
@@ -100,29 +53,14 @@ function newBase(babel, options = {}) {
100
53
  * **Beware:** It mutates `config`.
101
54
  *
102
55
  * @param {object} config
103
- * @param {string} env `development` or `production`.
104
56
  * @return {object} Returns mutated config for chaining.
105
57
  * @ignore
106
58
  */
107
- function addStyling(config, env) {
108
- const cssModulesTransformOps = {
109
- extensions: ['.css', '.scss'],
110
- processorOpts: { parser: postcssScss },
111
- };
112
- switch (env) {
113
- case getWebpackBabelConfig.ENVIRONMENTS.DEV:
114
- case getWebpackBabelConfig.ENVIRONMENTS.TEST:
115
- cssModulesTransformOps.generateScopedName = generateScopedNameDev;
116
- break;
117
- case getWebpackBabelConfig.ENVIRONMENTS.PROD:
118
- cssModulesTransformOps.generateScopedName = generateScopedNameProd;
119
- break;
120
- default:
121
- }
122
- config.plugins.push([
123
- '@dr.pogodin/css-modules-transform',
124
- cssModulesTransformOps,
125
- ]);
59
+ function addStyling(config) {
60
+ const cssModulesOps = config.plugins.find(
61
+ ([name]) => name === '@dr.pogodin/react-css-modules',
62
+ )[1];
63
+ cssModulesOps.replaceImport = true;
126
64
  return config;
127
65
  }
128
66
 
@@ -1,59 +1,16 @@
1
- /**
2
- * [Babel](https://babeljs.io/) preset for Webpack builds.
3
- *
4
- * To include it into a Babel configuration:
5
- * ```json
6
- * {
7
- * "presets": ["@dr.pogodin/react-utils/config/babel/webpack"]
8
- * }
9
- * ```
10
- *
11
- * To provide additional options (for supported options see documentation for
12
- * _ops_ argument of {@link module:babel/webpack.getPreset getPreset()} method
13
- * below):
14
- * ```json
15
- * {
16
- * "presets": [
17
- * ["@dr.pogodin/react-utils/config/babel/webpack", {
18
- * "someOption": "someValue"
19
- * }]
20
- * ]
21
- * }
22
- * ```
23
- *
24
- * This preset does the following:
25
- *
26
- * - Sets up [@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env),
27
- * and [@babel/preset-react](https://babeljs.io/docs/en/babel-preset-react)
28
- * presets which are needed to compile modern JS(X) code.
29
- *
30
- * - Sets up [@dr.pogodin/babel-preset-svgr](https://www.npmjs.com/package/@dr.pogodin/babel-preset-svgr)
31
- * preset, which allows to import SVG files as React components.
32
- *
33
- * - Sets up [babel-plugin-module-resolver](https://www.npmjs.com/package/babel-plugin-module-resolver),
34
- * which helps to resolve module imports relative to `/src/shared`,
35
- * and `/src` folders of host codebase.
36
- *
37
- * - Sets up [@babel/plugin-transform-runtime](https://babeljs.io/docs/en/babel-plugin-transform-runtime),
38
- * which enables the re-use of Babel's injected helper code to save on
39
- * codesize.
40
- *
41
- * - Sets up [@dr.pogodin/babel-plugin-react-css-modules](https://www.npmjs.com/package/@dr.pogodin/babel-plugin-react-css-modules),
42
- * which is a part of CSS modules setup that transforms `styleName` props of
43
- * React components into globally unique `className` props. Generated class
44
- * names are verbose in _development_ and _test_ environments, to faciliate
45
- * debugging, and they are short 6-symbol-long hashes in _production_ Babel
46
- * environment, to ensure compact CSS and JS output code.
47
- *
48
- * - In _development_ environment it also sets up `react-refresh/babel`.
49
- */
50
-
51
1
  const { pick } = require('lodash');
52
2
 
53
3
  const {
54
- generateScopedNameDev,
55
- generateScopedNameProd,
56
- } = require('../shared/utils');
4
+ generateScopedNameFactory,
5
+ } = require('@dr.pogodin/babel-plugin-react-css-modules/utils');
6
+
7
+ const generateScopedNameDev = generateScopedNameFactory(
8
+ '[package]___[path][name]___[local]___[hash:base64:6]',
9
+ );
10
+
11
+ const generateScopedNameProd = generateScopedNameFactory(
12
+ '[hash:base64:6]',
13
+ );
57
14
 
58
15
  /**
59
16
  * @static
package/node-entry.js ADDED
@@ -0,0 +1,5 @@
1
+ const build = process.env.NODE_ENV === 'production'
2
+ ? 'production' : 'development';
3
+
4
+ // eslint-disable-next-line import/no-dynamic-require
5
+ module.exports = require(`./build/${build}`);
package/null.js ADDED
File without changes
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.14.3",
2
+ "version": "1.15.2",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -9,16 +9,16 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@babel/runtime": "^7.17.2",
12
- "@dr.pogodin/babel-plugin-react-css-modules": "^6.6.1",
13
- "@dr.pogodin/react-global-state": "^0.6.5",
14
- "@dr.pogodin/react-themes": "^1.3.3",
12
+ "@dr.pogodin/babel-plugin-react-css-modules": "^6.7.0",
13
+ "@dr.pogodin/react-global-state": "^0.7.1",
14
+ "@dr.pogodin/react-themes": "^1.4.1",
15
15
  "axios": "^0.26.0",
16
16
  "commander": "^9.0.0",
17
17
  "compression": "^1.7.4",
18
18
  "config": "^3.3.7",
19
19
  "cookie-parser": "^1.4.6",
20
20
  "cross-env": "^7.0.3",
21
- "dayjs": "^1.10.7",
21
+ "dayjs": "^1.10.8",
22
22
  "express": "^4.17.3",
23
23
  "helmet": "^5.0.2",
24
24
  "http-status-codes": "^2.2.0",
@@ -32,7 +32,7 @@
32
32
  "react": "^17.0.2",
33
33
  "react-dom": "^17.0.2",
34
34
  "react-helmet": "^6.1.0",
35
- "react-router-dom": "^6.2.1",
35
+ "react-router-dom": "^6.2.2",
36
36
  "request-ip": "^2.1.3",
37
37
  "rimraf": "^3.0.2",
38
38
  "serialize-javascript": "^6.0.0",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "description": "Collection of generic ReactJS components and utils",
45
45
  "devDependencies": {
46
- "@babel/cli": "^7.17.3",
46
+ "@babel/cli": "^7.17.6",
47
47
  "@babel/core": "^7.17.5",
48
48
  "@babel/eslint-parser": "^7.17.0",
49
49
  "@babel/eslint-plugin": "^7.16.5",
@@ -51,7 +51,6 @@
51
51
  "@babel/plugin-transform-runtime": "^7.17.0",
52
52
  "@babel/preset-env": "^7.16.11",
53
53
  "@babel/preset-react": "^7.16.7",
54
- "@dr.pogodin/babel-plugin-css-modules-transform": "^1.10.0",
55
54
  "@dr.pogodin/babel-plugin-transform-assets": "^1.1.1",
56
55
  "@dr.pogodin/babel-preset-svgr": "^1.4.0",
57
56
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
@@ -60,22 +59,22 @@
60
59
  "babel-loader": "^8.2.3",
61
60
  "babel-plugin-module-resolver": "^4.1.0",
62
61
  "core-js": "^3.21.1",
63
- "css-loader": "^6.6.0",
62
+ "css-loader": "^6.7.1",
64
63
  "css-minimizer-webpack-plugin": "^3.4.1",
65
- "eslint": "^8.9.0",
64
+ "eslint": "^8.10.0",
66
65
  "eslint-config-airbnb": "^19.0.4",
67
66
  "eslint-import-resolver-babel-module": "^5.3.1",
68
67
  "eslint-plugin-import": "^2.25.4",
69
68
  "eslint-plugin-jest": "^26.1.1",
70
69
  "eslint-plugin-jsx-a11y": "^6.5.1",
71
- "eslint-plugin-react": "^7.28.0",
70
+ "eslint-plugin-react": "^7.29.3",
72
71
  "eslint-plugin-react-hooks": "^4.3.0",
73
72
  "identity-obj-proxy": "^3.0.0",
74
73
  "jest": "^27.5.1",
75
- "mini-css-extract-plugin": "^2.5.3",
74
+ "mini-css-extract-plugin": "^2.6.0",
76
75
  "mockdate": "^3.0.5",
77
76
  "nodelist-foreach-polyfill": "^1.2.0",
78
- "postcss": "^8.4.6",
77
+ "postcss": "^8.4.8",
79
78
  "postcss-loader": "^6.2.1",
80
79
  "postcss-scss": "^4.0.3",
81
80
  "pretty": "^2.0.0",
@@ -83,24 +82,50 @@
83
82
  "react-test-renderer": "^17.0.2",
84
83
  "regenerator-runtime": "^0.13.9",
85
84
  "resolve-url-loader": "^5.0.0",
86
- "sass": "^1.49.8",
85
+ "sass": "^1.49.9",
87
86
  "sass-loader": "^12.6.0",
88
87
  "sitemap": "^7.1.1",
89
- "stylelint": "^14.5.1",
88
+ "stylelint": "^14.5.3",
90
89
  "stylelint-config-standard-scss": "^3.0.0",
91
90
  "supertest": "^6.2.2",
92
- "webpack": "^5.69.1",
91
+ "webpack": "^5.70.0",
93
92
  "webpack-dev-middleware": "^5.3.1",
94
93
  "webpack-hot-middleware": "^2.25.1",
95
94
  "webpack-merge": "^5.8.0",
96
- "workbox-core": "^6.4.2",
97
- "workbox-precaching": "^6.4.2",
98
- "workbox-webpack-plugin": "^6.4.2"
95
+ "workbox-core": "^6.5.1",
96
+ "workbox-precaching": "^6.5.1",
97
+ "workbox-webpack-plugin": "^6.5.1"
99
98
  },
100
99
  "engines": {
101
100
  "node": ">=14.x",
102
101
  "npm": ">=6.x"
103
102
  },
103
+ "main": "./node-entry.js",
104
+ "exports": {
105
+ ".": {
106
+ "browser": {
107
+ "development": "./build/development/web.bundle.js",
108
+ "production": "./build/production/web.bundle.js"
109
+ },
110
+ "node": {
111
+ "webpack": "./build/production/web.bundle.js",
112
+ "default": "./node-entry.js"
113
+ },
114
+ "react-native": "./node-entry.js"
115
+ },
116
+ "./config/*": "./config/*.js",
117
+ "./mixins": "./src/styles/mixins.scss",
118
+ "./dev-styles": {
119
+ "node": "./null.js",
120
+ "browser": "./build/development/style.css"
121
+ },
122
+ "./prod-styles": {
123
+ "node": "./null.js",
124
+ "browser": "./build/production/style.css"
125
+ },
126
+ "./build/development/client/init": "./build/development/client/init.js",
127
+ "./build/production/client/init": "./build/production/client/init.js"
128
+ },
104
129
  "homepage": "https://dr.pogodin.studio",
105
130
  "keywords": [
106
131
  "Development",
@@ -115,7 +140,6 @@
115
140
  "Web"
116
141
  ],
117
142
  "license": "MIT",
118
- "main": "index.js",
119
143
  "name": "@dr.pogodin/react-utils",
120
144
  "repository": {
121
145
  "type": "git",
@@ -1,20 +0,0 @@
1
- /**
2
- * Misc utilities reusable in different JS-format config files.
3
- */
4
-
5
- const {
6
- generateScopedNameFactory,
7
- } = require('@dr.pogodin/babel-plugin-react-css-modules/utils');
8
-
9
- const generateScopedNameDev = generateScopedNameFactory(
10
- '[package]___[path][name]___[local]___[hash:base64:6]',
11
- );
12
-
13
- const generateScopedNameProd = generateScopedNameFactory(
14
- '[hash:base64:6]',
15
- );
16
-
17
- module.exports = {
18
- generateScopedNameDev,
19
- generateScopedNameProd,
20
- };
package/dev-styles.js DELETED
@@ -1,7 +0,0 @@
1
- const lib = require('./index');
2
-
3
- if (lib.isomorphy.IS_CLIENT_SIDE) {
4
- /* eslint-disable global-require */
5
- require('./build/development/style.css');
6
- /* eslint-enable global-require */
7
- }
package/index.js DELETED
@@ -1,32 +0,0 @@
1
- /**
2
- * Entry point of the library.
3
- *
4
- * Depending on NODE_ENV variable, it proxies production or development build of
5
- * the library.
6
- */
7
- /* eslint-disable global-require, import/no-dynamic-require,
8
- import/no-unresolved, no-eval */
9
-
10
- let lib;
11
-
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;
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/mixins.scss DELETED
@@ -1 +0,0 @@
1
- @import "src/styles/mixins";
package/prod-styles.js DELETED
@@ -1,7 +0,0 @@
1
- const lib = require('./index');
2
-
3
- if (lib.isomorphy.IS_CLIENT_SIDE) {
4
- /* eslint-disable global-require */
5
- require('./build/production/style.css');
6
- /* eslint-enable global-require */
7
- }