@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
@@ -1,58 +1,17 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
8
  var __getProtoOf = Object.getPrototypeOf;
6
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
- var stdin_exports = {};
26
- __export(stdin_exports, {
27
- default: () => src_default
28
- });
29
- module.exports = __toCommonJS(stdin_exports);
30
- var import_path = __toESM(require("path"));
31
- var import_plugin_lint = __toESM(require("@modern-js/plugin-lint"));
32
- var import_utils = require("@modern-js/utils");
33
- var import_analyze = __toESM(require("./analyze"));
34
- var import_initialize = __toESM(require("./initialize"));
35
- var import_hooks = require("./hooks");
36
- var import_locale = require("./locale");
37
- var import_language = require("./utils/language");
38
- var import_commands = require("./utils/commands");
39
- var import_restart = require("./utils/restart");
40
- __reExport(stdin_exports, require("./defineConfig"), module.exports);
41
- __reExport(stdin_exports, require("./types"), module.exports);
42
- var __create2 = Object.create;
43
- var __defProp2 = Object.defineProperty;
44
- var __defProps = Object.defineProperties;
45
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
46
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
47
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
48
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
49
- var __getProtoOf2 = Object.getPrototypeOf;
50
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
51
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
52
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
53
12
  var __spreadValues = (a, b) => {
54
13
  for (var prop in b || (b = {}))
55
- if (__hasOwnProp2.call(b, prop))
14
+ if (__hasOwnProp.call(b, prop))
56
15
  __defNormalProp(a, prop, b[prop]);
57
16
  if (__getOwnPropSymbols)
58
17
  for (var prop of __getOwnPropSymbols(b)) {
@@ -62,18 +21,24 @@ var __spreadValues = (a, b) => {
62
21
  return a;
63
22
  };
64
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
65
- var __copyProps2 = (to, from, except, desc) => {
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
66
29
  if (from && typeof from === "object" || typeof from === "function") {
67
- for (let key of __getOwnPropNames2(from))
68
- if (!__hasOwnProp2.call(to, key) && key !== except)
69
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
70
33
  }
71
34
  return to;
72
35
  };
73
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
74
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
36
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
75
39
  mod
76
40
  ));
41
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
77
42
  var __async = (__this, __arguments, generator) => {
78
43
  return new Promise((resolve, reject) => {
79
44
  var fulfilled = (value) => {
@@ -94,10 +59,75 @@ var __async = (__this, __arguments, generator) => {
94
59
  step((generator = generator.apply(__this, __arguments)).next());
95
60
  });
96
61
  };
62
+ var src_exports = {};
63
+ __export(src_exports, {
64
+ buildCommand: () => buildCommand,
65
+ default: () => src_default,
66
+ devCommand: () => devCommand
67
+ });
68
+ module.exports = __toCommonJS(src_exports);
69
+ var import_path = __toESM(require("path"));
70
+ var import_plugin_lint = __toESM(require("@modern-js/plugin-lint"));
71
+ var import_utils = require("@modern-js/utils");
72
+ var import_lodash = require("@modern-js/utils/lodash");
73
+ var import_analyze = __toESM(require("./analyze"));
74
+ var import_initialize = __toESM(require("./initialize"));
75
+ var import_hooks = require("./hooks");
76
+ var import_locale = require("./locale");
77
+ var import_language = require("./utils/language");
78
+ var import_commands = require("./utils/commands");
79
+ var import_restart = require("./utils/restart");
80
+ __reExport(src_exports, require("./defineConfig"), module.exports);
81
+ __reExport(src_exports, require("./types"), module.exports);
97
82
  const upgradeModel = import_utils.Import.lazy(
98
83
  "@modern-js/upgrade",
99
84
  require
100
85
  );
86
+ const devCommand = (program, api) => __async(void 0, null, function* () {
87
+ const runner = api.useHookRunners();
88
+ const devToolMetas = yield runner.registerDev();
89
+ const devProgram = program.command("dev").alias("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).action((options) => __async(void 0, null, function* () {
90
+ const { dev } = yield Promise.resolve().then(() => __toESM(require("./commands/dev")));
91
+ yield dev(api, options);
92
+ }));
93
+ for (const meta of devToolMetas) {
94
+ if (!meta.subCommands) {
95
+ continue;
96
+ }
97
+ for (const subCmd of meta.subCommands) {
98
+ devProgram.command(subCmd).action((..._0) => __async(void 0, [..._0], function* (options = {}) {
99
+ const { appDirectory } = api.useAppContext();
100
+ const { isTypescript } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
101
+ yield runner.beforeDevTask(meta);
102
+ yield meta.action(options, {
103
+ isTsProject: isTypescript(appDirectory)
104
+ });
105
+ }));
106
+ }
107
+ }
108
+ });
109
+ const buildCommand = (program, api) => __async(void 0, null, function* () {
110
+ const runner = api.useHookRunners();
111
+ const platformBuilders = yield runner.registerBuildPlatform();
112
+ const buildProgram = program.command("build").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.build.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).action((options) => __async(void 0, null, function* () {
113
+ const { build } = yield Promise.resolve().then(() => __toESM(require("./commands/build")));
114
+ yield build(api, options);
115
+ process.exit(0);
116
+ }));
117
+ for (const platformBuilder of platformBuilders) {
118
+ const platforms = (0, import_lodash.castArray)(platformBuilder.platform);
119
+ for (const platform of platforms) {
120
+ buildProgram.command(platform).action(() => __async(void 0, null, function* () {
121
+ const { appDirectory } = api.useAppContext();
122
+ const { isTypescript } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
123
+ yield runner.beforeBuildPlatform(platformBuilders);
124
+ yield platformBuilder.build(platform, {
125
+ isTsProject: isTypescript(appDirectory)
126
+ });
127
+ }));
128
+ }
129
+ }
130
+ });
101
131
  var src_default = () => ({
102
132
  name: "@modern-js/app-tools",
103
133
  post: [
@@ -107,7 +137,7 @@ var src_default = () => ({
107
137
  "@modern-js/plugin-document",
108
138
  "@modern-js/plugin-state",
109
139
  "@modern-js/plugin-router",
110
- "@modern-js/plugin-router-legacy",
140
+ "@modern-js/plugin-router-v5",
111
141
  "@modern-js/plugin-polyfill"
112
142
  ],
113
143
  registerHook: import_hooks.hooks,
@@ -116,67 +146,56 @@ var src_default = () => ({
116
146
  const locale = (0, import_language.getLocaleLanguage)();
117
147
  import_locale.i18n.changeLanguage({ locale });
118
148
  return {
119
- commands({ program }) {
120
- program.command("dev").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option(
121
- "-c --config <config>",
122
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
123
- ).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).action((options) => __async(this, null, function* () {
124
- const { dev } = yield Promise.resolve().then(() => __toESM2(require("./commands/dev")));
125
- yield dev(api, options);
126
- }));
127
- program.command("build").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.build.describe)).option(
128
- "-c --config <config>",
129
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
130
- ).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).action((options) => __async(this, null, function* () {
131
- const { build } = yield Promise.resolve().then(() => __toESM2(require("./commands/build")));
132
- yield build(api, options);
133
- process.exit(0);
134
- }));
135
- program.command("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.start.describe)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).option(
136
- "-c --config <config>",
137
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
138
- ).action(() => __async(this, null, function* () {
139
- const { start } = yield Promise.resolve().then(() => __toESM2(require("./commands/start")));
140
- yield start(api);
141
- }));
142
- program.command("deploy").usage("[options]").option(
143
- "-c --config <config>",
144
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
145
- ).description(import_locale.i18n.t(import_locale.localeKeys.command.deploy.describe)).action((options) => __async(this, null, function* () {
146
- const { build } = yield Promise.resolve().then(() => __toESM2(require("./commands/build")));
147
- yield build(api);
148
- const { deploy } = yield Promise.resolve().then(() => __toESM2(require("./commands/deploy")));
149
- yield deploy(api, options);
150
- process.exit(0);
151
- }));
152
- program.command("new").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.new.describe)).option("-d, --debug", import_locale.i18n.t(import_locale.localeKeys.command.new.debug), false).option(
153
- "-c, --config <config>",
154
- import_locale.i18n.t(import_locale.localeKeys.command.new.config)
155
- ).option("--dist-tag <tag>", import_locale.i18n.t(import_locale.localeKeys.command.new.distTag)).option("--registry", import_locale.i18n.t(import_locale.localeKeys.command.new.registry)).action((options) => __async(this, null, function* () {
156
- const { MWANewAction } = yield Promise.resolve().then(() => __toESM2(require("@modern-js/new-action")));
157
- yield MWANewAction(__spreadProps(__spreadValues({}, options), { locale }));
158
- }));
159
- program.command("inspect").description("inspect internal webpack config").option(
160
- `--env <env>`,
161
- import_locale.i18n.t(import_locale.localeKeys.command.inspect.env),
162
- "development"
163
- ).option(
164
- "--output <output>",
165
- import_locale.i18n.t(import_locale.localeKeys.command.inspect.output),
166
- "/"
167
- ).option("--verbose", import_locale.i18n.t(import_locale.localeKeys.command.inspect.verbose)).option(
168
- "-c --config <config>",
169
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
170
- ).action((options) => __async(this, null, function* () {
171
- const { inspect } = yield Promise.resolve().then(() => __toESM2(require("./commands/inspect")));
172
- inspect(api, options);
173
- }));
174
- upgradeModel.defineCommand(program.command("upgrade"));
149
+ commands(_0) {
150
+ return __async(this, arguments, function* ({ program }) {
151
+ yield devCommand(program, api);
152
+ yield buildCommand(program, api);
153
+ program.command("serve").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.serve.describe)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).option(
154
+ "-c --config <config>",
155
+ import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
156
+ ).action(() => __async(this, null, function* () {
157
+ const { start } = yield Promise.resolve().then(() => __toESM(require("./commands/serve")));
158
+ yield start(api);
159
+ }));
160
+ program.command("deploy").usage("[options]").option(
161
+ "-c --config <config>",
162
+ import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
163
+ ).description(import_locale.i18n.t(import_locale.localeKeys.command.deploy.describe)).action((options) => __async(this, null, function* () {
164
+ const { build } = yield Promise.resolve().then(() => __toESM(require("./commands/build")));
165
+ yield build(api);
166
+ const { deploy } = yield Promise.resolve().then(() => __toESM(require("./commands/deploy")));
167
+ yield deploy(api, options);
168
+ process.exit(0);
169
+ }));
170
+ program.command("new").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.new.describe)).option("-d, --debug", import_locale.i18n.t(import_locale.localeKeys.command.new.debug), false).option(
171
+ "-c, --config <config>",
172
+ import_locale.i18n.t(import_locale.localeKeys.command.new.config)
173
+ ).option("--dist-tag <tag>", import_locale.i18n.t(import_locale.localeKeys.command.new.distTag)).option("--registry", import_locale.i18n.t(import_locale.localeKeys.command.new.registry)).action((options) => __async(this, null, function* () {
174
+ const { MWANewAction } = yield Promise.resolve().then(() => __toESM(require("@modern-js/new-action")));
175
+ yield MWANewAction(__spreadProps(__spreadValues({}, options), { locale }));
176
+ }));
177
+ program.command("inspect").description("inspect internal webpack config").option(
178
+ `--env <env>`,
179
+ import_locale.i18n.t(import_locale.localeKeys.command.inspect.env),
180
+ "development"
181
+ ).option(
182
+ "--output <output>",
183
+ import_locale.i18n.t(import_locale.localeKeys.command.inspect.output),
184
+ "/"
185
+ ).option("--verbose", import_locale.i18n.t(import_locale.localeKeys.command.inspect.verbose)).option(
186
+ "-c --config <config>",
187
+ import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
188
+ ).action((options) => __async(this, null, function* () {
189
+ const { inspect } = yield Promise.resolve().then(() => __toESM(require("./commands/inspect")));
190
+ inspect(api, options);
191
+ }));
192
+ upgradeModel.defineCommand(program.command("upgrade"));
193
+ });
175
194
  },
176
195
  prepare() {
177
196
  return __async(this, null, function* () {
178
197
  const command = (0, import_commands.getCommand)();
179
- if (command === "dev" || command === "build") {
198
+ if (command === "dev" || command === "start" || command === "build") {
180
199
  const appContext = api.useAppContext();
181
200
  yield (0, import_utils.emptyDir)(appContext.distDirectory);
182
201
  }
@@ -189,7 +208,7 @@ var src_default = () => ({
189
208
  const { appDirectory, srcDirectory } = appContext;
190
209
  const absolutePath = import_path.default.resolve(appDirectory, filename);
191
210
  if (!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")) {
192
- const { closeServer } = yield Promise.resolve().then(() => __toESM2(require("./utils/createServer")));
211
+ const { closeServer } = yield Promise.resolve().then(() => __toESM(require("./utils/createServer")));
193
212
  yield closeServer();
194
213
  yield (0, import_restart.restart)(api.useHookRunners(), filename);
195
214
  }
@@ -203,3 +222,8 @@ var src_default = () => ({
203
222
  };
204
223
  }
205
224
  });
225
+ // Annotate the CommonJS export names for ESM import in node:
226
+ 0 && (module.exports = {
227
+ buildCommand,
228
+ devCommand
229
+ });
@@ -1,7 +1,24 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
5
22
  var __export = (target, all) => {
6
23
  for (var name in all)
7
24
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,35 +32,6 @@ var __copyProps = (to, from, except, desc) => {
15
32
  return to;
16
33
  };
17
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
20
- default: () => initialize_default
21
- });
22
- module.exports = __toCommonJS(stdin_exports);
23
- var import_utils = require("@modern-js/utils");
24
- var import_schema = require("../schema");
25
- var import_commands = require("../utils/commands");
26
- var import_transformNormalizedConfig = require("../config/initial/transformNormalizedConfig");
27
- var import_config = require("../config");
28
- var __defProp2 = Object.defineProperty;
29
- var __defProps = Object.defineProperties;
30
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
31
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
32
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
33
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
34
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
35
- var __spreadValues = (a, b) => {
36
- for (var prop in b || (b = {}))
37
- if (__hasOwnProp2.call(b, prop))
38
- __defNormalProp(a, prop, b[prop]);
39
- if (__getOwnPropSymbols)
40
- for (var prop of __getOwnPropSymbols(b)) {
41
- if (__propIsEnum.call(b, prop))
42
- __defNormalProp(a, prop, b[prop]);
43
- }
44
- return a;
45
- };
46
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
47
35
  var __async = (__this, __arguments, generator) => {
48
36
  return new Promise((resolve, reject) => {
49
37
  var fulfilled = (value) => {
@@ -64,6 +52,16 @@ var __async = (__this, __arguments, generator) => {
64
52
  step((generator = generator.apply(__this, __arguments)).next());
65
53
  });
66
54
  };
55
+ var initialize_exports = {};
56
+ __export(initialize_exports, {
57
+ default: () => initialize_default
58
+ });
59
+ module.exports = __toCommonJS(initialize_exports);
60
+ var import_utils = require("@modern-js/utils");
61
+ var import_schema = require("../schema");
62
+ var import_commands = require("../utils/commands");
63
+ var import_transformNormalizedConfig = require("../config/initial/transformNormalizedConfig");
64
+ var import_config = require("../config");
67
65
  var initialize_default = () => ({
68
66
  name: "@modern-js/plugin-initialize",
69
67
  setup(api) {
@@ -110,11 +108,13 @@ var initialize_default = () => ({
110
108
  tools: normalizedConfig.tools || {},
111
109
  testing: normalizedConfig.testing || {},
112
110
  plugins: normalizedConfig.plugins || [],
111
+ builderPlugins: normalizedConfig.builderPlugins || [],
113
112
  runtime: normalizedConfig.runtime || {},
114
113
  runtimeByEntries: normalizedConfig.runtimeByEntries || {},
115
114
  deploy: normalizedConfig.deploy || {},
116
115
  performance: normalizedConfig.performance || {},
117
- experiments: normalizedConfig.experiments || {}
116
+ experiments: normalizedConfig.experiments || {},
117
+ autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
118
118
  }
119
119
  };
120
120
  });
@@ -125,10 +125,11 @@ var initialize_default = () => ({
125
125
  function getDevServerPort(appContext, resolved) {
126
126
  return __async(this, null, function* () {
127
127
  var _a;
128
- const command = (0, import_commands.getCommand)();
129
- if ((0, import_utils.isDev)() && command === "dev") {
128
+ if ((0, import_utils.isDev)() && (0, import_commands.isDevCommand)()) {
130
129
  return ((_a = appContext.port) != null ? _a : 0) > 0 ? appContext.port : yield (0, import_utils.getPort)(resolved.server.port || 8080);
131
130
  }
132
131
  return resolved.server.port;
133
132
  });
134
133
  }
134
+ // Annotate the CommonJS export names for ESM import in node:
135
+ 0 && (module.exports = {});
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
18
+ var en_exports = {};
19
+ __export(en_exports, {
20
20
  EN_LOCALE: () => EN_LOCALE
21
21
  });
22
- module.exports = __toCommonJS(stdin_exports);
22
+ module.exports = __toCommonJS(en_exports);
23
23
  const EN_LOCALE = {
24
24
  command: {
25
25
  shared: {
@@ -34,7 +34,7 @@ const EN_LOCALE = {
34
34
  build: {
35
35
  describe: "build application"
36
36
  },
37
- start: { describe: "start server" },
37
+ serve: { describe: "start server" },
38
38
  deploy: { describe: "deploy application" },
39
39
  new: {
40
40
  describe: "generator runner for MWA project",
@@ -50,3 +50,7 @@ const EN_LOCALE = {
50
50
  }
51
51
  }
52
52
  };
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ EN_LOCALE
56
+ });
@@ -15,14 +15,19 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
18
+ var locale_exports = {};
19
+ __export(locale_exports, {
20
20
  i18n: () => i18n,
21
21
  localeKeys: () => localeKeys
22
22
  });
23
- module.exports = __toCommonJS(stdin_exports);
23
+ module.exports = __toCommonJS(locale_exports);
24
24
  var import_plugin_i18n = require("@modern-js/plugin-i18n");
25
25
  var import_zh = require("./zh");
26
26
  var import_en = require("./en");
27
27
  const i18n = new import_plugin_i18n.I18n();
28
28
  const localeKeys = i18n.init("zh", { zh: import_zh.ZH_LOCALE, en: import_en.EN_LOCALE });
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ i18n,
32
+ localeKeys
33
+ });
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
18
+ var zh_exports = {};
19
+ __export(zh_exports, {
20
20
  ZH_LOCALE: () => ZH_LOCALE
21
21
  });
22
- module.exports = __toCommonJS(stdin_exports);
22
+ module.exports = __toCommonJS(zh_exports);
23
23
  const ZH_LOCALE = {
24
24
  command: {
25
25
  shared: {
@@ -34,7 +34,7 @@ const ZH_LOCALE = {
34
34
  build: {
35
35
  describe: "构建应用命令"
36
36
  },
37
- start: { describe: "应用启动命令" },
37
+ serve: { describe: "应用启动命令" },
38
38
  deploy: { describe: "部署应用命令" },
39
39
  new: {
40
40
  describe: "MWA 项目中执行生成器",
@@ -50,3 +50,7 @@ const ZH_LOCALE = {
50
50
  }
51
51
  }
52
52
  };
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ ZH_LOCALE
56
+ });
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
18
+ var Schema_exports = {};
19
+ __export(Schema_exports, {
20
20
  Schema: () => Schema
21
21
  });
22
- module.exports = __toCommonJS(stdin_exports);
22
+ module.exports = __toCommonJS(Schema_exports);
23
23
  var import_lodash = require("@modern-js/utils/lodash");
24
24
  class Schema extends Map {
25
25
  constructor(baseSchema = {}) {
@@ -57,3 +57,7 @@ class Schema extends Map {
57
57
  }));
58
58
  }
59
59
  }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ Schema
63
+ });
@@ -21,12 +21,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  mod
22
22
  ));
23
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var stdin_exports = {};
25
- __export(stdin_exports, {
24
+ var schema_exports = {};
25
+ __export(schema_exports, {
26
26
  legacySchema: () => import_legacy.default,
27
27
  schema: () => schema
28
28
  });
29
- module.exports = __toCommonJS(stdin_exports);
29
+ module.exports = __toCommonJS(schema_exports);
30
30
  var import_constants = require("@modern-js/utils/constants");
31
31
  var import_Schema = require("./Schema");
32
32
  var import_legacy = __toESM(require("./legacy"));
@@ -41,7 +41,7 @@ const source = {
41
41
  properties: {
42
42
  entry: { type: ["string", "array"] },
43
43
  disableMount: { type: "boolean" },
44
- enableFileSystemRoutes: { type: "boolean" }
44
+ customBootstrap: { type: "string" }
45
45
  },
46
46
  additionalProperties: false
47
47
  },
@@ -52,6 +52,7 @@ const source = {
52
52
  enableAsyncEntry: { type: "boolean" },
53
53
  disableDefaultEntries: { type: "boolean" },
54
54
  entriesDir: { type: "string" },
55
+ disableEntryDirs: { type: "array" },
55
56
  configDir: { type: "string" },
56
57
  designSystem: { type: "object" }
57
58
  };
@@ -70,11 +71,7 @@ const output = {
70
71
  ssg: { typeof: ["boolean", "object", "function"] },
71
72
  disableNodePolyfill: { type: "boolean" }
72
73
  };
73
- const dev = {
74
- proxy: {
75
- type: ["boolean", "object"]
76
- }
77
- };
74
+ const dev = {};
78
75
  const server = {
79
76
  routes: { type: "object" },
80
77
  publicRoutes: { type: "object" },
@@ -101,7 +98,7 @@ const server = {
101
98
  enableMicroFrontendDebug: { type: "boolean" },
102
99
  watchOptions: { type: "object" },
103
100
  compiler: { type: "string" },
104
- disableFrameworkExt: { type: "boolean" }
101
+ enableFrameworkExt: { type: "boolean" }
105
102
  };
106
103
  const tools = {
107
104
  tailwindcss: { type: "object" },
@@ -111,5 +108,11 @@ const tools = {
111
108
  const deploy = {
112
109
  microFrontend: { type: ["boolean", "object"] }
113
110
  };
111
+ const builderPlugins = { type: "array" };
114
112
  const schema = new import_Schema.Schema();
115
- schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy);
113
+ schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy).set("builderPlugin", builderPlugins);
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ legacySchema,
117
+ schema
118
+ });
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var stdin_exports = {};
19
- __export(stdin_exports, {
18
+ var legacy_exports = {};
19
+ __export(legacy_exports, {
20
20
  default: () => legacy_default
21
21
  });
22
- module.exports = __toCommonJS(stdin_exports);
22
+ module.exports = __toCommonJS(legacy_exports);
23
23
  var import_constants = require("@modern-js/utils/constants");
24
24
  var import_Schema = require("./Schema");
25
25
  const source = {
@@ -32,8 +32,7 @@ const source = {
32
32
  required: ["entry"],
33
33
  properties: {
34
34
  entry: { type: ["string", "array"] },
35
- disableMount: { type: "boolean" },
36
- enableFileSystemRoutes: { type: "boolean" }
35
+ disableMount: { type: "boolean" }
37
36
  },
38
37
  additionalProperties: false
39
38
  },
@@ -137,7 +136,7 @@ const server = {
137
136
  enableMicroFrontendDebug: { type: "boolean" },
138
137
  watchOptions: { type: "object" },
139
138
  compiler: { type: "string" },
140
- disableFrameworkExt: { type: "boolean" }
139
+ enableFrameworkExt: { type: "boolean" }
141
140
  };
142
141
  const dev = {
143
142
  proxy: {
@@ -166,3 +165,5 @@ const bff = {
166
165
  const schema = new import_Schema.Schema();
167
166
  schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy);
168
167
  var legacy_default = schema;
168
+ // Annotate the CommonJS export names for ESM import in node:
169
+ 0 && (module.exports = {});
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var deploy_exports = {};
15
+ module.exports = __toCommonJS(deploy_exports);