@modern-js/app-tools 2.0.0-canary.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +746 -0
  2. package/bin/modern.js +3 -0
  3. package/dist/js/modern/analyze/Builder.js +39 -0
  4. package/dist/js/modern/analyze/constants.js +16 -0
  5. package/dist/js/modern/analyze/generateCode.js +14 -15
  6. package/dist/js/modern/analyze/getBundleEntry.js +5 -1
  7. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +9 -6
  8. package/dist/js/modern/analyze/getFileSystemEntry.js +11 -3
  9. package/dist/js/modern/analyze/index.js +79 -8
  10. package/dist/js/modern/analyze/nestedRoutes.js +29 -22
  11. package/dist/js/modern/analyze/templates.js +28 -7
  12. package/dist/js/modern/analyze/utils.js +21 -4
  13. package/dist/js/modern/builder/builderPlugins/compatModern.js +12 -5
  14. package/dist/js/modern/builder/index.js +14 -16
  15. package/dist/js/modern/builder/share.js +4 -4
  16. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +3 -1
  17. package/dist/js/modern/commands/dev.js +6 -9
  18. package/dist/js/modern/commands/index.js +1 -1
  19. package/dist/js/modern/commands/{start.js → serve.js} +3 -1
  20. package/dist/js/modern/config/default.js +38 -61
  21. package/dist/js/modern/config/initial/createOutputConfig.js +1 -3
  22. package/dist/js/modern/config/initial/createSourceConfig.js +5 -1
  23. package/dist/js/modern/config/initial/inits.js +7 -0
  24. package/dist/js/modern/config/initial/transformNormalizedConfig.js +5 -1
  25. package/dist/js/modern/hooks.js +6 -1
  26. package/dist/js/modern/index.js +96 -59
  27. package/dist/js/modern/initialize/index.js +5 -4
  28. package/dist/js/modern/locale/en.js +1 -1
  29. package/dist/js/modern/locale/zh.js +1 -1
  30. package/dist/js/modern/schema/index.js +6 -8
  31. package/dist/js/modern/schema/legacy.js +2 -3
  32. package/dist/js/modern/utils/commands.js +6 -1
  33. package/dist/js/modern/utils/env.js +15 -0
  34. package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
  35. package/dist/js/node/analyze/Builder.js +64 -0
  36. package/dist/js/node/analyze/constants.js +44 -3
  37. package/dist/js/node/analyze/generateCode.js +33 -29
  38. package/dist/js/node/analyze/getBundleEntry.js +12 -4
  39. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +33 -28
  40. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +24 -22
  41. package/dist/js/node/analyze/getClientRoutes/index.js +8 -3
  42. package/dist/js/node/analyze/getClientRoutes/utils.js +10 -3
  43. package/dist/js/node/analyze/getFileSystemEntry.js +18 -6
  44. package/dist/js/node/analyze/getHtmlTemplate.js +18 -14
  45. package/dist/js/node/analyze/getServerRoutes.js +36 -34
  46. package/dist/js/node/analyze/index.js +105 -59
  47. package/dist/js/node/analyze/isDefaultExportFunction.js +7 -3
  48. package/dist/js/node/analyze/makeLegalIdentifier.js +7 -3
  49. package/dist/js/node/analyze/nestedRoutes.js +58 -49
  50. package/dist/js/node/analyze/templates.js +64 -37
  51. package/dist/js/node/analyze/utils.js +40 -18
  52. package/dist/js/node/builder/builderPlugins/compatModern.js +36 -27
  53. package/dist/js/node/builder/index.js +42 -55
  54. package/dist/js/node/builder/loaders/routerLoader.js +5 -3
  55. package/dist/js/node/builder/loaders/serverModuleLoader.js +5 -3
  56. package/dist/js/node/builder/share.js +11 -7
  57. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +7 -3
  58. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +7 -3
  59. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +12 -8
  60. package/dist/js/node/commands/build.js +30 -28
  61. package/dist/js/node/commands/deploy.js +9 -5
  62. package/dist/js/node/commands/dev.js +39 -40
  63. package/dist/js/node/commands/index.js +5 -5
  64. package/dist/js/node/commands/inspect.js +10 -6
  65. package/dist/js/node/commands/{start.js → serve.js} +16 -10
  66. package/dist/js/node/config/default.js +44 -64
  67. package/dist/js/node/config/index.js +10 -3
  68. package/dist/js/node/config/initial/createHtmlConfig.js +7 -3
  69. package/dist/js/node/config/initial/createOutputConfig.js +8 -6
  70. package/dist/js/node/config/initial/createSourceConfig.js +12 -4
  71. package/dist/js/node/config/initial/createToolsConfig.js +7 -3
  72. package/dist/js/node/config/initial/index.js +9 -3
  73. package/dist/js/node/config/initial/inits.js +33 -22
  74. package/dist/js/node/config/initial/transformNormalizedConfig.js +12 -4
  75. package/dist/js/node/defineConfig.js +25 -22
  76. package/dist/js/node/exports/server.js +7 -3
  77. package/dist/js/node/hooks.js +13 -4
  78. package/dist/js/node/index.js +135 -111
  79. package/dist/js/node/initialize/index.js +33 -32
  80. package/dist/js/node/locale/en.js +8 -4
  81. package/dist/js/node/locale/index.js +8 -3
  82. package/dist/js/node/locale/zh.js +8 -4
  83. package/dist/js/node/schema/Schema.js +7 -3
  84. package/dist/js/node/schema/index.js +14 -11
  85. package/dist/js/node/schema/legacy.js +7 -6
  86. package/dist/js/node/types/config/deploy.js +15 -0
  87. package/dist/js/node/types/config/dev.js +15 -0
  88. package/dist/js/node/types/config/experiments.js +15 -0
  89. package/dist/js/node/types/config/html.js +15 -0
  90. package/dist/js/node/types/config/index.js +3 -3
  91. package/dist/js/node/types/config/output.js +15 -0
  92. package/dist/js/node/types/config/performance.js +15 -0
  93. package/dist/js/node/types/config/security.js +15 -0
  94. package/dist/js/node/types/config/source.js +15 -0
  95. package/dist/js/node/types/config/tools.js +15 -0
  96. package/dist/js/node/types/hooks.js +15 -0
  97. package/dist/js/node/types/index.js +5 -5
  98. package/dist/js/node/types/legacyConfig/deploy.js +15 -0
  99. package/dist/js/node/types/legacyConfig/dev.js +15 -0
  100. package/dist/js/node/types/legacyConfig/index.js +15 -0
  101. package/dist/js/node/types/legacyConfig/output.js +15 -0
  102. package/dist/js/node/types/legacyConfig/source.js +15 -0
  103. package/dist/js/node/types/legacyConfig/tools.js +15 -0
  104. package/dist/js/node/utils/commands.js +14 -4
  105. package/dist/js/node/utils/config.js +35 -30
  106. package/dist/js/node/utils/createFileWatcher.js +15 -10
  107. package/dist/js/node/utils/createServer.js +35 -29
  108. package/dist/js/node/utils/env.js +38 -0
  109. package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
  110. package/dist/js/node/utils/getSpecifiedEntries.js +10 -6
  111. package/dist/js/node/utils/language.js +7 -3
  112. package/dist/js/node/utils/printInstructions.js +10 -6
  113. package/dist/js/node/utils/restart.js +11 -7
  114. package/dist/js/node/utils/routes.js +11 -7
  115. package/dist/js/node/utils/types.js +15 -0
  116. package/dist/js/treeshaking/analyze/Builder.js +199 -0
  117. package/dist/js/treeshaking/analyze/constants.js +13 -1
  118. package/dist/js/treeshaking/analyze/generateCode.js +14 -17
  119. package/dist/js/treeshaking/analyze/getBundleEntry.js +5 -1
  120. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +9 -6
  121. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +11 -3
  122. package/dist/js/treeshaking/analyze/index.js +110 -7
  123. package/dist/js/treeshaking/analyze/nestedRoutes.js +30 -23
  124. package/dist/js/treeshaking/analyze/templates.js +13 -8
  125. package/dist/js/treeshaking/analyze/utils.js +15 -4
  126. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +6 -1
  127. package/dist/js/treeshaking/builder/index.js +13 -20
  128. package/dist/js/treeshaking/builder/share.js +1 -4
  129. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +3 -1
  130. package/dist/js/treeshaking/commands/dev.js +19 -24
  131. package/dist/js/treeshaking/commands/index.js +1 -1
  132. package/dist/js/treeshaking/commands/{start.js → serve.js} +10 -3
  133. package/dist/js/treeshaking/config/default.js +53 -56
  134. package/dist/js/treeshaking/config/initial/createOutputConfig.js +1 -3
  135. package/dist/js/treeshaking/config/initial/createSourceConfig.js +5 -1
  136. package/dist/js/treeshaking/config/initial/inits.js +7 -0
  137. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +5 -1
  138. package/dist/js/treeshaking/hooks.js +6 -1
  139. package/dist/js/treeshaking/index.js +349 -132
  140. package/dist/js/treeshaking/initialize/index.js +6 -5
  141. package/dist/js/treeshaking/locale/en.js +1 -1
  142. package/dist/js/treeshaking/locale/zh.js +1 -1
  143. package/dist/js/treeshaking/schema/index.js +11 -12
  144. package/dist/js/treeshaking/schema/legacy.js +1 -4
  145. package/dist/js/treeshaking/utils/commands.js +5 -1
  146. package/dist/js/treeshaking/utils/env.js +13 -0
  147. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
  148. package/dist/types/analyze/Builder.d.ts +8 -0
  149. package/dist/types/analyze/constants.d.ts +13 -1
  150. package/dist/types/analyze/templates.d.ts +3 -1
  151. package/dist/types/analyze/utils.d.ts +2 -1
  152. package/dist/types/builder/builderPlugins/compatModern.d.ts +3 -3
  153. package/dist/types/builder/index.d.ts +2 -2
  154. package/dist/types/commands/index.d.ts +1 -1
  155. package/dist/types/commands/{start.d.ts → serve.d.ts} +0 -0
  156. package/dist/types/index.d.ts +5 -1
  157. package/dist/types/locale/en.d.ts +1 -1
  158. package/dist/types/locale/index.d.ts +2 -2
  159. package/dist/types/locale/zh.d.ts +1 -1
  160. package/dist/types/schema/Schema.d.ts +1 -1
  161. package/dist/types/types/config/deploy.d.ts +1 -1
  162. package/dist/types/types/config/dev.d.ts +4 -4
  163. package/dist/types/types/config/experiments.d.ts +3 -3
  164. package/dist/types/types/config/html.d.ts +3 -3
  165. package/dist/types/types/config/index.d.ts +6 -3
  166. package/dist/types/types/config/output.d.ts +6 -6
  167. package/dist/types/types/config/performance.d.ts +3 -3
  168. package/dist/types/types/config/security.d.ts +3 -3
  169. package/dist/types/types/config/source.d.ts +6 -5
  170. package/dist/types/types/config/tools.d.ts +3 -3
  171. package/dist/types/types/hooks.d.ts +9 -1
  172. package/dist/types/types/index.d.ts +6 -6
  173. package/dist/types/types/legacyConfig/deploy.d.ts +1 -1
  174. package/dist/types/types/legacyConfig/dev.d.ts +2 -2
  175. package/dist/types/types/legacyConfig/index.d.ts +1 -1
  176. package/dist/types/types/legacyConfig/output.d.ts +2 -2
  177. package/dist/types/types/legacyConfig/source.d.ts +1 -2
  178. package/dist/types/types/legacyConfig/tools.d.ts +2 -2
  179. package/dist/types/utils/commands.d.ts +2 -1
  180. package/dist/types/utils/env.d.ts +2 -0
  181. package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
  182. package/dist/types/utils/types.d.ts +5 -5
  183. package/package.json +27 -24
@@ -33,9 +33,6 @@ var source = {
33
33
  },
34
34
  disableMount: {
35
35
  type: "boolean"
36
- },
37
- enableFileSystemRoutes: {
38
- type: "boolean"
39
36
  }
40
37
  },
41
38
  additionalProperties: false
@@ -287,7 +284,7 @@ var server = {
287
284
  compiler: {
288
285
  type: "string"
289
286
  },
290
- disableFrameworkExt: {
287
+ enableFrameworkExt: {
291
288
  type: "boolean"
292
289
  }
293
290
  };
@@ -3,4 +3,8 @@ var getCommand = function() {
3
3
  var command = args[0];
4
4
  return command;
5
5
  };
6
- export { getCommand };
6
+ var isDevCommand = function() {
7
+ var command = getCommand();
8
+ return command === "dev" || command === "start";
9
+ };
10
+ export { getCommand, isDevCommand };
@@ -0,0 +1,13 @@
1
+ function getAutoInjectEnv(appContext) {
2
+ var metaName = appContext.metaName;
3
+ var prefix = "".concat(metaName.split(/[-_]/)[0], "_").toUpperCase();
4
+ var envReg = new RegExp("^".concat(prefix));
5
+ return Object.keys(process.env).reduce(function(prev, key) {
6
+ var value = process.env[key];
7
+ if (envReg.test(key) && typeof value !== "undefined") {
8
+ prev["process.env.".concat(key)] = value;
9
+ }
10
+ return prev;
11
+ }, {});
12
+ }
13
+ export { getAutoInjectEnv };
@@ -0,0 +1,210 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _asyncToGenerator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _defineProperty(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _objectSpread(target) {
44
+ for(var i = 1; i < arguments.length; i++){
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+ if (typeof Object.getOwnPropertySymbols === "function") {
48
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
+ }));
51
+ }
52
+ ownKeys.forEach(function(key) {
53
+ _defineProperty(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ function ownKeys(object, enumerableOnly) {
59
+ var keys = Object.keys(object);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var symbols = Object.getOwnPropertySymbols(object);
62
+ if (enumerableOnly) {
63
+ symbols = symbols.filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
+ });
66
+ }
67
+ keys.push.apply(keys, symbols);
68
+ }
69
+ return keys;
70
+ }
71
+ function _objectSpreadProps(target, source) {
72
+ source = source != null ? source : {};
73
+ if (Object.getOwnPropertyDescriptors) {
74
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
+ } else {
76
+ ownKeys(Object(source)).forEach(function(key) {
77
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
+ });
79
+ }
80
+ return target;
81
+ }
82
+ var __generator = this && this.__generator || function(thisArg, body) {
83
+ var f, y, t, g, _ = {
84
+ label: 0,
85
+ sent: function() {
86
+ if (t[0] & 1) throw t[1];
87
+ return t[1];
88
+ },
89
+ trys: [],
90
+ ops: []
91
+ };
92
+ return g = {
93
+ next: verb(0),
94
+ "throw": verb(1),
95
+ "return": verb(2)
96
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
97
+ return this;
98
+ }), g;
99
+ function verb(n) {
100
+ return function(v) {
101
+ return step([
102
+ n,
103
+ v
104
+ ]);
105
+ };
106
+ }
107
+ function step(op) {
108
+ if (f) throw new TypeError("Generator is already executing.");
109
+ while(_)try {
110
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
111
+ if (y = 0, t) op = [
112
+ op[0] & 2,
113
+ t.value
114
+ ];
115
+ switch(op[0]){
116
+ case 0:
117
+ case 1:
118
+ t = op;
119
+ break;
120
+ case 4:
121
+ _.label++;
122
+ return {
123
+ value: op[1],
124
+ done: false
125
+ };
126
+ case 5:
127
+ _.label++;
128
+ y = op[1];
129
+ op = [
130
+ 0
131
+ ];
132
+ continue;
133
+ case 7:
134
+ op = _.ops.pop();
135
+ _.trys.pop();
136
+ continue;
137
+ default:
138
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
139
+ _ = 0;
140
+ continue;
141
+ }
142
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
143
+ _.label = op[1];
144
+ break;
145
+ }
146
+ if (op[0] === 6 && _.label < t[1]) {
147
+ _.label = t[1];
148
+ t = op;
149
+ break;
150
+ }
151
+ if (t && _.label < t[2]) {
152
+ _.label = t[2];
153
+ _.ops.push(op);
154
+ break;
155
+ }
156
+ if (t[2]) _.ops.pop();
157
+ _.trys.pop();
158
+ continue;
159
+ }
160
+ op = body.call(thisArg, _);
161
+ } catch (e) {
162
+ op = [
163
+ 6,
164
+ e
165
+ ];
166
+ y = 0;
167
+ } finally{
168
+ f = t = 0;
169
+ }
170
+ if (op[0] & 5) throw op[1];
171
+ return {
172
+ value: op[0] ? op[1] : void 0,
173
+ done: true
174
+ };
175
+ }
176
+ };
177
+ function getServerInternalPlugins(api) {
178
+ return _getServerInternalPlugins.apply(this, arguments);
179
+ }
180
+ function _getServerInternalPlugins() {
181
+ _getServerInternalPlugins = _asyncToGenerator(function(api) {
182
+ var hookRunners, ref, serverPlugins, serverInternalPlugins;
183
+ return __generator(this, function(_state) {
184
+ switch(_state.label){
185
+ case 0:
186
+ hookRunners = api.useHookRunners();
187
+ return [
188
+ 4,
189
+ hookRunners.collectServerPlugins({
190
+ plugins: []
191
+ })
192
+ ];
193
+ case 1:
194
+ ref = _state.sent(), serverPlugins = ref.plugins;
195
+ serverInternalPlugins = serverPlugins.reduce(function(result, plugin) {
196
+ return Object.assign(result, plugin);
197
+ }, {});
198
+ api.setAppContext(_objectSpreadProps(_objectSpread({}, api.useAppContext()), {
199
+ serverInternalPlugins: serverInternalPlugins
200
+ }));
201
+ return [
202
+ 2,
203
+ serverInternalPlugins
204
+ ];
205
+ }
206
+ });
207
+ });
208
+ return _getServerInternalPlugins.apply(this, arguments);
209
+ }
210
+ export { getServerInternalPlugins };
@@ -0,0 +1,8 @@
1
+ import type { BuildOptions } from 'esbuild';
2
+ export declare class Builder {
3
+ private buildRes;
4
+ build(options: BuildOptions): Promise<void>;
5
+ stop(): void;
6
+ }
7
+ export declare const loaderBuilder: Builder;
8
+ export declare const serverLoaderBuilder: Builder;
@@ -15,4 +15,16 @@ export declare const FILE_SYSTEM_ROUTES_INDEX = "index";
15
15
  export declare const FILE_SYSTEM_ROUTES_IGNORED_REGEX: RegExp;
16
16
  export declare const HTML_PARTIALS_FOLDER = "html";
17
17
  export declare const HTML_PARTIALS_EXTENSIONS: string[];
18
- export declare const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
18
+ export declare const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
19
+ export declare const NESTED_ROUTE: {
20
+ LAYOUT_FILE: string;
21
+ LAYOUT_LOADER_FILE: string;
22
+ PAGE_FILE: string;
23
+ PAGE_LOADER_FILE: string;
24
+ LOADING_FILE: string;
25
+ ERROR_FILE: string;
26
+ LOADER_FILE: string;
27
+ };
28
+ export declare const APP_CONFIG_NAME = "appConfig";
29
+ export declare const APP_INIT_EXPORTED = "init";
30
+ export declare const APP_INIT_IMPORTED = "appInit";
@@ -39,11 +39,13 @@ export declare const fileSystemRoutes: ({
39
39
  ssrMode,
40
40
  nestedRoutesEntry,
41
41
  entryName,
42
- internalDirectory
42
+ internalDirectory,
43
+ internalDirAlias
43
44
  }: {
44
45
  routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
45
46
  ssrMode: 'string' | 'stream' | false;
46
47
  nestedRoutesEntry?: string | undefined;
47
48
  entryName: string;
48
49
  internalDirectory: string;
50
+ internalDirAlias: string;
49
51
  }) => Promise<string>;
@@ -14,7 +14,8 @@ export declare const getDefaultImports: ({
14
14
  internalDirAlias: string;
15
15
  internalDirectory: string;
16
16
  }) => ImportStatement[];
17
- export declare const isRouteComponentFile: (filePath: string) => boolean;
17
+ export declare const isPageComponentFile: (filePath: string) => boolean;
18
+ export declare const isNestedRouteComponent: (nestedRouteEntries: string[], absoluteFilePath: string) => boolean;
18
19
  export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
19
20
  export declare const parseModule: ({
20
21
  source,
@@ -1,11 +1,11 @@
1
1
  import { BuilderPlugin } from '@modern-js/builder-shared';
2
2
  import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
3
3
  import type { IAppContext, AppNormalizedConfig } from '../../types';
4
- declare type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
5
- declare type FnParameter<T extends {
4
+ type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
5
+ type FnParameter<T extends {
6
6
  [p: string]: (arg: any) => void;
7
7
  }> = { [P in keyof T]: Parameter<T[P]> };
8
- export declare type PluginCompatModernOptions = FnParameter<Partial<Pick<BuilderPluginAPI, 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterStartDevServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeStartDevServer' | 'onDevCompileDone' | 'onExit'>>>;
8
+ export type PluginCompatModernOptions = FnParameter<Partial<Pick<BuilderPluginAPI, 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterStartDevServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeStartDevServer' | 'onDevCompileDone' | 'onExit'>>>;
9
9
  /**
10
10
  * Provides default configuration consistent with modern.js v1
11
11
  */
@@ -3,13 +3,13 @@ import { BuilderConfig, BuilderWebpackProvider } from '@modern-js/builder-webpac
3
3
  import type { IAppContext } from '@modern-js/core';
4
4
  import type { AppNormalizedConfig } from '../types';
5
5
  import { PluginCompatModernOptions } from './builderPlugins/compatModern';
6
- export declare type BuilderOptions = {
6
+ export type BuilderOptions = {
7
7
  target?: BuilderTarget | BuilderTarget[];
8
8
  normalizedConfig: AppNormalizedConfig;
9
9
  appContext: IAppContext;
10
10
  compatPluginConfig?: PluginCompatModernOptions;
11
11
  };
12
- export declare function createBuilderForEdenX({
12
+ export declare function createBuilderForModern({
13
13
  normalizedConfig,
14
14
  appContext,
15
15
  compatPluginConfig
@@ -1,3 +1,3 @@
1
1
  export * from './dev';
2
2
  export * from './build';
3
- export * from './start';
3
+ export * from './serve';
File without changes
@@ -1,7 +1,11 @@
1
- import { CliPlugin } from '@modern-js/core';
1
+ import { Command } from '@modern-js/utils';
2
+ import { CliPlugin, PluginAPI } from '@modern-js/core';
2
3
  import { AppTools } from './types';
3
4
  export * from './defineConfig';
4
5
  export * from './types';
6
+ export type { RuntimeUserConfig } from './types/config';
7
+ export declare const devCommand: (program: Command, api: PluginAPI<AppTools>) => Promise<void>;
8
+ export declare const buildCommand: (program: Command, api: PluginAPI<AppTools>) => Promise<void>;
5
9
 
6
10
  declare const _default: () => CliPlugin<AppTools>;
7
11
 
@@ -12,7 +12,7 @@ export declare const EN_LOCALE: {
12
12
  build: {
13
13
  describe: string;
14
14
  };
15
- start: {
15
+ serve: {
16
16
  describe: string;
17
17
  };
18
18
  deploy: {
@@ -14,7 +14,7 @@ declare const localeKeys: {
14
14
  build: {
15
15
  describe: string;
16
16
  };
17
- start: {
17
+ serve: {
18
18
  describe: string;
19
19
  };
20
20
  deploy: {
@@ -47,7 +47,7 @@ declare const localeKeys: {
47
47
  build: {
48
48
  describe: string;
49
49
  };
50
- start: {
50
+ serve: {
51
51
  describe: string;
52
52
  };
53
53
  deploy: {
@@ -12,7 +12,7 @@ export declare const ZH_LOCALE: {
12
12
  build: {
13
13
  describe: string;
14
14
  };
15
- start: {
15
+ serve: {
16
16
  describe: string;
17
17
  };
18
18
  deploy: {
@@ -1,4 +1,4 @@
1
- export declare type ValidateSchema = {
1
+ export type ValidateSchema = {
2
2
  target: string;
3
3
  schema: any;
4
4
  };
@@ -6,4 +6,4 @@ export interface MicroFrontend {
6
6
  export interface DeployUserConfig {
7
7
  microFrontend?: boolean | MicroFrontend;
8
8
  }
9
- export declare type DeployNormalizedConfig = DeployUserConfig;
9
+ export type DeployNormalizedConfig = DeployUserConfig;
@@ -1,7 +1,7 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
- declare type BuilderEnvConfig = Required<BuilderConfig>['dev'];
3
- export declare type DevProxyOptions = string | Record<string, string>;
4
- export interface DevUserConfig extends Pick<BuilderEnvConfig, 'assetPrefix' | 'https'> {
2
+ type BuilderDevConfig = Required<BuilderConfig>['dev'];
3
+ export type DevProxyOptions = string | Record<string, string>;
4
+ export interface DevUserConfig extends Omit<BuilderDevConfig, 'port'> {
5
5
  /**
6
6
  * The configuration of `dev.proxy` is provided by `proxy` plugin.
7
7
  * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
@@ -9,5 +9,5 @@ export interface DevUserConfig extends Pick<BuilderEnvConfig, 'assetPrefix' | 'h
9
9
  */
10
10
  proxy?: string | Record<string, string>;
11
11
  }
12
- export declare type DevNormalizedConfig = DevUserConfig;
12
+ export type DevNormalizedConfig = DevUserConfig;
13
13
  export {};
@@ -1,4 +1,4 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
- export declare type BuilderExperimentsConfig = Required<BuilderConfig>['experiments'];
3
- export declare type ExperimentsUserConfig = BuilderExperimentsConfig;
4
- export declare type ExperimentsNormalizedConfig = ExperimentsUserConfig;
2
+ export type BuilderExperimentsConfig = Required<BuilderConfig>['experiments'];
3
+ export type ExperimentsUserConfig = BuilderExperimentsConfig;
4
+ export type ExperimentsNormalizedConfig = ExperimentsUserConfig;
@@ -1,4 +1,4 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
- export declare type BuilderHtmlConfig = Required<BuilderConfig>['html'];
3
- export declare type HtmlUserConfig = BuilderHtmlConfig;
4
- export declare type HtmlNormalizedConfig = HtmlUserConfig;
2
+ export type BuilderHtmlConfig = Required<BuilderConfig>['html'];
3
+ export type HtmlUserConfig = BuilderHtmlConfig;
4
+ export type HtmlNormalizedConfig = HtmlUserConfig;
@@ -1,5 +1,6 @@
1
1
  import type { UserConfig } from '@modern-js/core';
2
2
  import type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig } from '@modern-js/server-core';
3
+ import type { BuilderPlugin } from '@modern-js/builder-webpack-provider';
3
4
  import type { AppToolsHooks } from '../hooks';
4
5
  import type { OutputNormalizedConfig, OutputUserConfig } from './output';
5
6
  import type { SourceNormalizedConfig, SourceUserConfig } from './source';
@@ -17,8 +18,8 @@ export interface RuntimeUserConfig {
17
18
  export interface RuntimeByEntriesUserConfig {
18
19
  [name: string]: RuntimeUserConfig;
19
20
  }
20
- export declare type RuntimeNormalizedConfig = RuntimeUserConfig;
21
- export declare type RuntimeByEntriesNormalizedConfig = RuntimeByEntriesUserConfig;
21
+ export type RuntimeNormalizedConfig = RuntimeUserConfig;
22
+ export type RuntimeByEntriesNormalizedConfig = RuntimeByEntriesUserConfig;
22
23
  export interface AppToolsUserConfig {
23
24
  source?: SourceUserConfig;
24
25
  output?: OutputUserConfig;
@@ -32,6 +33,7 @@ export interface AppToolsUserConfig {
32
33
  runtimeByEntries?: RuntimeByEntriesUserConfig;
33
34
  performance?: PerformanceUserConfig;
34
35
  experiments?: ExperimentsUserConfig;
36
+ builderPlugins?: BuilderPlugin[];
35
37
  /**
36
38
  * The configuration of `bff` is provided by `bff` plugin.
37
39
  * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
@@ -40,7 +42,7 @@ export interface AppToolsUserConfig {
40
42
 
41
43
  bff?: BffUserConfig;
42
44
  }
43
- export declare type AppToolsNormalizedConfig = {
45
+ export type AppToolsNormalizedConfig = {
44
46
  source: SourceNormalizedConfig;
45
47
  bff: BffNormalizedConfig;
46
48
  dev: DevNormalizedConfig;
@@ -54,6 +56,7 @@ export declare type AppToolsNormalizedConfig = {
54
56
  tools: ToolsNormalizedConfig;
55
57
  performance: PerformanceNormalizedConfig;
56
58
  experiments: ExperimentsNormalizedConfig;
59
+ builderPlugins: BuilderPlugin[];
57
60
  cliOptions?: Record<string, any>;
58
61
  _raw: UserConfig<{
59
62
  hooks: AppToolsHooks;
@@ -1,22 +1,22 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
- export declare type BuilderOutputConfig = Required<BuilderConfig>['output'];
2
+ export type BuilderOutputConfig = Required<BuilderConfig>['output'];
3
3
  export interface OutputUserConfig extends BuilderOutputConfig {
4
4
  ssg?: SSGConfig;
5
5
  disableNodePolyfill?: boolean;
6
6
  }
7
- export declare type OutputNormalizedConfig = OutputUserConfig;
8
- export declare type SSGRouteOptions = string | {
7
+ export type OutputNormalizedConfig = OutputUserConfig;
8
+ export type SSGRouteOptions = string | {
9
9
  url: string;
10
10
  output?: string;
11
11
  params?: Record<string, any>[];
12
12
  headers?: Record<string, any>;
13
13
  };
14
- export declare type SSGSingleEntryOptions = boolean | {
14
+ export type SSGSingleEntryOptions = boolean | {
15
15
  preventDefault?: string[];
16
16
  headers?: Record<string, any>;
17
17
  routes?: SSGRouteOptions[];
18
18
  };
19
- export declare type SSGMultiEntryOptions = Record<string, SSGSingleEntryOptions>;
20
- export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string, payload: {
19
+ export type SSGMultiEntryOptions = Record<string, SSGSingleEntryOptions>;
20
+ export type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string, payload: {
21
21
  baseUrl?: string;
22
22
  }) => SSGSingleEntryOptions);
@@ -1,4 +1,4 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
- export declare type BuilderPerformanceConfig = Required<BuilderConfig>['performance'];
3
- export declare type PerformanceUserConfig = BuilderPerformanceConfig;
4
- export declare type PerformanceNormalizedConfig = PerformanceUserConfig;
2
+ export type BuilderPerformanceConfig = Required<BuilderConfig>['performance'];
3
+ export type PerformanceUserConfig = BuilderPerformanceConfig;
4
+ export type PerformanceNormalizedConfig = PerformanceUserConfig;
@@ -1,4 +1,4 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
- export declare type BuilderSecurityConfig = Required<BuilderConfig>['security'];
3
- export declare type SecurityUserConfig = BuilderSecurityConfig;
4
- export declare type SecurityNormalizedConfig = SecurityUserConfig;
2
+ export type BuilderSecurityConfig = Required<BuilderConfig>['security'];
3
+ export type SecurityUserConfig = BuilderSecurityConfig;
4
+ export type SecurityNormalizedConfig = SecurityUserConfig;
@@ -1,16 +1,17 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
- export declare type BuilderSourceConfig = Required<BuilderConfig>['source'];
3
- export declare type Entry = string | {
2
+ export type BuilderSourceConfig = Required<BuilderConfig>['source'];
3
+ export type Entry = string | {
4
4
  entry: string;
5
- enableFileSystemRoutes?: boolean;
6
5
  disableMount?: boolean;
6
+ customBootstrap?: string;
7
7
  };
8
- export declare type Entries = Record<string, Entry>;
8
+ export type Entries = Record<string, Entry>;
9
9
  export interface SourceUserConfig extends BuilderSourceConfig {
10
10
  entries?: Entries;
11
11
  enableAsyncEntry?: boolean;
12
12
  disableDefaultEntries?: boolean;
13
13
  entriesDir?: string;
14
+ disableEntryDirs?: string[];
14
15
  configDir?: string;
15
16
  /**
16
17
  * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
@@ -20,4 +21,4 @@ export interface SourceUserConfig extends BuilderSourceConfig {
20
21
 
21
22
  designSystem?: Record<string, any>;
22
23
  }
23
- export declare type SourceNormalizedConfig = SourceUserConfig;
24
+ export type SourceNormalizedConfig = SourceUserConfig;
@@ -2,14 +2,14 @@ import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
2
  import type { JestConfig } from '@modern-js/core';
3
3
  import type { PluginSwcOptions } from '@modern-js/builder-plugin-swc';
4
4
  import type { PluginEsbuildOptions } from '@modern-js/builder-plugin-esbuild';
5
- export declare type BuilderToolsConfig = Required<BuilderConfig>['tools'];
5
+ export type BuilderToolsConfig = Required<BuilderConfig>['tools'];
6
6
  /**
7
7
  * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
8
8
  * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
9
9
  * @requires `tailwindcss` plugin
10
10
  */
11
11
 
12
- export declare type Tailwindcss = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
12
+ export type Tailwindcss = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
13
13
  export interface ToolsUserConfig extends BuilderToolsConfig {
14
14
  tailwindcss?: Tailwindcss;
15
15
  jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
@@ -21,4 +21,4 @@ export interface ToolsUserConfig extends BuilderToolsConfig {
21
21
 
22
22
  swc?: PluginSwcOptions;
23
23
  }
24
- export declare type ToolsNormalizedConfig = ToolsUserConfig;
24
+ export type ToolsNormalizedConfig = ToolsUserConfig;
@@ -1,6 +1,7 @@
1
1
  import type { webpack } from '@modern-js/builder-webpack-provider';
2
2
  import type { AsyncWaterfall, AsyncWorkflow, ParallelWorkflow } from '@modern-js/plugin';
3
3
  import type { Entrypoint, HtmlPartials, NestedRoute, PageRoute, RouteLegacy, ServerRoute } from '@modern-js/types';
4
+ import type { RegisterBuildPlatformResult, DevToolData } from '@modern-js/core';
4
5
  import type { Stats, MultiStats } from '@modern-js/builder-shared';
5
6
  export interface ImportSpecifier {
6
7
  local?: string;
@@ -16,7 +17,7 @@ export interface RuntimePlugin {
16
17
  options: string;
17
18
  args?: string;
18
19
  }
19
- export declare type AppToolsHooks = {
20
+ export type AppToolsHooks = {
20
21
  modifyEntryExport: AsyncWaterfall<{
21
22
  entrypoint: Entrypoint;
22
23
  exportStatement: string;
@@ -53,6 +54,9 @@ export declare type AppToolsHooks = {
53
54
  code: string;
54
55
  }>;
55
56
  addDefineTypes: AsyncWaterfall<void>;
57
+ collectServerPlugins: AsyncWaterfall<{
58
+ plugins: Array<Record<string, string>>;
59
+ }>;
56
60
  beforeDev: AsyncWorkflow<void, unknown>;
57
61
  afterDev: AsyncWorkflow<void, unknown>;
58
62
  beforeCreateCompiler: AsyncWorkflow<{
@@ -78,4 +82,8 @@ export declare type AppToolsHooks = {
78
82
  eventType: 'add' | 'change' | 'unlink';
79
83
  }, void>;
80
84
  beforeRestart: AsyncWorkflow<void, void>;
85
+ registerDev: ParallelWorkflow<void, DevToolData>;
86
+ beforeDevTask: ParallelWorkflow<DevToolData, void>;
87
+ registerBuildPlatform: ParallelWorkflow<void, RegisterBuildPlatformResult>;
88
+ beforeBuildPlatform: ParallelWorkflow<RegisterBuildPlatformResult[], void>;
81
89
  };
@@ -7,17 +7,17 @@ export * from './config';
7
7
  export * from './legacyConfig';
8
8
  export type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig, SSR, SSRByEntries } from '@modern-js/server-core';
9
9
  export type { IAppContext, PluginAPI, CliPlugin, NormalizedConfig, UserConfig } from '@modern-js/core';
10
- export declare type AppTools = {
10
+ export type AppTools = {
11
11
  hooks: AppToolsHooks;
12
12
  userConfig: AppToolsUserConfig;
13
13
  normalizedConfig: AppToolsNormalizedConfig;
14
14
  };
15
- export declare type LegacyAppTools = {
15
+ export type LegacyAppTools = {
16
16
  hooks: AppToolsHooks;
17
17
  userConfig: AppToolsLegacyUserConfig;
18
18
  normalizedConfig: AppToolsLegacyNormalizedConfig;
19
19
  };
20
- export declare type AppNormalizedConfig = NormalizedConfig<AppTools>;
21
- export declare type AppLegacyNormalizedConfig = NormalizedConfig<LegacyAppTools>;
22
- export declare type AppUserConfig = UserConfig<AppTools>;
23
- export declare type AppLegacyUserConfig = UserConfig<LegacyAppTools>;
20
+ export type AppNormalizedConfig = NormalizedConfig<AppTools>;
21
+ export type AppLegacyNormalizedConfig = NormalizedConfig<LegacyAppTools>;
22
+ export type AppUserConfig = UserConfig<AppTools>;
23
+ export type AppLegacyUserConfig = UserConfig<LegacyAppTools>;