@modern-js/app-tools 2.0.0-beta.1 → 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 (220) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/dist/js/modern/analyze/generateCode.js +1 -1
  3. package/dist/js/modern/analyze/getBundleEntry.js +1 -1
  4. package/dist/js/modern/analyze/getFileSystemEntry.js +1 -1
  5. package/dist/js/modern/analyze/getHtmlTemplate.js +1 -1
  6. package/dist/js/modern/analyze/getServerRoutes.js +10 -6
  7. package/dist/js/modern/analyze/index.js +12 -27
  8. package/dist/js/modern/builder/builderPlugins/compatModern.js +12 -11
  9. package/dist/js/modern/builder/index.js +33 -16
  10. package/dist/js/modern/builder/share.js +1 -1
  11. package/dist/js/modern/commands/build.js +8 -2
  12. package/dist/js/modern/commands/dev.js +18 -9
  13. package/dist/js/modern/commands/inspect.js +4 -2
  14. package/dist/js/modern/commands/start.js +1 -0
  15. package/dist/js/modern/config/default.js +207 -0
  16. package/dist/js/modern/config/index.js +2 -0
  17. package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
  18. package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +14 -16
  19. package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
  20. package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
  21. package/dist/js/modern/config/initial/index.js +11 -0
  22. package/dist/js/modern/config/initial/inits.js +117 -0
  23. package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
  24. package/dist/js/modern/defineConfig.js +12 -0
  25. package/dist/js/modern/hooks.js +23 -19
  26. package/dist/js/modern/index.js +7 -5
  27. package/dist/js/modern/initialize/index.js +72 -0
  28. package/dist/js/modern/schema/Schema.js +39 -0
  29. package/dist/js/modern/schema/index.js +139 -0
  30. package/dist/js/modern/schema/legacy.js +284 -0
  31. package/dist/js/modern/types/config/deploy.js +0 -0
  32. package/dist/js/modern/types/config/dev.js +0 -0
  33. package/dist/js/modern/types/config/experiments.js +0 -0
  34. package/dist/js/modern/types/config/html.js +0 -0
  35. package/dist/js/modern/types/config/index.js +2 -0
  36. package/dist/js/modern/types/config/output.js +0 -0
  37. package/dist/js/modern/types/config/performance.js +0 -0
  38. package/dist/js/modern/types/config/security.js +0 -0
  39. package/dist/js/modern/types/config/source.js +0 -0
  40. package/dist/js/modern/types/config/tools.js +0 -0
  41. package/dist/js/modern/types/hooks.js +0 -0
  42. package/dist/js/modern/types/index.js +4 -0
  43. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  44. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  45. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  46. package/dist/js/modern/types/legacyConfig/output.js +1 -0
  47. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  48. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  49. package/dist/js/modern/utils/config.js +1 -1
  50. package/dist/js/modern/utils/createFileWatcher.js +82 -0
  51. package/dist/js/modern/utils/restart.js +17 -0
  52. package/dist/js/node/analyze/generateCode.js +1 -1
  53. package/dist/js/node/analyze/getBundleEntry.js +1 -1
  54. package/dist/js/node/analyze/getFileSystemEntry.js +1 -1
  55. package/dist/js/node/analyze/getHtmlTemplate.js +1 -1
  56. package/dist/js/node/analyze/getServerRoutes.js +10 -6
  57. package/dist/js/node/analyze/index.js +13 -39
  58. package/dist/js/node/builder/builderPlugins/compatModern.js +12 -11
  59. package/dist/js/node/builder/index.js +34 -16
  60. package/dist/js/node/builder/share.js +1 -1
  61. package/dist/js/node/commands/build.js +8 -2
  62. package/dist/js/node/commands/dev.js +18 -9
  63. package/dist/js/node/commands/inspect.js +4 -2
  64. package/dist/js/node/commands/start.js +1 -0
  65. package/dist/js/node/config/default.js +214 -0
  66. package/dist/js/node/config/index.js +31 -0
  67. package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
  68. package/dist/js/node/{builder → config/initial}/createOutputConfig.js +14 -16
  69. package/dist/js/node/config/initial/createSourceConfig.js +38 -0
  70. package/dist/js/node/config/initial/createToolsConfig.js +47 -0
  71. package/dist/js/node/config/initial/index.js +24 -0
  72. package/dist/js/node/config/initial/inits.js +127 -0
  73. package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
  74. package/dist/js/node/defineConfig.js +20 -0
  75. package/dist/js/node/hooks.js +23 -28
  76. package/dist/js/node/index.js +30 -16
  77. package/dist/js/node/initialize/index.js +79 -0
  78. package/dist/js/node/schema/Schema.js +46 -0
  79. package/dist/js/node/schema/index.js +152 -0
  80. package/dist/js/node/schema/legacy.js +291 -0
  81. package/dist/js/node/types/config/deploy.js +0 -0
  82. package/dist/js/node/types/config/dev.js +0 -0
  83. package/dist/js/node/types/config/experiments.js +0 -0
  84. package/dist/js/node/types/config/html.js +0 -0
  85. package/dist/js/node/types/config/index.js +16 -0
  86. package/dist/js/node/types/config/output.js +0 -0
  87. package/dist/js/node/types/config/performance.js +0 -0
  88. package/dist/js/node/types/config/security.js +0 -0
  89. package/dist/js/node/types/config/source.js +0 -0
  90. package/dist/js/node/types/config/tools.js +0 -0
  91. package/dist/js/node/types/hooks.js +0 -0
  92. package/dist/js/node/types/index.js +38 -0
  93. package/dist/js/node/types/legacyConfig/deploy.js +0 -0
  94. package/dist/js/node/types/legacyConfig/dev.js +0 -0
  95. package/dist/js/node/types/legacyConfig/index.js +0 -0
  96. package/dist/js/node/types/legacyConfig/output.js +5 -0
  97. package/dist/js/node/types/legacyConfig/source.js +0 -0
  98. package/dist/js/node/types/legacyConfig/tools.js +0 -0
  99. package/dist/js/node/utils/config.js +1 -1
  100. package/dist/js/node/utils/createFileWatcher.js +90 -0
  101. package/dist/js/node/utils/restart.js +23 -0
  102. package/dist/js/treeshaking/analyze/generateCode.js +1 -1
  103. package/dist/js/treeshaking/analyze/getBundleEntry.js +1 -1
  104. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +1 -1
  105. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +1 -1
  106. package/dist/js/treeshaking/analyze/getServerRoutes.js +8 -7
  107. package/dist/js/treeshaking/analyze/index.js +10 -26
  108. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +12 -11
  109. package/dist/js/treeshaking/builder/index.js +31 -16
  110. package/dist/js/treeshaking/builder/share.js +1 -1
  111. package/dist/js/treeshaking/commands/build.js +33 -23
  112. package/dist/js/treeshaking/commands/dev.js +36 -22
  113. package/dist/js/treeshaking/commands/inspect.js +8 -3
  114. package/dist/js/treeshaking/commands/start.js +1 -0
  115. package/dist/js/treeshaking/config/default.js +200 -0
  116. package/dist/js/treeshaking/config/index.js +2 -0
  117. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
  118. package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
  119. package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
  120. package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
  121. package/dist/js/treeshaking/config/initial/index.js +11 -0
  122. package/dist/js/treeshaking/config/initial/inits.js +114 -0
  123. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
  124. package/dist/js/treeshaking/defineConfig.js +14 -0
  125. package/dist/js/treeshaking/hooks.js +23 -19
  126. package/dist/js/treeshaking/index.js +7 -5
  127. package/dist/js/treeshaking/initialize/index.js +121 -0
  128. package/dist/js/treeshaking/schema/Schema.js +75 -0
  129. package/dist/js/treeshaking/schema/index.js +138 -0
  130. package/dist/js/treeshaking/schema/legacy.js +273 -0
  131. package/dist/js/treeshaking/types/config/deploy.js +0 -0
  132. package/dist/js/treeshaking/types/config/dev.js +0 -0
  133. package/dist/js/treeshaking/types/config/experiments.js +0 -0
  134. package/dist/js/treeshaking/types/config/html.js +0 -0
  135. package/dist/js/treeshaking/types/config/index.js +2 -0
  136. package/dist/js/treeshaking/types/config/output.js +0 -0
  137. package/dist/js/treeshaking/types/config/performance.js +0 -0
  138. package/dist/js/treeshaking/types/config/security.js +0 -0
  139. package/dist/js/treeshaking/types/config/source.js +0 -0
  140. package/dist/js/treeshaking/types/config/tools.js +0 -0
  141. package/dist/js/treeshaking/types/hooks.js +0 -0
  142. package/dist/js/treeshaking/types/index.js +4 -0
  143. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
  144. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
  145. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
  146. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  147. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
  148. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
  149. package/dist/js/treeshaking/utils/config.js +1 -1
  150. package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
  151. package/dist/js/treeshaking/utils/restart.js +45 -0
  152. package/dist/types/analyze/generateCode.d.ts +3 -2
  153. package/dist/types/analyze/getBundleEntry.d.ts +2 -2
  154. package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
  155. package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
  156. package/dist/types/analyze/getServerRoutes.d.ts +3 -2
  157. package/dist/types/analyze/index.d.ts +3 -41
  158. package/dist/types/analyze/templates.d.ts +1 -1
  159. package/dist/types/analyze/utils.d.ts +1 -1
  160. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -2
  161. package/dist/types/builder/index.d.ts +5 -2
  162. package/dist/types/builder/share.d.ts +2 -2
  163. package/dist/types/commands/build.d.ts +2 -2
  164. package/dist/types/commands/deploy.d.ts +2 -2
  165. package/dist/types/commands/dev.d.ts +2 -2
  166. package/dist/types/commands/inspect.d.ts +9 -1
  167. package/dist/types/commands/start.d.ts +2 -2
  168. package/dist/types/config/default.d.ts +3 -0
  169. package/dist/types/config/index.d.ts +2 -0
  170. package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
  171. package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
  172. package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
  173. package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
  174. package/dist/types/config/initial/index.d.ts +4 -0
  175. package/dist/types/config/initial/inits.d.ts +4 -0
  176. package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
  177. package/dist/types/defineConfig.d.ts +7 -0
  178. package/dist/types/hooks.d.ts +2 -42
  179. package/dist/types/index.d.ts +5 -5
  180. package/dist/types/initialize/index.d.ts +3 -0
  181. package/dist/types/schema/Schema.d.ts +14 -0
  182. package/dist/types/schema/index.d.ts +4 -0
  183. package/dist/types/schema/legacy.d.ts +3 -0
  184. package/dist/types/types/config/deploy.d.ts +9 -0
  185. package/dist/types/types/config/dev.d.ts +13 -0
  186. package/dist/types/types/config/experiments.d.ts +4 -0
  187. package/dist/types/types/config/html.d.ts +4 -0
  188. package/dist/types/types/config/index.d.ts +62 -0
  189. package/dist/types/types/config/output.d.ts +23 -0
  190. package/dist/types/types/config/performance.d.ts +4 -0
  191. package/dist/types/types/config/security.d.ts +4 -0
  192. package/dist/types/types/config/source.d.ts +22 -0
  193. package/dist/types/types/config/tools.d.ts +15 -0
  194. package/dist/types/types/hooks.d.ts +80 -0
  195. package/dist/types/types/index.d.ts +23 -0
  196. package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
  197. package/dist/types/types/legacyConfig/dev.d.ts +12 -0
  198. package/dist/types/types/legacyConfig/index.d.ts +33 -0
  199. package/dist/types/types/legacyConfig/output.d.ts +51 -0
  200. package/dist/types/types/legacyConfig/source.d.ts +25 -0
  201. package/dist/types/types/legacyConfig/tools.d.ts +16 -0
  202. package/dist/types/utils/config.d.ts +2 -2
  203. package/dist/types/utils/createFileWatcher.d.ts +3 -0
  204. package/dist/types/utils/printInstructions.d.ts +3 -3
  205. package/dist/types/utils/restart.d.ts +3 -0
  206. package/package.json +24 -24
  207. package/dist/js/modern/builder/createHtmlConfig.js +0 -58
  208. package/dist/js/modern/builder/createSourceConfig.js +0 -74
  209. package/dist/js/modern/builder/createToolsConfig.js +0 -87
  210. package/dist/js/node/builder/createHtmlConfig.js +0 -68
  211. package/dist/js/node/builder/createSourceConfig.js +0 -82
  212. package/dist/js/node/builder/createToolsConfig.js +0 -94
  213. package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
  214. package/dist/js/treeshaking/builder/createOutputConfig.js +0 -70
  215. package/dist/js/treeshaking/builder/createSourceConfig.js +0 -88
  216. package/dist/js/treeshaking/builder/createToolsConfig.js +0 -85
  217. package/dist/types/builder/createHtmlConfig.d.ts +0 -6
  218. package/dist/types/builder/createOutputConfig.d.ts +0 -3
  219. package/dist/types/builder/createSourceConfig.d.ts +0 -5
  220. package/dist/types/builder/createToolsConfig.d.ts +0 -13
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Schema = void 0;
7
+ var _lodash = require("@modern-js/utils/lodash");
8
+ 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; }
9
+ class Schema extends Map {
10
+ constructor(baseSchema = {}) {
11
+ super();
12
+ _defineProperty(this, "schema", void 0);
13
+ this.schema = baseSchema;
14
+ }
15
+ setSchema(key, object) {
16
+ Object.entries(object).forEach(([k, v]) => {
17
+ const target = `${key}.${k}`;
18
+ this.set(target, v);
19
+ });
20
+ return this;
21
+ }
22
+ set(key, value) {
23
+ if (this.has(key)) {
24
+ (0, _lodash.merge)(this.schema[key], value);
25
+ } else {
26
+ this.schema[key] = value;
27
+ }
28
+ return this;
29
+ }
30
+ has(key) {
31
+ return key in this.schema;
32
+ }
33
+ get(key) {
34
+ return this.schema[key];
35
+ }
36
+ delete(key) {
37
+ return delete this.schema[key];
38
+ }
39
+ generate() {
40
+ return Object.entries(this.schema).map(([target, schema]) => ({
41
+ target,
42
+ schema
43
+ }));
44
+ }
45
+ }
46
+ exports.Schema = Schema;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "legacySchema", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _legacy.default;
10
+ }
11
+ });
12
+ exports.schema = void 0;
13
+ var _constants = require("@modern-js/utils/constants");
14
+ var _Schema = require("./Schema");
15
+ var _legacy = _interopRequireDefault(require("./legacy"));
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ const source = {
18
+ entries: {
19
+ type: 'object',
20
+ patternProperties: {
21
+ [_constants.ENTRY_NAME_PATTERN]: {
22
+ if: {
23
+ type: 'object'
24
+ },
25
+ then: {
26
+ required: ['entry'],
27
+ properties: {
28
+ entry: {
29
+ type: ['string', 'array']
30
+ },
31
+ disableMount: {
32
+ type: 'boolean'
33
+ },
34
+ enableFileSystemRoutes: {
35
+ type: 'boolean'
36
+ }
37
+ },
38
+ additionalProperties: false
39
+ },
40
+ else: {
41
+ type: ['string', 'array']
42
+ }
43
+ }
44
+ }
45
+ },
46
+ enableAsyncEntry: {
47
+ type: 'boolean'
48
+ },
49
+ disableDefaultEntries: {
50
+ type: 'boolean'
51
+ },
52
+ entriesDir: {
53
+ type: 'string'
54
+ },
55
+ configDir: {
56
+ type: 'string'
57
+ },
58
+ designSystem: {
59
+ type: 'object'
60
+ }
61
+ };
62
+ const bff = {
63
+ prefix: {
64
+ type: 'string'
65
+ },
66
+ proxy: {
67
+ type: 'object',
68
+ additionalProperties: {
69
+ type: 'string'
70
+ }
71
+ }
72
+ };
73
+ const output = {
74
+ ssg: {
75
+ typeof: ['boolean', 'object', 'function']
76
+ },
77
+ enableModernMode: {
78
+ type: 'boolean'
79
+ },
80
+ disableNodePolyfill: {
81
+ type: 'boolean'
82
+ }
83
+ };
84
+ const dev = {
85
+ proxy: {
86
+ type: ['boolean', 'object']
87
+ }
88
+ };
89
+ const server = {
90
+ routes: {
91
+ type: 'object'
92
+ },
93
+ publicRoutes: {
94
+ type: 'object'
95
+ },
96
+ ssr: {
97
+ type: ['boolean', 'object']
98
+ },
99
+ ssrByEntries: {
100
+ type: 'object'
101
+ },
102
+ baseUrl: {
103
+ anyOf: [{
104
+ type: 'string'
105
+ }, {
106
+ type: 'array',
107
+ items: {
108
+ type: 'string'
109
+ }
110
+ }]
111
+ },
112
+ port: {
113
+ type: 'number'
114
+ },
115
+ logger: {
116
+ type: ['boolean', 'object']
117
+ },
118
+ metrics: {
119
+ type: ['boolean', 'object']
120
+ },
121
+ enableMicroFrontendDebug: {
122
+ type: 'boolean'
123
+ },
124
+ watchOptions: {
125
+ type: 'object'
126
+ },
127
+ compiler: {
128
+ type: 'string'
129
+ },
130
+ disableFrameworkExt: {
131
+ type: 'boolean'
132
+ }
133
+ };
134
+ const tools = {
135
+ tailwindcss: {
136
+ type: 'object'
137
+ },
138
+ jest: {
139
+ typeof: ['object', 'function']
140
+ },
141
+ esbuild: {
142
+ typeof: ['object']
143
+ }
144
+ };
145
+ const deploy = {
146
+ microFrontend: {
147
+ type: ['boolean', 'object']
148
+ }
149
+ };
150
+ const schema = new _Schema.Schema();
151
+ exports.schema = schema;
152
+ schema.setSchema('bff', bff).setSchema('dev', dev).setSchema('server', server).setSchema('source', source).setSchema('output', output).setSchema('tools', tools).setSchema('deploy', deploy);
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _constants = require("@modern-js/utils/constants");
8
+ var _Schema = require("./Schema");
9
+ const source = {
10
+ entries: {
11
+ type: 'object',
12
+ patternProperties: {
13
+ [_constants.ENTRY_NAME_PATTERN]: {
14
+ if: {
15
+ type: 'object'
16
+ },
17
+ then: {
18
+ required: ['entry'],
19
+ properties: {
20
+ entry: {
21
+ type: ['string', 'array']
22
+ },
23
+ disableMount: {
24
+ type: 'boolean'
25
+ },
26
+ enableFileSystemRoutes: {
27
+ type: 'boolean'
28
+ }
29
+ },
30
+ additionalProperties: false
31
+ },
32
+ else: {
33
+ type: ['string', 'array']
34
+ }
35
+ }
36
+ }
37
+ },
38
+ preEntry: {
39
+ type: ['string', 'array']
40
+ },
41
+ alias: {
42
+ typeof: ['object', 'function']
43
+ },
44
+ enableAsyncEntry: {
45
+ type: 'boolean'
46
+ },
47
+ disableDefaultEntries: {
48
+ type: 'boolean'
49
+ },
50
+ envVars: {
51
+ type: 'array'
52
+ },
53
+ globalVars: {
54
+ type: 'object'
55
+ },
56
+ moduleScopes: {
57
+ instanceof: ['Array', 'Function']
58
+ },
59
+ entriesDir: {
60
+ type: 'string'
61
+ },
62
+ configDir: {
63
+ type: 'string'
64
+ },
65
+ include: {
66
+ type: ['array']
67
+ }
68
+ };
69
+ const output = {
70
+ assetPrefix: {
71
+ type: 'string'
72
+ },
73
+ path: {
74
+ type: 'string'
75
+ },
76
+ jsPath: {
77
+ type: 'string'
78
+ },
79
+ cssPath: {
80
+ type: 'string'
81
+ },
82
+ htmlPath: {
83
+ type: 'string'
84
+ },
85
+ mediaPath: {
86
+ type: 'string'
87
+ },
88
+ mountId: {
89
+ type: 'string'
90
+ },
91
+ favicon: {
92
+ type: 'string'
93
+ },
94
+ faviconByEntries: {
95
+ type: 'object',
96
+ patternProperties: {
97
+ [_constants.ENTRY_NAME_PATTERN]: {
98
+ type: 'string'
99
+ }
100
+ }
101
+ },
102
+ title: {
103
+ type: 'string'
104
+ },
105
+ titleByEntries: {
106
+ type: 'object',
107
+ patternProperties: {
108
+ [_constants.ENTRY_NAME_PATTERN]: {
109
+ type: 'string'
110
+ }
111
+ }
112
+ },
113
+ meta: {
114
+ type: 'object'
115
+ },
116
+ metaByEntries: {
117
+ type: 'object',
118
+ patternProperties: {
119
+ [_constants.ENTRY_NAME_PATTERN]: {
120
+ type: 'object'
121
+ }
122
+ }
123
+ },
124
+ inject: {
125
+ enum: [true, 'head', 'body', false]
126
+ },
127
+ injectByEntries: {
128
+ type: 'object',
129
+ patternProperties: {
130
+ [_constants.ENTRY_NAME_PATTERN]: {
131
+ enum: [true, 'head', 'body', false]
132
+ }
133
+ }
134
+ },
135
+ copy: {
136
+ type: 'array'
137
+ },
138
+ scriptExt: {
139
+ type: 'object'
140
+ },
141
+ disableTsChecker: {
142
+ type: 'boolean'
143
+ },
144
+ disableHtmlFolder: {
145
+ type: 'boolean'
146
+ },
147
+ disableCssModuleExtension: {
148
+ type: 'boolean'
149
+ },
150
+ disableCssExtract: {
151
+ type: 'boolean'
152
+ },
153
+ enableCssModuleTSDeclaration: {
154
+ type: 'boolean'
155
+ },
156
+ disableMinimize: {
157
+ type: 'boolean'
158
+ },
159
+ enableInlineStyles: {
160
+ type: 'boolean'
161
+ },
162
+ enableInlineScripts: {
163
+ type: 'boolean'
164
+ },
165
+ disableSourceMap: {
166
+ type: 'boolean'
167
+ },
168
+ disableInlineRuntimeChunk: {
169
+ type: 'boolean'
170
+ },
171
+ disableAssetsCache: {
172
+ type: 'boolean'
173
+ },
174
+ enableLatestDecorators: {
175
+ type: 'boolean'
176
+ },
177
+ enableTsLoader: {
178
+ type: 'boolean'
179
+ },
180
+ dataUriLimit: {
181
+ type: 'number'
182
+ },
183
+ templateParameters: {
184
+ type: 'object'
185
+ },
186
+ templateParametersByEntries: {
187
+ type: 'object',
188
+ patternProperties: {
189
+ [_constants.ENTRY_NAME_PATTERN]: {
190
+ type: 'object'
191
+ }
192
+ }
193
+ },
194
+ polyfill: {
195
+ type: 'string',
196
+ enum: ['usage', 'entry', 'off', 'ua']
197
+ },
198
+ cssModuleLocalIdentName: {
199
+ type: 'string'
200
+ },
201
+ federation: {
202
+ type: 'object'
203
+ },
204
+ disableNodePolyfill: {
205
+ type: 'boolean'
206
+ },
207
+ enableModernMode: {
208
+ type: 'boolean'
209
+ }
210
+ };
211
+ const server = {
212
+ routes: {
213
+ type: 'object'
214
+ },
215
+ publicRoutes: {
216
+ type: 'object'
217
+ },
218
+ ssr: {
219
+ type: ['boolean', 'object']
220
+ },
221
+ ssrByEntries: {
222
+ type: 'object'
223
+ },
224
+ baseUrl: {
225
+ anyOf: [{
226
+ type: 'string'
227
+ }, {
228
+ type: 'array',
229
+ items: {
230
+ type: 'string'
231
+ }
232
+ }]
233
+ },
234
+ port: {
235
+ type: 'number'
236
+ },
237
+ logger: {
238
+ type: ['boolean', 'object']
239
+ },
240
+ metrics: {
241
+ type: ['boolean', 'object']
242
+ },
243
+ enableMicroFrontendDebug: {
244
+ type: 'boolean'
245
+ },
246
+ watchOptions: {
247
+ type: 'object'
248
+ },
249
+ compiler: {
250
+ type: 'string'
251
+ },
252
+ disableFrameworkExt: {
253
+ type: 'boolean'
254
+ }
255
+ };
256
+ const dev = {
257
+ proxy: {
258
+ type: ['boolean', 'object']
259
+ }
260
+ };
261
+ const deploy = {
262
+ microFrontend: {
263
+ type: ['boolean', 'object']
264
+ }
265
+ };
266
+ const tools = {
267
+ tailwindcss: {
268
+ type: 'object'
269
+ },
270
+ jest: {
271
+ typeof: ['object', 'function']
272
+ },
273
+ esbuild: {
274
+ typeof: ['object']
275
+ }
276
+ };
277
+ const bff = {
278
+ prefix: {
279
+ type: 'string'
280
+ },
281
+ proxy: {
282
+ type: 'object',
283
+ additionalProperties: {
284
+ type: 'string'
285
+ }
286
+ }
287
+ };
288
+ const schema = new _Schema.Schema();
289
+ schema.setSchema('bff', bff).setSchema('dev', dev).setSchema('server', server).setSchema('source', source).setSchema('output', output).setSchema('tools', tools).setSchema('deploy', deploy);
290
+ var _default = schema;
291
+ exports.default = _default;
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _output = require("./output");
7
+ Object.keys(_output).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _output[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _output[key];
14
+ }
15
+ });
16
+ });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _hooks = require("./hooks");
7
+ Object.keys(_hooks).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _hooks[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _hooks[key];
14
+ }
15
+ });
16
+ });
17
+ var _config = require("./config");
18
+ Object.keys(_config).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _config[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _config[key];
25
+ }
26
+ });
27
+ });
28
+ var _legacyConfig = require("./legacyConfig");
29
+ Object.keys(_legacyConfig).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _legacyConfig[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _legacyConfig[key];
36
+ }
37
+ });
38
+ });
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
File without changes
File without changes
@@ -70,7 +70,7 @@ const safeReplacer = () => {
70
70
  exports.safeReplacer = safeReplacer;
71
71
  const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
72
72
  var _resolvedConfig$outpu;
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', _utils.OUTPUT_CONFIG_FILE);
73
+ const outputPath = path.join(appDirectory, ((_resolvedConfig$outpu = resolvedConfig.output.distPath) === null || _resolvedConfig$outpu === void 0 ? void 0 : _resolvedConfig$outpu.root) || './dist', _utils.OUTPUT_CONFIG_FILE);
74
74
  await _utils.fs.writeJSON(outputPath, resolvedConfig, {
75
75
  spaces: 2,
76
76
  replacer: safeReplacer()
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFileWatcher = void 0;
7
+ var _crypto = _interopRequireDefault(require("crypto"));
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _path = _interopRequireDefault(require("path"));
10
+ var _utils = require("@modern-js/utils");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /**
13
+ * Get user config from package.json.
14
+ * @param appDirectory - App root directory.
15
+ * @returns modernConfig or undefined
16
+ */
17
+ // FIXME: read package.json again;
18
+ const getPackageConfig = (appDirectory, packageJsonConfig) => {
19
+ const PACKAGE_JSON_CONFIG_NAME = 'modernConfig';
20
+ const json = JSON.parse(_fs.default.readFileSync(_path.default.resolve(appDirectory, './package.json'), 'utf8'));
21
+ return json[packageJsonConfig !== null && packageJsonConfig !== void 0 ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
22
+ };
23
+ const addServerConfigToDeps = async (dependencies, appDirectory, serverConfigFile) => {
24
+ const serverConfig = await (0, _utils.getServerConfig)(appDirectory, serverConfigFile);
25
+ if (serverConfig) {
26
+ dependencies.push(serverConfig);
27
+ }
28
+ };
29
+ const debug = (0, _utils.createDebugger)('watch-files');
30
+ const md5 = data => _crypto.default.createHash('md5').update(data).digest('hex');
31
+ const hashMap = new Map();
32
+ const createFileWatcher = async (appContext, configDir, hooksRunner) => {
33
+ // only add fs watcher on dev mode.
34
+ if ((0, _utils.isDev)() || (0, _utils.isTest)()) {
35
+ const {
36
+ appDirectory,
37
+ configFile
38
+ } = appContext;
39
+ const extraFiles = await hooksRunner.watchFiles();
40
+ const configPath = _path.default.join(appDirectory, configDir);
41
+ const dependencies = getPackageConfig(appContext.appDirectory, appContext.packageName) ? [_path.default.resolve(appDirectory, './package.json')] : [];
42
+
43
+ // 将 server.config 加入到 loaded.dependencies,以便对文件监听做热更新
44
+ await addServerConfigToDeps(dependencies, appContext.appDirectory, appContext.serverConfigFile);
45
+ const watched = [`${configPath}/html`, ...extraFiles, ...dependencies, configFile].filter(Boolean);
46
+ debug(`watched: %o`, watched);
47
+ const watcher = _utils.chokidar.watch(watched, {
48
+ cwd: appDirectory,
49
+ ignoreInitial: true,
50
+ ignorePermissionErrors: true,
51
+ ignored: [/node_modules/, '**/__test__/**', '**/*.test.(js|jsx|ts|tsx)', '**/*.spec.(js|jsx|ts|tsx)', '**/*.stories.(js|jsx|ts|tsx)']
52
+ });
53
+ watcher.on('change', changed => {
54
+ const lastHash = hashMap.get(changed);
55
+ const currentHash = md5(_fs.default.readFileSync(_path.default.join(appDirectory, changed), 'utf8'));
56
+ if (currentHash !== lastHash) {
57
+ debug(`file change: %s`, changed);
58
+ hashMap.set(changed, currentHash);
59
+ hooksRunner.fileChange({
60
+ filename: changed,
61
+ eventType: 'change'
62
+ });
63
+ }
64
+ });
65
+ watcher.on('add', name => {
66
+ debug(`add file: %s`, name);
67
+ const currentHash = md5(_fs.default.readFileSync(_path.default.join(appDirectory, name), 'utf8'));
68
+ hashMap.set(name, currentHash);
69
+ hooksRunner.fileChange({
70
+ filename: name,
71
+ eventType: 'add'
72
+ });
73
+ });
74
+ watcher.on('unlink', name => {
75
+ debug(`remove file: %s`, name);
76
+ if (hashMap.has(name)) {
77
+ hashMap.delete(name);
78
+ }
79
+ hooksRunner.fileChange({
80
+ filename: name,
81
+ eventType: 'unlink'
82
+ });
83
+ });
84
+ watcher.on('error', err => {
85
+ throw err;
86
+ });
87
+ return watcher;
88
+ }
89
+ };
90
+ exports.createFileWatcher = createFileWatcher;