@dr.pogodin/react-utils 1.56.5 → 1.57.0-alpha.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.
package/CHANGELOG.md CHANGED
@@ -1 +1,7 @@
1
- [Release Notes](https://github.com/birdofpreyru/react-utils/releases)
1
+ # Changelog
2
+
3
+ ## Upcoming v1.57.0 release
4
+
5
+ ## Older Releases
6
+
7
+ See at the [GitHub Releases Page](https://github.com/birdofpreyru/react-utils/releases).
package/bin/release.sh CHANGED
@@ -23,4 +23,4 @@ gsutil -m rsync -d -r docs/build gs://docs.pogodin.studio/react-utils
23
23
 
24
24
  # Library package release.
25
25
  export NPM_ID_TOKEN=$(circleci run oidc get --claims '{"aud": "npm:registry.npmjs.org"}')
26
- npm publish --access public
26
+ npm publish --access public --tag v1.57-alpha
@@ -1,6 +1,6 @@
1
- import { generateScopedNameFactory, } from '@dr.pogodin/babel-plugin-react-css-modules/utils';
2
- const generateScopedNameDev = generateScopedNameFactory('[package]___[path][name]___[local]___[hash:base64:6]');
3
- const generateScopedNameProd = generateScopedNameFactory('[hash:base64:6]');
1
+ import { localIdentNameFactory, } from '@dr.pogodin/babel-plugin-react-css-modules/utils';
2
+ const localIdentNameDev = localIdentNameFactory('[package]___[path][name]___[local]___[hash:base64:6]');
3
+ const localIdentNameProd = localIdentNameFactory('[hash:base64:6]');
4
4
  /**
5
5
  * Supported Babel environments.
6
6
  */
@@ -72,10 +72,10 @@ function addStyling(config, env) {
72
72
  switch (env) {
73
73
  case ENVIRONMENTS.DEV:
74
74
  case ENVIRONMENTS.TEST:
75
- cssModulesOps.generateScopedName = generateScopedNameDev;
75
+ cssModulesOps.localIdentName = localIdentNameDev;
76
76
  break;
77
77
  case ENVIRONMENTS.PROD:
78
- cssModulesOps.generateScopedName = generateScopedNameProd;
78
+ cssModulesOps.localIdentName = localIdentNameProd;
79
79
  break;
80
80
  default:
81
81
  }
@@ -30,6 +30,7 @@ export default {
30
30
  testPathIgnorePatterns: [
31
31
  '/__assets__/',
32
32
  '/node_modules/',
33
+ '/babel.config.js',
33
34
  ],
34
35
  transform: {
35
36
  '\\.((j|t)sx?|svg)$': 'babel-jest',
@@ -11,7 +11,7 @@ export type OptionsT = {
11
11
  babelLoaderExclude?: RuleSetRule['exclude'];
12
12
  babelLoaderOptions?: object;
13
13
  context: string;
14
- cssLocalIdent?: string;
14
+ cssLocalIdent: string;
15
15
  dontEmitBuildInfo?: boolean;
16
16
  dontUseProgressPlugin?: boolean;
17
17
  entry: string | string[];
@@ -3,16 +3,14 @@ import { randomBytes } from 'node:crypto';
3
3
  import nodeFs from 'node:fs';
4
4
  import { createRequire } from 'node:module';
5
5
  import { resolve } from 'node:path';
6
- import autoprefixer from 'autoprefixer';
7
6
  import { clone, defaults, isFunction, isObject, } from 'lodash-es';
8
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
9
7
  import { SitemapStream, streamToPromise } from 'sitemap';
10
8
  // NOTE: As "webpack" is still distributed as CJS module, now that we have
11
9
  // switched to MJS, importing plugins from it in MJS import style does not work,
12
10
  // thus we need to import the default export, and use its fields.
13
11
  import webpack from 'webpack';
14
12
  import WorkboxPlugin from 'workbox-webpack-plugin';
15
- import { getLocalIdent, } from '@dr.pogodin/babel-plugin-react-css-modules/utils';
13
+ import { localIdentNameFactory, } from '@dr.pogodin/babel-plugin-react-css-modules/utils';
16
14
  const COREJS_REGEX = /\/core-js/;
17
15
  const require = createRequire(import.meta.url);
18
16
  /**
@@ -225,8 +223,21 @@ export default function configFactory(ops) {
225
223
  const res = {
226
224
  context: o.context,
227
225
  entry,
226
+ experiments: { css: true },
228
227
  mode: o.mode,
229
228
  module: {
229
+ generator: {
230
+ 'css/module': {
231
+ localIdentName: localIdentNameFactory(o.cssLocalIdent),
232
+ },
233
+ },
234
+ parser: {
235
+ 'css/module': {
236
+ // We keep it "false" for now, as in our setup Babel plugins take care
237
+ // of injecting necessary CSS module identifiers into JS code.
238
+ namedExports: false,
239
+ },
240
+ },
230
241
  rules: [{
231
242
  /* Loads font resources from "src/assets/fonts" folder. */
232
243
  test: /\.(eot|otf|ttf|woff2?)$/,
@@ -258,43 +269,13 @@ export default function configFactory(ops) {
258
269
  }, {
259
270
  /* Loads SCSS stylesheets. */
260
271
  test: /\.scss$/,
261
- use: [
262
- MiniCssExtractPlugin.loader, {
263
- loader: 'css-loader',
264
- options: {
265
- modules: {
266
- getLocalIdent,
267
- localIdentName: o.cssLocalIdent,
268
- // This flag defaults `true` for ES module builds since css-loader@7.0.0:
269
- // https://github.com/webpack-contrib/css-loader/releases/tag/v7.0.0
270
- // We'll keep it `false` to avoid a breaking change for dependant
271
- // projects, and I am also not sure what are the benefits of
272
- // named CSS exports anyway.
273
- namedExport: false,
274
- },
275
- },
276
- }, {
277
- loader: 'postcss-loader',
278
- options: {
279
- postcssOptions: {
280
- plugins: [autoprefixer],
281
- },
282
- },
283
- }, 'resolve-url-loader', {
284
- loader: 'sass-loader',
285
- options: {
286
- sourceMap: true,
287
- },
272
+ type: 'css/module',
273
+ use: {
274
+ loader: 'sass-loader',
275
+ options: {
276
+ sourceMap: true,
288
277
  },
289
- ],
290
- }, {
291
- /* Loads CSS stylesheets. It is assumed that CSS stylesheets come only
292
- * from dependencies, as we use SCSS inside our own code. */
293
- test: /\.css$/,
294
- use: [
295
- MiniCssExtractPlugin.loader,
296
- 'css-loader',
297
- ],
278
+ },
298
279
  }],
299
280
  },
300
281
  node: {
@@ -1,8 +1,6 @@
1
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
2
1
  import { type Configuration } from 'webpack';
3
2
  import { type OptionsT as BaseOptionsT } from './app-base.js';
4
3
  type OptionsT = BaseOptionsT & {
5
- cssExtractionOptions?: MiniCssExtractPlugin.PluginOptions;
6
4
  dontUseHmr?: boolean;
7
5
  dontUseReactGlobalStateDebugging?: boolean;
8
6
  };
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable import/no-extraneous-dependencies */
2
2
  import { clone, defaults } from 'lodash-es';
3
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
4
3
  import webpack from 'webpack';
5
4
  import { merge } from 'webpack-merge';
6
5
  import ReactRefreshPlugin from '@pmmmwh/react-refresh-webpack-plugin';
@@ -19,7 +18,6 @@ export default function configFactory(ops) {
19
18
  entry.push('webpack-dev-middleware/client');
20
19
  entry.push(...Array.isArray(o.entry) ? o.entry : [o.entry]);
21
20
  const plugins = [
22
- new MiniCssExtractPlugin(Object.assign({ chunkFilename: '[id].css', filename: '[id].css' }, ops.cssExtractionOptions)),
23
21
  new webpack.DefinePlugin({
24
22
  'process.env.BABEL_ENV': JSON.stringify('development'),
25
23
  'process.env.DEV_TOOLS': JSON.stringify(true),
@@ -3,12 +3,9 @@
3
3
  * @module webpack/app-production
4
4
  * @desc Production Webpack configuration for applications.
5
5
  */
6
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
7
6
  import { type Configuration } from 'webpack';
8
7
  import { type OptionsT as BaseOptionsT } from './app-base.js';
9
- type OptionsT = BaseOptionsT & {
10
- cssExtractionOptions?: MiniCssExtractPlugin.PluginOptions;
11
- };
8
+ type OptionsT = BaseOptionsT;
12
9
  /**
13
10
  * @param {object} ops
14
11
  * @param {string} ops.context Base URL for resolution of relative config paths.
@@ -4,8 +4,7 @@
4
4
  * @desc Production Webpack configuration for applications.
5
5
  */
6
6
  /* eslint-disable import/no-extraneous-dependencies */
7
- import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
8
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
7
+ import MinimizerPlugin from 'minimizer-webpack-plugin';
9
8
  import webpack from 'webpack';
10
9
  import { merge } from 'webpack-merge';
11
10
  import baseFactory from './app-base.js';
@@ -24,16 +23,29 @@ export default function configFactory(ops) {
24
23
  optimization: {
25
24
  minimizer: [
26
25
  '...',
27
- new CssMinimizerPlugin({
28
- minimizerOptions: {
29
- preset: ['default', {
30
- /* Due to the way our styles are organized, these dangerous
31
- * optimizations can break our styles, thus they are disabled. */
32
- discardUnused: false,
33
- reduceIdents: false,
34
- zindex: false,
35
- }],
26
+ // TODO: This sets up (S)CSS minimization with CSS Nano minimizer
27
+ // (the same we relied upon in previous versions of Webpack setup);
28
+ // however, Webpack now includes its own, build-in CSS minimizer,
29
+ // and encourages to drop CSS Nano / PostCSS dependency for minimization.
30
+ // At the first glance, out of the box the built-in minimizer does not
31
+ // produce identical results (perhaps, because it does not handle .scss
32
+ // modules by default); because of this, and to be on the safer side,
33
+ // we'll keep CSS Nano in the pipeline for now, and look to get rid of
34
+ // it later.
35
+ new MinimizerPlugin({
36
+ minify: {
37
+ implementation: MinimizerPlugin.cssnanoMinify,
38
+ options: {
39
+ preset: ['default', {
40
+ // Due to the way our styles are organized, these dangerous
41
+ // optimizations can break our styles, thus they are disabled.
42
+ discardUnused: false,
43
+ reduceIdents: false,
44
+ zindex: false,
45
+ }],
46
+ },
36
47
  },
48
+ test: /\.s?css$/,
37
49
  }),
38
50
  ],
39
51
  },
@@ -42,7 +54,6 @@ export default function configFactory(ops) {
42
54
  'process.env.BABEL_ENV': JSON.stringify('production'),
43
55
  'process.env.NODE_ENV': JSON.stringify('production'),
44
56
  }),
45
- new MiniCssExtractPlugin(Object.assign({ chunkFilename: '[contenthash].css', filename: '[contenthash].css' }, ops.cssExtractionOptions)),
46
57
  ],
47
58
  });
48
59
  return res;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.56.5",
2
+ "version": "1.57.0-alpha.2",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-run-with-babel": "bin/run-with-babel.js",
@@ -9,15 +9,15 @@
9
9
  "url": "https://github.com/birdofpreyru/react-utils/issues"
10
10
  },
11
11
  "dependencies": {
12
- "@babel/runtime-corejs3": "^8.0.0",
12
+ "@babel/runtime-corejs3": "^8.0.6",
13
13
  "@commander-js/extra-typings": "^15.0.0",
14
- "@dr.pogodin/babel-plugin-react-css-modules": "^7.1.0",
14
+ "@dr.pogodin/babel-plugin-react-css-modules": "^8.0.0-alpha.8",
15
15
  "@dr.pogodin/csurf": "^1.17.1",
16
16
  "@dr.pogodin/js-utils": "^0.2.0",
17
17
  "@dr.pogodin/react-global-state": "^0.25.0",
18
18
  "@dr.pogodin/react-helmet": "^3.2.3",
19
19
  "@dr.pogodin/react-themes": "^1.11.0",
20
- "@jest/environment": "^30.5.1",
20
+ "@jest/environment": "^30.5.2",
21
21
  "axios": "^1.20.0",
22
22
  "commander": "^15.0.0",
23
23
  "compression": "^1.8.1",
@@ -46,18 +46,18 @@
46
46
  },
47
47
  "description": "Collection of generic ReactJS components and utils",
48
48
  "devDependencies": {
49
- "@babel/cli": "^8.0.4",
50
- "@babel/core": "^8.0.1",
51
- "@babel/plugin-transform-runtime": "^8.0.1",
52
- "@babel/preset-env": "^8.0.2",
49
+ "@babel/cli": "^8.0.6",
50
+ "@babel/core": "^8.0.6",
51
+ "@babel/plugin-transform-runtime": "^8.0.6",
52
+ "@babel/preset-env": "^8.0.6",
53
53
  "@babel/preset-react": "^8.0.1",
54
54
  "@babel/preset-typescript": "^8.0.1",
55
- "@babel/register": "^8.0.1",
55
+ "@babel/register": "^8.0.6",
56
56
  "@dr.pogodin/babel-plugin-add-import-extension": "^3.0.2",
57
57
  "@dr.pogodin/babel-plugin-transform-assets": "^2.0.0",
58
58
  "@dr.pogodin/babel-preset-svgr": "^2.0.0",
59
59
  "@dr.pogodin/eslint-configs": "^0.3.7",
60
- "@jest/globals": "^30.5.1",
60
+ "@jest/globals": "^30.5.2",
61
61
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.3",
62
62
  "@standard-schema/spec": "^1.1.0",
63
63
  "@testing-library/dom": "^10.4.1",
@@ -81,28 +81,24 @@
81
81
  "@types/serve-favicon": "^2.5.7",
82
82
  "@types/supertest": "^7.2.1",
83
83
  "@types/webpack": "^5.28.5",
84
- "autoprefixer": "^10.5.5",
85
- "babel-jest": "^30.5.1",
84
+ "babel-jest": "^30.5.2",
86
85
  "babel-loader": "^10.1.1",
87
86
  "babel-plugin-module-resolver": "^5.0.3",
88
87
  "babel-plugin-polyfill-corejs3": "^1.0.0",
89
88
  "babel-plugin-react-compiler": "^1.0.0",
90
- "css-loader": "^7.1.5",
91
- "css-minimizer-webpack-plugin": "^8.0.0",
89
+ "cssnano": "^9.1.2",
92
90
  "identity-obj-proxy": "^3.0.0",
93
- "jest": "^30.5.1",
94
- "jest-environment-jsdom": "^30.5.1",
91
+ "jest": "^30.5.2",
92
+ "jest-environment-jsdom": "^30.5.2",
95
93
  "memfs": "^4.71.0",
96
- "mini-css-extract-plugin": "^2.10.2",
94
+ "minimizer-webpack-plugin": "^5.12.0",
97
95
  "mockdate": "^3.0.5",
98
96
  "nodelist-foreach-polyfill": "^1.2.0",
99
97
  "postcss": "^8.5.28",
100
- "postcss-loader": "^8.2.1",
101
98
  "postcss-scss": "^4.0.9",
102
99
  "pretty": "^2.0.0",
103
100
  "react-refresh": "^0.18.0",
104
- "resolve-url-loader": "^5.0.0",
105
- "sass": "^1.104.0",
101
+ "sass": "^1.104.1",
106
102
  "sass-loader": "^17.0.1",
107
103
  "sitemap": "^9.0.1",
108
104
  "source-map-loader": "^5.0.0",
@@ -113,7 +109,7 @@
113
109
  "tstyche": "^7.2.4",
114
110
  "typed-scss-modules": "^8.1.1",
115
111
  "typescript": "^6.0.3",
116
- "webpack": "^5.110.3",
112
+ "webpack": "^5.111.1",
117
113
  "webpack-dev-middleware": "^8.3.0",
118
114
  "webpack-merge": "^6.0.1",
119
115
  "workbox-core": "^7.4.1",