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

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 +724 -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
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
  import { ensureAbsolutePath, getPort, isDev } from "@modern-js/utils";
41
41
  import { legacySchema, schema } from "../schema";
42
- import { getCommand } from "../utils/commands";
42
+ import { isDevCommand } from "../utils/commands";
43
43
  import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
44
44
  import {
45
45
  checkIsLegacyConfig,
@@ -92,11 +92,13 @@ var initialize_default = () => ({
92
92
  tools: normalizedConfig.tools || {},
93
93
  testing: normalizedConfig.testing || {},
94
94
  plugins: normalizedConfig.plugins || [],
95
+ builderPlugins: normalizedConfig.builderPlugins || [],
95
96
  runtime: normalizedConfig.runtime || {},
96
97
  runtimeByEntries: normalizedConfig.runtimeByEntries || {},
97
98
  deploy: normalizedConfig.deploy || {},
98
99
  performance: normalizedConfig.performance || {},
99
- experiments: normalizedConfig.experiments || {}
100
+ experiments: normalizedConfig.experiments || {},
101
+ autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
100
102
  }
101
103
  };
102
104
  });
@@ -107,8 +109,7 @@ var initialize_default = () => ({
107
109
  function getDevServerPort(appContext, resolved) {
108
110
  return __async(this, null, function* () {
109
111
  var _a;
110
- const command = getCommand();
111
- if (isDev() && command === "dev") {
112
+ if (isDev() && isDevCommand()) {
112
113
  return ((_a = appContext.port) != null ? _a : 0) > 0 ? appContext.port : yield getPort(resolved.server.port || 8080);
113
114
  }
114
115
  return resolved.server.port;
@@ -12,7 +12,7 @@ const EN_LOCALE = {
12
12
  build: {
13
13
  describe: "build application"
14
14
  },
15
- start: { describe: "start server" },
15
+ serve: { describe: "start server" },
16
16
  deploy: { describe: "deploy application" },
17
17
  new: {
18
18
  describe: "generator runner for MWA project",
@@ -12,7 +12,7 @@ const ZH_LOCALE = {
12
12
  build: {
13
13
  describe: "构建应用命令"
14
14
  },
15
- start: { describe: "应用启动命令" },
15
+ serve: { describe: "应用启动命令" },
16
16
  deploy: { describe: "部署应用命令" },
17
17
  new: {
18
18
  describe: "MWA 项目中执行生成器",
@@ -11,7 +11,7 @@ const source = {
11
11
  properties: {
12
12
  entry: { type: ["string", "array"] },
13
13
  disableMount: { type: "boolean" },
14
- enableFileSystemRoutes: { type: "boolean" }
14
+ customBootstrap: { type: "string" }
15
15
  },
16
16
  additionalProperties: false
17
17
  },
@@ -22,6 +22,7 @@ const source = {
22
22
  enableAsyncEntry: { type: "boolean" },
23
23
  disableDefaultEntries: { type: "boolean" },
24
24
  entriesDir: { type: "string" },
25
+ disableEntryDirs: { type: "array" },
25
26
  configDir: { type: "string" },
26
27
  designSystem: { type: "object" }
27
28
  };
@@ -40,11 +41,7 @@ const output = {
40
41
  ssg: { typeof: ["boolean", "object", "function"] },
41
42
  disableNodePolyfill: { type: "boolean" }
42
43
  };
43
- const dev = {
44
- proxy: {
45
- type: ["boolean", "object"]
46
- }
47
- };
44
+ const dev = {};
48
45
  const server = {
49
46
  routes: { type: "object" },
50
47
  publicRoutes: { type: "object" },
@@ -71,7 +68,7 @@ const server = {
71
68
  enableMicroFrontendDebug: { type: "boolean" },
72
69
  watchOptions: { type: "object" },
73
70
  compiler: { type: "string" },
74
- disableFrameworkExt: { type: "boolean" }
71
+ enableFrameworkExt: { type: "boolean" }
75
72
  };
76
73
  const tools = {
77
74
  tailwindcss: { type: "object" },
@@ -81,8 +78,9 @@ const tools = {
81
78
  const deploy = {
82
79
  microFrontend: { type: ["boolean", "object"] }
83
80
  };
81
+ const builderPlugins = { type: "array" };
84
82
  const schema = new Schema();
85
- schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy);
83
+ 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);
86
84
  import { default as default2 } from "./legacy";
87
85
  export {
88
86
  default2 as legacySchema,
@@ -10,8 +10,7 @@ const source = {
10
10
  required: ["entry"],
11
11
  properties: {
12
12
  entry: { type: ["string", "array"] },
13
- disableMount: { type: "boolean" },
14
- enableFileSystemRoutes: { type: "boolean" }
13
+ disableMount: { type: "boolean" }
15
14
  },
16
15
  additionalProperties: false
17
16
  },
@@ -115,7 +114,7 @@ const server = {
115
114
  enableMicroFrontendDebug: { type: "boolean" },
116
115
  watchOptions: { type: "object" },
117
116
  compiler: { type: "string" },
118
- disableFrameworkExt: { type: "boolean" }
117
+ enableFrameworkExt: { type: "boolean" }
119
118
  };
120
119
  const dev = {
121
120
  proxy: {
@@ -3,6 +3,11 @@ const getCommand = () => {
3
3
  const command = args[0];
4
4
  return command;
5
5
  };
6
+ const isDevCommand = () => {
7
+ const command = getCommand();
8
+ return command === "dev" || command === "start";
9
+ };
6
10
  export {
7
- getCommand
11
+ getCommand,
12
+ isDevCommand
8
13
  };
@@ -0,0 +1,15 @@
1
+ function getAutoInjectEnv(appContext) {
2
+ const { metaName } = appContext;
3
+ const prefix = `${metaName.split(/[-_]/)[0]}_`.toUpperCase();
4
+ const envReg = new RegExp(`^${prefix}`);
5
+ return Object.keys(process.env).reduce((prev, key) => {
6
+ const value = process.env[key];
7
+ if (envReg.test(key) && typeof value !== "undefined") {
8
+ prev[`process.env.${key}`] = value;
9
+ }
10
+ return prev;
11
+ }, {});
12
+ }
13
+ export {
14
+ getAutoInjectEnv
15
+ };
@@ -0,0 +1,58 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ function getServerInternalPlugins(api) {
41
+ return __async(this, null, function* () {
42
+ const hookRunners = api.useHookRunners();
43
+ const { plugins: serverPlugins } = yield hookRunners.collectServerPlugins({
44
+ plugins: []
45
+ });
46
+ const serverInternalPlugins = serverPlugins.reduce(
47
+ (result, plugin) => Object.assign(result, plugin),
48
+ {}
49
+ );
50
+ api.setAppContext(__spreadProps(__spreadValues({}, api.useAppContext()), {
51
+ serverInternalPlugins
52
+ }));
53
+ return serverInternalPlugins;
54
+ });
55
+ }
56
+ export {
57
+ getServerInternalPlugins
58
+ };
@@ -0,0 +1,64 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __async = (__this, __arguments, generator) => {
19
+ return new Promise((resolve, reject) => {
20
+ var fulfilled = (value) => {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ };
27
+ var rejected = (value) => {
28
+ try {
29
+ step(generator.throw(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
+ step((generator = generator.apply(__this, __arguments)).next());
36
+ });
37
+ };
38
+ var Builder_exports = {};
39
+ __export(Builder_exports, {
40
+ Builder: () => Builder,
41
+ loaderBuilder: () => loaderBuilder,
42
+ serverLoaderBuilder: () => serverLoaderBuilder
43
+ });
44
+ module.exports = __toCommonJS(Builder_exports);
45
+ var import_esbuild = require("esbuild");
46
+ class Builder {
47
+ build(options) {
48
+ return __async(this, null, function* () {
49
+ this.buildRes = yield (0, import_esbuild.build)(options);
50
+ });
51
+ }
52
+ stop() {
53
+ var _a, _b;
54
+ ((_a = this.buildRes) == null ? void 0 : _a.stop) && ((_b = this.buildRes) == null ? void 0 : _b.stop());
55
+ }
56
+ }
57
+ const loaderBuilder = new Builder();
58
+ const serverLoaderBuilder = new Builder();
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ Builder,
62
+ loaderBuilder,
63
+ serverLoaderBuilder
64
+ });
@@ -15,9 +15,12 @@ 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 constants_exports = {};
19
+ __export(constants_exports, {
20
+ APP_CONFIG_NAME: () => APP_CONFIG_NAME,
20
21
  APP_FILE_NAME: () => APP_FILE_NAME,
22
+ APP_INIT_EXPORTED: () => APP_INIT_EXPORTED,
23
+ APP_INIT_IMPORTED: () => APP_INIT_IMPORTED,
21
24
  ENTRY_BOOTSTRAP_FILE_NAME: () => ENTRY_BOOTSTRAP_FILE_NAME,
22
25
  ENTRY_POINT_FILE_NAME: () => ENTRY_POINT_FILE_NAME,
23
26
  FILE_SYSTEM_ROUTES_COMPONENTS_DIR: () => FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
@@ -32,11 +35,12 @@ __export(stdin_exports, {
32
35
  INDEX_FILE_NAME: () => INDEX_FILE_NAME,
33
36
  JS_EXTENSIONS: () => JS_EXTENSIONS,
34
37
  LOADER_EXPORT_NAME: () => LOADER_EXPORT_NAME,
38
+ NESTED_ROUTE: () => NESTED_ROUTE,
35
39
  NESTED_ROUTES_DIR: () => NESTED_ROUTES_DIR,
36
40
  PAGES_DIR_NAME: () => PAGES_DIR_NAME,
37
41
  TEMP_LOADERS_DIR: () => TEMP_LOADERS_DIR
38
42
  });
39
- module.exports = __toCommonJS(stdin_exports);
43
+ module.exports = __toCommonJS(constants_exports);
40
44
  const JS_EXTENSIONS = [".js", ".ts", ".jsx", ".tsx"];
41
45
  const INDEX_FILE_NAME = "index";
42
46
  const APP_FILE_NAME = "App";
@@ -55,3 +59,40 @@ const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/
55
59
  const HTML_PARTIALS_FOLDER = "html";
56
60
  const HTML_PARTIALS_EXTENSIONS = [".htm", ".html", ".ejs"];
57
61
  const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
62
+ const NESTED_ROUTE = {
63
+ LAYOUT_FILE: "layout",
64
+ LAYOUT_LOADER_FILE: "layout.loader",
65
+ PAGE_FILE: "page",
66
+ PAGE_LOADER_FILE: "page.loader",
67
+ LOADING_FILE: "loading",
68
+ ERROR_FILE: "error",
69
+ LOADER_FILE: "loader"
70
+ };
71
+ const APP_CONFIG_NAME = "appConfig";
72
+ const APP_INIT_EXPORTED = "init";
73
+ const APP_INIT_IMPORTED = "appInit";
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ APP_CONFIG_NAME,
77
+ APP_FILE_NAME,
78
+ APP_INIT_EXPORTED,
79
+ APP_INIT_IMPORTED,
80
+ ENTRY_BOOTSTRAP_FILE_NAME,
81
+ ENTRY_POINT_FILE_NAME,
82
+ FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
83
+ FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
84
+ FILE_SYSTEM_ROUTES_FILE_NAME,
85
+ FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
86
+ FILE_SYSTEM_ROUTES_IGNORED_REGEX,
87
+ FILE_SYSTEM_ROUTES_INDEX,
88
+ FILE_SYSTEM_ROUTES_LAYOUT,
89
+ HTML_PARTIALS_EXTENSIONS,
90
+ HTML_PARTIALS_FOLDER,
91
+ INDEX_FILE_NAME,
92
+ JS_EXTENSIONS,
93
+ LOADER_EXPORT_NAME,
94
+ NESTED_ROUTE,
95
+ NESTED_ROUTES_DIR,
96
+ PAGES_DIR_NAME,
97
+ TEMP_LOADERS_DIR
98
+ });
@@ -21,22 +21,6 @@ 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, {
26
- createImportStatements: () => createImportStatements,
27
- generateCode: () => generateCode
28
- });
29
- module.exports = __toCommonJS(stdin_exports);
30
- var import_path = __toESM(require("path"));
31
- var import_utils = require("@modern-js/utils");
32
- var import_core = require("@modern-js/core");
33
- var import_esbuild = require("esbuild");
34
- var import_commands = require("../utils/commands");
35
- var templates = __toESM(require("./templates"));
36
- var import_getClientRoutes = require("./getClientRoutes");
37
- var import_constants = require("./constants");
38
- var import_utils2 = require("./utils");
39
- var import_nestedRoutes = require("./nestedRoutes");
40
24
  var __async = (__this, __arguments, generator) => {
41
25
  return new Promise((resolve, reject) => {
42
26
  var fulfilled = (value) => {
@@ -57,6 +41,22 @@ var __async = (__this, __arguments, generator) => {
57
41
  step((generator = generator.apply(__this, __arguments)).next());
58
42
  });
59
43
  };
44
+ var generateCode_exports = {};
45
+ __export(generateCode_exports, {
46
+ createImportStatements: () => createImportStatements,
47
+ generateCode: () => generateCode
48
+ });
49
+ module.exports = __toCommonJS(generateCode_exports);
50
+ var import_path = __toESM(require("path"));
51
+ var import_utils = require("@modern-js/utils");
52
+ var import_core = require("@modern-js/core");
53
+ var import_commands = require("../utils/commands");
54
+ var templates = __toESM(require("./templates"));
55
+ var import_getClientRoutes = require("./getClientRoutes");
56
+ var import_constants = require("./constants");
57
+ var import_utils2 = require("./utils");
58
+ var import_nestedRoutes = require("./nestedRoutes");
59
+ var import_Builder = require("./Builder");
60
60
  const loader = {
61
61
  ".js": "jsx",
62
62
  ".ts": "tsx"
@@ -110,13 +110,12 @@ ${initialize || ""}`
110
110
  ).join("\n");
111
111
  };
112
112
  const buildLoader = (entry, outfile) => __async(void 0, null, function* () {
113
- const command = (0, import_commands.getCommand)();
114
- yield (0, import_esbuild.build)({
113
+ yield import_Builder.loaderBuilder.build({
115
114
  format: "esm",
116
115
  platform: "browser",
117
116
  target: "esnext",
118
117
  loader,
119
- watch: command === "dev" && {},
118
+ watch: (0, import_commands.isDevCommand)() && {},
120
119
  bundle: true,
121
120
  logLevel: "error",
122
121
  entryPoints: [entry],
@@ -124,8 +123,8 @@ const buildLoader = (entry, outfile) => __async(void 0, null, function* () {
124
123
  plugins: [
125
124
  {
126
125
  name: "make-all-packages-external",
127
- setup(build2) {
128
- build2.onResolve({ filter: EXTERNAL_REGEXP }, (args) => {
126
+ setup(build) {
127
+ build.onResolve({ filter: EXTERNAL_REGEXP }, (args) => {
129
128
  let external = true;
130
129
  if (args.kind === "entry-point") {
131
130
  external = false;
@@ -141,13 +140,12 @@ const buildLoader = (entry, outfile) => __async(void 0, null, function* () {
141
140
  });
142
141
  });
143
142
  const buildServerLoader = (entry, outfile) => __async(void 0, null, function* () {
144
- const command = (0, import_commands.getCommand)();
145
- yield (0, import_esbuild.build)({
143
+ yield import_Builder.serverLoaderBuilder.build({
146
144
  format: "cjs",
147
145
  platform: "node",
148
146
  target: "esnext",
149
147
  loader,
150
- watch: command === "dev" && {},
148
+ watch: (0, import_commands.isDevCommand)() && {},
151
149
  bundle: true,
152
150
  logLevel: "error",
153
151
  entryPoints: [entry],
@@ -155,7 +153,7 @@ const buildServerLoader = (entry, outfile) => __async(void 0, null, function* ()
155
153
  });
156
154
  });
157
155
  const generateCode = (appContext, config, entrypoints, api) => __async(void 0, null, function* () {
158
- var _a, _b;
156
+ var _a, _b, _c;
159
157
  const {
160
158
  internalDirectory,
161
159
  distDirectory,
@@ -165,9 +163,9 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
165
163
  packageName
166
164
  } = appContext;
167
165
  const hookRunners = api.useHookRunners();
168
- const islegacy = Boolean((_b = (_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.router) == null ? void 0 : _b.legacy);
166
+ const isV5 = typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
169
167
  const { mountId } = config.html;
170
- const getRoutes = islegacy ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
168
+ const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
171
169
  yield Promise.all(entrypoints.map(generateEntryCode));
172
170
  function generateEntryCode(entrypoint) {
173
171
  return __async(this, null, function* () {
@@ -186,7 +184,7 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
186
184
  });
187
185
  }
188
186
  if (entrypoint.nestedRoutesEntry) {
189
- if (!islegacy) {
187
+ if (!isV5) {
190
188
  nestedRoute = yield (0, import_nestedRoutes.walk)(
191
189
  entrypoint.nestedRoutesEntry,
192
190
  entrypoint.nestedRoutesEntry,
@@ -239,7 +237,8 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
239
237
  ssrMode: mode,
240
238
  nestedRoutesEntry: entrypoint.nestedRoutesEntry,
241
239
  entryName: entrypoint.entryName,
242
- internalDirectory
240
+ internalDirectory,
241
+ internalDirAlias
243
242
  })
244
243
  });
245
244
  if (entrypoint.nestedRoutesEntry) {
@@ -344,3 +343,8 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
344
343
  });
345
344
  }
346
345
  });
346
+ // Annotate the CommonJS export names for ESM import in node:
347
+ 0 && (module.exports = {
348
+ createImportStatements,
349
+ generateCode
350
+ });
@@ -21,11 +21,11 @@ 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 getBundleEntry_exports = {};
25
+ __export(getBundleEntry_exports, {
26
26
  getBundleEntry: () => getBundleEntry
27
27
  });
28
- module.exports = __toCommonJS(stdin_exports);
28
+ module.exports = __toCommonJS(getBundleEntry_exports);
29
29
  var import_path = __toESM(require("path"));
30
30
  var import_utils = require("@modern-js/utils");
31
31
  var import_getFileSystemEntry = require("./getFileSystemEntry");
@@ -69,8 +69,12 @@ const getBundleEntry = (appContext, config) => {
69
69
  entryName: name,
70
70
  entry: (0, import_utils.ensureAbsolutePath)(appDirectory, value.entry),
71
71
  isAutoMount: !value.disableMount,
72
- fileSystemRoutes: value.enableFileSystemRoutes ? {} : void 0
72
+ customBootstrap: value.customBootstrap && (0, import_utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
73
+ fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
73
74
  };
75
+ if (entrypoint.fileSystemRoutes) {
76
+ entrypoint.nestedRoutesEntry = entrypoint.entry;
77
+ }
74
78
  if (!ifAlreadyExists(defaults, entrypoint)) {
75
79
  defaults.push(entrypoint);
76
80
  }
@@ -85,3 +89,7 @@ const getBundleEntry = (appContext, config) => {
85
89
  }
86
90
  return defaults;
87
91
  };
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ getBundleEntry
95
+ });
@@ -1,9 +1,26 @@
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;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7
24
  var __export = (target, all) => {
8
25
  for (var name in all)
9
26
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -21,36 +38,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
38
  mod
22
39
  ));
23
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var stdin_exports = {};
25
- __export(stdin_exports, {
41
+ var getRoutes_exports = {};
42
+ __export(getRoutes_exports, {
26
43
  getClientRoutes: () => getClientRoutes
27
44
  });
28
- module.exports = __toCommonJS(stdin_exports);
45
+ module.exports = __toCommonJS(getRoutes_exports);
29
46
  var import_path = __toESM(require("path"));
30
47
  var import_utils = require("@modern-js/utils");
31
48
  var import_makeLegalIdentifier = require("../makeLegalIdentifier");
32
49
  var import_constants = require("../constants");
33
50
  var import_utils2 = require("../utils");
34
51
  var import_utils3 = require("./utils");
35
- var __defProp2 = Object.defineProperty;
36
- var __defProps = Object.defineProperties;
37
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
38
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
39
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
40
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
41
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
42
- var __spreadValues = (a, b) => {
43
- for (var prop in b || (b = {}))
44
- if (__hasOwnProp2.call(b, prop))
45
- __defNormalProp(a, prop, b[prop]);
46
- if (__getOwnPropSymbols)
47
- for (var prop of __getOwnPropSymbols(b)) {
48
- if (__propIsEnum.call(b, prop))
49
- __defNormalProp(a, prop, b[prop]);
50
- }
51
- return a;
52
- };
53
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
54
52
  const compName = (srcDirectory, filePath) => {
55
53
  const legalCompName = (0, import_makeLegalIdentifier.makeLegalIdentifier)(
56
54
  import_path.default.relative(srcDirectory, filePath)
@@ -194,20 +192,23 @@ const getClientRoutes = ({
194
192
  internalDirectory,
195
193
  internalDirAlias
196
194
  }) => {
197
- const { entry, entryName } = entrypoint;
198
- if (!import_utils.fs.existsSync(entry)) {
195
+ const { entryName, pageRoutesEntry } = entrypoint;
196
+ if (!pageRoutesEntry) {
197
+ return [];
198
+ }
199
+ if (!import_utils.fs.existsSync(pageRoutesEntry)) {
199
200
  throw new Error(
200
- `generate file system routes error, ${entry} directory not found.`
201
+ `generate file system routes error, ${pageRoutesEntry} directory not found.`
201
202
  );
202
203
  }
203
- if (!(import_utils.fs.existsSync(entry) && import_utils.fs.statSync(entry).isDirectory())) {
204
+ if (!(import_utils.fs.existsSync(pageRoutesEntry) && import_utils.fs.statSync(pageRoutesEntry).isDirectory())) {
204
205
  throw new Error(
205
- `generate file system routes error, ${entry} should be directory.`
206
+ `generate file system routes error, ${pageRoutesEntry} should be directory.`
206
207
  );
207
208
  }
208
209
  let routes = [];
209
210
  recursiveReadDir({
210
- dir: entry,
211
+ dir: pageRoutesEntry,
211
212
  routes,
212
213
  basePath: "/",
213
214
  srcDirectory,
@@ -235,3 +236,7 @@ const getClientRoutes = ({
235
236
  (0, import_utils3.debug)(`fileSystem routes: %o`, routes);
236
237
  return routes;
237
238
  };
239
+ // Annotate the CommonJS export names for ESM import in node:
240
+ 0 && (module.exports = {
241
+ getClientRoutes
242
+ });