@midwayjs/core 3.12.0 → 3.12.1
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/dist/util/index.js +13 -3
- package/package.json +2 -2
package/dist/util/index.js
CHANGED
|
@@ -54,6 +54,7 @@ const safeRequire = (p, enabledCache = true) => {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
exports.safeRequire = safeRequire;
|
|
57
|
+
const innerLoadModuleCache = {};
|
|
57
58
|
/**
|
|
58
59
|
* load module, and it can be chosen commonjs or esm mode
|
|
59
60
|
* @param p
|
|
@@ -76,9 +77,18 @@ const loadModule = async (p, options = {}) => {
|
|
|
76
77
|
else {
|
|
77
78
|
// if json file, import need add options
|
|
78
79
|
if (p.endsWith('.json')) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
/**
|
|
81
|
+
* attention: import json not support under nodejs 16
|
|
82
|
+
* use readFileSync instead
|
|
83
|
+
*/
|
|
84
|
+
if (!innerLoadModuleCache[p]) {
|
|
85
|
+
// return (await import(p, { assert: { type: 'json' } })).default;
|
|
86
|
+
const content = (0, fs_1.readFileSync)(p, {
|
|
87
|
+
encoding: 'utf-8',
|
|
88
|
+
});
|
|
89
|
+
innerLoadModuleCache[p] = JSON.parse(content);
|
|
90
|
+
}
|
|
91
|
+
return innerLoadModuleCache[p];
|
|
82
92
|
}
|
|
83
93
|
else {
|
|
84
94
|
return await import(p);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=12"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "48413b87b12354cb8207de6aa58e0a4ca22ea000"
|
|
46
46
|
}
|