@dr.pogodin/react-utils 1.13.0 → 1.14.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/build/development/index.js +1 -11
- package/build/development/index.js.map +1 -1
- package/build/development/server/server.js +14 -0
- package/build/development/server/server.js.map +1 -1
- package/build/development/shared/components/CodeSplit/ClientSide.js +28 -17
- package/build/development/shared/components/CodeSplit/ClientSide.js.map +1 -1
- package/build/development/shared/components/CodeSplit/ServerSide.js +19 -46
- package/build/development/shared/components/CodeSplit/ServerSide.js.map +1 -1
- package/build/development/shared/components/CodeSplit/index.js +6 -10
- package/build/development/shared/components/CodeSplit/index.js.map +1 -1
- package/build/development/shared/components/index.js +0 -8
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/utils/Semaphore.js +54 -0
- package/build/development/shared/utils/Semaphore.js.map +1 -0
- package/build/development/shared/utils/config.js +1 -3
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/index.js +31 -9
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +43 -0
- package/build/development/shared/utils/splitComponent.js.map +1 -0
- package/build/development/shared/utils/webpack.js +26 -39
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/development/web.bundle.js +46 -16
- package/build/production/index.js +1 -2
- package/build/production/index.js.map +1 -1
- package/build/production/server/server.js +6 -2
- package/build/production/server/server.js.map +1 -1
- package/build/production/shared/components/CodeSplit/ClientSide.js +15 -10
- package/build/production/shared/components/CodeSplit/ClientSide.js.map +1 -1
- package/build/production/shared/components/CodeSplit/ServerSide.js +9 -15
- package/build/production/shared/components/CodeSplit/ServerSide.js.map +1 -1
- package/build/production/shared/components/CodeSplit/index.js +5 -2
- package/build/production/shared/components/CodeSplit/index.js.map +1 -1
- package/build/production/shared/components/index.js +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/utils/Semaphore.js +8 -0
- package/build/production/shared/utils/Semaphore.js.map +1 -0
- package/build/production/shared/utils/config.js +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/index.js +5 -3
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +14 -0
- package/build/production/shared/utils/splitComponent.js.map +1 -0
- package/build/production/shared/utils/webpack.js +4 -27
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/config/babel/node-ssr.js +2 -4
- package/package.json +24 -26
|
@@ -14,7 +14,9 @@ var _exportNames = {
|
|
|
14
14
|
isomorphy: true,
|
|
15
15
|
time: true,
|
|
16
16
|
webpack: true,
|
|
17
|
-
Emitter: true
|
|
17
|
+
Emitter: true,
|
|
18
|
+
Semaphore: true,
|
|
19
|
+
splitComponent: true
|
|
18
20
|
};
|
|
19
21
|
Object.defineProperty(exports, "Emitter", {
|
|
20
22
|
enumerable: true,
|
|
@@ -23,6 +25,12 @@ Object.defineProperty(exports, "Emitter", {
|
|
|
23
25
|
}
|
|
24
26
|
});
|
|
25
27
|
exports.JU = void 0;
|
|
28
|
+
Object.defineProperty(exports, "Semaphore", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return _Semaphore.default;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
26
34
|
Object.defineProperty(exports, "ThemeProvider", {
|
|
27
35
|
enumerable: true,
|
|
28
36
|
get: function () {
|
|
@@ -36,6 +44,12 @@ Object.defineProperty(exports, "config", {
|
|
|
36
44
|
}
|
|
37
45
|
});
|
|
38
46
|
exports.isomorphy = void 0;
|
|
47
|
+
Object.defineProperty(exports, "splitComponent", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () {
|
|
50
|
+
return _splitComponent.default;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
39
53
|
Object.defineProperty(exports, "themed", {
|
|
40
54
|
enumerable: true,
|
|
41
55
|
get: function () {
|
|
@@ -81,22 +95,29 @@ Object.keys(_Barrier).forEach(function (key) {
|
|
|
81
95
|
|
|
82
96
|
var _Emitter = _interopRequireDefault(require("./Emitter"));
|
|
83
97
|
|
|
98
|
+
var _Semaphore = _interopRequireDefault(require("./Semaphore"));
|
|
99
|
+
|
|
100
|
+
var _splitComponent = _interopRequireDefault(require("./splitComponent"));
|
|
101
|
+
|
|
84
102
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
85
103
|
|
|
86
104
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
87
105
|
|
|
88
106
|
_reactThemes.default.COMPOSE = _reactThemes.COMPOSE;
|
|
89
|
-
_reactThemes.default.PRIORITY = _reactThemes.PRIORITY;
|
|
90
|
-
|
|
107
|
+
_reactThemes.default.PRIORITY = _reactThemes.PRIORITY; // Note: it should be done this way, as in some environments
|
|
108
|
+
// "process" might not exist, and process.env.NODE_CONFIG_ENV
|
|
109
|
+
// not injected by Webpack.
|
|
91
110
|
|
|
92
|
-
|
|
111
|
+
let NODE_CONFIG_ENV;
|
|
93
112
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
/* eslint-enable global-require */
|
|
113
|
+
try {
|
|
114
|
+
NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;
|
|
115
|
+
} catch {
|
|
116
|
+
/* noop */
|
|
99
117
|
}
|
|
118
|
+
|
|
119
|
+
const env = NODE_CONFIG_ENV || process.env.NODE_ENV;
|
|
120
|
+
const JU = env !== 'production' && webpack.requireWeak("./jest", __dirname);
|
|
100
121
|
/**
|
|
101
122
|
* @category Utilities
|
|
102
123
|
* @global
|
|
@@ -133,6 +154,7 @@ if (isomorphy.IS_SERVER_SIDE && (process.env.NODE_CONFIG_ENV || process.env.NODE
|
|
|
133
154
|
* // is performed.
|
|
134
155
|
*/
|
|
135
156
|
|
|
157
|
+
exports.JU = JU;
|
|
136
158
|
|
|
137
159
|
async function withRetries(action, maxRetries = 5, interval = 1000) {
|
|
138
160
|
/* eslint-disable no-await-in-loop */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/shared/utils/index.js"],"names":["themed","COMPOSE","PRIORITY","
|
|
1
|
+
{"version":3,"sources":["../../../../src/shared/utils/index.js"],"names":["themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","webpack","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","time","timer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAMA;;AACA;;;;AACA;;AACA;;;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AACA;;;;;;AAEAA,qBAAOC,OAAP,GAAiBA,oBAAjB;AACAD,qBAAOE,QAAP,GAAkBA,qBAAlB,C,CAEA;AACA;AACA;;AACA,IAAIC,eAAJ;;AACA,IAAI;AACFA,EAAAA,eAAe,GAAGC,OAAO,CAACC,GAAR,CAAYF,eAA9B;AACD,CAFD,CAEE,MAAM;AAAE;AAAY;;AAEtB,MAAME,GAAG,GAAGF,eAAe,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAA3C;AACA,MAAMC,EAAE,GAAGF,GAAG,KAAK,YAAR,IAAwBG,OAAO,CAACC,WAAR,WAA8BC,SAA9B,CAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,eAAeC,WAAf,CAA2BC,MAA3B,EAAmCC,UAAU,GAAG,CAAhD,EAAmDC,QAAQ,GAAG,IAA9D,EAAoE;AACzE;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,GAAkB,EAAEA,CAApB,EAAuB;AACrB,QAAI;AACF,aAAO,MAAMH,MAAM,EAAnB;AACD,KAFD,CAEE,OAAOI,KAAP,EAAc;AACd,UAAID,CAAC,GAAGF,UAAR,EAAoB,MAAMI,cAAKC,KAAL,CAAWJ,QAAX,CAAN,CAApB,KACK,MAAME,KAAN;AACN;AACF;AACD;;AACD","sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport * from './Barrier';\nexport { default as Emitter } from './Emitter';\nexport { default as Semaphore } from './Semaphore';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await time.timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"file":"index.js"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = splitComponent;
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
var _CodeSplit = _interopRequireDefault(require("../components/CodeSplit"));
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Wraps a regular React component into a "code splitting" component,
|
|
16
|
+
* i.e. all code used exclusively by that component and its sub-tree
|
|
17
|
+
* will go into a separate, asynchronously loaded, code chunk for
|
|
18
|
+
* the client-side.
|
|
19
|
+
* @param {object} options
|
|
20
|
+
* @param {string} options.chunkName
|
|
21
|
+
* @param {function} options.getClientSide
|
|
22
|
+
* @param {React.ElementType} [options.placeholder]
|
|
23
|
+
* @param {React.ElementType} [options.serverSide]
|
|
24
|
+
* @returns {React.ElementType}
|
|
25
|
+
*/
|
|
26
|
+
function splitComponent({
|
|
27
|
+
chunkName,
|
|
28
|
+
getClientSide,
|
|
29
|
+
placeholder,
|
|
30
|
+
serverSide
|
|
31
|
+
}) {
|
|
32
|
+
// eslint-disable-next-line react/prop-types
|
|
33
|
+
return ({
|
|
34
|
+
children = [],
|
|
35
|
+
...props
|
|
36
|
+
} = {}) => /*#__PURE__*/(0, _react.createElement)(_CodeSplit.default, { ...props,
|
|
37
|
+
chunkName,
|
|
38
|
+
getClientSide,
|
|
39
|
+
placeholder,
|
|
40
|
+
serverSide
|
|
41
|
+
}, ...children);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=splitComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/shared/utils/splitComponent.js"],"names":["splitComponent","chunkName","getClientSide","placeholder","serverSide","children","props","CodeSplit"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAwB;AACrCC,EAAAA,SADqC;AAErCC,EAAAA,aAFqC;AAGrCC,EAAAA,WAHqC;AAIrCC,EAAAA;AAJqC,CAAxB,EAKZ;AACD;AACA,SAAO,CAAC;AAAEC,IAAAA,QAAQ,GAAG,EAAb;AAAiB,OAAGC;AAApB,MAA8B,EAA/B,kBAAsC,0BAC3CC,kBAD2C,EAE3C,EACE,GAAGD,KADL;AAEEL,IAAAA,SAFF;AAGEC,IAAAA,aAHF;AAIEC,IAAAA,WAJF;AAKEC,IAAAA;AALF,GAF2C,EAS3C,GAAGC,QATwC,CAA7C;AAWD","sourcesContent":["import { createElement } from 'react';\nimport CodeSplit from 'components/CodeSplit';\n\n/**\n * Wraps a regular React component into a \"code splitting\" component,\n * i.e. all code used exclusively by that component and its sub-tree\n * will go into a separate, asynchronously loaded, code chunk for\n * the client-side.\n * @param {object} options\n * @param {string} options.chunkName\n * @param {function} options.getClientSide\n * @param {React.ElementType} [options.placeholder]\n * @param {React.ElementType} [options.serverSide]\n * @returns {React.ElementType}\n */\nexport default function splitComponent({\n chunkName,\n getClientSide,\n placeholder,\n serverSide,\n}) {\n // eslint-disable-next-line react/prop-types\n return ({ children = [], ...props } = {}) => createElement(\n CodeSplit,\n {\n ...props,\n chunkName,\n getClientSide,\n placeholder,\n serverSide,\n },\n ...children,\n );\n}\n"],"file":"splitComponent.js"}
|
|
@@ -6,52 +6,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.requireWeak = requireWeak;
|
|
7
7
|
exports.resolveWeak = resolveWeak;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* @category Utilities
|
|
11
|
-
* @module webpack
|
|
12
|
-
* @desc
|
|
13
|
-
* ```js
|
|
14
|
-
* import { webpack } from '@dr.pogodin/react-utils';
|
|
15
|
-
* ```
|
|
16
|
-
* Webpack-related utilities.
|
|
17
|
-
*/
|
|
9
|
+
var _isomorphy = require("./isomorphy");
|
|
18
10
|
|
|
19
11
|
/**
|
|
20
|
-
* ```js
|
|
21
|
-
* import { webpack } from '@dr.pogodin/react-utils';
|
|
22
|
-
* const { requireWeak } = webpack;
|
|
23
|
-
* ```
|
|
24
12
|
* Requires the specified module without including it into the bundle during
|
|
25
|
-
* Webpack build.
|
|
26
|
-
*
|
|
27
|
-
* WARNING: Beware to pass in relative paths: they will be resolved relative
|
|
28
|
-
* to the library distribution function, this is not what you want in most of
|
|
29
|
-
* cases. To convert a relative path to the absolute one, do in the caller code
|
|
30
|
-
* ```
|
|
31
|
-
* import path from 'path';
|
|
32
|
-
* const p = path.resolve(__dirname, './relative/path');
|
|
33
|
-
* const module = requireWeak(p);
|
|
34
|
-
* ```
|
|
35
|
-
* In case you use an absolute path that relies on Babel module resolver,
|
|
36
|
-
* pass it through resolveWeak function below.
|
|
37
|
-
*
|
|
13
|
+
* Webpack build.
|
|
38
14
|
* @param {string} modulePath
|
|
15
|
+
* @param {string} [basePath]
|
|
39
16
|
* @return {object} Required module.
|
|
40
17
|
*/
|
|
41
|
-
function requireWeak(modulePath) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
18
|
+
function requireWeak(modulePath, basePath) {
|
|
19
|
+
if (_isomorphy.IS_CLIENT_SIDE) return null;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
/* eslint-disable no-eval */
|
|
23
|
+
const {
|
|
24
|
+
resolve
|
|
25
|
+
} = eval('require')('path');
|
|
26
|
+
const path = basePath ? resolve(basePath, modulePath) : modulePath;
|
|
27
|
+
const {
|
|
28
|
+
default: def,
|
|
29
|
+
...named
|
|
30
|
+
} = eval('require')(path);
|
|
31
|
+
/* eslint-enable no-eval */
|
|
48
32
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
33
|
+
if (!def) return named;
|
|
34
|
+
Object.entries(named).forEach(([key, value]) => {
|
|
35
|
+
if (def[key]) throw Error('Conflict between default and named exports');
|
|
36
|
+
def[key] = value;
|
|
37
|
+
});
|
|
38
|
+
return def;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
55
42
|
}
|
|
56
43
|
/**
|
|
57
44
|
* Resolves specified module path with help of Babel's module resolver.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/shared/utils/webpack.js"],"names":["requireWeak","modulePath","
|
|
1
|
+
{"version":3,"sources":["../../../../src/shared/utils/webpack.js"],"names":["requireWeak","modulePath","basePath","IS_CLIENT_SIDE","resolve","eval","path","default","def","named","Object","entries","forEach","key","value","Error","resolveWeak"],"mappings":";;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAqBC,UAArB,EAAiCC,QAAjC,EAA2C;AAChD,MAAIC,yBAAJ,EAAoB,OAAO,IAAP;;AAEpB,MAAI;AACF;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAcC,IAAI,CAAC,SAAD,CAAJ,CAAgB,MAAhB,CAApB;AACA,UAAMC,IAAI,GAAGJ,QAAQ,GAAGE,OAAO,CAACF,QAAD,EAAWD,UAAX,CAAV,GAAmCA,UAAxD;AACA,UAAM;AAAEM,MAAAA,OAAO,EAAEC,GAAX;AAAgB,SAAGC;AAAnB,QAA6BJ,IAAI,CAAC,SAAD,CAAJ,CAAgBC,IAAhB,CAAnC;AACA;;AAEA,QAAI,CAACE,GAAL,EAAU,OAAOC,KAAP;AAEVC,IAAAA,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,OAAtB,CAA8B,CAAC,CAACC,GAAD,EAAMC,KAAN,CAAD,KAAkB;AAC9C,UAAIN,GAAG,CAACK,GAAD,CAAP,EAAc,MAAME,KAAK,CAAC,4CAAD,CAAX;AACdP,MAAAA,GAAG,CAACK,GAAD,CAAH,GAAWC,KAAX;AACD,KAHD;AAIA,WAAON,GAAP;AACD,GAdD,CAcE,MAAM;AACN,WAAO,IAAP;AACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASQ,WAAT,CAAqBf,UAArB,EAAiC;AACtC,SAAOA,UAAP;AACD","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 {string} modulePath\n * @param {string} [basePath]\n * @return {object} Required module.\n */\nexport function requireWeak(modulePath, basePath) {\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 { default: def, ...named } = eval('require')(path);\n /* eslint-enable no-eval */\n\n if (!def) return named;\n\n Object.entries(named).forEach(([key, value]) => {\n if (def[key]) throw Error('Conflict between default and named exports');\n def[key] = value;\n });\n return def;\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) {\n return modulePath;\n}\n"],"file":"webpack.js"}
|