@modern-js/core 1.0.0-rc.5 → 1.0.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/CHANGELOG.md +274 -0
- package/README.md +21 -20
- package/dist/js/modern/config/defaults.js +2 -1
- package/dist/js/modern/config/index.js +1 -1
- package/dist/js/modern/config/schema/deploy.js +1 -15
- package/dist/js/modern/config/schema/index.js +3 -0
- package/dist/js/modern/config/schema/server.js +3 -0
- package/dist/js/modern/context.js +4 -4
- package/dist/js/modern/index.js +17 -13
- package/dist/js/modern/initWatcher.js +2 -8
- package/dist/js/modern/loadEnv.js +1 -1
- package/dist/js/modern/loadPlugins.js +3 -3
- package/dist/js/node/config/defaults.js +2 -1
- package/dist/js/node/config/index.js +1 -1
- package/dist/js/node/config/schema/deploy.js +1 -15
- package/dist/js/node/config/schema/index.js +3 -0
- package/dist/js/node/config/schema/server.js +3 -0
- package/dist/js/node/context.js +9 -9
- package/dist/js/node/index.js +54 -23
- package/dist/js/node/initWatcher.js +5 -12
- package/dist/js/node/loadEnv.js +3 -3
- package/dist/js/node/loadPlugins.js +2 -2
- package/dist/types/config/defaults.d.ts +1 -0
- package/dist/types/config/index.d.ts +3 -3
- package/dist/types/config/schema/deploy.d.ts +1 -15
- package/dist/types/config/schema/index.d.ts +7 -15
- package/dist/types/config/schema/server.d.ts +3 -0
- package/dist/types/context.d.ts +3 -9
- package/dist/types/index.d.ts +5 -3
- package/dist/types/initWatcher.d.ts +1 -2
- package/package.json +19 -8
- package/src/config/defaults.ts +1 -1
- package/src/config/index.ts +4 -4
- package/src/config/schema/deploy.ts +1 -7
- package/src/config/schema/index.ts +6 -1
- package/src/config/schema/server.ts +1 -0
- package/src/context.ts +4 -4
- package/src/index.ts +30 -22
- package/src/initWatcher.ts +2 -6
- package/src/loadEnv.ts +1 -1
- package/src/loadPlugins.ts +2 -1
- package/tests/loadEnv.test.ts +1 -1
- package/tests/loadPlugin.test.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,279 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 224f7fe: fix server route match
|
|
8
|
+
- 30ac27c: feat: add generator package description
|
|
9
|
+
- 0fd196e: feat: fix bugs
|
|
10
|
+
- 204c626: feat: initial
|
|
11
|
+
- 63be0a5: fix: #118 #104
|
|
12
|
+
- Updated dependencies [224f7fe]
|
|
13
|
+
- Updated dependencies [30ac27c]
|
|
14
|
+
- Updated dependencies [0fd196e]
|
|
15
|
+
- Updated dependencies [204c626]
|
|
16
|
+
- Updated dependencies [63be0a5]
|
|
17
|
+
- @modern-js/load-config@1.0.0
|
|
18
|
+
- @modern-js/plugin@1.0.0
|
|
19
|
+
- @modern-js/utils@1.0.0
|
|
20
|
+
|
|
21
|
+
## 1.0.0-rc.23
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 224f7fe: fix server route match
|
|
26
|
+
- 30ac27c: feat: add generator package description
|
|
27
|
+
- 0fd196e: feat: fix bugs
|
|
28
|
+
- 204c626: feat: initial
|
|
29
|
+
- 63be0a5: fix: #118 #104
|
|
30
|
+
- Updated dependencies [224f7fe]
|
|
31
|
+
- Updated dependencies [30ac27c]
|
|
32
|
+
- Updated dependencies [0fd196e]
|
|
33
|
+
- Updated dependencies [204c626]
|
|
34
|
+
- Updated dependencies [63be0a5]
|
|
35
|
+
- @modern-js/load-config@1.0.0-rc.28
|
|
36
|
+
- @modern-js/plugin@1.0.0-rc.23
|
|
37
|
+
- @modern-js/utils@1.0.0-rc.23
|
|
38
|
+
|
|
39
|
+
## 1.0.0-rc.22
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 224f7fe: fix server route match
|
|
44
|
+
- 30ac27c: feat: add generator package description
|
|
45
|
+
- 0fd196e: feat: fix bugs
|
|
46
|
+
- 204c626: feat: initial
|
|
47
|
+
- 63be0a5: fix: #118 #104
|
|
48
|
+
- Updated dependencies [224f7fe]
|
|
49
|
+
- Updated dependencies [30ac27c]
|
|
50
|
+
- Updated dependencies [0fd196e]
|
|
51
|
+
- Updated dependencies [204c626]
|
|
52
|
+
- Updated dependencies [63be0a5]
|
|
53
|
+
- @modern-js/load-config@1.0.0-rc.27
|
|
54
|
+
- @modern-js/plugin@1.0.0-rc.22
|
|
55
|
+
- @modern-js/utils@1.0.0-rc.22
|
|
56
|
+
|
|
57
|
+
## 1.0.0-rc.21
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- 224f7fe: fix server route match
|
|
62
|
+
- 30ac27c: feat: add generator package description
|
|
63
|
+
- 0fd196e: feat: fix bugs
|
|
64
|
+
- 204c626: feat: initial
|
|
65
|
+
- 63be0a5: fix: #118 #104
|
|
66
|
+
- Updated dependencies [224f7fe]
|
|
67
|
+
- Updated dependencies [30ac27c]
|
|
68
|
+
- Updated dependencies [0fd196e]
|
|
69
|
+
- Updated dependencies [204c626]
|
|
70
|
+
- Updated dependencies [63be0a5]
|
|
71
|
+
- @modern-js/load-config@1.0.0-rc.26
|
|
72
|
+
- @modern-js/plugin@1.0.0-rc.21
|
|
73
|
+
- @modern-js/utils@1.0.0-rc.21
|
|
74
|
+
|
|
75
|
+
## 1.0.0-rc.20
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- 224f7fe: fix server route match
|
|
80
|
+
- 30ac27c: feat: add generator package description
|
|
81
|
+
- feat: fix bugs
|
|
82
|
+
- 204c626: feat: initial
|
|
83
|
+
- 63be0a5: fix: #118 #104
|
|
84
|
+
- Updated dependencies [224f7fe]
|
|
85
|
+
- Updated dependencies [30ac27c]
|
|
86
|
+
- Updated dependencies [undefined]
|
|
87
|
+
- Updated dependencies [204c626]
|
|
88
|
+
- Updated dependencies [63be0a5]
|
|
89
|
+
- @modern-js/load-config@1.0.0-rc.24
|
|
90
|
+
- @modern-js/plugin@1.0.0-rc.20
|
|
91
|
+
- @modern-js/utils@1.0.0-rc.20
|
|
92
|
+
|
|
93
|
+
## 1.0.0-rc.19
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- 224f7fe: fix server route match
|
|
98
|
+
- 30ac27c: feat: add generator package description
|
|
99
|
+
- 204c626: feat: initial
|
|
100
|
+
- 63be0a5: fix: #118 #104
|
|
101
|
+
- Updated dependencies [224f7fe]
|
|
102
|
+
- Updated dependencies [30ac27c]
|
|
103
|
+
- Updated dependencies [204c626]
|
|
104
|
+
- Updated dependencies [63be0a5]
|
|
105
|
+
- @modern-js/load-config@1.0.0-rc.23
|
|
106
|
+
- @modern-js/plugin@1.0.0-rc.19
|
|
107
|
+
- @modern-js/utils@1.0.0-rc.19
|
|
108
|
+
|
|
109
|
+
## 1.0.0-rc.18
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- 224f7fe: fix server route match
|
|
114
|
+
- 30ac27c: feat: add generator package description
|
|
115
|
+
- 204c626: feat: initial
|
|
116
|
+
- 63be0a5: fix: #118 #104
|
|
117
|
+
- Updated dependencies [224f7fe]
|
|
118
|
+
- Updated dependencies [30ac27c]
|
|
119
|
+
- Updated dependencies [204c626]
|
|
120
|
+
- Updated dependencies [63be0a5]
|
|
121
|
+
- @modern-js/load-config@1.0.0-rc.22
|
|
122
|
+
- @modern-js/plugin@1.0.0-rc.18
|
|
123
|
+
- @modern-js/utils@1.0.0-rc.18
|
|
124
|
+
|
|
125
|
+
## 1.0.0-rc.17
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- 224f7fe: fix server route match
|
|
130
|
+
- 30ac27c: feat: add generator package description
|
|
131
|
+
- 204c626: feat: initial
|
|
132
|
+
- fix: #118 #104
|
|
133
|
+
- Updated dependencies [224f7fe]
|
|
134
|
+
- Updated dependencies [30ac27c]
|
|
135
|
+
- Updated dependencies [204c626]
|
|
136
|
+
- Updated dependencies [undefined]
|
|
137
|
+
- @modern-js/load-config@1.0.0-rc.17
|
|
138
|
+
- @modern-js/plugin@1.0.0-rc.17
|
|
139
|
+
- @modern-js/utils@1.0.0-rc.17
|
|
140
|
+
|
|
141
|
+
## 1.0.0-rc.16
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- 224f7fe: fix server route match
|
|
146
|
+
- 30ac27c: feat: add generator package description
|
|
147
|
+
- 204c626: feat: initial
|
|
148
|
+
- Updated dependencies [224f7fe]
|
|
149
|
+
- Updated dependencies [30ac27c]
|
|
150
|
+
- Updated dependencies [204c626]
|
|
151
|
+
- @modern-js/load-config@1.0.0-rc.16
|
|
152
|
+
- @modern-js/plugin@1.0.0-rc.16
|
|
153
|
+
- @modern-js/utils@1.0.0-rc.16
|
|
154
|
+
|
|
155
|
+
## 1.0.0-rc.15
|
|
156
|
+
|
|
157
|
+
### Patch Changes
|
|
158
|
+
|
|
159
|
+
- 224f7fe: fix server route match
|
|
160
|
+
- 30ac27c: feat: add generator package description
|
|
161
|
+
- 204c626: feat: initial
|
|
162
|
+
- Updated dependencies [224f7fe]
|
|
163
|
+
- Updated dependencies [30ac27c]
|
|
164
|
+
- Updated dependencies [204c626]
|
|
165
|
+
- @modern-js/load-config@1.0.0-rc.15
|
|
166
|
+
- @modern-js/plugin@1.0.0-rc.15
|
|
167
|
+
- @modern-js/utils@1.0.0-rc.15
|
|
168
|
+
|
|
169
|
+
## 1.0.0-rc.14
|
|
170
|
+
|
|
171
|
+
### Patch Changes
|
|
172
|
+
|
|
173
|
+
- 224f7fe: fix server route match
|
|
174
|
+
- 204c626: feat: initial
|
|
175
|
+
- Updated dependencies [224f7fe]
|
|
176
|
+
- Updated dependencies [204c626]
|
|
177
|
+
- @modern-js/load-config@1.0.0-rc.14
|
|
178
|
+
- @modern-js/plugin@1.0.0-rc.14
|
|
179
|
+
- @modern-js/utils@1.0.0-rc.14
|
|
180
|
+
|
|
181
|
+
## 1.0.0-rc.13
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- 224f7fe: fix server route match
|
|
186
|
+
- 204c626: feat: initial
|
|
187
|
+
- Updated dependencies [224f7fe]
|
|
188
|
+
- Updated dependencies [204c626]
|
|
189
|
+
- @modern-js/load-config@1.0.0-rc.13
|
|
190
|
+
- @modern-js/plugin@1.0.0-rc.13
|
|
191
|
+
- @modern-js/utils@1.0.0-rc.13
|
|
192
|
+
|
|
193
|
+
## 1.0.0-rc.12
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- 224f7fe: fix server route match
|
|
198
|
+
- 204c626: feat: initial
|
|
199
|
+
- Updated dependencies [224f7fe]
|
|
200
|
+
- Updated dependencies [204c626]
|
|
201
|
+
- @modern-js/load-config@1.0.0-rc.12
|
|
202
|
+
- @modern-js/plugin@1.0.0-rc.12
|
|
203
|
+
- @modern-js/utils@1.0.0-rc.12
|
|
204
|
+
|
|
205
|
+
## 1.0.0-rc.11
|
|
206
|
+
|
|
207
|
+
### Patch Changes
|
|
208
|
+
|
|
209
|
+
- 224f7fe: fix server route match
|
|
210
|
+
- 204c626: feat: initial
|
|
211
|
+
- Updated dependencies [224f7fe]
|
|
212
|
+
- Updated dependencies [204c626]
|
|
213
|
+
- @modern-js/load-config@1.0.0-rc.11
|
|
214
|
+
- @modern-js/plugin@1.0.0-rc.11
|
|
215
|
+
- @modern-js/utils@1.0.0-rc.11
|
|
216
|
+
|
|
217
|
+
## 1.0.0-rc.10
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- 224f7fe: fix server route match
|
|
222
|
+
- 204c626: feat: initial
|
|
223
|
+
- Updated dependencies [224f7fe]
|
|
224
|
+
- Updated dependencies [204c626]
|
|
225
|
+
- @modern-js/load-config@1.0.0-rc.10
|
|
226
|
+
- @modern-js/plugin@1.0.0-rc.10
|
|
227
|
+
- @modern-js/utils@1.0.0-rc.10
|
|
228
|
+
|
|
229
|
+
## 1.0.0-rc.9
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- 224f7fe: fix server route match
|
|
234
|
+
- 204c626: feat: initial
|
|
235
|
+
- Updated dependencies [224f7fe]
|
|
236
|
+
- Updated dependencies [204c626]
|
|
237
|
+
- @modern-js/load-config@1.0.0-rc.9
|
|
238
|
+
- @modern-js/plugin@1.0.0-rc.9
|
|
239
|
+
- @modern-js/utils@1.0.0-rc.9
|
|
240
|
+
|
|
241
|
+
## 1.0.0-rc.8
|
|
242
|
+
|
|
243
|
+
### Patch Changes
|
|
244
|
+
|
|
245
|
+
- 224f7fe: fix server route match
|
|
246
|
+
- 204c626: feat: initial
|
|
247
|
+
- Updated dependencies [224f7fe]
|
|
248
|
+
- Updated dependencies [204c626]
|
|
249
|
+
- @modern-js/load-config@1.0.0-rc.8
|
|
250
|
+
- @modern-js/plugin@1.0.0-rc.8
|
|
251
|
+
- @modern-js/utils@1.0.0-rc.8
|
|
252
|
+
|
|
253
|
+
## 1.0.0-rc.7
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- 224f7fe: fix server route match
|
|
258
|
+
- 204c626: feat: initial
|
|
259
|
+
- Updated dependencies [224f7fe]
|
|
260
|
+
- Updated dependencies [204c626]
|
|
261
|
+
- @modern-js/load-config@1.0.0-rc.7
|
|
262
|
+
- @modern-js/plugin@1.0.0-rc.7
|
|
263
|
+
- @modern-js/utils@1.0.0-rc.7
|
|
264
|
+
|
|
265
|
+
## 1.0.0-rc.6
|
|
266
|
+
|
|
267
|
+
### Patch Changes
|
|
268
|
+
|
|
269
|
+
- 224f7fe: fix server route match
|
|
270
|
+
- 204c626: feat: initial
|
|
271
|
+
- Updated dependencies [224f7fe]
|
|
272
|
+
- Updated dependencies [204c626]
|
|
273
|
+
- @modern-js/load-config@1.0.0-rc.6
|
|
274
|
+
- @modern-js/plugin@1.0.0-rc.6
|
|
275
|
+
- @modern-js/utils@1.0.0-rc.6
|
|
276
|
+
|
|
3
277
|
## 1.0.0-rc.5
|
|
4
278
|
|
|
5
279
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,31 +2,32 @@
|
|
|
2
2
|
<p align="center">
|
|
3
3
|
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
4
4
|
</p>
|
|
5
|
+
<p align="center">
|
|
6
|
+
现代 Web 工程体系
|
|
7
|
+
<br/>
|
|
8
|
+
<a href="https://modernjs.dev" target="blank">
|
|
9
|
+
modernjs.dev
|
|
10
|
+
</a>
|
|
11
|
+
</p>
|
|
12
|
+
<p align="center">
|
|
13
|
+
The meta-framework suite designed from scratch for frontend-focused modern web development
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
# Introduction
|
|
5
17
|
|
|
6
|
-
|
|
18
|
+
> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
- 介绍 Modern.js (即将上线)
|
|
9
21
|
- [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
|
|
10
22
|
- [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
|
|
23
|
+
- [字节跳动是如何落地微前端的](https://mp.weixin.qq.com/s/L9wbfNG5fTXF5bx7dcgj4Q)
|
|
11
24
|
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
Modern.js 的 1.0.0.rc 版已经发到 npm,目前在做测试改进,README 文档之后统一提供(现阶段加入测试和开发,可以发 [issue](https://github.com/modern-js-dev/modern.js/issues) 留微信联系),完整的文档站计划在10月14日上线
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
## Getting Started
|
|
30
26
|
|
|
27
|
+
- [Quick Start](https://modernjs.dev/docs/start)
|
|
28
|
+
- [Guides](https://modernjs.dev/docs/guides)
|
|
29
|
+
- [API References](https://modernjs.dev/docs/apis)
|
|
31
30
|
|
|
31
|
+
## Contributing
|
|
32
32
|
|
|
33
|
+
- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)
|
|
@@ -20,7 +20,7 @@ const debug = createDebugger('resolve-config');
|
|
|
20
20
|
export { defaults as defaultsConfig };
|
|
21
21
|
export const defineConfig = config => config;
|
|
22
22
|
export const loadUserConfig = async (appDirectory, filePath) => {
|
|
23
|
-
const loaded = loadConfig(appDirectory, filePath);
|
|
23
|
+
const loaded = await loadConfig(appDirectory, filePath);
|
|
24
24
|
const config = !loaded ? {} : await (typeof loaded.config === 'function' ? loaded.config(0) : loaded.config);
|
|
25
25
|
return {
|
|
26
26
|
config: mergeWith({}, config || {}, (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {}),
|
|
@@ -3,21 +3,7 @@ export const deploy = {
|
|
|
3
3
|
type: 'object',
|
|
4
4
|
properties: {
|
|
5
5
|
microFrontend: {
|
|
6
|
-
type: 'object'
|
|
7
|
-
dependencies: {
|
|
8
|
-
enableHtmlEntry: {
|
|
9
|
-
properties: {
|
|
10
|
-
enableLegacy: {
|
|
11
|
-
enum: [false]
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
properties: {
|
|
17
|
-
enableHtmlEntry: {
|
|
18
|
-
type: 'boolean'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
6
|
+
type: ['boolean', 'object']
|
|
21
7
|
},
|
|
22
8
|
domain: {
|
|
23
9
|
type: ['array', 'string']
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@modern-js/utils';
|
|
2
2
|
import { createContext } from '@modern-js/plugin';
|
|
3
3
|
import address from 'address';
|
|
4
4
|
export const AppContext = createContext({});
|
|
5
5
|
export const ConfigContext = createContext({});
|
|
6
6
|
export const ResolvedConfigContext = createContext({});
|
|
7
|
-
export const useAppContext = () => AppContext.use();
|
|
8
|
-
export const useConfigContext = () => ConfigContext.use();
|
|
9
|
-
export const useResolvedConfigContext = () => ResolvedConfigContext.use();
|
|
7
|
+
export const useAppContext = () => AppContext.use().value;
|
|
8
|
+
export const useConfigContext = () => ConfigContext.use().value;
|
|
9
|
+
export const useResolvedConfigContext = () => ResolvedConfigContext.use().value;
|
|
10
10
|
export const initAppContext = (appDirectory, plugins, configFile) => ({
|
|
11
11
|
appDirectory,
|
|
12
12
|
configFile,
|
package/dist/js/modern/index.js
CHANGED
|
@@ -4,10 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import path from '
|
|
8
|
-
import { createAsyncManager,
|
|
7
|
+
import { path, upath, compatRequire, pkgUp, ensureAbsolutePath, logger } from '@modern-js/utils';
|
|
8
|
+
import { createAsyncManager, createAsyncWorkflow, createParallelWorkflow } from '@modern-js/plugin';
|
|
9
9
|
import { enable } from '@modern-js/plugin/node';
|
|
10
|
-
import { compatRequire, pkgUp, ensureAbsolutePath, logger } from '@modern-js/utils';
|
|
11
10
|
import { program } from "./utils/commander";
|
|
12
11
|
import { resolveConfig, defineConfig, loadUserConfig } from "./config";
|
|
13
12
|
import { loadPlugins } from "./loadPlugins";
|
|
@@ -15,6 +14,8 @@ import { AppContext, ConfigContext, initAppContext, ResolvedConfigContext, useAp
|
|
|
15
14
|
import { initWatcher } from "./initWatcher";
|
|
16
15
|
import { loadEnv } from "./loadEnv";
|
|
17
16
|
export { defaultsConfig } from "./config";
|
|
17
|
+
export * from '@modern-js/plugin';
|
|
18
|
+
export * from '@modern-js/plugin/node';
|
|
18
19
|
program.name('modern').usage('<command> [options]').version(process.env.MODERN_JS_VERSION || '0.1.0');
|
|
19
20
|
const hooksMap = {
|
|
20
21
|
config: createParallelWorkflow(),
|
|
@@ -33,8 +34,8 @@ export const {
|
|
|
33
34
|
registe: registerHook,
|
|
34
35
|
useRunner: mountHook
|
|
35
36
|
} = manager;
|
|
36
|
-
export const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin(compatRequire(require.resolve(plugin))));
|
|
37
|
-
export { defineConfig,
|
|
37
|
+
export const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin(compatRequire(upath.normalize(require.resolve(plugin)))));
|
|
38
|
+
export { defineConfig, AppContext, useAppContext, useConfigContext, useResolvedConfigContext };
|
|
38
39
|
|
|
39
40
|
const initAppDir = async () => {
|
|
40
41
|
const pkg = await pkgUp({
|
|
@@ -53,6 +54,7 @@ const createCli = () => {
|
|
|
53
54
|
let isRestart = false;
|
|
54
55
|
|
|
55
56
|
const init = async (argv = []) => {
|
|
57
|
+
enable();
|
|
56
58
|
manager.clear();
|
|
57
59
|
const appDirectory = await initAppDir();
|
|
58
60
|
loadEnv(appDirectory);
|
|
@@ -100,31 +102,33 @@ const createCli = () => {
|
|
|
100
102
|
};
|
|
101
103
|
|
|
102
104
|
async function run(argv) {
|
|
103
|
-
enable();
|
|
104
105
|
const {
|
|
105
106
|
loadedConfig,
|
|
106
107
|
appContext,
|
|
107
108
|
resolved
|
|
108
109
|
} = await init(argv);
|
|
109
|
-
initWatcher(loadedConfig, appContext.appDirectory, resolved, hooksRunner, argv);
|
|
110
110
|
await hooksRunner.commands({
|
|
111
111
|
program
|
|
112
112
|
});
|
|
113
|
+
initWatcher(loadedConfig, appContext.appDirectory, resolved.source.configDir, hooksRunner, argv);
|
|
113
114
|
manager.run(() => program.parse(process.argv));
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
async function restart() {
|
|
117
118
|
isRestart = true;
|
|
119
|
+
logger.info('Restart...\n');
|
|
120
|
+
let hasGetError = false;
|
|
118
121
|
|
|
119
122
|
try {
|
|
120
|
-
|
|
121
|
-
await init();
|
|
122
|
-
return true;
|
|
123
|
+
await init(process.argv.slice(2));
|
|
123
124
|
} catch (err) {
|
|
124
|
-
|
|
125
|
+
console.error(err);
|
|
126
|
+
hasGetError = true;
|
|
127
|
+
} finally {
|
|
128
|
+
if (!hasGetError) {
|
|
129
|
+
manager.run(() => program.parse(process.argv));
|
|
130
|
+
}
|
|
125
131
|
}
|
|
126
|
-
|
|
127
|
-
return false;
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
return {
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import crypto from 'crypto';
|
|
3
2
|
import fs from 'fs';
|
|
3
|
+
import { path, isDev, createDebugger } from '@modern-js/utils';
|
|
4
4
|
import chokidar from 'chokidar';
|
|
5
|
-
import { isDev, createDebugger } from '@modern-js/utils';
|
|
6
5
|
const debug = createDebugger('watch-files');
|
|
7
6
|
|
|
8
7
|
const md5 = data => crypto.createHash('md5').update(data).digest('hex');
|
|
9
8
|
|
|
10
9
|
const hashMap = new Map();
|
|
11
|
-
export const initWatcher = async (loaded, appDirectory,
|
|
10
|
+
export const initWatcher = async (loaded, appDirectory, configDir, hooksRunner, argv) => {
|
|
12
11
|
// only add fs watcher on dev mode.
|
|
13
12
|
if (isDev() && argv[0] === 'dev') {
|
|
14
|
-
const {
|
|
15
|
-
source: {
|
|
16
|
-
configDir
|
|
17
|
-
}
|
|
18
|
-
} = resovledConfig;
|
|
19
13
|
const extraFiles = await hooksRunner.watchFiles();
|
|
20
14
|
const configPath = path.join(appDirectory, configDir);
|
|
21
15
|
const watched = [`${configPath}/html`, ...extraFiles, loaded === null || loaded === void 0 ? void 0 : loaded.filePath, ...loaded.dependencies].filter(Boolean);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isDepExists, createDebugger, compatRequire, INTERNAL_PLUGINS } from '@modern-js/utils';
|
|
1
|
+
import { isDepExists, createDebugger, compatRequire, INTERNAL_PLUGINS, upath } from '@modern-js/utils';
|
|
2
2
|
const debug = createDebugger('load-plugins');
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -12,9 +12,9 @@ const resolvePlugin = (appDirectory, plugin) => {
|
|
|
12
12
|
let filePath = '';
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
|
-
filePath = require.resolve(name, {
|
|
15
|
+
filePath = upath.normalizeSafe(require.resolve(name, {
|
|
16
16
|
paths: [appDirectory]
|
|
17
|
-
});
|
|
17
|
+
}));
|
|
18
18
|
delete require.cache[filePath];
|
|
19
19
|
} catch (err) {
|
|
20
20
|
if (err.code === 'MODULE_NOT_FOUND') {
|
|
@@ -50,7 +50,7 @@ const defineConfig = config => config;
|
|
|
50
50
|
exports.defineConfig = defineConfig;
|
|
51
51
|
|
|
52
52
|
const loadUserConfig = async (appDirectory, filePath) => {
|
|
53
|
-
const loaded = (0, _loadConfig.loadConfig)(appDirectory, filePath);
|
|
53
|
+
const loaded = await (0, _loadConfig.loadConfig)(appDirectory, filePath);
|
|
54
54
|
const config = !loaded ? {} : await (typeof loaded.config === 'function' ? loaded.config(0) : loaded.config);
|
|
55
55
|
return {
|
|
56
56
|
config: (0, _lodash.default)({}, config || {}, (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {}),
|
|
@@ -11,21 +11,7 @@ const deploy = {
|
|
|
11
11
|
type: 'object',
|
|
12
12
|
properties: {
|
|
13
13
|
microFrontend: {
|
|
14
|
-
type: 'object'
|
|
15
|
-
dependencies: {
|
|
16
|
-
enableHtmlEntry: {
|
|
17
|
-
properties: {
|
|
18
|
-
enableLegacy: {
|
|
19
|
-
enum: [false]
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
properties: {
|
|
25
|
-
enableHtmlEntry: {
|
|
26
|
-
type: 'boolean'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
14
|
+
type: ['boolean', 'object']
|
|
29
15
|
},
|
|
30
16
|
domain: {
|
|
31
17
|
type: ['array', 'string']
|
package/dist/js/node/context.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.initAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
10
|
var _plugin = require("@modern-js/plugin");
|
|
11
11
|
|
|
@@ -20,15 +20,15 @@ exports.ConfigContext = ConfigContext;
|
|
|
20
20
|
const ResolvedConfigContext = (0, _plugin.createContext)({});
|
|
21
21
|
exports.ResolvedConfigContext = ResolvedConfigContext;
|
|
22
22
|
|
|
23
|
-
const useAppContext = () => AppContext.use();
|
|
23
|
+
const useAppContext = () => AppContext.use().value;
|
|
24
24
|
|
|
25
25
|
exports.useAppContext = useAppContext;
|
|
26
26
|
|
|
27
|
-
const useConfigContext = () => ConfigContext.use();
|
|
27
|
+
const useConfigContext = () => ConfigContext.use().value;
|
|
28
28
|
|
|
29
29
|
exports.useConfigContext = useConfigContext;
|
|
30
30
|
|
|
31
|
-
const useResolvedConfigContext = () => ResolvedConfigContext.use();
|
|
31
|
+
const useResolvedConfigContext = () => ResolvedConfigContext.use().value;
|
|
32
32
|
|
|
33
33
|
exports.useResolvedConfigContext = useResolvedConfigContext;
|
|
34
34
|
|
|
@@ -37,12 +37,12 @@ const initAppContext = (appDirectory, plugins, configFile) => ({
|
|
|
37
37
|
configFile,
|
|
38
38
|
ip: _address.default.ip(),
|
|
39
39
|
port: 0,
|
|
40
|
-
packageName: require(
|
|
41
|
-
srcDirectory:
|
|
40
|
+
packageName: require(_utils.path.resolve(appDirectory, './package.json')).name,
|
|
41
|
+
srcDirectory: _utils.path.resolve(appDirectory, './src'),
|
|
42
42
|
distDirectory: '',
|
|
43
|
-
sharedDirectory:
|
|
44
|
-
nodeModulesDirectory:
|
|
45
|
-
internalDirectory:
|
|
43
|
+
sharedDirectory: _utils.path.resolve(appDirectory, './shared'),
|
|
44
|
+
nodeModulesDirectory: _utils.path.resolve(appDirectory, './node_modules'),
|
|
45
|
+
internalDirectory: _utils.path.resolve(appDirectory, './node_modules/.modern-js'),
|
|
46
46
|
plugins,
|
|
47
47
|
htmlTemplates: {},
|
|
48
48
|
serverRoutes: [],
|