@dr.pogodin/react-utils 1.47.0-alpha.2 → 1.47.0-alpha.3
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/babel.config.js +1 -1
- package/babel.module.config.js +11 -0
- package/bin/build.js +8 -4
- package/bin/setup.js +2 -3
- package/build/development/client/getInj.js +9 -18
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +14 -21
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +2 -6
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +9 -178
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +1 -8
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +25 -50
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +56 -67
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +47 -58
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +8 -31
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js +2 -9
- package/build/development/server/utils/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js +9 -16
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +6 -13
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +4 -10
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +11 -18
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +6 -13
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +16 -22
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +6 -13
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +7 -14
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +15 -22
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +7 -14
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +12 -18
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +16 -23
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +10 -17
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +16 -130
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +12 -19
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +20 -28
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +13 -19
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +10 -17
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js +1 -7
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/components/selectors/index.js +3 -27
- package/build/development/shared/components/selectors/index.js.map +1 -1
- package/build/development/shared/utils/config.js +8 -16
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/globalState.js +3 -8
- package/build/development/shared/utils/globalState.js.map +1 -1
- package/build/development/shared/utils/index.js +12 -89
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js +2 -9
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/isomorphy/environment-check.js +2 -8
- package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/development/shared/utils/isomorphy/index.js +7 -32
- package/build/development/shared/utils/isomorphy/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +20 -31
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/global.js +1 -7
- package/build/development/shared/utils/jest/global.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +20 -44
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +22 -29
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +22 -31
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +13 -16
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/client/getInj.js +5 -5
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +3 -3
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js +2 -2
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js +2 -2
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js +3 -3
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js +8 -8
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +21 -19
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +9 -9
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +9 -9
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/server/utils/index.js +2 -1
- package/build/production/server/utils/index.js.map +1 -1
- package/build/production/shared/components/Button/index.js +4 -4
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +4 -4
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +5 -5
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js +3 -3
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +7 -7
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +2 -2
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +2 -2
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js +5 -5
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -2
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +4 -4
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +4 -4
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +4 -4
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +3 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +4 -4
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/components/selectors/common.js +2 -2
- package/build/production/shared/components/selectors/common.js.map +1 -1
- package/build/production/shared/components/selectors/index.js +1 -1
- package/build/production/shared/components/selectors/index.js.map +1 -1
- package/build/production/shared/utils/config.js +3 -3
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/globalState.js +2 -2
- package/build/production/shared/utils/globalState.js.map +1 -1
- package/build/production/shared/utils/index.js +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy/buildInfo.js +3 -3
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/isomorphy/environment-check.js +3 -3
- package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/production/shared/utils/isomorphy/index.js +4 -4
- package/build/production/shared/utils/isomorphy/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +14 -14
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/global.js +1 -1
- package/build/production/shared/utils/jest/global.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +11 -11
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +11 -11
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +3 -3
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js +6 -6
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +1 -1
- package/build/types-code/server/index.d.ts +2 -2
- package/build/web/client/getInj.js +2 -2
- package/build/web/client/getInj.js.map +1 -1
- package/build/web/server/index.js +9 -15
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +12 -10
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +2 -4
- package/build/web/server/server.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv.js +1 -2
- package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/web/shared/utils/webpack.js +11 -7
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/node-ssr.js +5 -5
- package/config/jest/default.js +1 -0
- package/config/webpack/app-base.js +11 -10
- package/config/webpack/app-development.js +3 -3
- package/config/webpack/lib-base.js +1 -1
- package/package.json +8 -6
- package/src/client/getInj.ts +2 -2
- package/src/server/index.ts +9 -15
- package/src/server/renderer.tsx +11 -10
- package/src/server/server.ts +2 -4
- package/src/shared/utils/jest/E2eSsrEnv.ts +1 -2
- package/src/shared/utils/webpack.ts +14 -8
- package/types.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","names":["IS_CLIENT_SIDE","
|
|
1
|
+
{"version":3,"file":"webpack.js","names":["createRequire","IS_CLIENT_SIDE","IS_SERVER_SIDE","require","import","meta","url","requireWeak","modulePath","basePathOrOptions","basePath","ops","resolve","path","module","default","def","named","res","Object","entries","forEach","name","value","assigned","undefined","Error","resolveWeak"],"sources":["../../../../src/shared/utils/webpack.ts"],"sourcesContent":["import type PathNS from 'node:path';\n\n// eslint-disable-next-line import/enforce-node-protocol-usage\nimport { createRequire } from 'module';\n\nimport { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './isomorphy';\n\ntype RequireWeakOptionsT = {\n basePath?: string;\n};\n\ntype RequireWeakResT<T> = T extends { default: infer D }\n ? (D extends null | undefined ? T : D & Omit<T, 'default'>)\n : T;\n\nlet require: ((url: string) => unknown) | undefined;\n\nif (IS_SERVER_SIDE) require = createRequire(import.meta.url);\n\n/**\n * Requires the specified module without including it into the bundle during\n * Webpack build.\n * @param modulePath\n * @param [basePath]\n * @return Required module.\n */\nexport function requireWeak<T extends object>(\n modulePath: string,\n\n // TODO: For now `basePath` can be provided directly as a string here,\n // for backward compatibility. Deprecate it in future, if any other\n // breaking changes are done for requireWeak().\n basePathOrOptions?: string | RequireWeakOptionsT,\n): RequireWeakResT<T> | null {\n if (IS_CLIENT_SIDE) return null;\n\n let basePath: string | undefined;\n let ops: RequireWeakOptionsT;\n if (typeof basePathOrOptions === 'string') {\n basePath = basePathOrOptions;\n } else {\n ops = basePathOrOptions ?? {};\n ({ basePath } = ops);\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { resolve } = require!('node:path') as typeof PathNS;\n\n const path = basePath ? resolve(basePath, modulePath) : modulePath;\n\n const module = require!(path) as T;\n\n if (!('default' in module) || !module.default) return module as RequireWeakResT<T>;\n\n const { default: def, ...named } = module;\n\n const res = def as RequireWeakResT<T>;\n\n Object.entries(named).forEach(([name, value]) => {\n const assigned = res[name as keyof RequireWeakResT<T>];\n if (assigned === undefined) {\n (res[name as keyof RequireWeakResT<T>] as unknown) = value;\n } else if (assigned !== value) {\n throw Error('Conflict between default and named exports');\n }\n });\n return res;\n}\n\n/**\n * Resolves specified module path with help of Babel's module resolver.\n * Yes, the function itself just returns its argument to the caller, but Babel\n * is configured to resolve the first argument of resolveWeak(..) function, thus\n * the result will be the resolved path.\n * @param {string} modulePath\n * @return {string} Absolute or relative path to the module.\n */\nexport function resolveWeak(modulePath: string): string {\n return modulePath;\n}\n"],"mappings":"AAEA;AACA,SAASA,aAAa,QAAQ,QAAQ;AAEtC,SAASC,cAAc,EAAEC,cAAc;AAUvC,IAAIC,OAA+C;AAEnD,IAAID,cAAc,EAAEC,OAAO,GAAGH,aAAa,CAACI,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzBC,UAAkB;AAElB;AACA;AACA;AACAC,iBAAgD,EACrB;EAC3B,IAAIR,cAAc,EAAE,OAAO,IAAI;EAE/B,IAAIS,QAA4B;EAChC,IAAIC,GAAwB;EAC5B,IAAI,OAAOF,iBAAiB,KAAK,QAAQ,EAAE;IACzCC,QAAQ,GAAGD,iBAAiB;EAC9B,CAAC,MAAM;IACLE,GAAG,GAAGF,iBAAiB,IAAI,CAAC,CAAC;IAC7B,CAAC;MAAEC;IAAS,CAAC,GAAGC,GAAG;EACrB;;EAEA;EACA,MAAM;IAAEC;EAAQ,CAAC,GAAGT,OAAO,CAAE,WAAW,CAAkB;EAE1D,MAAMU,IAAI,GAAGH,QAAQ,GAAGE,OAAO,CAACF,QAAQ,EAAEF,UAAU,CAAC,GAAGA,UAAU;EAElE,MAAMM,MAAM,GAAGX,OAAO,CAAEU,IAAI,CAAM;EAElC,IAAI,EAAE,SAAS,IAAIC,MAAM,CAAC,IAAI,CAACA,MAAM,CAACC,OAAO,EAAE,OAAOD,MAAM;EAE5D,MAAM;IAAEC,OAAO,EAAEC,GAAG;IAAE,GAAGC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAMI,GAAG,GAAGF,GAAyB;EAErCG,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,KAAK;IAC/C,MAAMC,QAAQ,GAAGN,GAAG,CAACI,IAAI,CAA6B;IACtD,IAAIE,QAAQ,KAAKC,SAAS,EAAE;MACzBP,GAAG,CAACI,IAAI,CAA6B,GAAeC,KAAK;IAC5D,CAAC,MAAM,IAAIC,QAAQ,KAAKD,KAAK,EAAE;MAC7B,MAAMG,KAAK,CAAC,4CAA4C,CAAC;IAC3D;EACF,CAAC,CAAC;EACF,OAAOR,GAAG;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,WAAWA,CAACnB,UAAkB,EAAU;EACtD,OAAOA,UAAU;AACnB","ignoreList":[]}
|
package/config/babel/node-ssr.js
CHANGED
|
@@ -32,12 +32,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.default = getConfig;
|
|
40
|
-
const
|
|
37
|
+
const lodash_es_1 = require("lodash-es");
|
|
41
38
|
const webpack_1 = __importStar(require("./webpack"));
|
|
42
39
|
/**
|
|
43
40
|
* Creates a new base config.
|
|
@@ -57,6 +54,9 @@ function newBase(babel, options = {}) {
|
|
|
57
54
|
extensions: ['gif', 'jpeg', 'jpg', 'png'],
|
|
58
55
|
name: `${baseAssetsOutputPath}/images/[md4:hash:20].[ext]`,
|
|
59
56
|
}]);
|
|
57
|
+
if (options.modules === false) {
|
|
58
|
+
config.plugins.push('babel-plugin-add-import-extension');
|
|
59
|
+
}
|
|
60
60
|
const moduleResolverPluginOps = config.plugins.find((x) => Array.isArray(x) && x[0] === 'module-resolver')[1];
|
|
61
61
|
moduleResolverPluginOps.transformFunctions = [
|
|
62
62
|
'requireWeak',
|
|
@@ -65,7 +65,7 @@ function newBase(babel, options = {}) {
|
|
|
65
65
|
'webpack.resolveWeak',
|
|
66
66
|
];
|
|
67
67
|
if (babel.env() === webpack_1.ENVIRONMENTS.DEV) {
|
|
68
|
-
(0,
|
|
68
|
+
(0, lodash_es_1.pull)(config.plugins, 'react-refresh/babel');
|
|
69
69
|
}
|
|
70
70
|
return config;
|
|
71
71
|
}
|
package/config/jest/default.js
CHANGED
|
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.default = configFactory;
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const sitemap_1 =
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
10
|
+
const sitemap_1 = require("sitemap");
|
|
11
|
+
const clone_js_1 = __importDefault(require("lodash/clone.js"));
|
|
12
|
+
const defaults_js_1 = __importDefault(require("lodash/defaults.js"));
|
|
13
|
+
const isFunction_js_1 = __importDefault(require("lodash/isFunction.js"));
|
|
14
|
+
const isObject_js_1 = __importDefault(require("lodash/isObject.js"));
|
|
15
15
|
const autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
16
16
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
17
17
|
const node_forge_1 = __importDefault(require("node-forge"));
|
|
@@ -129,7 +129,7 @@ const utils_1 = require("@dr.pogodin/babel-plugin-react-css-modules/utils");
|
|
|
129
129
|
*/
|
|
130
130
|
function configFactory(ops) {
|
|
131
131
|
var _a, _b;
|
|
132
|
-
const o = (0,
|
|
132
|
+
const o = (0, defaults_js_1.default)((0, clone_js_1.default)(ops), {
|
|
133
133
|
babelLoaderOptions: {},
|
|
134
134
|
cssLocalIdent: '[hash:base64:6]',
|
|
135
135
|
outputPath: 'build/web-public',
|
|
@@ -144,12 +144,12 @@ function configFactory(ops) {
|
|
|
144
144
|
const sitemapUrl = node_path_1.default.resolve(o.context, o.sitemap);
|
|
145
145
|
// eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-require-imports
|
|
146
146
|
let source = require(sitemapUrl);
|
|
147
|
-
if ((0,
|
|
147
|
+
if ((0, isFunction_js_1.default)(source))
|
|
148
148
|
source = source();
|
|
149
|
-
const sm = new sitemap_1.
|
|
149
|
+
const sm = new sitemap_1.SitemapStream();
|
|
150
150
|
source.forEach((item) => sm.write(item));
|
|
151
151
|
sm.end();
|
|
152
|
-
void sitemap_1.
|
|
152
|
+
void (0, sitemap_1.streamToPromise)(sm).then((sitemap) => {
|
|
153
153
|
const outUrl = node_path_1.default.resolve(o.context, o.outputPath);
|
|
154
154
|
if (!fs.existsSync(outUrl))
|
|
155
155
|
fs.mkdirSync(outUrl);
|
|
@@ -210,7 +210,7 @@ function configFactory(ops) {
|
|
|
210
210
|
plugins.push(new webpack_1.ProgressPlugin());
|
|
211
211
|
/* Adds InjectManifest plugin from WorkBox, if opted to. */
|
|
212
212
|
if (o.workbox) {
|
|
213
|
-
if (!(0,
|
|
213
|
+
if (!(0, isObject_js_1.default)(o.workbox))
|
|
214
214
|
o.workbox = {};
|
|
215
215
|
plugins.push(new workbox_webpack_plugin_1.default.InjectManifest(Object.assign(Object.assign({ swSrc: node_path_1.default.resolve(__dirname, '../workbox/default.js') }, o.workbox), { swDest: '__service-worker.js' })));
|
|
216
216
|
}
|
|
@@ -323,6 +323,7 @@ function configFactory(ops) {
|
|
|
323
323
|
'.json',
|
|
324
324
|
'.scss',
|
|
325
325
|
],
|
|
326
|
+
fallback: { module: false },
|
|
326
327
|
symlinks: false,
|
|
327
328
|
},
|
|
328
329
|
};
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.default = configFactory;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const clone_js_1 = __importDefault(require("lodash/clone.js"));
|
|
9
|
+
const defaults_js_1 = __importDefault(require("lodash/defaults.js"));
|
|
10
10
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
11
11
|
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
12
12
|
const webpack_1 = __importDefault(require("webpack"));
|
|
@@ -18,7 +18,7 @@ const app_base_1 = __importDefault(require("./app-base"));
|
|
|
18
18
|
* @param [ops.dontUseHmr]
|
|
19
19
|
*/
|
|
20
20
|
function configFactory(ops) {
|
|
21
|
-
const o = (0,
|
|
21
|
+
const o = (0, defaults_js_1.default)((0, clone_js_1.default)(ops), {
|
|
22
22
|
cssLocalIdent: '[package]___[path][name]___[local]___[hash:base64:6]',
|
|
23
23
|
});
|
|
24
24
|
const entry = ['@dr.pogodin/react-utils/build/development/client/init'];
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.47.0-alpha.
|
|
2
|
+
"version": "1.47.0-alpha.3",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-setup": "bin/setup.js"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@dr.pogodin/babel-plugin-react-css-modules": "^6.13.8",
|
|
13
13
|
"@dr.pogodin/csurf": "^1.16.6",
|
|
14
14
|
"@dr.pogodin/js-utils": "^0.1.4",
|
|
15
|
-
"@dr.pogodin/react-global-state": "^0.21.
|
|
15
|
+
"@dr.pogodin/react-global-state": "^0.21.1",
|
|
16
16
|
"@dr.pogodin/react-helmet": "^3.0.4",
|
|
17
17
|
"@dr.pogodin/react-themes": "^1.9.3",
|
|
18
18
|
"@jest/environment": "^30.2.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"express": "^5.1.0",
|
|
28
28
|
"helmet": "^8.1.0",
|
|
29
29
|
"http-status-codes": "^2.3.0",
|
|
30
|
-
"lodash": "^4.17.21",
|
|
30
|
+
"lodash-es": "^4.17.21",
|
|
31
31
|
"morgan": "^1.10.1",
|
|
32
32
|
"node-forge": "^1.3.1",
|
|
33
33
|
"qs": "^6.14.0",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"@types/express": "^5.0.5",
|
|
70
70
|
"@types/jest": "^30.0.0",
|
|
71
71
|
"@types/lodash": "^4.17.20",
|
|
72
|
+
"@types/lodash-es": "^4.17.12",
|
|
72
73
|
"@types/morgan": "^1.9.10",
|
|
73
74
|
"@types/node-forge": "^1.3.14",
|
|
74
75
|
"@types/pretty": "^2.0.3",
|
|
@@ -83,6 +84,7 @@
|
|
|
83
84
|
"autoprefixer": "^10.4.21",
|
|
84
85
|
"babel-jest": "^30.2.0",
|
|
85
86
|
"babel-loader": "^10.0.0",
|
|
87
|
+
"babel-plugin-add-import-extension": "^1.6.0",
|
|
86
88
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
87
89
|
"babel-plugin-transform-import-meta": "^2.3.3",
|
|
88
90
|
"core-js": "^3.46.0",
|
|
@@ -104,7 +106,7 @@
|
|
|
104
106
|
"resolve-url-loader": "^5.0.0",
|
|
105
107
|
"sass": "^1.93.3",
|
|
106
108
|
"sass-loader": "^16.0.6",
|
|
107
|
-
"sitemap": "^
|
|
109
|
+
"sitemap": "^9.0.0",
|
|
108
110
|
"source-map-loader": "^5.0.0",
|
|
109
111
|
"stylelint": "^16.25.0",
|
|
110
112
|
"stylelint-config-standard-scss": "^16.0.0",
|
|
@@ -177,8 +179,8 @@
|
|
|
177
179
|
"scripts": {
|
|
178
180
|
"build": "rimraf build && npm run build:configs && npm run build:types-scss && npm run build:types-code && npm run build:web && npm run build:dev && npm run build:prod",
|
|
179
181
|
"build:configs": "tsc --project tsconfig.configs.json",
|
|
180
|
-
"build:dev": "node bin/build -i build/web -t development --lib --webpack-config webpack.config.ts --no-webpack",
|
|
181
|
-
"build:prod": "node bin/build -i build/web -t production --lib --webpack-config webpack.config.ts --no-webpack",
|
|
182
|
+
"build:dev": "node bin/build -i build/web -t development --lib --babel-config babel.module.config.js --webpack-config webpack.config.ts --no-webpack",
|
|
183
|
+
"build:prod": "node bin/build -i build/web -t production --lib --babel-config babel.module.config.js --webpack-config webpack.config.ts --no-webpack",
|
|
182
184
|
"build:types-code": "rimraf build/types-code && tsc --project tsconfig.types.json && tsc-alias -p tsconfig.types.json",
|
|
183
185
|
"build:types-scss": "rimraf build/types-scss && typed-scss-modules .",
|
|
184
186
|
"build:web": "rimraf build/web && babel ./src --config-file ./babel.libweb.config.js --out-dir build/web -x .js,.jsx,.ts,.tsx --source-maps --copy-files",
|
package/src/client/getInj.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
// Note: this way, only required part of "node-forge": AES, and some utils,
|
|
6
6
|
// is bundled into client-side code.
|
|
7
|
-
import forge from 'node-forge/lib/forge';
|
|
7
|
+
import forge from 'node-forge/lib/forge.js';
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line import/no-unassigned-import
|
|
10
|
-
import 'node-forge/lib/aes';
|
|
10
|
+
import 'node-forge/lib/aes.js';
|
|
11
11
|
|
|
12
12
|
import type { InjT } from 'utils/globalState';
|
|
13
13
|
|
package/src/server/index.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-unassigned-import
|
|
2
|
-
import 'source-map-support/register';
|
|
2
|
+
import 'source-map-support/register.js';
|
|
3
3
|
|
|
4
4
|
import http from 'node:http';
|
|
5
5
|
import https from 'node:https';
|
|
6
6
|
|
|
7
|
-
import cloneDeep from 'lodash
|
|
8
|
-
import defaults from 'lodash/defaults';
|
|
9
|
-
import isFinite from 'lodash/isFinite';
|
|
10
|
-
import isNumber from 'lodash/isNumber';
|
|
11
|
-
import isString from 'lodash/isString';
|
|
12
|
-
import toNumber from 'lodash/toNumber';
|
|
7
|
+
import { cloneDeep, defaults } from 'lodash-es';
|
|
13
8
|
|
|
14
9
|
// Polyfill required by ReactJS.
|
|
15
10
|
// TODO: Double-check, if it is still required by React v19?
|
|
16
11
|
// eslint-disable-next-line import/no-unassigned-import
|
|
17
|
-
import 'raf/polyfill';
|
|
12
|
+
import 'raf/polyfill.js';
|
|
18
13
|
|
|
19
14
|
import type { Configuration } from 'webpack';
|
|
20
15
|
|
|
@@ -41,13 +36,12 @@ export { errors, getDefaultCspSettings, type ServerT };
|
|
|
41
36
|
* Normalizes a port into a number, string, or false.
|
|
42
37
|
* TODO: Drop this function?
|
|
43
38
|
* @param value Port name or number.
|
|
44
|
-
* @return Port number (Number), name (String)
|
|
39
|
+
* @return Port number (Number), name (String).
|
|
45
40
|
*/
|
|
46
41
|
function normalizePort(value: number | string) {
|
|
47
|
-
const port =
|
|
48
|
-
if (isFinite(port)) return port; /* port number */
|
|
49
|
-
|
|
50
|
-
return false;
|
|
42
|
+
const port = typeof value === 'string' ? parseInt(value) : value;
|
|
43
|
+
if (Number.isFinite(port)) return port; /* port number */
|
|
44
|
+
return value; /* named pipe */
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
type OptionsT = ServerOptionsT & {
|
|
@@ -212,7 +206,7 @@ export default async function launchServer(
|
|
|
212
206
|
/* Sets error handler for HTTP(S) server. */
|
|
213
207
|
httpServer.on('error', (error: Error) => {
|
|
214
208
|
if ((error as { syscall?: string }).syscall !== 'listen') throw error;
|
|
215
|
-
const bind =
|
|
209
|
+
const bind = typeof ops.port === 'string' ? `Pipe ${ops.port}` : `Port ${ops.port}`;
|
|
216
210
|
|
|
217
211
|
/* Human-readable message for some specific listen errors. */
|
|
218
212
|
switch ((error as { code?: string }).code) {
|
|
@@ -231,7 +225,7 @@ export default async function launchServer(
|
|
|
231
225
|
/* Listening event handler for HTTP(S) server. */
|
|
232
226
|
httpServer.on('listening', () => {
|
|
233
227
|
const addr = httpServer.address()!;
|
|
234
|
-
const bind =
|
|
228
|
+
const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;
|
|
235
229
|
ops.logger!.info(`Server listening on ${bind} in ${
|
|
236
230
|
process.env.NODE_ENV} mode`);
|
|
237
231
|
});
|
package/src/server/renderer.tsx
CHANGED
|
@@ -15,13 +15,12 @@ import winston from 'winston';
|
|
|
15
15
|
import { GlobalStateProvider, SsrContext } from '@dr.pogodin/react-global-state';
|
|
16
16
|
import { timer } from '@dr.pogodin/js-utils';
|
|
17
17
|
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import omit from 'lodash/omit';
|
|
18
|
+
import {
|
|
19
|
+
cloneDeep,
|
|
20
|
+
defaults,
|
|
21
|
+
get,
|
|
22
|
+
mapValues,
|
|
23
|
+
} from 'lodash-es';
|
|
25
24
|
|
|
26
25
|
import config from 'config';
|
|
27
26
|
import forge from 'node-forge';
|
|
@@ -36,7 +35,9 @@ import type { ChunkGroupsT, SsrContextT } from 'utils/globalState';
|
|
|
36
35
|
|
|
37
36
|
import Cache from './Cache';
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
// @ts-expect-error "Property 'SECRET' does not exist on type 'IConfig'."
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
|
+
const { SECRET, ...sanitizedConfig } = config;
|
|
40
41
|
|
|
41
42
|
// Note: These type definitions for logger are copied from Winston logger,
|
|
42
43
|
// then simplified to make it easier to fit an alternative logger into this
|
|
@@ -196,7 +197,7 @@ function groupExtraScripts(scripts: Array<string | ScriptT> = []) {
|
|
|
196
197
|
[SCRIPT_LOCATIONS.HEAD_OPEN]: '',
|
|
197
198
|
};
|
|
198
199
|
for (const script of scripts) {
|
|
199
|
-
if (
|
|
200
|
+
if (typeof script === 'string') {
|
|
200
201
|
if (script) res[SCRIPT_LOCATIONS.DEFAULT] += script;
|
|
201
202
|
} else if (script.code) {
|
|
202
203
|
if (script.location in res) res[script.location] += script.code;
|
|
@@ -312,7 +313,7 @@ export default function factory(
|
|
|
312
313
|
webpackConfig: Configuration,
|
|
313
314
|
options: OptionsT,
|
|
314
315
|
): RequestHandler {
|
|
315
|
-
const ops: OptionsT = defaults(
|
|
316
|
+
const ops: OptionsT = defaults({ ...options }, {
|
|
316
317
|
beforeRender: async () => Promise.resolve({}),
|
|
317
318
|
maxSsrRounds: 10,
|
|
318
319
|
ssrTimeout: 1000,
|
package/src/server/server.ts
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
import { sep } from 'node:path';
|
|
6
6
|
import { pathToFileURL } from 'node:url';
|
|
7
7
|
|
|
8
|
-
import cloneDeep from 'lodash
|
|
9
|
-
import mapValues from 'lodash/mapValues';
|
|
10
|
-
import pick from 'lodash/pick';
|
|
8
|
+
import { cloneDeep, mapValues, pick } from 'lodash-es';
|
|
11
9
|
|
|
12
10
|
import compression from 'compression';
|
|
13
11
|
import cookieParser from 'cookie-parser';
|
|
@@ -250,7 +248,7 @@ export default async function factory(
|
|
|
250
248
|
} as Location;
|
|
251
249
|
}
|
|
252
250
|
|
|
253
|
-
const { webpack } = await import(/* webpackChunkName: "server-side-code" */ 'webpack');
|
|
251
|
+
const { default: webpack } = await import(/* webpackChunkName: "server-side-code" */ 'webpack');
|
|
254
252
|
|
|
255
253
|
const { default: webpackDevMiddleware } = await import(
|
|
256
254
|
/* webpackChunkName: "server-side-code" */ 'webpack-dev-middleware'
|
|
@@ -20,8 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
|
|
21
21
|
import type { Request, Response } from 'express';
|
|
22
22
|
|
|
23
|
-
import defaults from 'lodash
|
|
24
|
-
import set from 'lodash/set';
|
|
23
|
+
import { defaults, set } from 'lodash-es';
|
|
25
24
|
|
|
26
25
|
import type { ReactNode } from 'react';
|
|
27
26
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type PathNS from 'node:path';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line import/enforce-node-protocol-usage
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
|
|
6
|
+
import { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './isomorphy';
|
|
4
7
|
|
|
5
8
|
type RequireWeakOptionsT = {
|
|
6
9
|
basePath?: string;
|
|
@@ -10,6 +13,10 @@ type RequireWeakResT<T> = T extends { default: infer D }
|
|
|
10
13
|
? (D extends null | undefined ? T : D & Omit<T, 'default'>)
|
|
11
14
|
: T;
|
|
12
15
|
|
|
16
|
+
let require: ((url: string) => unknown) | undefined;
|
|
17
|
+
|
|
18
|
+
if (IS_SERVER_SIDE) require = createRequire(import.meta.url);
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* Requires the specified module without including it into the bundle during
|
|
15
22
|
* Webpack build.
|
|
@@ -36,14 +43,12 @@ export function requireWeak<T extends object>(
|
|
|
36
43
|
({ basePath } = ops);
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
// eslint-disable-next-line no-eval
|
|
40
|
-
const req = eval('require') as (path: string) => unknown;
|
|
41
|
-
|
|
42
46
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
43
|
-
const { resolve } =
|
|
47
|
+
const { resolve } = require!('node:path') as typeof PathNS;
|
|
44
48
|
|
|
45
49
|
const path = basePath ? resolve(basePath, modulePath) : modulePath;
|
|
46
|
-
|
|
50
|
+
|
|
51
|
+
const module = require!(path) as T;
|
|
47
52
|
|
|
48
53
|
if (!('default' in module) || !module.default) return module as RequireWeakResT<T>;
|
|
49
54
|
|
|
@@ -53,8 +58,9 @@ export function requireWeak<T extends object>(
|
|
|
53
58
|
|
|
54
59
|
Object.entries(named).forEach(([name, value]) => {
|
|
55
60
|
const assigned = res[name as keyof RequireWeakResT<T>];
|
|
56
|
-
if (assigned
|
|
57
|
-
|
|
61
|
+
if (assigned === undefined) {
|
|
62
|
+
(res[name as keyof RequireWeakResT<T>] as unknown) = value;
|
|
63
|
+
} else if (assigned !== value) {
|
|
58
64
|
throw Error('Conflict between default and named exports');
|
|
59
65
|
}
|
|
60
66
|
});
|
package/types.d.ts
CHANGED