@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,273 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { ENTRY_NAME_PATTERN } from '@modern-js/utils/constants';
3
+ import { Schema } from "./Schema";
4
+ var source = {
5
+ entries: {
6
+ type: 'object',
7
+ patternProperties: _defineProperty({}, 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
+ preEntry: {
32
+ type: ['string', 'array']
33
+ },
34
+ alias: {
35
+ "typeof": ['object', 'function']
36
+ },
37
+ enableAsyncEntry: {
38
+ type: 'boolean'
39
+ },
40
+ disableDefaultEntries: {
41
+ type: 'boolean'
42
+ },
43
+ envVars: {
44
+ type: 'array'
45
+ },
46
+ globalVars: {
47
+ type: 'object'
48
+ },
49
+ moduleScopes: {
50
+ "instanceof": ['Array', 'Function']
51
+ },
52
+ entriesDir: {
53
+ type: 'string'
54
+ },
55
+ configDir: {
56
+ type: 'string'
57
+ },
58
+ include: {
59
+ type: ['array']
60
+ }
61
+ };
62
+ var output = {
63
+ assetPrefix: {
64
+ type: 'string'
65
+ },
66
+ path: {
67
+ type: 'string'
68
+ },
69
+ jsPath: {
70
+ type: 'string'
71
+ },
72
+ cssPath: {
73
+ type: 'string'
74
+ },
75
+ htmlPath: {
76
+ type: 'string'
77
+ },
78
+ mediaPath: {
79
+ type: 'string'
80
+ },
81
+ mountId: {
82
+ type: 'string'
83
+ },
84
+ favicon: {
85
+ type: 'string'
86
+ },
87
+ faviconByEntries: {
88
+ type: 'object',
89
+ patternProperties: _defineProperty({}, ENTRY_NAME_PATTERN, {
90
+ type: 'string'
91
+ })
92
+ },
93
+ title: {
94
+ type: 'string'
95
+ },
96
+ titleByEntries: {
97
+ type: 'object',
98
+ patternProperties: _defineProperty({}, ENTRY_NAME_PATTERN, {
99
+ type: 'string'
100
+ })
101
+ },
102
+ meta: {
103
+ type: 'object'
104
+ },
105
+ metaByEntries: {
106
+ type: 'object',
107
+ patternProperties: _defineProperty({}, ENTRY_NAME_PATTERN, {
108
+ type: 'object'
109
+ })
110
+ },
111
+ inject: {
112
+ "enum": [true, 'head', 'body', false]
113
+ },
114
+ injectByEntries: {
115
+ type: 'object',
116
+ patternProperties: _defineProperty({}, ENTRY_NAME_PATTERN, {
117
+ "enum": [true, 'head', 'body', false]
118
+ })
119
+ },
120
+ copy: {
121
+ type: 'array'
122
+ },
123
+ scriptExt: {
124
+ type: 'object'
125
+ },
126
+ disableTsChecker: {
127
+ type: 'boolean'
128
+ },
129
+ disableHtmlFolder: {
130
+ type: 'boolean'
131
+ },
132
+ disableCssModuleExtension: {
133
+ type: 'boolean'
134
+ },
135
+ disableCssExtract: {
136
+ type: 'boolean'
137
+ },
138
+ enableCssModuleTSDeclaration: {
139
+ type: 'boolean'
140
+ },
141
+ disableMinimize: {
142
+ type: 'boolean'
143
+ },
144
+ enableInlineStyles: {
145
+ type: 'boolean'
146
+ },
147
+ enableInlineScripts: {
148
+ type: 'boolean'
149
+ },
150
+ disableSourceMap: {
151
+ type: 'boolean'
152
+ },
153
+ disableInlineRuntimeChunk: {
154
+ type: 'boolean'
155
+ },
156
+ disableAssetsCache: {
157
+ type: 'boolean'
158
+ },
159
+ enableLatestDecorators: {
160
+ type: 'boolean'
161
+ },
162
+ enableTsLoader: {
163
+ type: 'boolean'
164
+ },
165
+ dataUriLimit: {
166
+ type: 'number'
167
+ },
168
+ templateParameters: {
169
+ type: 'object'
170
+ },
171
+ templateParametersByEntries: {
172
+ type: 'object',
173
+ patternProperties: _defineProperty({}, ENTRY_NAME_PATTERN, {
174
+ type: 'object'
175
+ })
176
+ },
177
+ polyfill: {
178
+ type: 'string',
179
+ "enum": ['usage', 'entry', 'off', 'ua']
180
+ },
181
+ cssModuleLocalIdentName: {
182
+ type: 'string'
183
+ },
184
+ federation: {
185
+ type: 'object'
186
+ },
187
+ disableNodePolyfill: {
188
+ type: 'boolean'
189
+ },
190
+ enableModernMode: {
191
+ type: 'boolean'
192
+ }
193
+ };
194
+ var server = {
195
+ routes: {
196
+ type: 'object'
197
+ },
198
+ publicRoutes: {
199
+ type: 'object'
200
+ },
201
+ ssr: {
202
+ type: ['boolean', 'object']
203
+ },
204
+ ssrByEntries: {
205
+ type: 'object'
206
+ },
207
+ baseUrl: {
208
+ anyOf: [{
209
+ type: 'string'
210
+ }, {
211
+ type: 'array',
212
+ items: {
213
+ type: 'string'
214
+ }
215
+ }]
216
+ },
217
+ port: {
218
+ type: 'number'
219
+ },
220
+ logger: {
221
+ type: ['boolean', 'object']
222
+ },
223
+ metrics: {
224
+ type: ['boolean', 'object']
225
+ },
226
+ enableMicroFrontendDebug: {
227
+ type: 'boolean'
228
+ },
229
+ watchOptions: {
230
+ type: 'object'
231
+ },
232
+ compiler: {
233
+ type: 'string'
234
+ },
235
+ disableFrameworkExt: {
236
+ type: 'boolean'
237
+ }
238
+ };
239
+ var dev = {
240
+ proxy: {
241
+ type: ['boolean', 'object']
242
+ }
243
+ };
244
+ var deploy = {
245
+ microFrontend: {
246
+ type: ['boolean', 'object']
247
+ }
248
+ };
249
+ var tools = {
250
+ tailwindcss: {
251
+ type: 'object'
252
+ },
253
+ jest: {
254
+ "typeof": ['object', 'function']
255
+ },
256
+ esbuild: {
257
+ "typeof": ['object']
258
+ }
259
+ };
260
+ var bff = {
261
+ prefix: {
262
+ type: 'string'
263
+ },
264
+ proxy: {
265
+ type: 'object',
266
+ additionalProperties: {
267
+ type: 'string'
268
+ }
269
+ }
270
+ };
271
+ var schema = new Schema();
272
+ schema.setSchema('bff', bff).setSchema('dev', dev).setSchema('server', server).setSchema('source', source).setSchema('output', output).setSchema('tools', tools).setSchema('deploy', deploy);
273
+ export default schema;
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
@@ -0,0 +1,4 @@
1
+ export * from "./hooks";
2
+ export * from "./config";
3
+ export * from "./legacyConfig";
4
+ export {};
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -18,10 +18,8 @@ export var buildServerConfig = /*#__PURE__*/function () {
18
18
  appDirectory = _ref.appDirectory, distDirectory = _ref.distDirectory, configFile = _ref.configFile, options = _ref.options;
19
19
  _context2.next = 3;
20
20
  return getServerConfig(appDirectory, configFile);
21
-
22
21
  case 3:
23
22
  configFilePath = _context2.sent;
24
-
25
23
  getOutputFile = /*#__PURE__*/function () {
26
24
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filepath) {
27
25
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -29,7 +27,6 @@ export var buildServerConfig = /*#__PURE__*/function () {
29
27
  switch (_context.prev = _context.next) {
30
28
  case 0:
31
29
  return _context.abrupt("return", path.resolve(distDirectory, "".concat(filepath.replace(new RegExp(CONFIG_FILE_EXTENSIONS.join('|')), ''), ".js")));
32
-
33
30
  case 1:
34
31
  case "end":
35
32
  return _context.stop();
@@ -37,26 +34,21 @@ export var buildServerConfig = /*#__PURE__*/function () {
37
34
  }
38
35
  }, _callee);
39
36
  }));
40
-
41
37
  return function getOutputFile(_x2) {
42
38
  return _ref3.apply(this, arguments);
43
39
  };
44
40
  }();
45
-
46
41
  if (!configFilePath) {
47
42
  _context2.next = 14;
48
43
  break;
49
44
  }
50
-
51
45
  configHelperFilePath = path.normalize(path.join(distDirectory, './config-helper.js'));
52
46
  helperCode = "\n export const defineConfig = (config) => config;\n ";
53
47
  _context2.next = 10;
54
48
  return fs.ensureDir(distDirectory);
55
-
56
49
  case 10:
57
50
  _context2.next = 12;
58
51
  return fs.writeFile(configHelperFilePath, helperCode);
59
-
60
52
  case 12:
61
53
  _context2.next = 14;
62
54
  return bundle(configFilePath, _objectSpread(_objectSpread({}, options), {}, {
@@ -74,7 +66,6 @@ export var buildServerConfig = /*#__PURE__*/function () {
74
66
  }
75
67
  }]
76
68
  }));
77
-
78
69
  case 14:
79
70
  case "end":
80
71
  return _context2.stop();
@@ -82,50 +73,44 @@ export var buildServerConfig = /*#__PURE__*/function () {
82
73
  }
83
74
  }, _callee2);
84
75
  }));
85
-
86
76
  return function buildServerConfig(_x) {
87
77
  return _ref2.apply(this, arguments);
88
78
  };
89
79
  }();
80
+
90
81
  /**
91
82
  *
92
83
  * 处理循环引用的 replacer
93
84
  */
94
-
95
85
  export var safeReplacer = function safeReplacer() {
96
86
  var cache = [];
97
87
  var keyCache = [];
98
88
  return function (key, value) {
99
89
  if (_typeof(value) === 'object' && value !== null) {
100
90
  var index = cache.indexOf(value);
101
-
102
91
  if (index !== -1) {
103
92
  return "[Circular ".concat(keyCache[index], "]");
104
93
  }
105
-
106
94
  cache.push(value);
107
95
  keyCache.push(key || 'root');
108
96
  }
109
-
110
97
  return value;
111
98
  };
112
99
  };
113
100
  export var emitResolvedConfig = /*#__PURE__*/function () {
114
101
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(appDirectory, resolvedConfig) {
115
102
  var _resolvedConfig$outpu;
116
-
117
103
  var outputPath;
118
104
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
119
105
  while (1) {
120
106
  switch (_context3.prev = _context3.next) {
121
107
  case 0:
122
- 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);
108
+ outputPath = path.join(appDirectory, ((_resolvedConfig$outpu = resolvedConfig.output.distPath) === null || _resolvedConfig$outpu === void 0 ? void 0 : _resolvedConfig$outpu.root) || './dist', OUTPUT_CONFIG_FILE);
123
109
  _context3.next = 3;
124
110
  return fs.writeJSON(outputPath, resolvedConfig, {
125
111
  spaces: 2,
126
112
  replacer: safeReplacer()
127
113
  });
128
-
129
114
  case 3:
130
115
  case "end":
131
116
  return _context3.stop();
@@ -133,7 +118,6 @@ export var emitResolvedConfig = /*#__PURE__*/function () {
133
118
  }
134
119
  }, _callee3);
135
120
  }));
136
-
137
121
  return function emitResolvedConfig(_x3, _x4) {
138
122
  return _ref4.apply(this, arguments);
139
123
  };
@@ -0,0 +1,123 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import crypto from 'crypto';
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { isDev, chokidar, createDebugger, isTest, getServerConfig } from '@modern-js/utils';
8
+ /**
9
+ * Get user config from package.json.
10
+ * @param appDirectory - App root directory.
11
+ * @returns modernConfig or undefined
12
+ */
13
+ // FIXME: read package.json again;
14
+ var getPackageConfig = function getPackageConfig(appDirectory, packageJsonConfig) {
15
+ var PACKAGE_JSON_CONFIG_NAME = 'modernConfig';
16
+ var json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'));
17
+ return json[packageJsonConfig !== null && packageJsonConfig !== void 0 ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
18
+ };
19
+ var addServerConfigToDeps = /*#__PURE__*/function () {
20
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dependencies, appDirectory, serverConfigFile) {
21
+ var serverConfig;
22
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
23
+ while (1) {
24
+ switch (_context.prev = _context.next) {
25
+ case 0:
26
+ _context.next = 2;
27
+ return getServerConfig(appDirectory, serverConfigFile);
28
+ case 2:
29
+ serverConfig = _context.sent;
30
+ if (serverConfig) {
31
+ dependencies.push(serverConfig);
32
+ }
33
+ case 4:
34
+ case "end":
35
+ return _context.stop();
36
+ }
37
+ }
38
+ }, _callee);
39
+ }));
40
+ return function addServerConfigToDeps(_x, _x2, _x3) {
41
+ return _ref.apply(this, arguments);
42
+ };
43
+ }();
44
+ var debug = createDebugger('watch-files');
45
+ var md5 = function md5(data) {
46
+ return crypto.createHash('md5').update(data).digest('hex');
47
+ };
48
+ var hashMap = new Map();
49
+ export var createFileWatcher = /*#__PURE__*/function () {
50
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(appContext, configDir, hooksRunner) {
51
+ var appDirectory, configFile, extraFiles, configPath, dependencies, watched, watcher;
52
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
53
+ while (1) {
54
+ switch (_context2.prev = _context2.next) {
55
+ case 0:
56
+ if (!(isDev() || isTest())) {
57
+ _context2.next = 17;
58
+ break;
59
+ }
60
+ appDirectory = appContext.appDirectory, configFile = appContext.configFile;
61
+ _context2.next = 4;
62
+ return hooksRunner.watchFiles();
63
+ case 4:
64
+ extraFiles = _context2.sent;
65
+ configPath = path.join(appDirectory, configDir);
66
+ dependencies = getPackageConfig(appContext.appDirectory, appContext.packageName) ? [path.resolve(appDirectory, './package.json')] : []; // 将 server.config 加入到 loaded.dependencies,以便对文件监听做热更新
67
+ _context2.next = 9;
68
+ return addServerConfigToDeps(dependencies, appContext.appDirectory, appContext.serverConfigFile);
69
+ case 9:
70
+ watched = ["".concat(configPath, "/html")].concat(_toConsumableArray(extraFiles), dependencies, [configFile]).filter(Boolean);
71
+ debug("watched: %o", watched);
72
+ watcher = chokidar.watch(watched, {
73
+ cwd: appDirectory,
74
+ ignoreInitial: true,
75
+ ignorePermissionErrors: true,
76
+ ignored: [/node_modules/, '**/__test__/**', '**/*.test.(js|jsx|ts|tsx)', '**/*.spec.(js|jsx|ts|tsx)', '**/*.stories.(js|jsx|ts|tsx)']
77
+ });
78
+ watcher.on('change', function (changed) {
79
+ var lastHash = hashMap.get(changed);
80
+ var currentHash = md5(fs.readFileSync(path.join(appDirectory, changed), 'utf8'));
81
+ if (currentHash !== lastHash) {
82
+ debug("file change: %s", changed);
83
+ hashMap.set(changed, currentHash);
84
+ hooksRunner.fileChange({
85
+ filename: changed,
86
+ eventType: 'change'
87
+ });
88
+ }
89
+ });
90
+ watcher.on('add', function (name) {
91
+ debug("add file: %s", name);
92
+ var currentHash = md5(fs.readFileSync(path.join(appDirectory, name), 'utf8'));
93
+ hashMap.set(name, currentHash);
94
+ hooksRunner.fileChange({
95
+ filename: name,
96
+ eventType: 'add'
97
+ });
98
+ });
99
+ watcher.on('unlink', function (name) {
100
+ debug("remove file: %s", name);
101
+ if (hashMap.has(name)) {
102
+ hashMap["delete"](name);
103
+ }
104
+ hooksRunner.fileChange({
105
+ filename: name,
106
+ eventType: 'unlink'
107
+ });
108
+ });
109
+ watcher.on('error', function (err) {
110
+ throw err;
111
+ });
112
+ return _context2.abrupt("return", watcher);
113
+ case 17:
114
+ case "end":
115
+ return _context2.stop();
116
+ }
117
+ }
118
+ }, _callee2);
119
+ }));
120
+ return function createFileWatcher(_x4, _x5, _x6) {
121
+ return _ref2.apply(this, arguments);
122
+ };
123
+ }();
@@ -16,13 +16,10 @@ export var closeServer = /*#__PURE__*/function () {
16
16
  _context.next = 4;
17
17
  break;
18
18
  }
19
-
20
19
  _context.next = 3;
21
20
  return server.close();
22
-
23
21
  case 3:
24
22
  server = null;
25
-
26
23
  case 4:
27
24
  case "end":
28
25
  return _context.stop();
@@ -30,7 +27,6 @@ export var closeServer = /*#__PURE__*/function () {
30
27
  }
31
28
  }, _callee);
32
29
  }));
33
-
34
30
  return function closeServer() {
35
31
  return _ref.apply(this, arguments);
36
32
  };
@@ -46,19 +42,15 @@ export var createServer = /*#__PURE__*/function () {
46
42
  _context2.next = 3;
47
43
  break;
48
44
  }
49
-
50
45
  _context2.next = 3;
51
46
  return server.close();
52
-
53
47
  case 3:
54
48
  server = new Server(options);
55
49
  _context2.next = 6;
56
50
  return server.init();
57
-
58
51
  case 6:
59
52
  app = _context2.sent;
60
53
  return _context2.abrupt("return", app);
61
-
62
54
  case 8:
63
55
  case "end":
64
56
  return _context2.stop();
@@ -66,14 +58,12 @@ export var createServer = /*#__PURE__*/function () {
66
58
  }
67
59
  }, _callee2);
68
60
  }));
69
-
70
61
  return function createServer(_x) {
71
62
  return _ref2.apply(this, arguments);
72
63
  };
73
64
  }();
74
65
  export var injectDataLoaderPlugin = function injectDataLoaderPlugin(internalPlugins) {
75
66
  var DataLoaderPlugin = require.resolve('@modern-js/plugin-data-loader/server');
76
-
77
67
  return _objectSpread(_objectSpread({}, internalPlugins), {}, {
78
68
  '@modern-js/plugin-data-loader': {
79
69
  path: DataLoaderPlugin,
@@ -4,7 +4,6 @@ import { inquirer } from '@modern-js/utils';
4
4
  export var getSpecifiedEntries = /*#__PURE__*/function () {
5
5
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(entry, entrypoints) {
6
6
  var entryNames, _yield$inquirer$promp, selected;
7
-
8
7
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9
8
  while (1) {
10
9
  switch (_context.prev = _context.next) {
@@ -12,20 +11,16 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
12
11
  entryNames = entrypoints.map(function (e) {
13
12
  return e.entryName;
14
13
  });
15
-
16
14
  if (entry) {
17
15
  _context.next = 3;
18
16
  break;
19
17
  }
20
-
21
18
  return _context.abrupt("return", entryNames);
22
-
23
19
  case 3:
24
20
  if (!(typeof entry === 'boolean')) {
25
21
  _context.next = 9;
26
22
  break;
27
23
  }
28
-
29
24
  _context.next = 6;
30
25
  return inquirer.prompt([{
31
26
  type: 'checkbox',
@@ -36,16 +31,13 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
36
31
  if (answer.length < 1) {
37
32
  return 'You must choose at least one topping.';
38
33
  }
39
-
40
34
  return true;
41
35
  }
42
36
  }]);
43
-
44
37
  case 6:
45
38
  _yield$inquirer$promp = _context.sent;
46
39
  selected = _yield$inquirer$promp.selected;
47
40
  return _context.abrupt("return", selected);
48
-
49
41
  case 9:
50
42
  entry.forEach(function (name) {
51
43
  if (!entryNames.includes(name)) {
@@ -53,7 +45,6 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
53
45
  }
54
46
  });
55
47
  return _context.abrupt("return", entry);
56
-
57
48
  case 11:
58
49
  case "end":
59
50
  return _context.stop();
@@ -61,7 +52,6 @@ export var getSpecifiedEntries = /*#__PURE__*/function () {
61
52
  }
62
53
  }, _callee);
63
54
  }));
64
-
65
55
  return function getSpecifiedEntries(_x, _x2) {
66
56
  return _ref.apply(this, arguments);
67
57
  };