@merkur/integration 0.33.0 → 0.35.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.
- package/lib/index.cjs +15 -1
- package/lib/index.es9.cjs +11 -1
- package/lib/index.es9.mjs +11 -1
- package/lib/index.js +15 -1
- package/lib/index.mjs +15 -1
- package/lib/index.umd.js +1 -1
- package/package.json +3 -3
- package/server/__tests__/indexSpec.js +17 -8
- package/server/index.js +102 -19
package/lib/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
let _isES9Supported;
|
|
4
4
|
let _isES11Supported;
|
|
5
|
+
let _isES13Supported;
|
|
5
6
|
|
|
6
7
|
function isES9Supported() {
|
|
7
8
|
if (_isES9Supported === undefined) {
|
|
@@ -28,6 +29,16 @@ function isES11Supported() {
|
|
|
28
29
|
return _isES11Supported;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
function isES13Supported() {
|
|
33
|
+
if (_isES13Supported === undefined) {
|
|
34
|
+
_isES13Supported =
|
|
35
|
+
exported.test('return [1,1].findLast(e => e === 1)') &&
|
|
36
|
+
exported.test('return Object.hasOwn({a:1}, "a")');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return _isES13Supported;
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
function test(snippet) {
|
|
32
43
|
try {
|
|
33
44
|
const fn = new Function(snippet);
|
|
@@ -42,6 +53,7 @@ function test(snippet) {
|
|
|
42
53
|
const exported = {
|
|
43
54
|
isES9Supported,
|
|
44
55
|
isES11Supported,
|
|
56
|
+
isES13Supported,
|
|
45
57
|
test,
|
|
46
58
|
};
|
|
47
59
|
|
|
@@ -150,7 +162,9 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
150
162
|
}
|
|
151
163
|
|
|
152
164
|
if (source === Object(source)) {
|
|
153
|
-
if (source.
|
|
165
|
+
if (source.es13 && exported.isES13Supported()) {
|
|
166
|
+
_asset.source = source.es13;
|
|
167
|
+
} else if (source.es11 && exported.isES11Supported()) {
|
|
154
168
|
_asset.source = source.es11;
|
|
155
169
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
156
170
|
_asset.source = source.es9;
|
package/lib/index.es9.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
let _isES9Supported;
|
|
4
4
|
let _isES11Supported;
|
|
5
|
+
let _isES13Supported;
|
|
5
6
|
function isES9Supported() {
|
|
6
7
|
if (_isES9Supported === undefined) {
|
|
7
8
|
_isES9Supported = exported.test('return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()') && !!Object.values;
|
|
@@ -14,6 +15,12 @@ function isES11Supported() {
|
|
|
14
15
|
}
|
|
15
16
|
return _isES11Supported;
|
|
16
17
|
}
|
|
18
|
+
function isES13Supported() {
|
|
19
|
+
if (_isES13Supported === undefined) {
|
|
20
|
+
_isES13Supported = exported.test('return [1,1].findLast(e => e === 1)') && exported.test('return Object.hasOwn({a:1}, "a")');
|
|
21
|
+
}
|
|
22
|
+
return _isES13Supported;
|
|
23
|
+
}
|
|
17
24
|
function test(snippet) {
|
|
18
25
|
try {
|
|
19
26
|
const fn = new Function(snippet);
|
|
@@ -26,6 +33,7 @@ function test(snippet) {
|
|
|
26
33
|
const exported = {
|
|
27
34
|
isES9Supported,
|
|
28
35
|
isES11Supported,
|
|
36
|
+
isES13Supported,
|
|
29
37
|
test
|
|
30
38
|
};
|
|
31
39
|
function _loadScript(asset, root) {
|
|
@@ -110,7 +118,9 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
110
118
|
return scripts;
|
|
111
119
|
}
|
|
112
120
|
if (source === Object(source)) {
|
|
113
|
-
if (source.
|
|
121
|
+
if (source.es13 && exported.isES13Supported()) {
|
|
122
|
+
_asset.source = source.es13;
|
|
123
|
+
} else if (source.es11 && exported.isES11Supported()) {
|
|
114
124
|
_asset.source = source.es11;
|
|
115
125
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
116
126
|
_asset.source = source.es9;
|
package/lib/index.es9.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let _isES9Supported;
|
|
2
2
|
let _isES11Supported;
|
|
3
|
+
let _isES13Supported;
|
|
3
4
|
function isES9Supported() {
|
|
4
5
|
if (_isES9Supported === undefined) {
|
|
5
6
|
_isES9Supported = exported.test('return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()') && !!Object.values;
|
|
@@ -12,6 +13,12 @@ function isES11Supported() {
|
|
|
12
13
|
}
|
|
13
14
|
return _isES11Supported;
|
|
14
15
|
}
|
|
16
|
+
function isES13Supported() {
|
|
17
|
+
if (_isES13Supported === undefined) {
|
|
18
|
+
_isES13Supported = exported.test('return [1,1].findLast(e => e === 1)') && exported.test('return Object.hasOwn({a:1}, "a")');
|
|
19
|
+
}
|
|
20
|
+
return _isES13Supported;
|
|
21
|
+
}
|
|
15
22
|
function test(snippet) {
|
|
16
23
|
try {
|
|
17
24
|
const fn = new Function(snippet);
|
|
@@ -24,6 +31,7 @@ function test(snippet) {
|
|
|
24
31
|
const exported = {
|
|
25
32
|
isES9Supported,
|
|
26
33
|
isES11Supported,
|
|
34
|
+
isES13Supported,
|
|
27
35
|
test
|
|
28
36
|
};
|
|
29
37
|
function _loadScript(asset, root) {
|
|
@@ -108,7 +116,9 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
108
116
|
return scripts;
|
|
109
117
|
}
|
|
110
118
|
if (source === Object(source)) {
|
|
111
|
-
if (source.
|
|
119
|
+
if (source.es13 && exported.isES13Supported()) {
|
|
120
|
+
_asset.source = source.es13;
|
|
121
|
+
} else if (source.es11 && exported.isES11Supported()) {
|
|
112
122
|
_asset.source = source.es11;
|
|
113
123
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
114
124
|
_asset.source = source.es9;
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
let _isES9Supported;
|
|
4
4
|
let _isES11Supported;
|
|
5
|
+
let _isES13Supported;
|
|
5
6
|
|
|
6
7
|
function isES9Supported() {
|
|
7
8
|
if (_isES9Supported === undefined) {
|
|
@@ -28,6 +29,16 @@ function isES11Supported() {
|
|
|
28
29
|
return _isES11Supported;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
function isES13Supported() {
|
|
33
|
+
if (_isES13Supported === undefined) {
|
|
34
|
+
_isES13Supported =
|
|
35
|
+
exported.test('return [1,1].findLast(e => e === 1)') &&
|
|
36
|
+
exported.test('return Object.hasOwn({a:1}, "a")');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return _isES13Supported;
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
function test(snippet) {
|
|
32
43
|
try {
|
|
33
44
|
const fn = new Function(snippet);
|
|
@@ -42,6 +53,7 @@ function test(snippet) {
|
|
|
42
53
|
const exported = {
|
|
43
54
|
isES9Supported,
|
|
44
55
|
isES11Supported,
|
|
56
|
+
isES13Supported,
|
|
45
57
|
test,
|
|
46
58
|
};
|
|
47
59
|
|
|
@@ -150,7 +162,9 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
150
162
|
}
|
|
151
163
|
|
|
152
164
|
if (source === Object(source)) {
|
|
153
|
-
if (source.
|
|
165
|
+
if (source.es13 && exported.isES13Supported()) {
|
|
166
|
+
_asset.source = source.es13;
|
|
167
|
+
} else if (source.es11 && exported.isES11Supported()) {
|
|
154
168
|
_asset.source = source.es11;
|
|
155
169
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
156
170
|
_asset.source = source.es9;
|
package/lib/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let _isES9Supported;
|
|
2
2
|
let _isES11Supported;
|
|
3
|
+
let _isES13Supported;
|
|
3
4
|
|
|
4
5
|
function isES9Supported() {
|
|
5
6
|
if (_isES9Supported === undefined) {
|
|
@@ -26,6 +27,16 @@ function isES11Supported() {
|
|
|
26
27
|
return _isES11Supported;
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
function isES13Supported() {
|
|
31
|
+
if (_isES13Supported === undefined) {
|
|
32
|
+
_isES13Supported =
|
|
33
|
+
exported.test('return [1,1].findLast(e => e === 1)') &&
|
|
34
|
+
exported.test('return Object.hasOwn({a:1}, "a")');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return _isES13Supported;
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
function test(snippet) {
|
|
30
41
|
try {
|
|
31
42
|
const fn = new Function(snippet);
|
|
@@ -40,6 +51,7 @@ function test(snippet) {
|
|
|
40
51
|
const exported = {
|
|
41
52
|
isES9Supported,
|
|
42
53
|
isES11Supported,
|
|
54
|
+
isES13Supported,
|
|
43
55
|
test,
|
|
44
56
|
};
|
|
45
57
|
|
|
@@ -148,7 +160,9 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
if (source === Object(source)) {
|
|
151
|
-
if (source.
|
|
163
|
+
if (source.es13 && exported.isES13Supported()) {
|
|
164
|
+
_asset.source = source.es13;
|
|
165
|
+
} else if (source.es11 && exported.isES11Supported()) {
|
|
152
166
|
_asset.source = source.es11;
|
|
153
167
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
154
168
|
_asset.source = source.es9;
|
package/lib/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("function"==typeof define&&define.amd)define("@merkur/integration",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var r={exports:{}};t(r.exports),e.Merkur=e.Merkur||{},e.Merkur.Integration=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){function t(e,t,r,n,o,i,s){try{var u=e[i](s),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}var r,n;Object.defineProperty(e,"__esModule",{value:!0}),e.loadAssets=function(e,t){return Promise.all([
|
|
1
|
+
!function(e,t){if("function"==typeof define&&define.amd)define("@merkur/integration",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var r={exports:{}};t(r.exports),e.Merkur=e.Merkur||{},e.Merkur.Integration=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){function t(e,t,r,n,o,i,s){try{var u=e[i](s),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}var r,n,o;Object.defineProperty(e,"__esModule",{value:!0}),e.loadAssets=function(e,t){return Promise.all([u(e,t),s(e,t)])},e.loadScriptAssets=u,e.loadStyleAssets=s,e.testScript=void 0;var i=e.testScript={isES9Supported:function(){return void 0===r&&(r=i.test("return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()")&&!!Object.values),r},isES11Supported:function(){return void 0===n&&(n=i.test("return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()")&&i.test('return typeof Promise.allSettled === "function"')&&i.test('return typeof globalThis !== "undefined"')&&i.test('return typeof 9007199254740991n === "bigint"')),n},isES13Supported:function(){return void 0===o&&(o=i.test("return [1,1].findLast(e => e === 1)")&&i.test('return Object.hasOwn({a:1}, "a")')),o},test:function(e){try{return!!new Function(e)()}catch(e){return!1}}};function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.head,r=t.querySelectorAll("style"),n=e.filter((function(e){return e.source&&("stylesheet"===e.type&&!t.querySelector("link[href='".concat(e.source,"']"))||"inlineStyle"===e.type&&Array.from(r).reduce((function(t,r){return r.innerHTML!==e.source&&t}),!0))}));return Promise.all(n.map((function(e){return function(e,t){return new Promise((function(r,n){if("stylesheet"===e.type){var o=document.createElement("link");o.onload=r,o.onerror=n,o.rel="stylesheet",o.href=e.source,t.appendChild(o)}else{var i=document.createElement("style");i.innerHTML=e.source,t.appendChild(i),r()}}))}(e,t)})))}function u(e){return c.apply(this,arguments)}function c(){var e;return e=function*(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.head,r=t.querySelectorAll("script"),n=e.reduce((function(e,t){var n=t.source,o=Object.assign({},t);if("script"!==o.type&&"inlineScript"!==o.type)return e;if(n===Object(n)&&(n.es13&&i.isES13Supported()?o.source=n.es13:n.es11&&i.isES11Supported()?o.source=n.es11:n.es9&&i.isES9Supported()?o.source=n.es9:o.source=null,!o.source)){var s="Asset '".concat(o.name,"' is missing ES variant and could not be loaded.");if(!o.optional){var u=new Error(s);throw u.asset=o,u}return console.warn(s),e}return Array.from(r).reduce((function(e,t){return t.text===o.source||e}),!1)||o.test&&i.test(o.test)||e.push(o),e}),[]);return Promise.all(n.map((function(e){return function(e,t){return new Promise((function(r,n){var o=t.querySelector("script[src='".concat(e.source,"']"));if(o)return e.test&&!i.test(e.test)||r(),o.addEventListener("load",r),void o.addEventListener("error",e.optional?r:n);var s=document.createElement("script");if("script"===e.type){s.defer=!0,s.onload=r,s.onerror=function(t){s.remove(),e.optional?r(t):n(t)},s.src=e.source;var u=e.attr;if(u&&Object.keys(u).length)for(var c in u){var a=u[c];"boolean"==typeof a?a?s.setAttribute(c,""):s.removeAttribute(c):s.setAttribute(c,a)}}else s.text=e.source,r();t.appendChild(s)}))}(e,t)})))},c=function(){var r=this,n=arguments;return new Promise((function(o,i){var s=e.apply(r,n);function u(e){t(s,o,i,u,c,"next",e)}function c(e){t(s,o,i,u,c,"throw",e)}u(void 0)}))},c.apply(this,arguments)}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/integration",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Merkur module for easy integration with other apps.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://merkur.js.org/",
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@merkur/core": "^0.
|
|
52
|
+
"@merkur/core": "^0.35.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@merkur/core": "*"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "383f29bdf67a7f4252876867687371a8d26f53f2"
|
|
58
58
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const { createAssets } = require('../index');
|
|
2
|
-
const fs = require('fs');
|
|
1
|
+
const { createAssets } = require('../index.js');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
3
|
|
|
4
4
|
const staticFolder = 'build/static';
|
|
5
5
|
const staticBaseUrl = 'https://seznam.cz/static';
|
|
@@ -14,11 +14,20 @@ const manifests = {
|
|
|
14
14
|
'{"widget.css": "widget.6f79bbbdbeda640aeda0.css", "widget.js": "widget.53fbc48b6fb616ecfd1b.js"}',
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
jest.mock('fs', () =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
jest.mock('node:fs', () => {
|
|
18
|
+
const originalModule = jest.requireActual('fs');
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
__esModule: true,
|
|
22
|
+
...originalModule,
|
|
23
|
+
promises: {
|
|
24
|
+
...originalModule.promises,
|
|
25
|
+
readFile: jest.fn((path) => {
|
|
26
|
+
return manifests[path];
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
});
|
|
22
31
|
|
|
23
32
|
global.console.warn = jest.fn();
|
|
24
33
|
|
|
@@ -67,7 +76,7 @@ describe('createAssets method', () => {
|
|
|
67
76
|
);
|
|
68
77
|
});
|
|
69
78
|
|
|
70
|
-
it('should not
|
|
79
|
+
it('should not modify original assets', async () => {
|
|
71
80
|
await createAssets({
|
|
72
81
|
assets,
|
|
73
82
|
staticFolder,
|
package/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
1
|
+
const path = require('node:path');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
3
|
|
|
4
4
|
const fsp = fs.promises;
|
|
5
5
|
|
|
@@ -58,23 +58,27 @@ async function createAssets({ assets, staticFolder, folders, staticBaseUrl }) {
|
|
|
58
58
|
assets = await assets;
|
|
59
59
|
const folderPath = path.join(staticFolder, folder);
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
try {
|
|
62
|
+
const manifestFile = await fsp.readFile(
|
|
63
|
+
path.join(folderPath, 'manifest.json'),
|
|
64
|
+
{ encoding: 'utf-8' },
|
|
65
|
+
);
|
|
66
|
+
const manifest = JSON.parse(manifestFile);
|
|
67
|
+
|
|
68
|
+
return Promise.all(
|
|
69
|
+
assets.map(async (asset) =>
|
|
70
|
+
processAssetInFolder({
|
|
71
|
+
asset: { ...asset },
|
|
72
|
+
folder,
|
|
73
|
+
fileName: manifest[asset.name],
|
|
74
|
+
staticBaseUrl,
|
|
75
|
+
staticFolder,
|
|
76
|
+
}),
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return assets;
|
|
81
|
+
}
|
|
78
82
|
},
|
|
79
83
|
[...assets],
|
|
80
84
|
);
|
|
@@ -91,7 +95,86 @@ async function createAssets({ assets, staticFolder, folders, staticBaseUrl }) {
|
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
97
|
|
|
98
|
+
const moduleCache = new Map();
|
|
99
|
+
function getFileStats(modulePath) {
|
|
100
|
+
return fs.statSync(modulePath, { throwIfNoEntry: false });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function deleteCache(modulePath, force = false) {
|
|
104
|
+
const stats = getFileStats(modulePath) ?? { mtimeMs: -1 };
|
|
105
|
+
|
|
106
|
+
if (!moduleCache.has(modulePath)) {
|
|
107
|
+
moduleCache.set(modulePath, stats);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!modulePath) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (force || stats.mtimeMs > moduleCache.get(modulePath).mtimeMs) {
|
|
115
|
+
moduleCache.set(modulePath, stats);
|
|
116
|
+
|
|
117
|
+
searchCache(modulePath, function (mod) {
|
|
118
|
+
delete require.cache[mod.id];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function searchCache(moduleName, callback) {
|
|
124
|
+
if (moduleName && require.cache[moduleName] !== undefined) {
|
|
125
|
+
const module = require.cache[moduleName];
|
|
126
|
+
|
|
127
|
+
traverse(module, callback);
|
|
128
|
+
|
|
129
|
+
Object.keys(module.constructor._pathCache).forEach(function (cacheKey) {
|
|
130
|
+
if (cacheKey.indexOf(moduleName) > -1) {
|
|
131
|
+
delete module.constructor._pathCache[cacheKey];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function traverse(module, callback) {
|
|
138
|
+
(module?.children || []).forEach(function (child) {
|
|
139
|
+
if (child && require.cache[child.id] !== undefined) {
|
|
140
|
+
traverse(require.cache[child.id], callback);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
callback(module);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const memoPathResolve = memo(path.resolve);
|
|
148
|
+
function requireUncached(module, options = {}) {
|
|
149
|
+
const modulePath = memoPathResolve(module);
|
|
150
|
+
|
|
151
|
+
if (process.env.NODE_WATCH === 'true') {
|
|
152
|
+
if (options.optional && modulePath && !getFileStats(modulePath)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
deleteCache(modulePath);
|
|
157
|
+
|
|
158
|
+
// Force delete cache on all dependencies
|
|
159
|
+
if (Array.isArray(options.dependencies)) {
|
|
160
|
+
options.dependencies.forEach((dep) =>
|
|
161
|
+
deleteCache(path.resolve(dep), true),
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return require(modulePath);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function asyncMiddleware(fn) {
|
|
170
|
+
return (req, res, next) => {
|
|
171
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
94
175
|
module.exports = {
|
|
176
|
+
requireUncached,
|
|
177
|
+
asyncMiddleware,
|
|
95
178
|
createAssets,
|
|
96
179
|
memo,
|
|
97
180
|
};
|