@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,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
+ }();
@@ -0,0 +1,45 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { cli } from '@modern-js/core';
4
+ import { logger, program } from '@modern-js/utils';
5
+ export function restart(_x) {
6
+ return _restart.apply(this, arguments);
7
+ }
8
+ function _restart() {
9
+ _restart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(hooksRunner) {
10
+ var hasGetError;
11
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
12
+ while (1) {
13
+ switch (_context.prev = _context.next) {
14
+ case 0:
15
+ logger.info('Restart...\n');
16
+ hasGetError = false;
17
+ _context.next = 4;
18
+ return hooksRunner.beforeRestart();
19
+ case 4:
20
+ _context.prev = 4;
21
+ _context.next = 7;
22
+ return cli.init(cli.initOptions);
23
+ case 7:
24
+ _context.next = 13;
25
+ break;
26
+ case 9:
27
+ _context.prev = 9;
28
+ _context.t0 = _context["catch"](4);
29
+ console.error(_context.t0);
30
+ hasGetError = true;
31
+ case 13:
32
+ _context.prev = 13;
33
+ if (!hasGetError) {
34
+ program.parse(process.argv);
35
+ }
36
+ return _context.finish(13);
37
+ case 16:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }
42
+ }, _callee, null, [[4, 9, 13, 16]]);
43
+ }));
44
+ return _restart.apply(this, arguments);
45
+ }
@@ -1,4 +1,5 @@
1
- import { IAppContext, NormalizedConfig, PluginAPI, ImportStatement } from '@modern-js/core';
1
+ import { IAppContext, PluginAPI } from '@modern-js/core';
2
2
  import type { Entrypoint } from '@modern-js/types';
3
+ import { AppNormalizedConfig, AppTools, ImportStatement } from '../types';
3
4
  export declare const createImportStatements: (statements: ImportStatement[]) => string;
4
- export declare const generateCode: (appContext: IAppContext, config: NormalizedConfig, entrypoints: Entrypoint[], api: PluginAPI) => Promise<void>;
5
+ export declare const generateCode: (appContext: IAppContext, config: AppNormalizedConfig, entrypoints: Entrypoint[], api: PluginAPI<AppTools>) => Promise<void>;
@@ -1,3 +1,3 @@
1
- import type { IAppContext, NormalizedConfig } from '@modern-js/core';
2
1
  import type { Entrypoint } from '@modern-js/types';
3
- export declare const getBundleEntry: (appContext: IAppContext, config: NormalizedConfig) => Entrypoint[];
2
+ import type { AppNormalizedConfig, IAppContext } from '../types';
3
+ export declare const getBundleEntry: (appContext: IAppContext, config: AppNormalizedConfig) => Entrypoint[];
@@ -1,4 +1,4 @@
1
- import type { NormalizedConfig, IAppContext } from '@modern-js/core';
2
1
  import type { Entrypoint } from '@modern-js/types';
2
+ import type { AppNormalizedConfig, IAppContext } from '../types';
3
3
  export type { Entrypoint };
4
- export declare const getFileSystemEntry: (appContext: IAppContext, config: NormalizedConfig) => Entrypoint[];
4
+ export declare const getFileSystemEntry: (appContext: IAppContext, config: AppNormalizedConfig) => Entrypoint[];
@@ -1,9 +1,9 @@
1
- import type { IAppContext, NormalizedConfig, PluginAPI } from '@modern-js/core';
2
1
  import type { Entrypoint, HtmlTemplates } from '@modern-js/types';
3
- export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI, {
2
+ import type { AppNormalizedConfig, AppTools, IAppContext, PluginAPI } from '../types';
3
+ export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI<AppTools>, {
4
4
  appContext,
5
5
  config
6
6
  }: {
7
7
  appContext: IAppContext;
8
- config: NormalizedConfig;
8
+ config: AppNormalizedConfig;
9
9
  }) => Promise<HtmlTemplates>;
@@ -1,9 +1,10 @@
1
- import type { NormalizedConfig, IAppContext } from '@modern-js/core';
1
+ import type { IAppContext } from '@modern-js/core';
2
2
  import type { Entrypoint, ServerRoute } from '@modern-js/types';
3
+ import type { AppNormalizedConfig } from '../types';
3
4
  export declare const getServerRoutes: (entrypoints: Entrypoint[], {
4
5
  appContext,
5
6
  config
6
7
  }: {
7
8
  appContext: IAppContext;
8
- config: NormalizedConfig;
9
+ config: AppNormalizedConfig;
9
10
  }) => ServerRoute[];
@@ -1,42 +1,4 @@
1
- import type { CliPlugin, RuntimePlugin, ImportStatement } from '@modern-js/core';
2
- import type { RouteLegacy, Entrypoint, ServerRoute, HtmlPartials, NestedRoute, PageRoute } from '@modern-js/types';
3
- import type { AppHooks } from '../hooks';
4
- export declare const modifyEntryImports: import("@modern-js/plugin").AsyncWaterfall<{
5
- imports: ImportStatement[];
6
- entrypoint: Entrypoint;
7
- }>;
8
- export declare const modifyEntryExport: import("@modern-js/plugin").AsyncWaterfall<{
9
- entrypoint: Entrypoint;
10
- exportStatement: string;
11
- }>;
12
- export declare const addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
13
- export declare const modifyEntryRuntimePlugins: import("@modern-js/plugin").AsyncWaterfall<{
14
- entrypoint: Entrypoint;
15
- plugins: RuntimePlugin[];
16
- }>;
17
- export declare const modifyEntryRenderFunction: import("@modern-js/plugin").AsyncWaterfall<{
18
- entrypoint: Entrypoint;
19
- code: string;
20
- }>;
21
- export declare const modifyAsyncEntry: import("@modern-js/plugin").AsyncWaterfall<{
22
- entrypoint: Entrypoint;
23
- code: string;
24
- }>;
25
- export declare const modifyFileSystemRoutes: import("@modern-js/plugin").AsyncWaterfall<{
26
- entrypoint: Entrypoint;
27
- routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
28
- }>;
29
- export declare const modifyServerRoutes: import("@modern-js/plugin").AsyncWaterfall<{
30
- routes: ServerRoute[];
31
- }>;
32
- export declare const htmlPartials: import("@modern-js/plugin").AsyncWaterfall<{
33
- entrypoint: Entrypoint;
34
- partials: HtmlPartials;
35
- }>;
36
- export declare const beforeGenerateRoutes: import("@modern-js/plugin").AsyncWaterfall<{
37
- entrypoint: Entrypoint;
38
- code: string;
39
- }>;
40
- export declare const addDefineTypes: import("@modern-js/plugin").AsyncWaterfall<void>;
41
- declare const _default: () => CliPlugin<AppHooks>;
1
+ import type { CliPlugin } from '@modern-js/core';
2
+ import { AppTools } from '../types';
3
+ declare const _default: () => CliPlugin<AppTools>;
42
4
  export default _default;
@@ -1,5 +1,5 @@
1
- import type { RuntimePlugin } from '@modern-js/core';
2
1
  import type { Entrypoint, NestedRoute, PageRoute, RouteLegacy } from '@modern-js/types';
2
+ import type { RuntimePlugin } from '../types';
3
3
  export declare const index: ({
4
4
  mountId,
5
5
  imports,
@@ -1,5 +1,5 @@
1
1
  import type { Entrypoint } from '@modern-js/types';
2
- import type { ImportStatement } from '@modern-js/core';
2
+ import type { ImportStatement } from '../types';
3
3
  export declare const walkDirectory: (dir: string) => string[];
4
4
  export declare const getDefaultImports: ({
5
5
  entrypoint,
@@ -1,6 +1,6 @@
1
1
  import { BuilderPlugin } from '@modern-js/builder-shared';
2
2
  import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
3
- import type { IAppContext, NormalizedConfig } from '@modern-js/core';
3
+ import type { IAppContext, AppNormalizedConfig } from '../../types';
4
4
  declare type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
5
5
  declare type FnParameter<T extends {
6
6
  [p: string]: (arg: any) => void;
@@ -9,5 +9,5 @@ export declare type PluginCompatModernOptions = FnParameter<Partial<Pick<Builder
9
9
  /**
10
10
  * Provides default configuration consistent with `@modern-js/webpack`
11
11
  */
12
- export declare const PluginCompatModern: (appContext: IAppContext, modernConfig: NormalizedConfig, options?: PluginCompatModernOptions) => BuilderPlugin<BuilderPluginAPI>;
12
+ export declare const PluginCompatModern: (appContext: IAppContext, modernConfig: AppNormalizedConfig, options?: PluginCompatModernOptions) => BuilderPlugin<BuilderPluginAPI>;
13
13
  export {};
@@ -1,9 +1,11 @@
1
1
  import { BuilderInstance, BuilderTarget, CreateBuilderOptions } from '@modern-js/builder';
2
- import type { IAppContext, NormalizedConfig } from '@modern-js/core';
2
+ import { BuilderConfig } from '@modern-js/builder-webpack-provider';
3
+ import type { IAppContext } from '@modern-js/core';
4
+ import type { AppNormalizedConfig } from '../types';
3
5
  import { PluginCompatModernOptions } from './builderPlugins/compatModern';
4
6
  export declare type BuilderOptions = {
5
7
  target?: BuilderTarget | BuilderTarget[];
6
- normalizedConfig: NormalizedConfig;
8
+ normalizedConfig: AppNormalizedConfig;
7
9
  appContext: IAppContext;
8
10
  compatPluginConfig?: PluginCompatModernOptions;
9
11
  };
@@ -12,4 +14,5 @@ export declare function createBuilderForEdenX({
12
14
  appContext,
13
15
  compatPluginConfig
14
16
  }: BuilderOptions): Promise<BuilderInstance>;
17
+ export declare function createBuilderProviderConfig(normalizedConfig: AppNormalizedConfig, appContext: IAppContext): BuilderConfig;
15
18
  export declare function createBuilderOptions(target: BuilderTarget | BuilderTarget[], appContext: IAppContext): CreateBuilderOptions;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { WebpackChain } from '@modern-js/builder-webpack-provider';
3
- import { IAppContext, NormalizedConfig } from '@modern-js/core';
4
- export declare function createCopyPattern(appContext: IAppContext, config: NormalizedConfig, patternsType: 'upload' | 'public', chain?: WebpackChain): {
3
+ import { AppNormalizedConfig, IAppContext } from '../types';
4
+ export declare function createCopyPattern(appContext: IAppContext, config: AppNormalizedConfig, patternsType: 'upload' | 'public', chain?: WebpackChain): {
5
5
  info: (file: {
6
6
  sourceFilename: string;
7
7
  }) => {
@@ -1,4 +1,4 @@
1
1
  import { PluginAPI } from '@modern-js/core';
2
2
  import type { BuildOptions } from '../utils/types';
3
- import type { AppHooks } from '../hooks';
4
- export declare const build: (api: PluginAPI<AppHooks>, options?: BuildOptions) => Promise<void>;
3
+ import type { AppTools } from '../types';
4
+ export declare const build: (api: PluginAPI<AppTools>, options?: BuildOptions) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
- import type { AppHooks } from '../hooks';
3
- export declare const deploy: (api: PluginAPI<AppHooks>, options: any) => Promise<void>;
2
+ import type { AppTools } from '../types';
3
+ export declare const deploy: (api: PluginAPI<AppTools>, options: any) => Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import { PluginAPI } from '@modern-js/core';
2
2
  import { DevOptions } from '../utils/types';
3
- import type { AppHooks } from '../hooks';
4
- export declare const dev: (api: PluginAPI<AppHooks>, options: DevOptions) => Promise<void>;
3
+ import type { AppTools } from '../types';
4
+ export declare const dev: (api: PluginAPI<AppTools>, options: DevOptions) => Promise<void>;
@@ -1,3 +1,11 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
2
  import type { InspectOptions } from '../utils/types';
3
- export declare const inspect: (api: PluginAPI, options: InspectOptions) => Promise<any>;
3
+ import type { AppTools } from '../types';
4
+ export declare const inspect: (api: PluginAPI<AppTools>, options: InspectOptions) => Promise<{
5
+ builderConfig: string;
6
+ bundlerConfigs: string[];
7
+ origin: {
8
+ builderConfig: Record<string, any>;
9
+ bundlerConfigs: Record<string, any>[];
10
+ };
11
+ }>;
@@ -1,3 +1,3 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
- import type { AppHooks } from '../hooks';
3
- export declare const start: (api: PluginAPI<AppHooks>) => Promise<void>;
2
+ import type { AppTools } from '../types';
3
+ export declare const start: (api: PluginAPI<AppTools>) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { IAppContext, AppUserConfig, AppLegacyUserConfig } from '../types';
2
+ export declare function createDefaultConfig(appContext: IAppContext): AppUserConfig;
3
+ export declare function createLegacyDefaultConfig(appContext: IAppContext): AppLegacyUserConfig;
@@ -0,0 +1,2 @@
1
+ export { createDefaultConfig, createLegacyDefaultConfig } from './default';
2
+ export { initialNormalizedConfig, checkIsLegacyConfig } from './initial';
@@ -0,0 +1,2 @@
1
+ import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
+ export declare function createHtmlConfig(config: Readonly<AppLegacyNormalizedConfig>): AppNormalizedConfig['html'];
@@ -0,0 +1,2 @@
1
+ import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
+ export declare function createOutputConfig(config: Readonly<AppLegacyNormalizedConfig>): AppNormalizedConfig['output'];
@@ -0,0 +1,2 @@
1
+ import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
+ export declare function createSourceConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig['source'];
@@ -0,0 +1,2 @@
1
+ import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
+ export declare function createToolsConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig['tools'];
@@ -0,0 +1,4 @@
1
+ import { AppNormalizedConfig, IAppContext, AppLegacyUserConfig, AppUserConfig } from '../../types';
2
+ export { transformNormalizedConfig } from './transformNormalizedConfig';
3
+ export declare function checkIsLegacyConfig(config: AppLegacyUserConfig | AppUserConfig): config is AppLegacyUserConfig;
4
+ export declare function initialNormalizedConfig(config: AppNormalizedConfig, appContext: IAppContext): AppNormalizedConfig;
@@ -0,0 +1,4 @@
1
+ import { AppNormalizedConfig, IAppContext } from '../../types';
2
+ export declare function initHtmlConfig(config: AppNormalizedConfig, appContext: IAppContext): import("@modern-js/builder-shared").SharedHtmlConfig;
3
+ export declare function initSourceConfig(config: AppNormalizedConfig, appContext: IAppContext): void;
4
+ export declare function initToolsConfig(config: AppNormalizedConfig): void;
@@ -0,0 +1,2 @@
1
+ import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
+ export declare function transformNormalizedConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig;
@@ -0,0 +1,7 @@
1
+ import { AppUserConfig, AppLegacyUserConfig } from './types';
2
+ export declare const defineConfig: (config: AppUserConfig) => AppUserConfig;
3
+ /**
4
+ * @deprecated
5
+ * Using defineConfig first.
6
+ */
7
+ export declare const defineLegacyConfig: (config: AppLegacyUserConfig) => AppLegacyUserConfig;
@@ -1,42 +1,2 @@
1
- import type { webpack } from '@modern-js/builder-webpack-provider/types';
2
- export declare const beforeDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
3
- export declare const afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
4
- export declare const beforeCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
5
- bundlerConfigs: webpack.Configuration[];
6
- }, unknown>;
7
- export declare const afterCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
8
- compiler: webpack.Compiler | webpack.MultiCompiler | undefined;
9
- }, unknown>;
10
- export declare const beforePrintInstructions: import("@modern-js/plugin").AsyncWaterfall<{
11
- instructions: string;
12
- }>;
13
- export declare const beforeBuild: import("@modern-js/plugin").AsyncWorkflow<{
14
- bundlerConfigs?: webpack.Configuration[] | undefined;
15
- }, unknown>;
16
- export declare const afterBuild: import("@modern-js/plugin").AsyncWorkflow<{
17
- stats?: webpack.Stats | webpack.MultiStats | undefined;
18
- }, unknown>;
19
- export declare const beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
20
- export declare const afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
21
- export declare const hooks: {
22
- beforeDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
23
- afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
24
- beforeCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
25
- bundlerConfigs: webpack.Configuration[];
26
- }, unknown>;
27
- afterCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
28
- compiler: webpack.Compiler | webpack.MultiCompiler | undefined;
29
- }, unknown>;
30
- beforePrintInstructions: import("@modern-js/plugin").AsyncWaterfall<{
31
- instructions: string;
32
- }>;
33
- beforeBuild: import("@modern-js/plugin").AsyncWorkflow<{
34
- bundlerConfigs?: webpack.Configuration[] | undefined;
35
- }, unknown>;
36
- afterBuild: import("@modern-js/plugin").AsyncWorkflow<{
37
- stats?: webpack.Stats | webpack.MultiStats | undefined;
38
- }, unknown>;
39
- beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
40
- afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
41
- };
42
- export declare type AppHooks = typeof hooks;
1
+ import { AppToolsHooks } from './types/hooks';
2
+ export declare const hooks: AppToolsHooks;
@@ -1,6 +1,6 @@
1
- import { defineConfig, CliPlugin } from '@modern-js/core';
2
- import { hooks, AppHooks } from './hooks';
3
- export { defineConfig, hooks };
4
- export type { AppHooks, CliPlugin };
5
- declare const _default: () => CliPlugin<AppHooks>;
1
+ import { CliPlugin } from '@modern-js/core';
2
+ import { AppTools } from './types';
3
+ export * from './defineConfig';
4
+ export * from './types';
5
+ declare const _default: () => CliPlugin<AppTools>;
6
6
  export default _default;
@@ -0,0 +1,3 @@
1
+ import { CliPlugin, AppTools } from '../types';
2
+ declare const _default: () => CliPlugin<AppTools>;
3
+ export default _default;
@@ -0,0 +1,14 @@
1
+ export declare type ValidateSchema = {
2
+ target: string;
3
+ schema: any;
4
+ };
5
+ export declare class Schema extends Map<string, any> {
6
+ private schema;
7
+ constructor(baseSchema?: Record<string, any>);
8
+ setSchema(key: string, object: Record<string, any>): this;
9
+ set(key: string, value: any): this;
10
+ has(key: string): boolean;
11
+ get(key: string): any;
12
+ delete(key: string): boolean;
13
+ generate(): ValidateSchema[];
14
+ }
@@ -0,0 +1,4 @@
1
+ import { Schema } from './Schema';
2
+ declare const schema: Schema;
3
+ export { default as legacySchema } from './legacy';
4
+ export { schema };
@@ -0,0 +1,3 @@
1
+ import { Schema } from './Schema';
2
+ declare const schema: Schema;
3
+ export default schema;
@@ -0,0 +1,9 @@
1
+ export interface MicroFrontend {
2
+ enableHtmlEntry?: boolean;
3
+ externalBasicLibrary?: boolean;
4
+ moduleApp?: string;
5
+ }
6
+ export interface DeployUserConfig {
7
+ microFrontend?: boolean | MicroFrontend;
8
+ }
9
+ export declare type DeployNormalizedConfig = DeployUserConfig;
@@ -0,0 +1,13 @@
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'> {
5
+ /**
6
+ * The configuration of `dev.proxy` is provided by `proxy` plugin.
7
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
8
+ * @requires `proxy` plugin
9
+ */
10
+ proxy?: string | Record<string, string>;
11
+ }
12
+ export declare type DevNormalizedConfig = DevUserConfig;
13
+ export {};
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,62 @@
1
+ import type { UserConfig } from '@modern-js/core';
2
+ import type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig } from '@modern-js/server-core';
3
+ import type { AppToolsHooks } from '../hooks';
4
+ import type { OutputNormalizedConfig, OutputUserConfig } from './output';
5
+ import type { SourceNormalizedConfig, SourceUserConfig } from './source';
6
+ import type { DevNormalizedConfig, DevUserConfig } from './dev';
7
+ import type { ToolsNormalizedConfig, ToolsUserConfig } from './tools';
8
+ import type { HtmlNormalizedConfig, HtmlUserConfig } from './html';
9
+ import type { SecurityNormalizedConfig, SecurityUserConfig } from './security';
10
+ import type { DeployNormalizedConfig, DeployUserConfig } from './deploy';
11
+ import type { ExperimentsUserConfig, ExperimentsNormalizedConfig } from './experiments';
12
+ import type { PerformanceNormalizedConfig, PerformanceUserConfig } from './performance';
13
+ export * from './output';
14
+ export interface RuntimeUserConfig {
15
+ [name: string]: any;
16
+ }
17
+ export interface RuntimeByEntriesUserConfig {
18
+ [name: string]: RuntimeUserConfig;
19
+ }
20
+ export declare type RuntimeNormalizedConfig = RuntimeUserConfig;
21
+ export declare type RuntimeByEntriesNormalizedConfig = RuntimeByEntriesUserConfig;
22
+ export interface AppToolsUserConfig {
23
+ source?: SourceUserConfig;
24
+ output?: OutputUserConfig;
25
+ server?: ServerUserConfig;
26
+ dev?: DevUserConfig;
27
+ deploy?: DeployUserConfig;
28
+ html?: HtmlUserConfig;
29
+ tools?: ToolsUserConfig;
30
+ runtime?: RuntimeUserConfig;
31
+ security?: SecurityUserConfig;
32
+ runtimeByEntries?: RuntimeByEntriesUserConfig;
33
+ performance?: PerformanceUserConfig;
34
+ experiments?: ExperimentsUserConfig;
35
+ /**
36
+ * The configuration of `bff` is provided by `bff` plugin.
37
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
38
+ * @requires `bff` plugin
39
+ */
40
+ bff?: BffUserConfig;
41
+ }
42
+ export declare type AppToolsNormalizedConfig = {
43
+ source: SourceNormalizedConfig;
44
+ bff: BffNormalizedConfig;
45
+ dev: DevNormalizedConfig;
46
+ deploy: DeployNormalizedConfig;
47
+ html: HtmlNormalizedConfig;
48
+ runtime: RuntimeNormalizedConfig;
49
+ runtimeByEntries: RuntimeByEntriesNormalizedConfig;
50
+ output: OutputNormalizedConfig;
51
+ security: SecurityNormalizedConfig;
52
+ server: ServerNormalizedConfig;
53
+ tools: ToolsNormalizedConfig;
54
+ performance: PerformanceNormalizedConfig;
55
+ experiments: ExperimentsNormalizedConfig;
56
+ cliOptions?: Record<string, any>;
57
+ _raw: UserConfig<{
58
+ hooks: AppToolsHooks;
59
+ userConfig: AppToolsUserConfig;
60
+ normalizedConfig: AppToolsNormalizedConfig;
61
+ }>;
62
+ };