@modern-js/app-tools 2.0.0-beta.0 → 2.0.0-beta.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.
Files changed (279) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/dist/js/modern/analyze/generateCode.js +30 -38
  3. package/dist/js/modern/analyze/getBundleEntry.js +5 -13
  4. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
  5. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
  6. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
  7. package/dist/js/modern/analyze/getFileSystemEntry.js +5 -18
  8. package/dist/js/modern/analyze/getHtmlTemplate.js +3 -10
  9. package/dist/js/modern/analyze/getServerRoutes.js +25 -38
  10. package/dist/js/modern/analyze/index.js +90 -48
  11. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
  12. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
  13. package/dist/js/modern/analyze/nestedRoutes.js +8 -33
  14. package/dist/js/modern/analyze/templates.js +22 -37
  15. package/dist/js/modern/analyze/utils.js +0 -7
  16. package/dist/js/modern/builder/builderPlugins/compatModern.js +41 -58
  17. package/dist/js/modern/builder/index.js +56 -37
  18. package/dist/js/modern/builder/share.js +1 -5
  19. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
  20. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
  21. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
  22. package/dist/js/modern/commands/build.js +12 -46
  23. package/dist/js/modern/commands/dev.js +20 -23
  24. package/dist/js/modern/commands/inspect.js +4 -19
  25. package/dist/js/modern/commands/start.js +1 -2
  26. package/dist/js/modern/config/default.js +207 -0
  27. package/dist/js/modern/config/index.js +2 -0
  28. package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
  29. package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +19 -18
  30. package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
  31. package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
  32. package/dist/js/modern/config/initial/index.js +11 -0
  33. package/dist/js/modern/config/initial/inits.js +117 -0
  34. package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
  35. package/dist/js/modern/defineConfig.js +12 -0
  36. package/dist/js/modern/hooks.js +23 -19
  37. package/dist/js/modern/index.js +12 -19
  38. package/dist/js/modern/initialize/index.js +72 -0
  39. package/dist/js/modern/schema/Schema.js +39 -0
  40. package/dist/js/modern/schema/index.js +139 -0
  41. package/dist/js/modern/schema/legacy.js +284 -0
  42. package/dist/js/modern/types/config/deploy.js +0 -0
  43. package/dist/js/modern/types/config/dev.js +0 -0
  44. package/dist/js/modern/types/config/experiments.js +0 -0
  45. package/dist/js/modern/types/config/html.js +0 -0
  46. package/dist/js/modern/types/config/index.js +2 -0
  47. package/dist/js/modern/types/config/output.js +0 -0
  48. package/dist/js/modern/types/config/performance.js +0 -0
  49. package/dist/js/modern/types/config/security.js +0 -0
  50. package/dist/js/modern/types/config/source.js +0 -0
  51. package/dist/js/modern/types/config/tools.js +0 -0
  52. package/dist/js/modern/types/hooks.js +0 -0
  53. package/dist/js/modern/types/index.js +4 -0
  54. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  55. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  56. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  57. package/dist/js/modern/types/legacyConfig/output.js +1 -0
  58. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  59. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  60. package/dist/js/modern/utils/config.js +2 -13
  61. package/dist/js/modern/utils/createFileWatcher.js +82 -0
  62. package/dist/js/modern/utils/createServer.js +0 -5
  63. package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
  64. package/dist/js/modern/utils/printInstructions.js +2 -1
  65. package/dist/js/modern/utils/restart.js +17 -0
  66. package/dist/js/modern/utils/routes.js +0 -2
  67. package/dist/js/node/analyze/generateCode.js +30 -61
  68. package/dist/js/node/analyze/getBundleEntry.js +5 -19
  69. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
  70. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
  71. package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
  72. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
  73. package/dist/js/node/analyze/getFileSystemEntry.js +5 -26
  74. package/dist/js/node/analyze/getHtmlTemplate.js +3 -24
  75. package/dist/js/node/analyze/getServerRoutes.js +24 -46
  76. package/dist/js/node/analyze/index.js +91 -70
  77. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
  78. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
  79. package/dist/js/node/analyze/nestedRoutes.js +8 -41
  80. package/dist/js/node/analyze/templates.js +22 -47
  81. package/dist/js/node/analyze/utils.js +0 -20
  82. package/dist/js/node/builder/builderPlugins/compatModern.js +41 -69
  83. package/dist/js/node/builder/index.js +57 -51
  84. package/dist/js/node/builder/share.js +1 -13
  85. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
  86. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
  87. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
  88. package/dist/js/node/commands/build.js +10 -57
  89. package/dist/js/node/commands/deploy.js +0 -2
  90. package/dist/js/node/commands/dev.js +19 -34
  91. package/dist/js/node/commands/index.js +0 -6
  92. package/dist/js/node/commands/inspect.js +4 -26
  93. package/dist/js/node/commands/start.js +1 -11
  94. package/dist/js/node/config/default.js +214 -0
  95. package/dist/js/node/config/index.js +31 -0
  96. package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
  97. package/dist/js/node/{builder → config/initial}/createOutputConfig.js +19 -20
  98. package/dist/js/node/config/initial/createSourceConfig.js +38 -0
  99. package/dist/js/node/config/initial/createToolsConfig.js +47 -0
  100. package/dist/js/node/config/initial/index.js +24 -0
  101. package/dist/js/node/config/initial/inits.js +127 -0
  102. package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
  103. package/dist/js/node/defineConfig.js +20 -0
  104. package/dist/js/node/exports/server.js +0 -1
  105. package/dist/js/node/hooks.js +23 -30
  106. package/dist/js/node/index.js +35 -48
  107. package/dist/js/node/initialize/index.js +79 -0
  108. package/dist/js/node/locale/index.js +0 -4
  109. package/dist/js/node/schema/Schema.js +46 -0
  110. package/dist/js/node/schema/index.js +152 -0
  111. package/dist/js/node/schema/legacy.js +291 -0
  112. package/dist/js/node/types/config/deploy.js +0 -0
  113. package/dist/js/node/types/config/dev.js +0 -0
  114. package/dist/js/node/types/config/experiments.js +0 -0
  115. package/dist/js/node/types/config/html.js +0 -0
  116. package/dist/js/node/types/config/index.js +16 -0
  117. package/dist/js/node/types/config/output.js +0 -0
  118. package/dist/js/node/types/config/performance.js +0 -0
  119. package/dist/js/node/types/config/security.js +0 -0
  120. package/dist/js/node/types/config/source.js +0 -0
  121. package/dist/js/node/types/config/tools.js +0 -0
  122. package/dist/js/node/types/hooks.js +0 -0
  123. package/dist/js/node/types/index.js +38 -0
  124. package/dist/js/node/types/legacyConfig/deploy.js +0 -0
  125. package/dist/js/node/types/legacyConfig/dev.js +0 -0
  126. package/dist/js/node/types/legacyConfig/index.js +0 -0
  127. package/dist/js/node/types/legacyConfig/output.js +5 -0
  128. package/dist/js/node/types/legacyConfig/source.js +0 -0
  129. package/dist/js/node/types/legacyConfig/tools.js +0 -0
  130. package/dist/js/node/utils/commands.js +0 -2
  131. package/dist/js/node/utils/config.js +2 -26
  132. package/dist/js/node/utils/createFileWatcher.js +90 -0
  133. package/dist/js/node/utils/createServer.js +0 -15
  134. package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
  135. package/dist/js/node/utils/language.js +0 -2
  136. package/dist/js/node/utils/printInstructions.js +2 -5
  137. package/dist/js/node/utils/restart.js +23 -0
  138. package/dist/js/node/utils/routes.js +0 -5
  139. package/dist/js/treeshaking/analyze/generateCode.js +58 -101
  140. package/dist/js/treeshaking/analyze/getBundleEntry.js +12 -20
  141. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
  142. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
  143. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
  144. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +5 -18
  145. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +3 -27
  146. package/dist/js/treeshaking/analyze/getServerRoutes.js +29 -41
  147. package/dist/js/treeshaking/analyze/index.js +195 -91
  148. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
  149. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
  150. package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
  151. package/dist/js/treeshaking/analyze/templates.js +31 -50
  152. package/dist/js/treeshaking/analyze/utils.js +7 -14
  153. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +50 -68
  154. package/dist/js/treeshaking/builder/index.js +69 -65
  155. package/dist/js/treeshaking/builder/share.js +1 -5
  156. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
  157. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
  158. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
  159. package/dist/js/treeshaking/commands/build.js +41 -116
  160. package/dist/js/treeshaking/commands/deploy.js +0 -3
  161. package/dist/js/treeshaking/commands/dev.js +38 -46
  162. package/dist/js/treeshaking/commands/inspect.js +9 -27
  163. package/dist/js/treeshaking/commands/start.js +1 -9
  164. package/dist/js/treeshaking/config/default.js +200 -0
  165. package/dist/js/treeshaking/config/index.js +2 -0
  166. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
  167. package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
  168. package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
  169. package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
  170. package/dist/js/treeshaking/config/initial/index.js +11 -0
  171. package/dist/js/treeshaking/config/initial/inits.js +114 -0
  172. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
  173. package/dist/js/treeshaking/defineConfig.js +14 -0
  174. package/dist/js/treeshaking/hooks.js +23 -19
  175. package/dist/js/treeshaking/index.js +8 -43
  176. package/dist/js/treeshaking/initialize/index.js +121 -0
  177. package/dist/js/treeshaking/schema/Schema.js +75 -0
  178. package/dist/js/treeshaking/schema/index.js +138 -0
  179. package/dist/js/treeshaking/schema/legacy.js +273 -0
  180. package/dist/js/treeshaking/types/config/deploy.js +0 -0
  181. package/dist/js/treeshaking/types/config/dev.js +0 -0
  182. package/dist/js/treeshaking/types/config/experiments.js +0 -0
  183. package/dist/js/treeshaking/types/config/html.js +0 -0
  184. package/dist/js/treeshaking/types/config/index.js +2 -0
  185. package/dist/js/treeshaking/types/config/output.js +0 -0
  186. package/dist/js/treeshaking/types/config/performance.js +0 -0
  187. package/dist/js/treeshaking/types/config/security.js +0 -0
  188. package/dist/js/treeshaking/types/config/source.js +0 -0
  189. package/dist/js/treeshaking/types/config/tools.js +0 -0
  190. package/dist/js/treeshaking/types/hooks.js +0 -0
  191. package/dist/js/treeshaking/types/index.js +4 -0
  192. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
  193. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
  194. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
  195. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  196. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
  197. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
  198. package/dist/js/treeshaking/utils/config.js +2 -18
  199. package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
  200. package/dist/js/treeshaking/utils/createServer.js +0 -10
  201. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
  202. package/dist/js/treeshaking/utils/printInstructions.js +0 -5
  203. package/dist/js/treeshaking/utils/restart.js +45 -0
  204. package/dist/js/treeshaking/utils/routes.js +0 -4
  205. package/dist/types/analyze/generateCode.d.ts +3 -2
  206. package/dist/types/analyze/getBundleEntry.d.ts +2 -2
  207. package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
  208. package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
  209. package/dist/types/analyze/getServerRoutes.d.ts +3 -2
  210. package/dist/types/analyze/index.d.ts +3 -42
  211. package/dist/types/analyze/nestedRoutes.d.ts +1 -1
  212. package/dist/types/analyze/templates.d.ts +4 -2
  213. package/dist/types/analyze/utils.d.ts +1 -1
  214. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -3
  215. package/dist/types/builder/index.d.ts +7 -8
  216. package/dist/types/builder/share.d.ts +2 -2
  217. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
  218. package/dist/types/commands/build.d.ts +2 -2
  219. package/dist/types/commands/deploy.d.ts +2 -2
  220. package/dist/types/commands/dev.d.ts +2 -2
  221. package/dist/types/commands/inspect.d.ts +6 -1
  222. package/dist/types/commands/start.d.ts +2 -2
  223. package/dist/types/config/default.d.ts +3 -0
  224. package/dist/types/config/index.d.ts +2 -0
  225. package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
  226. package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
  227. package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
  228. package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
  229. package/dist/types/config/initial/index.d.ts +4 -0
  230. package/dist/types/config/initial/inits.d.ts +4 -0
  231. package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
  232. package/dist/types/defineConfig.d.ts +7 -0
  233. package/dist/types/hooks.d.ts +2 -42
  234. package/dist/types/index.d.ts +5 -7
  235. package/dist/types/initialize/index.d.ts +3 -0
  236. package/dist/types/schema/Schema.d.ts +14 -0
  237. package/dist/types/schema/index.d.ts +4 -0
  238. package/dist/types/schema/legacy.d.ts +3 -0
  239. package/dist/types/types/config/deploy.d.ts +9 -0
  240. package/dist/types/types/config/dev.d.ts +13 -0
  241. package/dist/types/types/config/experiments.d.ts +4 -0
  242. package/dist/types/types/config/html.d.ts +4 -0
  243. package/dist/types/types/config/index.d.ts +62 -0
  244. package/dist/types/types/config/output.d.ts +23 -0
  245. package/dist/types/types/config/performance.d.ts +4 -0
  246. package/dist/types/types/config/security.d.ts +4 -0
  247. package/dist/types/types/config/source.d.ts +22 -0
  248. package/dist/types/types/config/tools.d.ts +15 -0
  249. package/dist/types/types/hooks.d.ts +80 -0
  250. package/dist/types/types/index.d.ts +23 -0
  251. package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
  252. package/dist/types/types/legacyConfig/dev.d.ts +12 -0
  253. package/dist/types/types/legacyConfig/index.d.ts +33 -0
  254. package/dist/types/types/legacyConfig/output.d.ts +51 -0
  255. package/dist/types/types/legacyConfig/source.d.ts +25 -0
  256. package/dist/types/types/legacyConfig/tools.d.ts +16 -0
  257. package/dist/types/utils/config.d.ts +2 -3
  258. package/dist/types/utils/createFileWatcher.d.ts +3 -0
  259. package/dist/types/utils/printInstructions.d.ts +3 -3
  260. package/dist/types/utils/restart.d.ts +3 -0
  261. package/package.json +26 -25
  262. package/dist/js/modern/builder/createHtmlConfig.js +0 -58
  263. package/dist/js/modern/builder/createSourceConfig.js +0 -85
  264. package/dist/js/modern/builder/createToolsConfig.js +0 -94
  265. package/dist/js/modern/utils/createCompiler.js +0 -58
  266. package/dist/js/node/builder/createHtmlConfig.js +0 -76
  267. package/dist/js/node/builder/createSourceConfig.js +0 -99
  268. package/dist/js/node/builder/createToolsConfig.js +0 -103
  269. package/dist/js/node/utils/createCompiler.js +0 -75
  270. package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
  271. package/dist/js/treeshaking/builder/createOutputConfig.js +0 -67
  272. package/dist/js/treeshaking/builder/createSourceConfig.js +0 -100
  273. package/dist/js/treeshaking/builder/createToolsConfig.js +0 -90
  274. package/dist/js/treeshaking/utils/createCompiler.js +0 -117
  275. package/dist/types/builder/createHtmlConfig.d.ts +0 -6
  276. package/dist/types/builder/createOutputConfig.d.ts +0 -3
  277. package/dist/types/builder/createSourceConfig.d.ts +0 -5
  278. package/dist/types/builder/createToolsConfig.d.ts +0 -13
  279. package/dist/types/utils/createCompiler.d.ts +0 -12
@@ -0,0 +1,284 @@
1
+ import { ENTRY_NAME_PATTERN } from '@modern-js/utils/constants';
2
+ import { Schema } from "./Schema";
3
+ const source = {
4
+ entries: {
5
+ type: 'object',
6
+ patternProperties: {
7
+ [ENTRY_NAME_PATTERN]: {
8
+ if: {
9
+ type: 'object'
10
+ },
11
+ then: {
12
+ required: ['entry'],
13
+ properties: {
14
+ entry: {
15
+ type: ['string', 'array']
16
+ },
17
+ disableMount: {
18
+ type: 'boolean'
19
+ },
20
+ enableFileSystemRoutes: {
21
+ type: 'boolean'
22
+ }
23
+ },
24
+ additionalProperties: false
25
+ },
26
+ else: {
27
+ type: ['string', 'array']
28
+ }
29
+ }
30
+ }
31
+ },
32
+ preEntry: {
33
+ type: ['string', 'array']
34
+ },
35
+ alias: {
36
+ typeof: ['object', 'function']
37
+ },
38
+ enableAsyncEntry: {
39
+ type: 'boolean'
40
+ },
41
+ disableDefaultEntries: {
42
+ type: 'boolean'
43
+ },
44
+ envVars: {
45
+ type: 'array'
46
+ },
47
+ globalVars: {
48
+ type: 'object'
49
+ },
50
+ moduleScopes: {
51
+ instanceof: ['Array', 'Function']
52
+ },
53
+ entriesDir: {
54
+ type: 'string'
55
+ },
56
+ configDir: {
57
+ type: 'string'
58
+ },
59
+ include: {
60
+ type: ['array']
61
+ }
62
+ };
63
+ const output = {
64
+ assetPrefix: {
65
+ type: 'string'
66
+ },
67
+ path: {
68
+ type: 'string'
69
+ },
70
+ jsPath: {
71
+ type: 'string'
72
+ },
73
+ cssPath: {
74
+ type: 'string'
75
+ },
76
+ htmlPath: {
77
+ type: 'string'
78
+ },
79
+ mediaPath: {
80
+ type: 'string'
81
+ },
82
+ mountId: {
83
+ type: 'string'
84
+ },
85
+ favicon: {
86
+ type: 'string'
87
+ },
88
+ faviconByEntries: {
89
+ type: 'object',
90
+ patternProperties: {
91
+ [ENTRY_NAME_PATTERN]: {
92
+ type: 'string'
93
+ }
94
+ }
95
+ },
96
+ title: {
97
+ type: 'string'
98
+ },
99
+ titleByEntries: {
100
+ type: 'object',
101
+ patternProperties: {
102
+ [ENTRY_NAME_PATTERN]: {
103
+ type: 'string'
104
+ }
105
+ }
106
+ },
107
+ meta: {
108
+ type: 'object'
109
+ },
110
+ metaByEntries: {
111
+ type: 'object',
112
+ patternProperties: {
113
+ [ENTRY_NAME_PATTERN]: {
114
+ type: 'object'
115
+ }
116
+ }
117
+ },
118
+ inject: {
119
+ enum: [true, 'head', 'body', false]
120
+ },
121
+ injectByEntries: {
122
+ type: 'object',
123
+ patternProperties: {
124
+ [ENTRY_NAME_PATTERN]: {
125
+ enum: [true, 'head', 'body', false]
126
+ }
127
+ }
128
+ },
129
+ copy: {
130
+ type: 'array'
131
+ },
132
+ scriptExt: {
133
+ type: 'object'
134
+ },
135
+ disableTsChecker: {
136
+ type: 'boolean'
137
+ },
138
+ disableHtmlFolder: {
139
+ type: 'boolean'
140
+ },
141
+ disableCssModuleExtension: {
142
+ type: 'boolean'
143
+ },
144
+ disableCssExtract: {
145
+ type: 'boolean'
146
+ },
147
+ enableCssModuleTSDeclaration: {
148
+ type: 'boolean'
149
+ },
150
+ disableMinimize: {
151
+ type: 'boolean'
152
+ },
153
+ enableInlineStyles: {
154
+ type: 'boolean'
155
+ },
156
+ enableInlineScripts: {
157
+ type: 'boolean'
158
+ },
159
+ disableSourceMap: {
160
+ type: 'boolean'
161
+ },
162
+ disableInlineRuntimeChunk: {
163
+ type: 'boolean'
164
+ },
165
+ disableAssetsCache: {
166
+ type: 'boolean'
167
+ },
168
+ enableLatestDecorators: {
169
+ type: 'boolean'
170
+ },
171
+ enableTsLoader: {
172
+ type: 'boolean'
173
+ },
174
+ dataUriLimit: {
175
+ type: 'number'
176
+ },
177
+ templateParameters: {
178
+ type: 'object'
179
+ },
180
+ templateParametersByEntries: {
181
+ type: 'object',
182
+ patternProperties: {
183
+ [ENTRY_NAME_PATTERN]: {
184
+ type: 'object'
185
+ }
186
+ }
187
+ },
188
+ polyfill: {
189
+ type: 'string',
190
+ enum: ['usage', 'entry', 'off', 'ua']
191
+ },
192
+ cssModuleLocalIdentName: {
193
+ type: 'string'
194
+ },
195
+ federation: {
196
+ type: 'object'
197
+ },
198
+ disableNodePolyfill: {
199
+ type: 'boolean'
200
+ },
201
+ enableModernMode: {
202
+ type: 'boolean'
203
+ }
204
+ };
205
+ const server = {
206
+ routes: {
207
+ type: 'object'
208
+ },
209
+ publicRoutes: {
210
+ type: 'object'
211
+ },
212
+ ssr: {
213
+ type: ['boolean', 'object']
214
+ },
215
+ ssrByEntries: {
216
+ type: 'object'
217
+ },
218
+ baseUrl: {
219
+ anyOf: [{
220
+ type: 'string'
221
+ }, {
222
+ type: 'array',
223
+ items: {
224
+ type: 'string'
225
+ }
226
+ }]
227
+ },
228
+ port: {
229
+ type: 'number'
230
+ },
231
+ logger: {
232
+ type: ['boolean', 'object']
233
+ },
234
+ metrics: {
235
+ type: ['boolean', 'object']
236
+ },
237
+ enableMicroFrontendDebug: {
238
+ type: 'boolean'
239
+ },
240
+ watchOptions: {
241
+ type: 'object'
242
+ },
243
+ compiler: {
244
+ type: 'string'
245
+ },
246
+ disableFrameworkExt: {
247
+ type: 'boolean'
248
+ }
249
+ };
250
+ const dev = {
251
+ proxy: {
252
+ type: ['boolean', 'object']
253
+ }
254
+ };
255
+ const deploy = {
256
+ microFrontend: {
257
+ type: ['boolean', 'object']
258
+ }
259
+ };
260
+ const tools = {
261
+ tailwindcss: {
262
+ type: 'object'
263
+ },
264
+ jest: {
265
+ typeof: ['object', 'function']
266
+ },
267
+ esbuild: {
268
+ typeof: ['object']
269
+ }
270
+ };
271
+ const bff = {
272
+ prefix: {
273
+ type: 'string'
274
+ },
275
+ proxy: {
276
+ type: 'object',
277
+ additionalProperties: {
278
+ type: 'string'
279
+ }
280
+ }
281
+ };
282
+ const schema = new Schema();
283
+ schema.setSchema('bff', bff).setSchema('dev', dev).setSchema('server', server).setSchema('source', source).setSchema('output', output).setSchema('tools', tools).setSchema('deploy', deploy);
284
+ export default schema;
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ export * from "./output";
2
+ export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ export * from "./hooks";
2
+ export * from "./config";
3
+ export * from "./legacyConfig";
4
+ export {};
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export {};
File without changes
File without changes
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  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
-
7
4
  import * as path from 'path';
8
5
  import { bundle } from '@modern-js/node-bundle-require';
9
6
  import { CONFIG_FILE_EXTENSIONS, fs, getServerConfig, OUTPUT_CONFIG_FILE } from '@modern-js/utils';
@@ -15,9 +12,7 @@ export const buildServerConfig = async ({
15
12
  options
16
13
  }) => {
17
14
  const configFilePath = await getServerConfig(appDirectory, configFile);
18
-
19
15
  const getOutputFile = async filepath => path.resolve(distDirectory, `${filepath.replace(new RegExp(CONFIG_FILE_EXTENSIONS.join('|')), '')}.js`);
20
-
21
16
  if (configFilePath) {
22
17
  const configHelperFilePath = path.normalize(path.join(distDirectory, './config-helper.js'));
23
18
  const helperCode = `
@@ -29,7 +24,6 @@ export const buildServerConfig = async ({
29
24
  getOutputFile,
30
25
  esbuildPlugins: [{
31
26
  name: 'native-build-config',
32
-
33
27
  setup(ctx) {
34
28
  ctx.onResolve({
35
29
  filter: /app-tools\/server/
@@ -39,38 +33,33 @@ export const buildServerConfig = async ({
39
33
  };
40
34
  });
41
35
  }
42
-
43
36
  }]
44
37
  }));
45
38
  }
46
39
  };
40
+
47
41
  /**
48
42
  *
49
43
  * 处理循环引用的 replacer
50
44
  */
51
-
52
45
  export const safeReplacer = () => {
53
46
  const cache = [];
54
47
  const keyCache = [];
55
48
  return function (key, value) {
56
49
  if (typeof value === 'object' && value !== null) {
57
50
  const index = cache.indexOf(value);
58
-
59
51
  if (index !== -1) {
60
52
  return `[Circular ${keyCache[index]}]`;
61
53
  }
62
-
63
54
  cache.push(value);
64
55
  keyCache.push(key || 'root');
65
56
  }
66
-
67
57
  return value;
68
58
  };
69
59
  };
70
60
  export const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
71
61
  var _resolvedConfig$outpu;
72
-
73
- const outputPath = path.join(appDirectory, (resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig$outpu = resolvedConfig.output) === null || _resolvedConfig$outpu === void 0 ? void 0 : _resolvedConfig$outpu.path) || './dist', OUTPUT_CONFIG_FILE);
62
+ const outputPath = path.join(appDirectory, ((_resolvedConfig$outpu = resolvedConfig.output.distPath) === null || _resolvedConfig$outpu === void 0 ? void 0 : _resolvedConfig$outpu.root) || './dist', OUTPUT_CONFIG_FILE);
74
63
  await fs.writeJSON(outputPath, resolvedConfig, {
75
64
  spaces: 2,
76
65
  replacer: safeReplacer()
@@ -0,0 +1,82 @@
1
+ import crypto from 'crypto';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { isDev, chokidar, createDebugger, isTest, getServerConfig } from '@modern-js/utils';
5
+ /**
6
+ * Get user config from package.json.
7
+ * @param appDirectory - App root directory.
8
+ * @returns modernConfig or undefined
9
+ */
10
+ // FIXME: read package.json again;
11
+ const getPackageConfig = (appDirectory, packageJsonConfig) => {
12
+ const PACKAGE_JSON_CONFIG_NAME = 'modernConfig';
13
+ const json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'));
14
+ return json[packageJsonConfig !== null && packageJsonConfig !== void 0 ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
15
+ };
16
+ const addServerConfigToDeps = async (dependencies, appDirectory, serverConfigFile) => {
17
+ const serverConfig = await getServerConfig(appDirectory, serverConfigFile);
18
+ if (serverConfig) {
19
+ dependencies.push(serverConfig);
20
+ }
21
+ };
22
+ const debug = createDebugger('watch-files');
23
+ const md5 = data => crypto.createHash('md5').update(data).digest('hex');
24
+ const hashMap = new Map();
25
+ export const createFileWatcher = async (appContext, configDir, hooksRunner) => {
26
+ // only add fs watcher on dev mode.
27
+ if (isDev() || isTest()) {
28
+ const {
29
+ appDirectory,
30
+ configFile
31
+ } = appContext;
32
+ const extraFiles = await hooksRunner.watchFiles();
33
+ const configPath = path.join(appDirectory, configDir);
34
+ const dependencies = getPackageConfig(appContext.appDirectory, appContext.packageName) ? [path.resolve(appDirectory, './package.json')] : [];
35
+
36
+ // 将 server.config 加入到 loaded.dependencies,以便对文件监听做热更新
37
+ await addServerConfigToDeps(dependencies, appContext.appDirectory, appContext.serverConfigFile);
38
+ const watched = [`${configPath}/html`, ...extraFiles, ...dependencies, configFile].filter(Boolean);
39
+ debug(`watched: %o`, watched);
40
+ const watcher = chokidar.watch(watched, {
41
+ cwd: appDirectory,
42
+ ignoreInitial: true,
43
+ ignorePermissionErrors: true,
44
+ ignored: [/node_modules/, '**/__test__/**', '**/*.test.(js|jsx|ts|tsx)', '**/*.spec.(js|jsx|ts|tsx)', '**/*.stories.(js|jsx|ts|tsx)']
45
+ });
46
+ watcher.on('change', changed => {
47
+ const lastHash = hashMap.get(changed);
48
+ const currentHash = md5(fs.readFileSync(path.join(appDirectory, changed), 'utf8'));
49
+ if (currentHash !== lastHash) {
50
+ debug(`file change: %s`, changed);
51
+ hashMap.set(changed, currentHash);
52
+ hooksRunner.fileChange({
53
+ filename: changed,
54
+ eventType: 'change'
55
+ });
56
+ }
57
+ });
58
+ watcher.on('add', name => {
59
+ debug(`add file: %s`, name);
60
+ const currentHash = md5(fs.readFileSync(path.join(appDirectory, name), 'utf8'));
61
+ hashMap.set(name, currentHash);
62
+ hooksRunner.fileChange({
63
+ filename: name,
64
+ eventType: 'add'
65
+ });
66
+ });
67
+ watcher.on('unlink', name => {
68
+ debug(`remove file: %s`, name);
69
+ if (hashMap.has(name)) {
70
+ hashMap.delete(name);
71
+ }
72
+ hooksRunner.fileChange({
73
+ filename: name,
74
+ eventType: 'unlink'
75
+ });
76
+ });
77
+ watcher.on('error', err => {
78
+ throw err;
79
+ });
80
+ return watcher;
81
+ }
82
+ };
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  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
-
7
4
  import { Server } from '@modern-js/server';
8
5
  let server = null;
9
6
  export const getServer = () => server;
@@ -17,14 +14,12 @@ export const createServer = async options => {
17
14
  if (server) {
18
15
  await server.close();
19
16
  }
20
-
21
17
  server = new Server(options);
22
18
  const app = await server.init();
23
19
  return app;
24
20
  };
25
21
  export const injectDataLoaderPlugin = internalPlugins => {
26
22
  const DataLoaderPlugin = require.resolve('@modern-js/plugin-data-loader/server');
27
-
28
23
  return _objectSpread(_objectSpread({}, internalPlugins), {}, {
29
24
  '@modern-js/plugin-data-loader': {
30
25
  path: DataLoaderPlugin,
@@ -1,11 +1,9 @@
1
1
  import { inquirer } from '@modern-js/utils';
2
2
  export const getSpecifiedEntries = async (entry, entrypoints) => {
3
3
  const entryNames = entrypoints.map(e => e.entryName);
4
-
5
4
  if (!entry) {
6
5
  return entryNames;
7
6
  }
8
-
9
7
  if (typeof entry === 'boolean') {
10
8
  const {
11
9
  selected
@@ -14,19 +12,15 @@ export const getSpecifiedEntries = async (entry, entrypoints) => {
14
12
  name: 'selected',
15
13
  choices: entryNames,
16
14
  message: '请选择需要构建的入口',
17
-
18
15
  validate(answer) {
19
16
  if (answer.length < 1) {
20
17
  return 'You must choose at least one topping.';
21
18
  }
22
-
23
19
  return true;
24
20
  }
25
-
26
21
  }]);
27
22
  return selected;
28
23
  }
29
-
30
24
  entry.forEach(name => {
31
25
  if (!entryNames.includes(name)) {
32
26
  throw new Error(`can not found entry ${name}, compiler entry should in ${entryNames.join(', ')}`);
@@ -1,7 +1,8 @@
1
1
  import { prettyInstructions, logger } from '@modern-js/utils';
2
2
  export const printInstructions = async (hookRunners, appContext, config) => {
3
- const message = prettyInstructions(appContext, config); // call beforePrintInstructions hook.
3
+ const message = prettyInstructions(appContext, config);
4
4
 
5
+ // call beforePrintInstructions hook.
5
6
  const {
6
7
  instructions
7
8
  } = await hookRunners.beforePrintInstructions({
@@ -0,0 +1,17 @@
1
+ import { cli } from '@modern-js/core';
2
+ import { logger, program } from '@modern-js/utils';
3
+ export async function restart(hooksRunner) {
4
+ logger.info('Restart...\n');
5
+ let hasGetError = false;
6
+ await hooksRunner.beforeRestart();
7
+ try {
8
+ await cli.init(cli.initOptions);
9
+ } catch (err) {
10
+ console.error(err);
11
+ hasGetError = true;
12
+ } finally {
13
+ if (!hasGetError) {
14
+ program.parse(process.argv);
15
+ }
16
+ }
17
+ }
@@ -1,6 +1,5 @@
1
1
  import path from 'path';
2
2
  import { fs, ROUTE_SPEC_FILE } from '@modern-js/utils';
3
-
4
3
  const generateRoutes = async appContext => {
5
4
  const {
6
5
  serverRoutes,
@@ -11,5 +10,4 @@ const generateRoutes = async appContext => {
11
10
  }, null, 2);
12
11
  await fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
13
12
  };
14
-
15
13
  export { generateRoutes };