alemonjs 2.0.0 → 2.0.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/lib/app/load.js +5 -24
- package/lib/jsx.js +5 -3
- package/package.json +1 -1
package/lib/app/load.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { dirname, join } from 'path';
|
|
2
|
-
import { existsSync
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
3
|
import { unChildren } from './hook-use-api.js';
|
|
4
4
|
import { showErrorModule, getRecursiveDirFiles, createEventName } from './utils.js';
|
|
5
|
+
import { createRequire } from 'module';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
// const createChildrenKey = () => {
|
|
8
|
-
// // 随机一个key
|
|
9
|
-
// const KEY = `${Date.now()}:${Math.random()}`
|
|
10
|
-
// // 如果存在。则重新生成
|
|
11
|
-
// // 把子应用挂起来
|
|
12
|
-
// // if (alemonjsCore.storeChildren[KEY]) {
|
|
13
|
-
// // return createChildrenKey()
|
|
14
|
-
// // }
|
|
15
|
-
// //
|
|
16
|
-
// }
|
|
17
|
-
// const require = createRequire(import.meta.url)
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
18
8
|
const mwReg = /^mw(\.|\..*\.)(js|ts|jsx|tsx)$/;
|
|
19
9
|
/**
|
|
20
10
|
* 加载文件
|
|
@@ -68,7 +58,7 @@ const loadChildren = async (mainPath, node) => {
|
|
|
68
58
|
return;
|
|
69
59
|
}
|
|
70
60
|
const mainDir = dirname(mainPath);
|
|
71
|
-
const show = e => {
|
|
61
|
+
const show = (e) => {
|
|
72
62
|
showErrorModule(e);
|
|
73
63
|
// 卸载索引
|
|
74
64
|
unChildren(mainDir);
|
|
@@ -149,17 +139,8 @@ const loadChildrenFile = async (node) => {
|
|
|
149
139
|
logger.error('The module name is not correct');
|
|
150
140
|
return;
|
|
151
141
|
}
|
|
152
|
-
const dir = join(process.cwd(), 'node_modules', node);
|
|
153
|
-
const pkgPath = join(dir, 'package.json');
|
|
154
|
-
if (!existsSync(pkgPath)) {
|
|
155
|
-
logger.error('The package.json does not exist', pkgPath);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
142
|
try {
|
|
159
|
-
|
|
160
|
-
const packageJson = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
161
|
-
// main
|
|
162
|
-
const mainPath = join(dir, packageJson.main);
|
|
143
|
+
const mainPath = require.resolve(node);
|
|
163
144
|
// 不存在 main
|
|
164
145
|
if (!existsSync(mainPath)) {
|
|
165
146
|
logger.error('The main file does not exist', mainPath);
|
package/lib/jsx.js
CHANGED
|
@@ -99,9 +99,11 @@ function JSX(...arg) {
|
|
|
99
99
|
}
|
|
100
100
|
else if (dataType === 'Mention') {
|
|
101
101
|
// <@!123456> 文本的显示会被平台显示。不用自己定义显示的文本,此处不使用 children
|
|
102
|
-
data.push(Mention$1(props.value, props?.belong
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
data.push(Mention$1(props.value, props?.belong
|
|
103
|
+
? {
|
|
104
|
+
belong: props?.belong
|
|
105
|
+
}
|
|
106
|
+
: null));
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
if (data.length === 0) {
|