@dr.pogodin/react-utils 1.39.6 → 1.40.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.
@@ -29,18 +29,16 @@ const lodash_1 = require("lodash");
29
29
  const webpack_1 = __importStar(require("./webpack"));
30
30
  /**
31
31
  * Creates a new base config.
32
- * @param {object} babel Babel compiler.
33
- * @param {object} [options] It supports all options of
34
- * {@link module:babel/webpack.getPreset babel/webpack's getPreset()},
35
- * but it overrides `targets` option with `current node` value, and further
32
+ * @param babel Babel compiler.
33
+ * @param [options] It supports all options of our Babel config for Webpack,
34
+ * but it overrides `targets` option with "current node" value, and further
36
35
  * accepts the following:
37
- * @param {string} [options.baseAssetsOutputPath] Path prefix for emitted
36
+ * @param [options.baseAssetsOutputPath] Path prefix for emitted
38
37
  * image assets.
39
- * @return {object} Created config object.
40
- * @ignore
38
+ * @return Created config object.
41
39
  */
42
40
  function newBase(babel, options = {}) {
43
- const config = (0, webpack_1.default)(babel, Object.assign(Object.assign({}, options), { targets: 'current node' }));
41
+ const config = (0, webpack_1.default)(babel, Object.assign({ modules: 'cjs', targets: 'current node' }, options));
44
42
  const baseAssetsOutputPath = options.baseAssetsOutputPath || '';
45
43
  config.plugins.push(['@dr.pogodin/transform-assets', {
46
44
  extensions: ['gif', 'jpeg', 'jpg', 'png'],
@@ -16,7 +16,9 @@ export type ConfigT = {
16
16
  presets: PresetOrPluginT[];
17
17
  plugins: PresetOrPluginT[];
18
18
  };
19
+ type ModuleT = 'amd' | 'auto' | 'cjs' | 'commonjs' | 'systemjs' | 'umd' | false;
19
20
  export type OptionsT = {
21
+ modules?: ModuleT;
20
22
  noRR?: boolean;
21
23
  noStyling?: boolean;
22
24
  targets?: string | string[] | {
@@ -20,10 +20,15 @@ var ENVIRONMENTS;
20
20
  * @return Generated config.
21
21
  */
22
22
  function newBaseConfig(options) {
23
+ var _a;
23
24
  return {
24
25
  presets: [
25
- // Chrome 69 is the browser for Android API 28.
26
- ['@babel/env', { targets: options.targets || 'defaults or chrome >= 69' }],
26
+ ['@babel/env', {
27
+ // Leaves it to the Webpack to deal with modules.
28
+ modules: (_a = options.modules) !== null && _a !== void 0 ? _a : false,
29
+ // Chrome 69 is the browser/WebView for Android 9 (API level 28).
30
+ targets: options.targets || 'defaults or chrome >= 69',
31
+ }],
27
32
  // TODO: Starting from Babel 8, "automatic" will be the default runtime,
28
33
  // thus once upgraded to Babel 8, runtime should be removed from
29
34
  // @babel/react options below.
@@ -5,7 +5,7 @@
5
5
  * Base [Webpack](https://webpack.js.org/) configuration for apps.
6
6
  */
7
7
  import nodeFs from 'fs';
8
- import { type Configuration } from 'webpack';
8
+ import { type Configuration, type RuleSetRule } from 'webpack';
9
9
  export type BuildInfoT = {
10
10
  key: string;
11
11
  publicPath: string;
@@ -14,6 +14,7 @@ export type BuildInfoT = {
14
14
  };
15
15
  export type OptionsT = {
16
16
  babelEnv: string;
17
+ babelLoaderExclude?: RuleSetRule['exclude'];
17
18
  babelLoaderOptions?: object;
18
19
  context: string;
19
20
  cssLocalIdent?: string;
@@ -37,6 +38,8 @@ export type OptionsT = {
37
38
  * directly with the created config object.
38
39
  * @param {string} ops.babelEnv Babel environment to use for the Babel
39
40
  * compilation step.
41
+ * @param [ops.babelLoaderExclude] Overrides the default value of `exclude`
42
+ * option of babel-loader, which is [/node_modules/].
40
43
  * @param {object} [ops.babelLoaderOptions] Overrides for default Babel options
41
44
  * of JSX and SVG files loader.
42
45
  * @param ops.context Base URL for resolution of relative config paths.
@@ -28,6 +28,8 @@ const utils_1 = require("@dr.pogodin/babel-plugin-react-css-modules/utils");
28
28
  * directly with the created config object.
29
29
  * @param {string} ops.babelEnv Babel environment to use for the Babel
30
30
  * compilation step.
31
+ * @param [ops.babelLoaderExclude] Overrides the default value of `exclude`
32
+ * option of babel-loader, which is [/node_modules/].
31
33
  * @param {object} [ops.babelLoaderOptions] Overrides for default Babel options
32
34
  * of JSX and SVG files loader.
33
35
  * @param ops.context Base URL for resolution of relative config paths.
@@ -128,6 +130,7 @@ const utils_1 = require("@dr.pogodin/babel-plugin-react-css-modules/utils");
128
130
  * - **`timestamp`** — The value set for `BUILD_TIMESTAMP`.
129
131
  */
130
132
  function configFactory(ops) {
133
+ var _a;
131
134
  const o = (0, lodash_1.defaults)((0, lodash_1.clone)(ops), {
132
135
  babelLoaderOptions: {},
133
136
  cssLocalIdent: '[hash:base64:6]',
@@ -264,9 +267,10 @@ function configFactory(ops) {
264
267
  enforce: 'pre',
265
268
  use: ['source-map-loader'],
266
269
  }, {
267
- /* Loads JS and JSX moudles, and inlines SVG assets. */
268
- test: ops.typescript ? /\.((j|t)sx?|svg)$/ : /\.(jsx?|svg)$/,
269
- exclude: [/node_modules/],
270
+ // Loads JS modules (.cjs, .js, .jsx); TS modules (.ts, .tsx);
271
+ // and SVG assets (.svg).
272
+ test: ops.typescript ? /\.(cjs|(j|t)sx?|svg)$/ : /\.(cjs|jsx?|svg)$/,
273
+ exclude: (_a = ops.babelLoaderExclude) !== null && _a !== void 0 ? _a : [/node_modules/],
270
274
  loader: 'babel-loader',
271
275
  options: Object.assign({ babelrc: false, configFile: false, envName: o.babelEnv, presets: [['@dr.pogodin/react-utils/config/babel/webpack', {
272
276
  typescript: ops.typescript,
@@ -25,7 +25,7 @@ function configFactory(ops) {
25
25
  '@dr.pogodin/react-utils/build/production/client/init',
26
26
  ...Array.isArray(ops.entry) ? ops.entry : [ops.entry],
27
27
  ];
28
- const res = (0, webpack_merge_1.merge)((0, app_base_1.default)(Object.assign(Object.assign({}, ops), { babelEnv: 'production', entry, mode: 'production' })), {
28
+ const res = (0, webpack_merge_1.merge)((0, app_base_1.default)(Object.assign(Object.assign({ babelLoaderExclude: [] }, ops), { babelEnv: 'production', babelLoaderOptions: Object.assign({ compact: true }, ops.babelLoaderOptions), entry, mode: 'production' })), {
29
29
  optimization: {
30
30
  minimizer: [
31
31
  '...',
@@ -32,6 +32,7 @@ function configFactory(ops) {
32
32
  '@dr.pogodin/react-themes',
33
33
  '@dr.pogodin/react-utils',
34
34
  'axios',
35
+ 'cookie',
35
36
  'dayjs',
36
37
  'lodash',
37
38
  /node-forge/,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.39.6",
2
+ "version": "1.40.0",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -15,7 +15,7 @@
15
15
  "@dr.pogodin/react-global-state": "^0.16.1",
16
16
  "@dr.pogodin/react-themes": "^1.7.0",
17
17
  "@jest/environment": "^29.7.0",
18
- "axios": "^1.7.2",
18
+ "axios": "^1.7.3",
19
19
  "commander": "^12.1.0",
20
20
  "compression": "^1.7.4",
21
21
  "config": "^3.3.12",
@@ -30,12 +30,12 @@
30
30
  "lodash": "^4.17.21",
31
31
  "morgan": "^1.10.0",
32
32
  "node-forge": "^1.3.1",
33
- "qs": "^6.12.3",
33
+ "qs": "^6.13.0",
34
34
  "raf": "^3.4.1",
35
35
  "react": "^18.3.1",
36
36
  "react-dom": "^18.3.1",
37
37
  "react-helmet": "^6.1.0",
38
- "react-router-dom": "^6.25.1",
38
+ "react-router-dom": "^6.26.0",
39
39
  "request-ip": "^3.3.0",
40
40
  "rimraf": "^6.0.0",
41
41
  "serialize-javascript": "^6.0.2",
@@ -83,7 +83,7 @@
83
83
  "@types/supertest": "^6.0.2",
84
84
  "@types/uuid": "^10.0.0",
85
85
  "@types/webpack": "^5.28.5",
86
- "autoprefixer": "^10.4.19",
86
+ "autoprefixer": "^10.4.20",
87
87
  "babel-jest": "^29.7.0",
88
88
  "babel-loader": "^9.1.3",
89
89
  "babel-plugin-module-resolver": "^5.0.2",
@@ -95,7 +95,7 @@
95
95
  "eslint-config-airbnb-typescript": "^18.0.0",
96
96
  "eslint-import-resolver-babel-module": "^5.3.2",
97
97
  "eslint-plugin-import": "^2.29.1",
98
- "eslint-plugin-jest": "^28.6.0",
98
+ "eslint-plugin-jest": "^28.7.0",
99
99
  "eslint-plugin-jsx-a11y": "^6.9.0",
100
100
  "eslint-plugin-react": "^7.35.0",
101
101
  "eslint-plugin-react-hooks": "^4.6.2",