@dr.pogodin/react-utils 1.41.13 → 1.41.15

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.
@@ -15,6 +15,12 @@ var _isomorphy = require("./isomorphy");
15
15
  */
16
16
  function requireWeak(modulePath, basePath) {
17
17
  if (_isomorphy.IS_CLIENT_SIDE) return null;
18
+
19
+ // TODO: On one hand, this try/catch wrap silencing errors is bad, as it may
20
+ // hide legit errors, in a way difficult to notice and understand; but on the
21
+ // other hand it fails for some (unclear, but legit?) reasons in some environments,
22
+ // like during the static code generation for docs. Perhaps, something should
23
+ // be implemented differently here.
18
24
  try {
19
25
  /* eslint-disable no-eval */
20
26
  const {
@@ -24,7 +30,7 @@ function requireWeak(modulePath, basePath) {
24
30
  const module = eval('require')(path);
25
31
  /* eslint-enable no-eval */
26
32
 
27
- if (!('default' in module)) return module;
33
+ if (!('default' in module) || !module.default) return module;
28
34
  const {
29
35
  default: def,
30
36
  ...named
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.js","names":["_isomorphy","require","requireWeak","modulePath","basePath","IS_CLIENT_SIDE","resolve","eval","path","module","default","def","named","res","Object","entries","forEach","name","value","assigned","undefined","Error","resolveWeak"],"sources":["../../../../src/shared/utils/webpack.ts"],"sourcesContent":["import { IS_CLIENT_SIDE } from './isomorphy';\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<Module extends NodeJS.Module>(\n modulePath: string,\n basePath?: string,\n): Module | null {\n if (IS_CLIENT_SIDE) return null;\n\n try {\n /* eslint-disable no-eval */\n const { resolve } = eval('require')('path');\n const path = basePath ? resolve(basePath, modulePath) : modulePath;\n const module = eval('require')(path) as Module;\n /* eslint-enable no-eval */\n\n if (!('default' in module)) return module;\n\n const { default: def, ...named } = module;\n\n const res = def as Module;\n\n Object.entries(named).forEach(([name, value]) => {\n const assigned = res[name as keyof Module];\n if (assigned !== undefined) {\n if (assigned !== value) {\n throw Error('Conflict between default and named exports');\n }\n } else res[name as keyof Module] = value;\n });\n return res;\n } catch {\n return null;\n }\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":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CACzBC,UAAkB,EAClBC,QAAiB,EACF;EACf,IAAIC,yBAAc,EAAE,OAAO,IAAI;EAE/B,IAAI;IACF;IACA,MAAM;MAAEC;IAAQ,CAAC,GAAGC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAMC,IAAI,GAAGJ,QAAQ,GAAGE,OAAO,CAACF,QAAQ,EAAED,UAAU,CAAC,GAAGA,UAAU;IAClE,MAAMM,MAAM,GAAGF,IAAI,CAAC,SAAS,CAAC,CAACC,IAAI,CAAW;IAC9C;;IAEA,IAAI,EAAE,SAAS,IAAIC,MAAM,CAAC,EAAE,OAAOA,MAAM;IAEzC,MAAM;MAAEC,OAAO,EAAEC,GAAG;MAAE,GAAGC;IAAM,CAAC,GAAGH,MAAM;IAEzC,MAAMI,GAAG,GAAGF,GAAa;IAEzBG,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,KAAK;MAC/C,MAAMC,QAAQ,GAAGN,GAAG,CAACI,IAAI,CAAiB;MAC1C,IAAIE,QAAQ,KAAKC,SAAS,EAAE;QAC1B,IAAID,QAAQ,KAAKD,KAAK,EAAE;UACtB,MAAMG,KAAK,CAAC,4CAA4C,CAAC;QAC3D;MACF,CAAC,MAAMR,GAAG,CAACI,IAAI,CAAiB,GAAGC,KAAK;IAC1C,CAAC,CAAC;IACF,OAAOL,GAAG;EACZ,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,WAAWA,CAACnB,UAAkB,EAAU;EACtD,OAAOA,UAAU;AACnB","ignoreList":[]}
1
+ {"version":3,"file":"webpack.js","names":["_isomorphy","require","requireWeak","modulePath","basePath","IS_CLIENT_SIDE","resolve","eval","path","module","default","def","named","res","Object","entries","forEach","name","value","assigned","undefined","Error","resolveWeak"],"sources":["../../../../src/shared/utils/webpack.ts"],"sourcesContent":["import { IS_CLIENT_SIDE } from './isomorphy';\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<Module extends NodeJS.Module>(\n modulePath: string,\n basePath?: string,\n): Module | null {\n if (IS_CLIENT_SIDE) return null;\n\n // TODO: On one hand, this try/catch wrap silencing errors is bad, as it may\n // hide legit errors, in a way difficult to notice and understand; but on the\n // other hand it fails for some (unclear, but legit?) reasons in some environments,\n // like during the static code generation for docs. Perhaps, something should\n // be implemented differently here.\n try {\n /* eslint-disable no-eval */\n const { resolve } = eval('require')('path');\n const path = basePath ? resolve(basePath, modulePath) : modulePath;\n const module = eval('require')(path) as Module;\n /* eslint-enable no-eval */\n\n if (!('default' in module) || !module.default) return module;\n\n const { default: def, ...named } = module;\n\n const res = def as Module;\n\n Object.entries(named).forEach(([name, value]) => {\n const assigned = res[name as keyof Module];\n if (assigned !== undefined) {\n if (assigned !== value) {\n throw Error('Conflict between default and named exports');\n }\n } else res[name as keyof Module] = value;\n });\n return res;\n } catch {\n return null;\n }\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":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CACzBC,UAAkB,EAClBC,QAAiB,EACF;EACf,IAAIC,yBAAc,EAAE,OAAO,IAAI;;EAE/B;EACA;EACA;EACA;EACA;EACA,IAAI;IACF;IACA,MAAM;MAAEC;IAAQ,CAAC,GAAGC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAMC,IAAI,GAAGJ,QAAQ,GAAGE,OAAO,CAACF,QAAQ,EAAED,UAAU,CAAC,GAAGA,UAAU;IAClE,MAAMM,MAAM,GAAGF,IAAI,CAAC,SAAS,CAAC,CAACC,IAAI,CAAW;IAC9C;;IAEA,IAAI,EAAE,SAAS,IAAIC,MAAM,CAAC,IAAI,CAACA,MAAM,CAACC,OAAO,EAAE,OAAOD,MAAM;IAE5D,MAAM;MAAEC,OAAO,EAAEC,GAAG;MAAE,GAAGC;IAAM,CAAC,GAAGH,MAAM;IAEzC,MAAMI,GAAG,GAAGF,GAAa;IAEzBG,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,KAAK;MAC/C,MAAMC,QAAQ,GAAGN,GAAG,CAACI,IAAI,CAAiB;MAC1C,IAAIE,QAAQ,KAAKC,SAAS,EAAE;QAC1B,IAAID,QAAQ,KAAKD,KAAK,EAAE;UACtB,MAAMG,KAAK,CAAC,4CAA4C,CAAC;QAC3D;MACF,CAAC,MAAMR,GAAG,CAACI,IAAI,CAAiB,GAAGC,KAAK;IAC1C,CAAC,CAAC;IACF,OAAOL,GAAG;EACZ,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,WAAWA,CAACnB,UAAkB,EAAU;EACtD,OAAOA,UAAU;AACnB","ignoreList":[]}