@modern-js/app-tools 2.14.0 → 2.16.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 (269) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/cjs/analyze/constants.js +37 -61
  3. package/dist/cjs/analyze/generateCode.js +102 -127
  4. package/dist/cjs/analyze/getBundleEntry.js +33 -66
  5. package/dist/cjs/analyze/getClientRoutes/getRoutes.js +61 -117
  6. package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +61 -115
  7. package/dist/cjs/analyze/getClientRoutes/index.js +15 -28
  8. package/dist/cjs/analyze/getClientRoutes/utils.js +24 -48
  9. package/dist/cjs/analyze/getFileSystemEntry.js +39 -79
  10. package/dist/cjs/analyze/getHtmlTemplate.js +88 -98
  11. package/dist/cjs/analyze/getServerRoutes.js +67 -110
  12. package/dist/cjs/analyze/index.js +265 -257
  13. package/dist/cjs/analyze/isDefaultExportFunction.js +66 -44
  14. package/dist/cjs/analyze/makeLegalIdentifier.js +7 -25
  15. package/dist/cjs/analyze/nestedRoutes.js +99 -104
  16. package/dist/cjs/analyze/templates.js +49 -110
  17. package/dist/cjs/analyze/utils.js +98 -102
  18. package/dist/cjs/builder/builder-rspack/adapterCopy.js +58 -100
  19. package/dist/cjs/builder/builder-rspack/index.js +14 -30
  20. package/dist/cjs/builder/builder-webpack/adapterModern.js +33 -50
  21. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +16 -32
  22. package/dist/cjs/builder/builder-webpack/index.js +65 -46
  23. package/dist/cjs/builder/generator/createBuilderOptions.js +10 -26
  24. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +11 -27
  25. package/dist/cjs/builder/generator/getBuilderTargets.js +13 -29
  26. package/dist/cjs/builder/generator/index.js +61 -55
  27. package/dist/cjs/builder/index.js +53 -43
  28. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +13 -36
  29. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +90 -90
  30. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +108 -111
  31. package/dist/cjs/builder/shared/builderPlugins/index.js +20 -19
  32. package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -30
  33. package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +32 -38
  34. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +86 -116
  35. package/dist/cjs/builder/shared/bundlerPlugins/index.js +20 -19
  36. package/dist/cjs/builder/shared/createCopyInfo.js +16 -42
  37. package/dist/cjs/builder/shared/index.js +20 -19
  38. package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +8 -24
  39. package/dist/cjs/builder/shared/types.js +4 -15
  40. package/dist/cjs/commands/build.js +23 -40
  41. package/dist/cjs/commands/deploy.js +7 -25
  42. package/dist/cjs/commands/dev.js +38 -57
  43. package/dist/cjs/commands/index.js +20 -19
  44. package/dist/cjs/commands/inspect.js +10 -30
  45. package/dist/cjs/commands/serve.js +28 -66
  46. package/dist/cjs/config/default.js +34 -34
  47. package/dist/cjs/config/index.js +20 -19
  48. package/dist/cjs/config/initialize/index.js +11 -29
  49. package/dist/cjs/config/initialize/inits.js +103 -82
  50. package/dist/cjs/config/legacy/createHtmlConfig.js +8 -40
  51. package/dist/cjs/config/legacy/createOutputConfig.js +8 -51
  52. package/dist/cjs/config/legacy/createSourceConfig.js +8 -38
  53. package/dist/cjs/config/legacy/createToolsConfig.js +8 -43
  54. package/dist/cjs/config/legacy/index.js +22 -46
  55. package/dist/cjs/defineConfig.js +16 -31
  56. package/dist/cjs/exports/server.js +7 -25
  57. package/dist/cjs/hooks.js +33 -51
  58. package/dist/cjs/index.js +185 -166
  59. package/dist/cjs/initialize/index.js +84 -100
  60. package/dist/cjs/locale/en.js +13 -27
  61. package/dist/cjs/locale/index.js +18 -28
  62. package/dist/cjs/locale/zh.js +13 -27
  63. package/dist/cjs/schema/Schema.js +27 -31
  64. package/dist/cjs/schema/index.js +141 -71
  65. package/dist/cjs/schema/legacy.js +273 -96
  66. package/dist/cjs/types/config/deploy.js +4 -15
  67. package/dist/cjs/types/config/dev.js +4 -15
  68. package/dist/cjs/types/config/experiments.js +4 -15
  69. package/dist/cjs/types/config/html.js +4 -15
  70. package/dist/cjs/types/config/index.js +18 -17
  71. package/dist/cjs/types/config/output.js +4 -15
  72. package/dist/cjs/types/config/performance.js +4 -15
  73. package/dist/cjs/types/config/security.js +4 -15
  74. package/dist/cjs/types/config/source.js +4 -15
  75. package/dist/cjs/types/config/tools.js +4 -15
  76. package/dist/cjs/types/hooks.js +4 -15
  77. package/dist/cjs/types/index.js +20 -19
  78. package/dist/cjs/types/legacyConfig/deploy.js +4 -15
  79. package/dist/cjs/types/legacyConfig/dev.js +4 -15
  80. package/dist/cjs/types/legacyConfig/index.js +4 -15
  81. package/dist/cjs/types/legacyConfig/output.js +4 -15
  82. package/dist/cjs/types/legacyConfig/source.js +4 -15
  83. package/dist/cjs/types/legacyConfig/tools.js +4 -15
  84. package/dist/cjs/types/utils.js +4 -15
  85. package/dist/cjs/utils/config.js +74 -79
  86. package/dist/cjs/utils/createServer.js +16 -42
  87. package/dist/cjs/utils/env.js +7 -25
  88. package/dist/cjs/utils/generateWatchFiles.js +31 -52
  89. package/dist/cjs/utils/getSelectedEntries.js +13 -35
  90. package/dist/cjs/utils/getServerInternalPlugins.js +8 -29
  91. package/dist/cjs/utils/printInstructions.js +10 -28
  92. package/dist/cjs/utils/restart.js +13 -31
  93. package/dist/cjs/utils/routes.js +18 -39
  94. package/dist/cjs/utils/types.js +4 -15
  95. package/dist/esm/analyze/constants.js +40 -41
  96. package/dist/esm/analyze/generateCode.js +477 -455
  97. package/dist/esm/analyze/getBundleEntry.js +53 -54
  98. package/dist/esm/analyze/getClientRoutes/getRoutes.js +201 -202
  99. package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +199 -200
  100. package/dist/esm/analyze/getClientRoutes/index.js +2 -3
  101. package/dist/esm/analyze/getClientRoutes/utils.js +15 -15
  102. package/dist/esm/analyze/getFileSystemEntry.js +86 -87
  103. package/dist/esm/analyze/getHtmlTemplate.js +289 -278
  104. package/dist/esm/analyze/getServerRoutes.js +203 -190
  105. package/dist/esm/analyze/index.js +679 -651
  106. package/dist/esm/analyze/isDefaultExportFunction.js +38 -39
  107. package/dist/esm/analyze/makeLegalIdentifier.js +8 -9
  108. package/dist/esm/analyze/nestedRoutes.js +400 -392
  109. package/dist/esm/analyze/templates.js +536 -509
  110. package/dist/esm/analyze/utils.js +357 -336
  111. package/dist/esm/builder/builder-rspack/adapterCopy.js +347 -330
  112. package/dist/esm/builder/builder-rspack/index.js +8 -9
  113. package/dist/esm/builder/builder-webpack/adapterModern.js +51 -43
  114. package/dist/esm/builder/builder-webpack/createCopyPattern.js +31 -32
  115. package/dist/esm/builder/builder-webpack/index.js +266 -249
  116. package/dist/esm/builder/generator/createBuilderOptions.js +37 -38
  117. package/dist/esm/builder/generator/createBuilderProviderConfig.js +62 -63
  118. package/dist/esm/builder/generator/getBuilderTargets.js +13 -14
  119. package/dist/esm/builder/generator/index.js +203 -196
  120. package/dist/esm/builder/index.js +183 -176
  121. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +90 -91
  122. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +300 -291
  123. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +337 -329
  124. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +108 -97
  125. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +66 -64
  126. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +364 -337
  127. package/dist/esm/builder/shared/createCopyInfo.js +9 -10
  128. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +2 -3
  129. package/dist/esm/builder/shared/types.js +1 -1
  130. package/dist/esm/commands/build.js +279 -272
  131. package/dist/esm/commands/deploy.js +150 -144
  132. package/dist/esm/commands/dev.js +296 -289
  133. package/dist/esm/commands/inspect.js +144 -138
  134. package/dist/esm/commands/serve.js +241 -235
  135. package/dist/esm/config/default.js +202 -203
  136. package/dist/esm/config/initialize/index.js +7 -8
  137. package/dist/esm/config/initialize/inits.js +189 -181
  138. package/dist/esm/config/legacy/createHtmlConfig.js +17 -18
  139. package/dist/esm/config/legacy/createOutputConfig.js +41 -42
  140. package/dist/esm/config/legacy/createSourceConfig.js +38 -39
  141. package/dist/esm/config/legacy/createToolsConfig.js +24 -25
  142. package/dist/esm/config/legacy/index.js +31 -32
  143. package/dist/esm/defineConfig.js +52 -53
  144. package/dist/esm/exports/server.js +1 -2
  145. package/dist/esm/hooks.js +26 -27
  146. package/dist/esm/index.js +685 -671
  147. package/dist/esm/initialize/index.js +276 -269
  148. package/dist/esm/locale/en.js +36 -37
  149. package/dist/esm/locale/index.js +2 -2
  150. package/dist/esm/locale/zh.js +36 -37
  151. package/dist/esm/schema/Schema.js +255 -244
  152. package/dist/esm/schema/index.js +165 -165
  153. package/dist/esm/schema/legacy.js +316 -317
  154. package/dist/esm/types/config/deploy.js +1 -1
  155. package/dist/esm/types/config/dev.js +1 -1
  156. package/dist/esm/types/config/experiments.js +1 -1
  157. package/dist/esm/types/config/html.js +1 -1
  158. package/dist/esm/types/config/output.js +1 -1
  159. package/dist/esm/types/config/performance.js +1 -1
  160. package/dist/esm/types/config/security.js +1 -1
  161. package/dist/esm/types/config/source.js +1 -1
  162. package/dist/esm/types/config/tools.js +1 -1
  163. package/dist/esm/types/hooks.js +1 -1
  164. package/dist/esm/types/legacyConfig/deploy.js +1 -1
  165. package/dist/esm/types/legacyConfig/dev.js +1 -1
  166. package/dist/esm/types/legacyConfig/index.js +1 -1
  167. package/dist/esm/types/legacyConfig/output.js +1 -1
  168. package/dist/esm/types/legacyConfig/source.js +1 -1
  169. package/dist/esm/types/legacyConfig/tools.js +1 -1
  170. package/dist/esm/types/utils.js +1 -1
  171. package/dist/esm/utils/config.js +285 -278
  172. package/dist/esm/utils/createServer.js +242 -234
  173. package/dist/esm/utils/env.js +11 -12
  174. package/dist/esm/utils/generateWatchFiles.js +205 -190
  175. package/dist/esm/utils/getSelectedEntries.js +180 -173
  176. package/dist/esm/utils/getServerInternalPlugins.js +197 -191
  177. package/dist/esm/utils/printInstructions.js +147 -141
  178. package/dist/esm/utils/restart.js +179 -173
  179. package/dist/esm/utils/routes.js +146 -139
  180. package/dist/esm/utils/types.js +1 -1
  181. package/dist/esm-node/analyze/constants.js +31 -46
  182. package/dist/esm-node/analyze/generateCode.js +28 -94
  183. package/dist/esm-node/analyze/getBundleEntry.js +8 -27
  184. package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +24 -65
  185. package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +24 -63
  186. package/dist/esm-node/analyze/getClientRoutes/index.js +2 -6
  187. package/dist/esm-node/analyze/getClientRoutes/utils.js +5 -19
  188. package/dist/esm-node/analyze/getFileSystemEntry.js +10 -37
  189. package/dist/esm-node/analyze/getHtmlTemplate.js +29 -59
  190. package/dist/esm-node/analyze/getServerRoutes.js +43 -75
  191. package/dist/esm-node/analyze/index.js +208 -230
  192. package/dist/esm-node/analyze/isDefaultExportFunction.js +7 -5
  193. package/dist/esm-node/analyze/makeLegalIdentifier.js +1 -4
  194. package/dist/esm-node/analyze/nestedRoutes.js +23 -43
  195. package/dist/esm-node/analyze/templates.js +22 -69
  196. package/dist/esm-node/analyze/utils.js +66 -60
  197. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +40 -62
  198. package/dist/esm-node/builder/builder-rspack/index.js +4 -5
  199. package/dist/esm-node/builder/builder-webpack/adapterModern.js +24 -26
  200. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +3 -10
  201. package/dist/esm-node/builder/builder-webpack/index.js +13 -11
  202. package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -5
  203. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +5 -6
  204. package/dist/esm-node/builder/generator/getBuilderTargets.js +5 -11
  205. package/dist/esm-node/builder/generator/index.js +7 -16
  206. package/dist/esm-node/builder/index.js +2 -7
  207. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -6
  208. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +34 -60
  209. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +54 -74
  210. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +23 -8
  211. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +25 -16
  212. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +66 -76
  213. package/dist/esm-node/builder/shared/createCopyInfo.js +2 -8
  214. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +1 -4
  215. package/dist/esm-node/builder/shared/types.js +1 -0
  216. package/dist/esm-node/commands/build.js +7 -9
  217. package/dist/esm-node/commands/deploy.js +1 -4
  218. package/dist/esm-node/commands/dev.js +19 -27
  219. package/dist/esm-node/commands/inspect.js +3 -8
  220. package/dist/esm-node/commands/serve.js +7 -25
  221. package/dist/esm-node/config/default.js +20 -11
  222. package/dist/esm-node/config/initialize/index.js +1 -4
  223. package/dist/esm-node/config/initialize/inits.js +48 -54
  224. package/dist/esm-node/config/legacy/createHtmlConfig.js +2 -19
  225. package/dist/esm-node/config/legacy/createOutputConfig.js +2 -30
  226. package/dist/esm-node/config/legacy/createSourceConfig.js +2 -17
  227. package/dist/esm-node/config/legacy/createToolsConfig.js +2 -22
  228. package/dist/esm-node/config/legacy/index.js +3 -18
  229. package/dist/esm-node/defineConfig.js +7 -13
  230. package/dist/esm-node/exports/server.js +1 -4
  231. package/dist/esm-node/hooks.js +2 -9
  232. package/dist/esm-node/index.js +95 -120
  233. package/dist/esm-node/initialize/index.js +74 -87
  234. package/dist/esm-node/locale/en.js +7 -6
  235. package/dist/esm-node/locale/index.js +5 -5
  236. package/dist/esm-node/locale/zh.js +7 -6
  237. package/dist/esm-node/schema/Schema.js +19 -8
  238. package/dist/esm-node/schema/index.js +121 -36
  239. package/dist/esm-node/schema/legacy.js +262 -72
  240. package/dist/esm-node/types/config/deploy.js +1 -0
  241. package/dist/esm-node/types/config/dev.js +1 -0
  242. package/dist/esm-node/types/config/experiments.js +1 -0
  243. package/dist/esm-node/types/config/html.js +1 -0
  244. package/dist/esm-node/types/config/output.js +1 -0
  245. package/dist/esm-node/types/config/performance.js +1 -0
  246. package/dist/esm-node/types/config/security.js +1 -0
  247. package/dist/esm-node/types/config/source.js +1 -0
  248. package/dist/esm-node/types/config/tools.js +1 -0
  249. package/dist/esm-node/types/hooks.js +1 -0
  250. package/dist/esm-node/types/legacyConfig/deploy.js +1 -0
  251. package/dist/esm-node/types/legacyConfig/dev.js +1 -0
  252. package/dist/esm-node/types/legacyConfig/index.js +1 -0
  253. package/dist/esm-node/types/legacyConfig/output.js +1 -0
  254. package/dist/esm-node/types/legacyConfig/source.js +1 -0
  255. package/dist/esm-node/types/legacyConfig/tools.js +1 -0
  256. package/dist/esm-node/types/utils.js +1 -0
  257. package/dist/esm-node/utils/config.js +16 -47
  258. package/dist/esm-node/utils/createServer.js +5 -12
  259. package/dist/esm-node/utils/env.js +1 -4
  260. package/dist/esm-node/utils/generateWatchFiles.js +13 -20
  261. package/dist/esm-node/utils/getSelectedEntries.js +2 -9
  262. package/dist/esm-node/utils/getServerInternalPlugins.js +2 -8
  263. package/dist/esm-node/utils/printInstructions.js +1 -4
  264. package/dist/esm-node/utils/restart.js +2 -11
  265. package/dist/esm-node/utils/routes.js +4 -4
  266. package/dist/esm-node/utils/types.js +1 -0
  267. package/dist/types/index.d.ts +2 -2
  268. package/lib/types.d.ts +1 -0
  269. package/package.json +29 -25
package/CHANGELOG.md CHANGED
@@ -1,5 +1,79 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.16.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e876ab: chore: package.json include the monorepo-relative directory
8
+
9
+ chore: 在 package.json 中声明 monorepo 的子路径
10
+
11
+ - 355d36e: feat: adjust create tools and new command option order
12
+
13
+ feat: 调整 create 工具及 new 命令 option 操作顺序
14
+
15
+ - 03997c2: chore(app-tools): export AppToolsOptions type
16
+
17
+ chore(app-tools): 导出 AppToolsOptions 类型
18
+
19
+ - Updated dependencies [fe92de6]
20
+ - Updated dependencies [091986a]
21
+ - Updated dependencies [5954330]
22
+ - Updated dependencies [50bc0db]
23
+ - Updated dependencies [fd4a8a6]
24
+ - Updated dependencies [7596520]
25
+ - Updated dependencies [4e876ab]
26
+ - Updated dependencies [6d5219e]
27
+ - Updated dependencies [e4e0e01]
28
+ - Updated dependencies [fb19f48]
29
+ - @modern-js/builder-shared@2.16.0
30
+ - @modern-js/builder-webpack-provider@2.16.0
31
+ - @modern-js/utils@2.16.0
32
+ - @modern-js/builder-rspack-provider@2.16.0
33
+ - @modern-js/plugin@2.16.0
34
+ - @modern-js/builder-plugin-node-polyfill@2.16.0
35
+ - @modern-js/node-bundle-require@2.16.0
36
+ - @modern-js/builder-plugin-esbuild@2.16.0
37
+ - @modern-js/plugin-data-loader@2.16.0
38
+ - @modern-js/new-action@2.16.0
39
+ - @modern-js/prod-server@2.16.0
40
+ - @modern-js/builder@2.16.0
41
+ - @modern-js/plugin-i18n@2.16.0
42
+ - @modern-js/plugin-lint@2.16.0
43
+ - @modern-js/upgrade@2.16.0
44
+ - @modern-js/server@2.16.0
45
+ - @modern-js/types@2.16.0
46
+ - @modern-js/core@2.16.0
47
+
48
+ ## 2.15.0
49
+
50
+ ### Patch Changes
51
+
52
+ - 18aeb8c: fix(app-tools): missing MODERN_TARGET type
53
+
54
+ fix(app-tools): 缺少 MODERN_TARGET 类型定义
55
+
56
+ - Updated dependencies [7d23d39]
57
+ - Updated dependencies [3e5e790]
58
+ - @modern-js/builder-rspack-provider@2.15.0
59
+ - @modern-js/builder-webpack-provider@2.15.0
60
+ - @modern-js/builder-shared@2.15.0
61
+ - @modern-js/builder@2.15.0
62
+ - @modern-js/builder-plugin-esbuild@2.15.0
63
+ - @modern-js/builder-plugin-node-polyfill@2.15.0
64
+ - @modern-js/core@2.15.0
65
+ - @modern-js/plugin-data-loader@2.15.0
66
+ - @modern-js/plugin-i18n@2.15.0
67
+ - @modern-js/plugin-lint@2.15.0
68
+ - @modern-js/new-action@2.15.0
69
+ - @modern-js/prod-server@2.15.0
70
+ - @modern-js/server@2.15.0
71
+ - @modern-js/node-bundle-require@2.15.0
72
+ - @modern-js/plugin@2.15.0
73
+ - @modern-js/types@2.15.0
74
+ - @modern-js/upgrade@2.15.0
75
+ - @modern-js/utils@2.15.0
76
+
3
77
  ## 2.14.0
4
78
 
5
79
  ### Minor Changes
@@ -1,47 +1,44 @@
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) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
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 constants_exports = {};
19
- __export(constants_exports, {
20
- APP_CONFIG_NAME: () => APP_CONFIG_NAME,
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ JS_EXTENSIONS: () => JS_EXTENSIONS,
14
+ INDEX_FILE_NAME: () => INDEX_FILE_NAME,
21
15
  APP_FILE_NAME: () => APP_FILE_NAME,
22
- APP_INIT_EXPORTED: () => APP_INIT_EXPORTED,
23
- APP_INIT_IMPORTED: () => APP_INIT_IMPORTED,
24
- ENTRY_BOOTSTRAP_FILE_NAME: () => ENTRY_BOOTSTRAP_FILE_NAME,
16
+ PAGES_DIR_NAME: () => PAGES_DIR_NAME,
17
+ NESTED_ROUTES_DIR: () => NESTED_ROUTES_DIR,
18
+ FILE_SYSTEM_ROUTES_FILE_NAME: () => FILE_SYSTEM_ROUTES_FILE_NAME,
19
+ LOADER_EXPORT_NAME: () => LOADER_EXPORT_NAME,
20
+ TEMP_LOADERS_DIR: () => TEMP_LOADERS_DIR,
25
21
  ENTRY_POINT_FILE_NAME: () => ENTRY_POINT_FILE_NAME,
26
- FILE_SYSTEM_ROUTES_COMPONENTS_DIR: () => FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
22
+ ENTRY_BOOTSTRAP_FILE_NAME: () => ENTRY_BOOTSTRAP_FILE_NAME,
27
23
  FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP: () => FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
28
- FILE_SYSTEM_ROUTES_FILE_NAME: () => FILE_SYSTEM_ROUTES_FILE_NAME,
24
+ FILE_SYSTEM_ROUTES_LAYOUT: () => FILE_SYSTEM_ROUTES_LAYOUT,
29
25
  FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT: () => FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
30
- FILE_SYSTEM_ROUTES_IGNORED_REGEX: () => FILE_SYSTEM_ROUTES_IGNORED_REGEX,
31
26
  FILE_SYSTEM_ROUTES_INDEX: () => FILE_SYSTEM_ROUTES_INDEX,
32
- FILE_SYSTEM_ROUTES_LAYOUT: () => FILE_SYSTEM_ROUTES_LAYOUT,
33
- HTML_PARTIALS_EXTENSIONS: () => HTML_PARTIALS_EXTENSIONS,
27
+ FILE_SYSTEM_ROUTES_IGNORED_REGEX: () => FILE_SYSTEM_ROUTES_IGNORED_REGEX,
34
28
  HTML_PARTIALS_FOLDER: () => HTML_PARTIALS_FOLDER,
35
- INDEX_FILE_NAME: () => INDEX_FILE_NAME,
36
- JS_EXTENSIONS: () => JS_EXTENSIONS,
37
- LOADER_EXPORT_NAME: () => LOADER_EXPORT_NAME,
29
+ HTML_PARTIALS_EXTENSIONS: () => HTML_PARTIALS_EXTENSIONS,
30
+ FILE_SYSTEM_ROUTES_COMPONENTS_DIR: () => FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
38
31
  NESTED_ROUTE: () => NESTED_ROUTE,
39
- NESTED_ROUTES_DIR: () => NESTED_ROUTES_DIR,
40
- PAGES_DIR_NAME: () => PAGES_DIR_NAME,
41
- TEMP_LOADERS_DIR: () => TEMP_LOADERS_DIR
32
+ APP_CONFIG_NAME: () => APP_CONFIG_NAME,
33
+ APP_INIT_EXPORTED: () => APP_INIT_EXPORTED,
34
+ APP_INIT_IMPORTED: () => APP_INIT_IMPORTED
42
35
  });
43
- module.exports = __toCommonJS(constants_exports);
44
- const JS_EXTENSIONS = [".js", ".ts", ".jsx", ".tsx"];
36
+ const JS_EXTENSIONS = [
37
+ ".js",
38
+ ".ts",
39
+ ".jsx",
40
+ ".tsx"
41
+ ];
45
42
  const INDEX_FILE_NAME = "index";
46
43
  const APP_FILE_NAME = "App";
47
44
  const PAGES_DIR_NAME = "pages";
@@ -57,7 +54,11 @@ const FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = "_app";
57
54
  const FILE_SYSTEM_ROUTES_INDEX = "index";
58
55
  const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/;
59
56
  const HTML_PARTIALS_FOLDER = "html";
60
- const HTML_PARTIALS_EXTENSIONS = [".htm", ".html", ".ejs"];
57
+ const HTML_PARTIALS_EXTENSIONS = [
58
+ ".htm",
59
+ ".html",
60
+ ".ejs"
61
+ ];
61
62
  const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
62
63
  const NESTED_ROUTE = {
63
64
  LAYOUT_FILE: "layout",
@@ -75,28 +76,3 @@ const NESTED_ROUTE = {
75
76
  const APP_CONFIG_NAME = "config";
76
77
  const APP_INIT_EXPORTED = "init";
77
78
  const APP_INIT_IMPORTED = "appInit";
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- APP_CONFIG_NAME,
81
- APP_FILE_NAME,
82
- APP_INIT_EXPORTED,
83
- APP_INIT_IMPORTED,
84
- ENTRY_BOOTSTRAP_FILE_NAME,
85
- ENTRY_POINT_FILE_NAME,
86
- FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
87
- FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
88
- FILE_SYSTEM_ROUTES_FILE_NAME,
89
- FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
90
- FILE_SYSTEM_ROUTES_IGNORED_REGEX,
91
- FILE_SYSTEM_ROUTES_INDEX,
92
- FILE_SYSTEM_ROUTES_LAYOUT,
93
- HTML_PARTIALS_EXTENSIONS,
94
- HTML_PARTIALS_FOLDER,
95
- INDEX_FILE_NAME,
96
- JS_EXTENSIONS,
97
- LOADER_EXPORT_NAME,
98
- NESTED_ROUTE,
99
- NESTED_ROUTES_DIR,
100
- PAGES_DIR_NAME,
101
- TEMP_LOADERS_DIR
102
- });
@@ -1,43 +1,70 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var generateCode_exports = {};
29
- __export(generateCode_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
30
13
  createImportStatements: () => createImportStatements,
31
14
  generateCode: () => generateCode
32
15
  });
33
- module.exports = __toCommonJS(generateCode_exports);
34
- var import_path = __toESM(require("path"));
35
- var import_utils = require("@modern-js/utils");
36
- var templates = __toESM(require("./templates"));
37
- var import_getClientRoutes = require("./getClientRoutes");
38
- var import_constants = require("./constants");
39
- var import_utils2 = require("./utils");
40
- var import_nestedRoutes = require("./nestedRoutes");
16
+ const _path = /* @__PURE__ */ _interop_require_default(require("path"));
17
+ const _utils = require("@modern-js/utils");
18
+ const _templates = /* @__PURE__ */ _interop_require_wildcard(require("./templates"));
19
+ const _getClientRoutes = require("./getClientRoutes");
20
+ const _constants = require("./constants");
21
+ const _utils1 = require("./utils");
22
+ const _nestedRoutes = require("./nestedRoutes");
23
+ function _interop_require_default(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
28
+ function _getRequireWildcardCache(nodeInterop) {
29
+ if (typeof WeakMap !== "function")
30
+ return null;
31
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
32
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
33
+ return (_getRequireWildcardCache = function(nodeInterop2) {
34
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
35
+ })(nodeInterop);
36
+ }
37
+ function _interop_require_wildcard(obj, nodeInterop) {
38
+ if (!nodeInterop && obj && obj.__esModule) {
39
+ return obj;
40
+ }
41
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
42
+ return {
43
+ default: obj
44
+ };
45
+ }
46
+ var cache = _getRequireWildcardCache(nodeInterop);
47
+ if (cache && cache.has(obj)) {
48
+ return cache.get(obj);
49
+ }
50
+ var newObj = {};
51
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
52
+ for (var key in obj) {
53
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
54
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
55
+ if (desc && (desc.get || desc.set)) {
56
+ Object.defineProperty(newObj, key, desc);
57
+ } else {
58
+ newObj[key] = obj[key];
59
+ }
60
+ }
61
+ }
62
+ newObj.default = obj;
63
+ if (cache) {
64
+ cache.set(obj, newObj);
65
+ }
66
+ return newObj;
67
+ }
41
68
  const createImportSpecifier = (specifiers) => {
42
69
  let defaults = "";
43
70
  const named = [];
@@ -59,7 +86,6 @@ const createImportSpecifier = (specifiers) => {
59
86
  }
60
87
  };
61
88
  const createImportStatements = (statements) => {
62
- var _a, _b;
63
89
  const deDuplicated = [];
64
90
  const seen = /* @__PURE__ */ new Map();
65
91
  for (const { value, specifiers, initialize } of statements) {
@@ -71,38 +97,30 @@ const createImportStatements = (statements) => {
71
97
  });
72
98
  seen.set(value, specifiers);
73
99
  } else {
100
+ var _deDuplicated_modifyIndex;
74
101
  seen.get(value).push(...specifiers);
75
102
  const modifyIndex = deDuplicated.findIndex((v) => v.value === value);
76
- const originInitialize = (_b = (_a = deDuplicated[modifyIndex]) == null ? void 0 : _a.initialize) != null ? _b : "";
77
- deDuplicated[modifyIndex].initialize = originInitialize.concat(
78
- `
79
- ${initialize || ""}`
80
- );
103
+ var _deDuplicated_modifyIndex_initialize;
104
+ const originInitialize = (_deDuplicated_modifyIndex_initialize = (_deDuplicated_modifyIndex = deDuplicated[modifyIndex]) === null || _deDuplicated_modifyIndex === void 0 ? void 0 : _deDuplicated_modifyIndex.initialize) !== null && _deDuplicated_modifyIndex_initialize !== void 0 ? _deDuplicated_modifyIndex_initialize : "";
105
+ deDuplicated[modifyIndex].initialize = originInitialize.concat(`
106
+ ${initialize || ""}`);
81
107
  }
82
108
  }
83
- return deDuplicated.map(
84
- ({ value, specifiers, initialize }) => `import ${createImportSpecifier(specifiers)} from '${value}';
85
- ${initialize || ""}`
86
- ).join("\n");
109
+ return deDuplicated.map(({ value, specifiers, initialize }) => `import ${createImportSpecifier(specifiers)} from '${value}';
110
+ ${initialize || ""}`).join("\n");
87
111
  };
88
112
  const generateCode = async (appContext, config, entrypoints, api) => {
89
- const {
90
- internalDirectory,
91
- srcDirectory,
92
- internalDirAlias,
93
- internalSrcAlias,
94
- packageName
95
- } = appContext;
113
+ const { internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName } = appContext;
96
114
  const hookRunners = api.useHookRunners();
97
- const isV5 = (0, import_utils.isRouterV5)(config);
115
+ const isV5 = (0, _utils.isRouterV5)(config);
98
116
  const { mountId } = config.html;
99
- const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
117
+ const getRoutes = isV5 ? _getClientRoutes.getClientRoutesLegacy : _getClientRoutes.getClientRoutes;
100
118
  await Promise.all(entrypoints.map(generateEntryCode));
101
119
  async function generateEntryCode(entrypoint) {
102
- var _a;
103
120
  const { entryName, isAutoMount, customBootstrap, fileSystemRoutes } = entrypoint;
104
121
  if (isAutoMount) {
105
122
  if (fileSystemRoutes) {
123
+ var _config_output;
106
124
  let initialRoutes = [];
107
125
  let nestedRoute = null;
108
126
  if (entrypoint.entry) {
@@ -115,15 +133,10 @@ const generateCode = async (appContext, config, entrypoints, api) => {
115
133
  });
116
134
  }
117
135
  if (!isV5 && entrypoint.nestedRoutesEntry) {
118
- nestedRoute = await (0, import_nestedRoutes.walk)(
119
- entrypoint.nestedRoutesEntry,
120
- entrypoint.nestedRoutesEntry,
121
- {
122
- name: internalSrcAlias,
123
- basename: srcDirectory
124
- },
125
- entrypoint.entryName
126
- );
136
+ nestedRoute = await (0, _nestedRoutes.walk)(entrypoint.nestedRoutesEntry, entrypoint.nestedRoutesEntry, {
137
+ name: internalSrcAlias,
138
+ basename: srcDirectory
139
+ }, entrypoint.entryName);
127
140
  if (nestedRoute) {
128
141
  initialRoutes.unshift(nestedRoute);
129
142
  }
@@ -133,75 +146,48 @@ const generateCode = async (appContext, config, entrypoints, api) => {
133
146
  routes: initialRoutes
134
147
  });
135
148
  const config2 = api.useResolvedConfigContext();
136
- const ssr = (0, import_utils.getEntryOptions)(
137
- entryName,
138
- config2.server.ssr,
139
- config2.server.ssrByEntries,
140
- packageName
141
- );
142
- const useSSG = (0, import_utils.isSSGEntry)(config2, entryName, entrypoints);
149
+ const ssr = (0, _utils.getEntryOptions)(entryName, config2.server.ssr, config2.server.ssrByEntries, packageName);
150
+ const useSSG = (0, _utils.isSSGEntry)(config2, entryName, entrypoints);
143
151
  let mode;
144
152
  if (ssr) {
145
153
  mode = typeof ssr === "object" ? ssr.mode || "string" : "string";
146
154
  }
147
155
  if (mode === "stream") {
148
- const hasPageRoute = routes.some(
149
- (route) => "type" in route && route.type === "page"
150
- );
156
+ const hasPageRoute = routes.some((route) => "type" in route && route.type === "page");
151
157
  if (hasPageRoute) {
152
- import_utils.logger.error(
153
- "Streaming ssr is not supported when pages dir exists"
154
- );
158
+ _utils.logger.error("Streaming ssr is not supported when pages dir exists");
155
159
  process.exit(1);
156
160
  }
157
161
  }
158
162
  const { code: code2 } = await hookRunners.beforeGenerateRoutes({
159
163
  entrypoint,
160
- code: await templates.fileSystemRoutes({
164
+ code: await _templates.fileSystemRoutes({
161
165
  routes,
162
166
  ssrMode: useSSG ? "string" : mode,
163
167
  nestedRoutesEntry: entrypoint.nestedRoutesEntry,
164
168
  entryName: entrypoint.entryName,
165
169
  internalDirectory,
166
- splitRouteChunks: (_a = config2 == null ? void 0 : config2.output) == null ? void 0 : _a.splitRouteChunks
170
+ splitRouteChunks: config2 === null || config2 === void 0 ? void 0 : (_config_output = config2.output) === null || _config_output === void 0 ? void 0 : _config_output.splitRouteChunks
167
171
  })
168
172
  });
169
- if (entrypoint.nestedRoutesEntry && (0, import_utils.isUseSSRBundle)(config2)) {
170
- const routesServerFile = (0, import_utils2.getServerLoadersFile)(
171
- internalDirectory,
172
- entryName
173
- );
174
- const code3 = templates.routesForServer({
173
+ if (entrypoint.nestedRoutesEntry && (0, _utils.isUseSSRBundle)(config2)) {
174
+ const routesServerFile = (0, _utils1.getServerLoadersFile)(internalDirectory, entryName);
175
+ const code3 = _templates.routesForServer({
175
176
  routes
176
177
  });
177
- await import_utils.fs.ensureFile(routesServerFile);
178
- await import_utils.fs.writeFile(routesServerFile, code3);
178
+ await _utils.fs.ensureFile(routesServerFile);
179
+ await _utils.fs.writeFile(routesServerFile, code3);
179
180
  }
180
- const serverLoaderCombined = templates.ssrLoaderCombinedModule(
181
- entrypoints,
182
- entrypoint,
183
- config2,
184
- appContext
185
- );
181
+ const serverLoaderCombined = _templates.ssrLoaderCombinedModule(entrypoints, entrypoint, config2, appContext);
186
182
  if (serverLoaderCombined) {
187
- const serverLoaderFile = (0, import_utils2.getServerCombinedModueFile)(
188
- internalDirectory,
189
- entryName
190
- );
191
- await import_utils.fs.outputFile(serverLoaderFile, serverLoaderCombined);
183
+ const serverLoaderFile = (0, _utils1.getServerCombinedModueFile)(internalDirectory, entryName);
184
+ await _utils.fs.outputFile(serverLoaderFile, serverLoaderCombined);
192
185
  }
193
- import_utils.fs.outputFileSync(
194
- import_path.default.resolve(
195
- internalDirectory,
196
- `./${entryName}/${import_constants.FILE_SYSTEM_ROUTES_FILE_NAME}`
197
- ),
198
- code2,
199
- "utf8"
200
- );
186
+ _utils.fs.outputFileSync(_path.default.resolve(internalDirectory, `./${entryName}/${_constants.FILE_SYSTEM_ROUTES_FILE_NAME}`), code2, "utf8");
201
187
  }
202
188
  const { imports: importStatements } = await hookRunners.modifyEntryImports({
203
189
  entrypoint,
204
- imports: (0, import_utils2.getDefaultImports)({
190
+ imports: (0, _utils1.getDefaultImports)({
205
191
  entrypoint,
206
192
  srcDirectory,
207
193
  internalSrcAlias,
@@ -215,7 +201,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
215
201
  });
216
202
  const { code: renderFunction } = await hookRunners.modifyEntryRenderFunction({
217
203
  entrypoint,
218
- code: templates.renderFunction({
204
+ code: _templates.renderFunction({
219
205
  plugins,
220
206
  customBootstrap,
221
207
  fileSystemRoutes
@@ -225,36 +211,25 @@ const generateCode = async (appContext, config, entrypoints, api) => {
225
211
  entrypoint,
226
212
  exportStatement: "export default AppWrapper;"
227
213
  });
228
- const code = templates.index({
214
+ const code = _templates.index({
229
215
  mountId,
230
216
  imports: createImportStatements(importStatements),
231
217
  renderFunction,
232
218
  exportStatement
233
219
  });
234
- const entryFile = import_path.default.resolve(
235
- internalDirectory,
236
- `./${entryName}/${import_constants.ENTRY_POINT_FILE_NAME}`
237
- );
220
+ const entryFile = _path.default.resolve(internalDirectory, `./${entryName}/${_constants.ENTRY_POINT_FILE_NAME}`);
238
221
  entrypoint.entry = entryFile;
239
222
  if (config.source.enableAsyncEntry) {
240
223
  const { code: asyncEntryCode } = await hookRunners.modifyAsyncEntry({
241
224
  entrypoint,
242
- code: `import('./${import_constants.ENTRY_BOOTSTRAP_FILE_NAME}');`
225
+ code: `import('./${_constants.ENTRY_BOOTSTRAP_FILE_NAME}');`
243
226
  });
244
- import_utils.fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
245
- const bootstrapFile = import_path.default.resolve(
246
- internalDirectory,
247
- `./${entryName}/${import_constants.ENTRY_BOOTSTRAP_FILE_NAME}`
248
- );
249
- import_utils.fs.outputFileSync(bootstrapFile, code, "utf8");
227
+ _utils.fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
228
+ const bootstrapFile = _path.default.resolve(internalDirectory, `./${entryName}/${_constants.ENTRY_BOOTSTRAP_FILE_NAME}`);
229
+ _utils.fs.outputFileSync(bootstrapFile, code, "utf8");
250
230
  } else {
251
- import_utils.fs.outputFileSync(entryFile, code, "utf8");
231
+ _utils.fs.outputFileSync(entryFile, code, "utf8");
252
232
  }
253
233
  }
254
234
  }
255
235
  };
256
- // Annotate the CommonJS export names for ESM import in node:
257
- 0 && (module.exports = {
258
- createImportStatements,
259
- generateCode
260
- });
@@ -1,42 +1,23 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var getBundleEntry_exports = {};
29
- __export(getBundleEntry_exports, {
30
- getBundleEntry: () => getBundleEntry
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
31
4
  });
32
- module.exports = __toCommonJS(getBundleEntry_exports);
33
- var import_path = __toESM(require("path"));
34
- var import_utils = require("@modern-js/utils");
35
- var import_getFileSystemEntry = require("./getFileSystemEntry");
36
- var import_constants = require("./constants");
5
+ Object.defineProperty(exports, "getBundleEntry", {
6
+ enumerable: true,
7
+ get: () => getBundleEntry
8
+ });
9
+ const _path = /* @__PURE__ */ _interop_require_default(require("path"));
10
+ const _utils = require("@modern-js/utils");
11
+ const _getFileSystemEntry = require("./getFileSystemEntry");
12
+ const _constants = require("./constants");
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
37
18
  const ensureExtensions = (file) => {
38
- if (!import_path.default.extname(file)) {
39
- return (0, import_utils.findExists)(import_constants.JS_EXTENSIONS.map((ext) => `${file}${ext}`)) || file;
19
+ if (!_path.default.extname(file)) {
20
+ return (0, _utils.findExists)(_constants.JS_EXTENSIONS.map((ext) => `${file}${ext}`)) || file;
40
21
  }
41
22
  return file;
42
23
  };
@@ -46,43 +27,35 @@ const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint)
46
27
  return true;
47
28
  }
48
29
  if (entrypoint.entry.startsWith(checked.entry) || checked.entry.startsWith(entrypoint.entry)) {
49
- throw new Error(
50
- `Entry configuration conflicts
30
+ throw new Error(`Entry configuration conflicts
51
31
  Your configuration: ${checked.entry}.
52
32
  Default entrypoint: ${entrypoint.entry}
53
- Please reset source.entries or set source.disableDefaultEntries to disable the default entry rules.`
54
- );
33
+ Please reset source.entries or set source.disableDefaultEntries to disable the default entry rules.`);
55
34
  }
56
35
  return false;
57
36
  });
58
37
  const getBundleEntry = (appContext, config) => {
59
38
  const { appDirectory, packageName } = appContext;
60
- const {
61
- source: { disableDefaultEntries, entries, entriesDir }
62
- } = config;
63
- const defaults = disableDefaultEntries ? [] : (0, import_getFileSystemEntry.getFileSystemEntry)(appContext, config);
39
+ const { source: { disableDefaultEntries, entries, entriesDir } } = config;
40
+ const defaults = disableDefaultEntries ? [] : (0, _getFileSystemEntry.getFileSystemEntry)(appContext, config);
64
41
  if (entries) {
65
42
  Object.keys(entries).forEach((name) => {
66
43
  const value = entries[name];
67
44
  const entrypoint = typeof value === "string" ? {
68
45
  entryName: name,
69
- entry: (0, import_utils.ensureAbsolutePath)(appDirectory, value),
70
- absoluteEntryDir: import_path.default.dirname(
71
- (0, import_utils.ensureAbsolutePath)(appDirectory, value)
72
- ),
46
+ entry: (0, _utils.ensureAbsolutePath)(appDirectory, value),
47
+ absoluteEntryDir: _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value)),
73
48
  isAutoMount: true,
74
- fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, value)).isDirectory() ? {} : void 0
49
+ fileSystemRoutes: _utils.fs.statSync((0, _utils.ensureAbsolutePath)(appDirectory, value)).isDirectory() ? {} : void 0
75
50
  } : {
76
51
  entryName: name,
77
- entry: (0, import_utils.ensureAbsolutePath)(appDirectory, value.entry),
78
- absoluteEntryDir: import_path.default.dirname(
79
- (0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)
80
- ),
52
+ entry: (0, _utils.ensureAbsolutePath)(appDirectory, value.entry),
53
+ absoluteEntryDir: _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)),
81
54
  isAutoMount: !value.disableMount,
82
- customBootstrap: value.customBootstrap && (0, import_utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
83
- fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
55
+ customBootstrap: value.customBootstrap && (0, _utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
56
+ fileSystemRoutes: _utils.fs.statSync((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
84
57
  };
85
- if (entrypoint.fileSystemRoutes && (0, import_utils.isRouterV5)(config)) {
58
+ if (entrypoint.fileSystemRoutes && (0, _utils.isRouterV5)(config)) {
86
59
  entrypoint.nestedRoutesEntry = entrypoint.entry;
87
60
  }
88
61
  if (!ifAlreadyExists(defaults, entrypoint)) {
@@ -91,15 +64,9 @@ const getBundleEntry = (appContext, config) => {
91
64
  });
92
65
  }
93
66
  if (!disableDefaultEntries) {
94
- const entriesDirAbs = (0, import_utils.ensureAbsolutePath)(appDirectory, entriesDir || "");
95
- const found = defaults.find(
96
- ({ entryName, entry, nestedRoutesEntry = "" }) => entryName === packageName || import_path.default.dirname(entry) === entriesDirAbs || import_path.default.dirname(nestedRoutesEntry) === entriesDirAbs
97
- );
98
- found && (found.entryName = import_utils.MAIN_ENTRY_NAME);
67
+ const entriesDirAbs = (0, _utils.ensureAbsolutePath)(appDirectory, entriesDir || "");
68
+ const found = defaults.find(({ entryName, entry, nestedRoutesEntry = "" }) => entryName === packageName || _path.default.dirname(entry) === entriesDirAbs || _path.default.dirname(nestedRoutesEntry) === entriesDirAbs);
69
+ found && (found.entryName = _utils.MAIN_ENTRY_NAME);
99
70
  }
100
71
  return defaults;
101
72
  };
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {
104
- getBundleEntry
105
- });