@dr.pogodin/react-utils 1.57.0-alpha.2 → 1.57.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/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 --tag v1.57-alpha
26
+ npm publish --access public
@@ -1,2 +1,2 @@
1
- import type { InjT } from '../shared/utils/globalState';
1
+ import type { InjT } from '../shared/utils/globalState.js';
2
2
  export default function getInj(): InjT | Promise<InjT>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Initialization of client-side environment.
3
3
  */
4
- import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo';
4
+ import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo.js';
5
5
  declare global {
6
6
  interface Window {
7
7
  __DEV_BUILD_INFO__: BuildInfoT | undefined;
@@ -6,7 +6,7 @@ declare global {
6
6
  }
7
7
  }
8
8
  export { type AsyncCollectionLoaderT, type AsyncCollectionT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, GlobalStateProvider, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, useGlobalStateObject, withGlobalStateType, } from '@dr.pogodin/react-global-state';
9
- export * from './shared/components';
9
+ export * from './shared/components/index.js';
10
10
  export { type BeforeRenderResT, type BeforeRenderT, type ConfigT, type ServerSsrContext, type ServerT, } from './server';
11
- export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, THEME_COMPOSE, THEME_PRIORITY, type Theme, ThemeProvider, assertEmptyObject, getConfig, setClientChunkGroups, splitComponent, time, useSsrContext, useTheme, webpack, withRetries, } from './shared/utils';
12
- export * from './shared/utils/isomorphy';
11
+ export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, THEME_COMPOSE, THEME_PRIORITY, type Theme, ThemeProvider, assertEmptyObject, getConfig, setClientChunkGroups, splitComponent, time, useSsrContext, useTheme, webpack, withRetries, } from './shared/utils/index.js';
12
+ export * from './shared/utils/isomorphy/index.js';
@@ -6,8 +6,8 @@ import type { ComponentType } from 'react';
6
6
  import type { Configuration, Stats } from 'webpack';
7
7
  import winston from 'winston';
8
8
  import { SsrContext } from '@dr.pogodin/react-global-state';
9
- import type { ChunkGroupsT, SsrContextT } from '../shared/utils/globalState';
10
- import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo';
9
+ import type { ChunkGroupsT, SsrContextT } from '../shared/utils/globalState.js';
10
+ import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo.js';
11
11
  interface LogMethodI {
12
12
  (level: string, message: string, ...meta: unknown[]): void;
13
13
  }
@@ -2,15 +2,15 @@
2
2
  * Just an aggregation of all exported components into a single module.
3
3
  */
4
4
  export { MetaTags } from '@dr.pogodin/react-helmet';
5
- export * from './selectors';
6
- export { BaseButton, default as Button } from './Button';
7
- export { default as Checkbox } from './Checkbox';
8
- export { default as Input } from './Input';
9
- export { default as Link } from './Link';
10
- export { BaseModal, default as Modal } from './Modal';
11
- export { default as NavLink } from './NavLink';
12
- export { default as PageLayout } from './PageLayout';
13
- export { default as Throbber } from './Throbber';
14
- export { default as WithTooltip } from './WithTooltip';
15
- export { default as YouTubeVideo } from './YouTubeVideo';
5
+ export * from './selectors/index.js';
6
+ export { BaseButton, default as Button } from './Button/index.js';
7
+ export { default as Checkbox } from './Checkbox/index.js';
8
+ export { default as Input } from './Input/index.js';
9
+ export { default as Link } from './Link.js';
10
+ export { BaseModal, default as Modal } from './Modal/index.js';
11
+ export { default as NavLink } from './NavLink.js';
12
+ export { default as PageLayout } from './PageLayout/index.js';
13
+ export { default as Throbber } from './Throbber/index.js';
14
+ export { default as WithTooltip } from './WithTooltip/index.js';
15
+ export { default as YouTubeVideo } from './YouTubeVideo/index.js';
16
16
  export { default as TextArea } from './TextArea';
@@ -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[];
@@ -133,4 +133,4 @@ export type OptionsT = {
133
133
  * - **`rndkey`** &mdash; The value set for `BUILD_RNDKEY`;
134
134
  * - **`timestamp`** &mdash; The value set for `BUILD_TIMESTAMP`.
135
135
  */
136
- export default function configFactory(ops: OptionsT): Configuration;
136
+ export default function configFactory({ babelEnv, babelLoaderExclude, babelLoaderOptions, context, cssLocalIdent, dontEmitBuildInfo, dontUseProgressPlugin, entry, fs, keepBuildInfo, mode, outputPath, publicPath, sitemap, typescript, workbox, }: OptionsT): Configuration;
@@ -3,7 +3,8 @@ 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 { clone, defaults, isFunction, isObject, } from 'lodash-es';
6
+ import autoprefixer from 'autoprefixer';
7
+ import { isFunction } from 'lodash-es';
7
8
  import { SitemapStream, streamToPromise } from 'sitemap';
8
9
  // NOTE: As "webpack" is still distributed as CJS module, now that we have
9
10
  // switched to MJS, importing plugins from it in MJS import style does not work,
@@ -122,21 +123,13 @@ const require = createRequire(import.meta.url);
122
123
  * - **`rndkey`** &mdash; The value set for `BUILD_RNDKEY`;
123
124
  * - **`timestamp`** &mdash; The value set for `BUILD_TIMESTAMP`.
124
125
  */
125
- export default function configFactory(ops) {
126
- var _a;
127
- const o = defaults(clone(ops), {
128
- babelLoaderOptions: {},
129
- cssLocalIdent: '[hash:base64:6]',
130
- outputPath: 'build/web-public',
131
- publicPath: '',
132
- });
133
- const fs = (_a = ops.fs) !== null && _a !== void 0 ? _a : nodeFs;
126
+ export default function configFactory({ babelEnv, babelLoaderExclude, babelLoaderOptions = {}, context, cssLocalIdent = '[hash:base64:6]', dontEmitBuildInfo, dontUseProgressPlugin, entry, fs = nodeFs, keepBuildInfo, mode, outputPath = 'build/web-public', publicPath = '', sitemap, typescript, workbox, }) {
134
127
  // TODO: Should it be improved and re-validated? Are we using it in any project
135
128
  // as is?
136
129
  /* TODO: This works in practice, but being async and not awaited it is a bad
137
130
  * pattern. */
138
- if (o.sitemap) {
139
- const sitemapUrl = resolve(o.context, o.sitemap);
131
+ if (sitemap) {
132
+ const sitemapUrl = resolve(context, sitemap);
140
133
  // eslint-disable-next-line import/no-dynamic-require
141
134
  let source = require(sitemapUrl);
142
135
  if (isFunction(source))
@@ -146,11 +139,11 @@ export default function configFactory(ops) {
146
139
  sm.write(item);
147
140
  });
148
141
  sm.end();
149
- void streamToPromise(sm).then((sitemap) => {
150
- const outUrl = resolve(o.context, o.outputPath);
142
+ void streamToPromise(sm).then((sitemapRes) => {
143
+ const outUrl = resolve(context, outputPath);
151
144
  if (!fs.existsSync(outUrl))
152
145
  fs.mkdirSync(outUrl);
153
- fs.writeFileSync(resolve(o.context, o.outputPath, 'sitemap.xml'), new DataView(sitemap.buffer));
146
+ fs.writeFileSync(resolve(context, outputPath, 'sitemap.xml'), new DataView(sitemapRes.buffer));
154
147
  });
155
148
  }
156
149
  // TODO: Once all assets are named by hashes, we probably don't need build
@@ -159,10 +152,10 @@ export default function configFactory(ops) {
159
152
  // timestamp, and any other similar information to the actual app, so it
160
153
  // can be used in some scenarious.
161
154
  let buildInfo;
162
- const buildInfoUrl = resolve(o.context, '.build-info');
163
- if (o.keepBuildInfo) {
155
+ const buildInfoUrl = resolve(context, '.build-info');
156
+ if (keepBuildInfo) {
164
157
  // If "true" - attempt to load from the filesystem.
165
- if (o.keepBuildInfo === true) {
158
+ if (keepBuildInfo === true) {
166
159
  if (fs.existsSync(buildInfoUrl)) {
167
160
  buildInfo = JSON.parse(fs.readFileSync(buildInfoUrl, 'utf8'));
168
161
  }
@@ -170,7 +163,7 @@ export default function configFactory(ops) {
170
163
  // to use in the build.
171
164
  }
172
165
  else
173
- buildInfo = o.keepBuildInfo;
166
+ buildInfo = keepBuildInfo;
174
167
  }
175
168
  // Even if "keepBuildInfo" option was provided, we still generate a new
176
169
  // build info object in case nothing could be loaded.
@@ -178,57 +171,55 @@ export default function configFactory(ops) {
178
171
  /* A random 32-bit key, that can be used for encryption. */
179
172
  key: randomBytes(32).toString('base64'),
180
173
  /* Public path used during build. */
181
- publicPath: o.publicPath,
174
+ publicPath,
182
175
  /* `true` if client-side code should setup a service worker. */
183
- useServiceWorker: Boolean(o.workbox),
176
+ useServiceWorker: Boolean(workbox),
184
177
  // Build timestamp.
185
178
  timestamp: new Date().toISOString(),
186
179
  }));
187
180
  // If not opted-out, we write the build info to the filesystem. We also attach
188
181
  // it to the factory function itself, so it can be easily accessed right after
189
182
  // the factory call in testing scenarios.
190
- if (!o.dontEmitBuildInfo) {
183
+ if (!dontEmitBuildInfo) {
191
184
  // Note: this is needed if "fs" option is provided, to ensure the factory
192
185
  // does not crash if the folder is not created in that filesystem.
193
- fs.mkdirSync(o.context, { recursive: true });
186
+ fs.mkdirSync(context, { recursive: true });
194
187
  fs.writeFileSync(buildInfoUrl, JSON.stringify(buildInfo));
195
188
  }
196
189
  /* Entry points normalization. */
197
- const entry = [
190
+ const normalizedEntry = [
198
191
  'nodelist-foreach-polyfill',
199
- ...Array.isArray(o.entry) ? o.entry : [o.entry],
192
+ ...Array.isArray(entry) ? entry : [entry],
200
193
  ];
201
194
  const plugins = [
202
195
  new webpack.DefinePlugin({ BUILD_INFO: JSON.stringify(buildInfo) }),
203
196
  ];
204
- if (!ops.dontUseProgressPlugin)
197
+ if (!dontUseProgressPlugin)
205
198
  plugins.push(new webpack.ProgressPlugin());
206
199
  /* Adds InjectManifest plugin from WorkBox, if opted to. */
207
- if (o.workbox) {
208
- if (!isObject(o.workbox))
209
- o.workbox = {};
210
- plugins.push(new WorkboxPlugin.InjectManifest(Object.assign(Object.assign({ swSrc: resolve(import.meta.dirname, '../workbox/default.js') }, o.workbox), { swDest: '__service-worker.js' })));
200
+ if (workbox) {
201
+ plugins.push(new WorkboxPlugin.InjectManifest(Object.assign(Object.assign({ swSrc: resolve(import.meta.dirname, '../workbox/default.js') }, workbox === true ? {} : workbox), { swDest: '__service-worker.js' })));
211
202
  }
212
- let { babelLoaderExclude } = ops;
213
- if (babelLoaderExclude) {
214
- if (!Array.isArray(babelLoaderExclude))
203
+ let babelLoaderExclude2 = babelLoaderExclude;
204
+ if (babelLoaderExclude2) {
205
+ if (!Array.isArray(babelLoaderExclude2))
215
206
  throw Error('Not supported');
216
207
  // BEWARE: This ensures Babel loader does not process CoreJS library,
217
208
  // which would break it creating circular references in its code.
218
- babelLoaderExclude = [...babelLoaderExclude, COREJS_REGEX];
209
+ babelLoaderExclude2 = [...babelLoaderExclude2, COREJS_REGEX];
219
210
  }
220
211
  else {
221
- babelLoaderExclude = [COREJS_REGEX];
212
+ babelLoaderExclude2 = [COREJS_REGEX];
222
213
  }
223
214
  const res = {
224
- context: o.context,
225
- entry,
215
+ context,
216
+ entry: normalizedEntry,
226
217
  experiments: { css: true },
227
- mode: o.mode,
218
+ mode,
228
219
  module: {
229
220
  generator: {
230
221
  'css/module': {
231
- localIdentName: localIdentNameFactory(o.cssLocalIdent),
222
+ localIdentName: localIdentNameFactory(cssLocalIdent),
232
223
  },
233
224
  },
234
225
  parser: {
@@ -254,11 +245,11 @@ export default function configFactory(ops) {
254
245
  // Loads JS modules (.cjs, .js, .jsx, .mjs); TS modules (.ts, .tsx);
255
246
  // and SVG assets (.svg).
256
247
  test: /\.(cjs|js|jsx|mjs|svg|ts|tsx)$/,
257
- exclude: babelLoaderExclude,
248
+ exclude: babelLoaderExclude2,
258
249
  loader: 'babel-loader',
259
- options: Object.assign({ babelrc: false, configFile: false, envName: o.babelEnv, presets: [['@dr.pogodin/react-utils/config/babel/webpack', {
260
- typescript: ops.typescript,
261
- }]], sourceType: 'unambiguous' }, o.babelLoaderOptions),
250
+ options: Object.assign({ babelrc: false, configFile: false, envName: babelEnv, presets: [['@dr.pogodin/react-utils/config/babel/webpack', {
251
+ typescript,
252
+ }]], sourceType: 'unambiguous' }, babelLoaderOptions),
262
253
  }, {
263
254
  /* Loads image assets. */
264
255
  test: /\.(gif|jpe?g|png)$/,
@@ -270,12 +261,19 @@ export default function configFactory(ops) {
270
261
  /* Loads SCSS stylesheets. */
271
262
  test: /\.scss$/,
272
263
  type: 'css/module',
273
- use: {
274
- loader: 'sass-loader',
275
- options: {
276
- sourceMap: true,
277
- },
278
- },
264
+ use: [{
265
+ loader: 'postcss-loader',
266
+ options: {
267
+ postcssOptions: {
268
+ plugins: [autoprefixer],
269
+ },
270
+ },
271
+ }, {
272
+ loader: 'sass-loader',
273
+ options: {
274
+ sourceMap: true,
275
+ },
276
+ }],
279
277
  }],
280
278
  },
281
279
  node: {
@@ -283,18 +281,20 @@ export default function configFactory(ops) {
283
281
  },
284
282
  output: {
285
283
  chunkFilename: '[contenthash].js',
284
+ cssChunkFilename: '[contenthash].css',
285
+ cssFilename: '[contenthash].css',
286
286
  filename: '[contenthash].js',
287
- path: resolve(import.meta.dirname, o.context, o.outputPath),
288
- publicPath: `${o.publicPath}/`,
287
+ path: resolve(import.meta.dirname, context, outputPath),
288
+ publicPath: `${publicPath}/`,
289
289
  },
290
290
  plugins,
291
291
  resolve: {
292
292
  alias: {
293
293
  // Aliases to JS an JSX files are handled by Babel.
294
- assets: resolve(o.context, 'src/assets'),
295
- components: resolve(o.context, 'src/shared/components'),
296
- fonts: resolve(o.context, 'src/assets/fonts'),
297
- styles: resolve(o.context, 'src/styles'),
294
+ assets: resolve(context, 'src/assets'),
295
+ components: resolve(context, 'src/shared/components'),
296
+ fonts: resolve(context, 'src/assets/fonts'),
297
+ styles: resolve(context, 'src/styles'),
298
298
  },
299
299
  extensions: [
300
300
  '.ts',
@@ -40,6 +40,8 @@ export default function configFactory(ops) {
40
40
  const res = merge(baseFactory(Object.assign(Object.assign({}, o), { babelEnv: 'development', entry, mode: 'development' })), {
41
41
  output: {
42
42
  chunkFilename: '[id].js',
43
+ cssChunkFilename: '[id].css',
44
+ cssFilename: '[id].css',
43
45
  filename: '[id].js',
44
46
  },
45
47
  plugins,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.57.0-alpha.2",
2
+ "version": "1.57.1",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-run-with-babel": "bin/run-with-babel.js",
@@ -11,16 +11,16 @@
11
11
  "dependencies": {
12
12
  "@babel/runtime-corejs3": "^8.0.6",
13
13
  "@commander-js/extra-typings": "^15.0.0",
14
- "@dr.pogodin/babel-plugin-react-css-modules": "^8.0.0-alpha.8",
15
- "@dr.pogodin/csurf": "^1.17.1",
14
+ "@dr.pogodin/babel-plugin-react-css-modules": "^8.0.0",
15
+ "@dr.pogodin/csurf": "^1.18.1",
16
16
  "@dr.pogodin/js-utils": "^0.2.0",
17
17
  "@dr.pogodin/react-global-state": "^0.25.0",
18
- "@dr.pogodin/react-helmet": "^3.2.3",
18
+ "@dr.pogodin/react-helmet": "^3.3.2",
19
19
  "@dr.pogodin/react-themes": "^1.11.0",
20
20
  "@jest/environment": "^30.5.2",
21
21
  "axios": "^1.20.0",
22
22
  "commander": "^15.0.0",
23
- "compression": "^1.8.1",
23
+ "compression": "^1.8.2",
24
24
  "config": "^5.0.1",
25
25
  "cookie": "^2.0.1",
26
26
  "cookie-parser": "^1.4.7",
@@ -31,15 +31,15 @@
31
31
  "helmet": "^8.3.0",
32
32
  "http-status-codes": "^2.3.0",
33
33
  "lodash-es": "^4.18.1",
34
- "morgan": "^1.12.0",
34
+ "morgan": "^1.12.1",
35
35
  "qs": "^6.16.0",
36
36
  "raf": "^3.4.1",
37
- "react": "^19.2.8",
38
- "react-dom": "^19.2.8",
39
- "react-router": "^8.3.1",
37
+ "react": "^19.3.0",
38
+ "react-dom": "^19.3.0",
39
+ "react-router": "^8.4.0",
40
40
  "request-ip": "^3.3.0",
41
41
  "rimraf": "^6.1.3",
42
- "serialize-javascript": "^7.1.1",
42
+ "serialize-javascript": "^7.1.2",
43
43
  "serve-favicon": "^2.5.1",
44
44
  "source-map-support": "^0.5.21",
45
45
  "winston": "^3.19.0"
@@ -60,7 +60,7 @@
60
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
- "@testing-library/dom": "^10.4.1",
63
+ "@testing-library/dom": "^10.4.2",
64
64
  "@testing-library/react": "^16.3.3",
65
65
  "@testing-library/user-event": "^14.6.7",
66
66
  "@tsconfig/recommended": "^1.0.13",
@@ -74,39 +74,41 @@
74
74
  "@types/lodash-es": "^4.17.12",
75
75
  "@types/morgan": "^1.9.10",
76
76
  "@types/pretty": "^2.0.3",
77
- "@types/react": "^19.2.18",
78
- "@types/react-dom": "^19.2.7",
77
+ "@types/react": "^19.3.0",
78
+ "@types/react-dom": "^19.3.0",
79
79
  "@types/request-ip": "^0.0.41",
80
80
  "@types/serialize-javascript": "^5.0.4",
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.6.1",
84
85
  "babel-jest": "^30.5.2",
85
86
  "babel-loader": "^10.1.1",
86
87
  "babel-plugin-module-resolver": "^5.0.3",
87
88
  "babel-plugin-polyfill-corejs3": "^1.0.0",
88
89
  "babel-plugin-react-compiler": "^1.0.0",
89
- "cssnano": "^9.1.2",
90
+ "cssnano": "^9.2.2",
90
91
  "identity-obj-proxy": "^3.0.0",
91
92
  "jest": "^30.5.2",
92
93
  "jest-environment-jsdom": "^30.5.2",
93
94
  "memfs": "^4.71.0",
94
- "minimizer-webpack-plugin": "^5.12.0",
95
+ "minimizer-webpack-plugin": "^5.13.0",
95
96
  "mockdate": "^3.0.5",
96
97
  "nodelist-foreach-polyfill": "^1.2.0",
97
98
  "postcss": "^8.5.28",
99
+ "postcss-loader": "^8.2.1",
98
100
  "postcss-scss": "^4.0.9",
99
101
  "pretty": "^2.0.0",
100
- "react-refresh": "^0.18.0",
102
+ "react-refresh": "^0.19.0",
101
103
  "sass": "^1.104.1",
102
104
  "sass-loader": "^17.0.1",
103
105
  "sitemap": "^9.0.1",
104
106
  "source-map-loader": "^5.0.0",
105
- "stylelint": "^17.15.0",
107
+ "stylelint": "^17.16.0",
106
108
  "stylelint-config-standard-scss": "^17.0.0",
107
- "supertest": "^7.2.2",
108
- "tsc-alias": "^1.9.4",
109
- "tstyche": "^7.2.4",
109
+ "supertest": "^7.3.1",
110
+ "tsc-alias": "^1.9.7",
111
+ "tstyche": "^7.2.5",
110
112
  "typed-scss-modules": "^8.1.1",
111
113
  "typescript": "^6.0.3",
112
114
  "webpack": "^5.111.1",