@modern-js/app-tools 2.4.0 → 2.5.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 (302) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/{js/node → cjs}/analyze/constants.js +0 -0
  3. package/dist/cjs/analyze/generateCode.js +249 -0
  4. package/dist/{js/node → cjs}/analyze/getBundleEntry.js +6 -0
  5. package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutes.js +1 -18
  6. package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutesLegacy.js +1 -18
  7. package/dist/{js/node → cjs}/analyze/getClientRoutes/index.js +0 -0
  8. package/dist/{js/node → cjs}/analyze/getClientRoutes/utils.js +0 -0
  9. package/dist/{js/node → cjs}/analyze/getFileSystemEntry.js +0 -0
  10. package/dist/{js/node → cjs}/analyze/getHtmlTemplate.js +4 -24
  11. package/dist/{js/node → cjs}/analyze/getServerRoutes.js +22 -42
  12. package/dist/cjs/analyze/index.js +290 -0
  13. package/dist/{js/node → cjs}/analyze/isDefaultExportFunction.js +0 -0
  14. package/dist/{js/node → cjs}/analyze/makeLegalIdentifier.js +0 -0
  15. package/dist/{js/node → cjs}/analyze/nestedRoutes.js +16 -50
  16. package/dist/{js/node → cjs}/analyze/templates.js +16 -49
  17. package/dist/{js/node → cjs}/analyze/utils.js +9 -29
  18. package/dist/{js/node → cjs}/builder/builder-rspack/index.js +0 -0
  19. package/dist/{js/node → cjs}/builder/builder-webpack/builderPlugins/compatModern.js +0 -0
  20. package/dist/{js/node → cjs}/builder/builder-webpack/index.js +22 -62
  21. package/dist/{js/node → cjs}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +7 -24
  22. package/dist/{js/node → cjs}/builder/builder-webpack/webpackPlugins/index.js +0 -0
  23. package/dist/{js/node → cjs}/builder/generator/createBuilderOptions.js +0 -0
  24. package/dist/{js/node → cjs}/builder/generator/createBuilderProviderConfig.js +14 -25
  25. package/dist/{js/node → cjs}/builder/generator/getBuilderTargets.js +4 -0
  26. package/dist/cjs/builder/generator/index.js +58 -0
  27. package/dist/{js/node → cjs}/builder/index.js +12 -34
  28. package/dist/{js/node → cjs}/builder/shared/builderPlugins/adapterModern.js +35 -34
  29. package/dist/{js/node → cjs}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
  30. package/dist/{js/node → cjs}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -0
  31. package/dist/{js/node → cjs}/builder/shared/createCopyPattern.js +0 -0
  32. package/dist/{js/node → cjs}/builder/shared/index.js +0 -0
  33. package/dist/{js/node → cjs}/builder/shared/loaders/serverModuleLoader.js +0 -0
  34. package/dist/{js/node → cjs}/builder/shared/types.js +0 -0
  35. package/dist/{js/node → cjs}/commands/build.js +9 -46
  36. package/dist/cjs/commands/deploy.js +31 -0
  37. package/dist/{js/node → cjs}/commands/dev.js +17 -52
  38. package/dist/{js/node → cjs}/commands/index.js +0 -0
  39. package/dist/{js/node → cjs}/commands/inspect.js +2 -22
  40. package/dist/{js/node → cjs}/commands/serve.js +8 -28
  41. package/dist/{js/node → cjs}/config/default.js +15 -26
  42. package/dist/{js/node → cjs}/config/index.js +0 -0
  43. package/dist/{js/node → cjs}/config/initialize/index.js +0 -0
  44. package/dist/{js/node → cjs}/config/initialize/inits.js +4 -20
  45. package/dist/{js/node → cjs}/config/legacy/createHtmlConfig.js +0 -0
  46. package/dist/{js/node → cjs}/config/legacy/createOutputConfig.js +0 -0
  47. package/dist/{js/node → cjs}/config/legacy/createSourceConfig.js +0 -0
  48. package/dist/{js/node → cjs}/config/legacy/createToolsConfig.js +0 -0
  49. package/dist/{js/node → cjs}/config/legacy/index.js +0 -0
  50. package/dist/cjs/defineConfig.js +33 -0
  51. package/dist/{js/node → cjs}/exports/server.js +0 -0
  52. package/dist/{js/node → cjs}/hooks.js +0 -0
  53. package/dist/cjs/index.js +198 -0
  54. package/dist/cjs/initialize/index.js +102 -0
  55. package/dist/{js/node → cjs}/locale/en.js +0 -0
  56. package/dist/{js/node → cjs}/locale/index.js +0 -0
  57. package/dist/{js/node → cjs}/locale/zh.js +0 -0
  58. package/dist/{js/node → cjs}/schema/Schema.js +0 -0
  59. package/dist/{js/node → cjs}/schema/index.js +0 -0
  60. package/dist/{js/node → cjs}/schema/legacy.js +0 -0
  61. package/dist/{js/node → cjs}/types/config/deploy.js +0 -0
  62. package/dist/{js/node → cjs}/types/config/dev.js +0 -0
  63. package/dist/{js/node → cjs}/types/config/experiments.js +0 -0
  64. package/dist/{js/node → cjs}/types/config/html.js +0 -0
  65. package/dist/{js/node → cjs}/types/config/index.js +0 -0
  66. package/dist/{js/node → cjs}/types/config/output.js +0 -0
  67. package/dist/{js/node → cjs}/types/config/performance.js +0 -0
  68. package/dist/{js/node → cjs}/types/config/security.js +0 -0
  69. package/dist/{js/node → cjs}/types/config/source.js +0 -0
  70. package/dist/{js/node → cjs}/types/config/tools.js +0 -0
  71. package/dist/{js/node → cjs}/types/hooks.js +0 -0
  72. package/dist/{js/node → cjs}/types/index.js +0 -0
  73. package/dist/{js/node → cjs}/types/legacyConfig/deploy.js +0 -0
  74. package/dist/{js/node → cjs}/types/legacyConfig/dev.js +0 -0
  75. package/dist/{js/node → cjs}/types/legacyConfig/index.js +0 -0
  76. package/dist/{js/node → cjs}/types/legacyConfig/output.js +0 -0
  77. package/dist/{js/node → cjs}/types/legacyConfig/source.js +0 -0
  78. package/dist/{js/node → cjs}/types/legacyConfig/tools.js +0 -0
  79. package/dist/{js/node → cjs}/types/utils.js +0 -0
  80. package/dist/{js/node → cjs}/utils/config.js +19 -57
  81. package/dist/{js/node → cjs}/utils/createServer.js +10 -46
  82. package/dist/{js/node → cjs}/utils/env.js +0 -0
  83. package/dist/{js/node → cjs}/utils/generateWatchFiles.js +16 -38
  84. package/dist/{js/node → cjs}/utils/getSelectedEntries.js +3 -23
  85. package/dist/cjs/utils/getServerInternalPlugins.js +41 -0
  86. package/dist/{js/node → cjs}/utils/language.js +0 -0
  87. package/dist/{js/node → cjs}/utils/printInstructions.js +3 -23
  88. package/dist/cjs/utils/restart.js +45 -0
  89. package/dist/{js/node → cjs}/utils/routes.js +3 -23
  90. package/dist/{js/node → cjs}/utils/types.js +0 -0
  91. package/dist/{js/treeshaking → esm}/analyze/constants.js +0 -0
  92. package/dist/{js/treeshaking → esm}/analyze/generateCode.js +14 -14
  93. package/dist/{js/treeshaking → esm}/analyze/getBundleEntry.js +4 -2
  94. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutes.js +1 -1
  95. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
  96. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/index.js +0 -0
  97. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/utils.js +0 -0
  98. package/dist/{js/treeshaking → esm}/analyze/getFileSystemEntry.js +1 -1
  99. package/dist/{js/treeshaking → esm}/analyze/getHtmlTemplate.js +0 -0
  100. package/dist/{js/treeshaking → esm}/analyze/getServerRoutes.js +8 -6
  101. package/dist/{js/treeshaking → esm}/analyze/index.js +8 -8
  102. package/dist/{js/treeshaking → esm}/analyze/isDefaultExportFunction.js +0 -0
  103. package/dist/{js/treeshaking → esm}/analyze/makeLegalIdentifier.js +0 -0
  104. package/dist/{js/treeshaking → esm}/analyze/nestedRoutes.js +5 -5
  105. package/dist/{js/treeshaking → esm}/analyze/templates.js +8 -7
  106. package/dist/{js/treeshaking → esm}/analyze/utils.js +3 -3
  107. package/dist/{js/treeshaking → esm}/builder/builder-rspack/index.js +0 -0
  108. package/dist/{js/treeshaking → esm}/builder/builder-webpack/builderPlugins/compatModern.js +4 -4
  109. package/dist/{js/treeshaking → esm}/builder/builder-webpack/index.js +2 -2
  110. package/dist/{js/treeshaking → esm}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +5 -2
  111. package/dist/{js/treeshaking → esm}/builder/builder-webpack/webpackPlugins/index.js +0 -0
  112. package/dist/{js/treeshaking → esm}/builder/generator/createBuilderOptions.js +2 -2
  113. package/dist/{js/treeshaking → esm}/builder/generator/createBuilderProviderConfig.js +0 -0
  114. package/dist/{js/treeshaking → esm}/builder/generator/getBuilderTargets.js +5 -1
  115. package/dist/{js/treeshaking → esm}/builder/generator/index.js +2 -2
  116. package/dist/{js/treeshaking → esm}/builder/index.js +0 -0
  117. package/dist/{js/treeshaking → esm}/builder/shared/builderPlugins/adapterModern.js +62 -13
  118. package/dist/{js/treeshaking → esm}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
  119. package/dist/{js/treeshaking → esm}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +2 -2
  120. package/dist/{js/treeshaking → esm}/builder/shared/createCopyPattern.js +0 -0
  121. package/dist/{js/treeshaking → esm}/builder/shared/index.js +0 -0
  122. package/dist/{js/treeshaking → esm}/builder/shared/loaders/serverModuleLoader.js +0 -0
  123. package/dist/{js/treeshaking → esm}/builder/shared/types.js +0 -0
  124. package/dist/{js/treeshaking → esm}/commands/build.js +0 -0
  125. package/dist/{js/treeshaking → esm}/commands/deploy.js +0 -0
  126. package/dist/{js/treeshaking → esm}/commands/dev.js +2 -2
  127. package/dist/{js/treeshaking → esm}/commands/index.js +0 -0
  128. package/dist/{js/treeshaking → esm}/commands/inspect.js +0 -0
  129. package/dist/{js/treeshaking → esm}/commands/serve.js +2 -2
  130. package/dist/{js/treeshaking → esm}/config/default.js +0 -0
  131. package/dist/{js/treeshaking → esm}/config/index.js +0 -0
  132. package/dist/{js/treeshaking → esm}/config/initialize/index.js +0 -0
  133. package/dist/{js/treeshaking → esm}/config/initialize/inits.js +2 -2
  134. package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
  135. package/dist/{js/treeshaking → esm}/config/legacy/createOutputConfig.js +1 -1
  136. package/dist/{js/treeshaking → esm}/config/legacy/createSourceConfig.js +1 -1
  137. package/dist/{js/treeshaking → esm}/config/legacy/createToolsConfig.js +1 -1
  138. package/dist/{js/treeshaking → esm}/config/legacy/index.js +0 -0
  139. package/dist/{js/treeshaking → esm}/defineConfig.js +0 -0
  140. package/dist/{js/treeshaking → esm}/exports/server.js +0 -0
  141. package/dist/{js/treeshaking → esm}/hooks.js +0 -0
  142. package/dist/{js/treeshaking → esm}/index.js +0 -0
  143. package/dist/{js/treeshaking → esm}/initialize/index.js +2 -2
  144. package/dist/{js/treeshaking → esm}/locale/en.js +0 -0
  145. package/dist/{js/treeshaking → esm}/locale/index.js +0 -0
  146. package/dist/{js/treeshaking → esm}/locale/zh.js +0 -0
  147. package/dist/{js/treeshaking → esm}/schema/Schema.js +0 -0
  148. package/dist/{js/treeshaking → esm}/schema/index.js +0 -0
  149. package/dist/{js/treeshaking → esm}/schema/legacy.js +0 -0
  150. package/dist/{js/treeshaking → esm}/types/config/deploy.js +0 -0
  151. package/dist/{js/treeshaking → esm}/types/config/dev.js +0 -0
  152. package/dist/{js/treeshaking → esm}/types/config/experiments.js +0 -0
  153. package/dist/{js/treeshaking → esm}/types/config/html.js +0 -0
  154. package/dist/{js/treeshaking → esm}/types/config/index.js +0 -0
  155. package/dist/{js/treeshaking → esm}/types/config/output.js +0 -0
  156. package/dist/{js/treeshaking → esm}/types/config/performance.js +0 -0
  157. package/dist/{js/treeshaking → esm}/types/config/security.js +0 -0
  158. package/dist/{js/treeshaking → esm}/types/config/source.js +0 -0
  159. package/dist/{js/treeshaking → esm}/types/config/tools.js +0 -0
  160. package/dist/{js/treeshaking → esm}/types/hooks.js +0 -0
  161. package/dist/{js/treeshaking → esm}/types/index.js +0 -0
  162. package/dist/{js/treeshaking → esm}/types/legacyConfig/deploy.js +0 -0
  163. package/dist/{js/treeshaking → esm}/types/legacyConfig/dev.js +0 -0
  164. package/dist/{js/treeshaking → esm}/types/legacyConfig/index.js +0 -0
  165. package/dist/{js/treeshaking → esm}/types/legacyConfig/output.js +0 -0
  166. package/dist/{js/treeshaking → esm}/types/legacyConfig/source.js +0 -0
  167. package/dist/{js/treeshaking → esm}/types/legacyConfig/tools.js +0 -0
  168. package/dist/{js/treeshaking → esm}/types/utils.js +0 -0
  169. package/dist/{js/treeshaking → esm}/utils/config.js +2 -2
  170. package/dist/{js/treeshaking → esm}/utils/createServer.js +0 -0
  171. package/dist/{js/treeshaking → esm}/utils/env.js +0 -0
  172. package/dist/{js/treeshaking → esm}/utils/generateWatchFiles.js +0 -0
  173. package/dist/{js/treeshaking → esm}/utils/getSelectedEntries.js +0 -0
  174. package/dist/{js/treeshaking → esm}/utils/getServerInternalPlugins.js +2 -2
  175. package/dist/{js/treeshaking → esm}/utils/language.js +0 -0
  176. package/dist/{js/treeshaking → esm}/utils/printInstructions.js +0 -0
  177. package/dist/{js/treeshaking → esm}/utils/restart.js +0 -0
  178. package/dist/{js/treeshaking → esm}/utils/routes.js +0 -0
  179. package/dist/{js/treeshaking → esm}/utils/types.js +0 -0
  180. package/dist/{js/modern → esm-node}/analyze/constants.js +0 -0
  181. package/dist/esm-node/analyze/generateCode.js +225 -0
  182. package/dist/{js/modern → esm-node}/analyze/getBundleEntry.js +6 -0
  183. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutes.js +1 -20
  184. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutesLegacy.js +1 -20
  185. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/index.js +0 -0
  186. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/utils.js +0 -0
  187. package/dist/{js/modern → esm-node}/analyze/getFileSystemEntry.js +0 -0
  188. package/dist/{js/modern → esm-node}/analyze/getHtmlTemplate.js +4 -24
  189. package/dist/{js/modern → esm-node}/analyze/getServerRoutes.js +24 -45
  190. package/dist/esm-node/analyze/index.js +281 -0
  191. package/dist/{js/modern → esm-node}/analyze/isDefaultExportFunction.js +0 -0
  192. package/dist/{js/modern → esm-node}/analyze/makeLegalIdentifier.js +0 -0
  193. package/dist/{js/modern → esm-node}/analyze/nestedRoutes.js +16 -52
  194. package/dist/{js/modern → esm-node}/analyze/templates.js +16 -51
  195. package/dist/{js/modern → esm-node}/analyze/utils.js +9 -29
  196. package/dist/{js/modern → esm-node}/builder/builder-rspack/index.js +0 -0
  197. package/dist/{js/modern → esm-node}/builder/builder-webpack/builderPlugins/compatModern.js +0 -0
  198. package/dist/esm-node/builder/builder-webpack/index.js +51 -0
  199. package/dist/{js/modern → esm-node}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +7 -24
  200. package/dist/{js/modern → esm-node}/builder/builder-webpack/webpackPlugins/index.js +0 -0
  201. package/dist/{js/modern → esm-node}/builder/generator/createBuilderOptions.js +0 -0
  202. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +26 -0
  203. package/dist/{js/modern → esm-node}/builder/generator/getBuilderTargets.js +10 -1
  204. package/dist/esm-node/builder/generator/index.js +29 -0
  205. package/dist/esm-node/builder/index.js +17 -0
  206. package/dist/{js/modern → esm-node}/builder/shared/builderPlugins/adapterModern.js +35 -36
  207. package/dist/{js/modern → esm-node}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
  208. package/dist/{js/modern → esm-node}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -0
  209. package/dist/{js/modern → esm-node}/builder/shared/createCopyPattern.js +0 -0
  210. package/dist/{js/modern → esm-node}/builder/shared/index.js +0 -0
  211. package/dist/{js/modern → esm-node}/builder/shared/loaders/serverModuleLoader.js +0 -0
  212. package/dist/{js/modern → esm-node}/builder/shared/types.js +0 -0
  213. package/dist/esm-node/commands/build.js +52 -0
  214. package/dist/esm-node/commands/deploy.js +8 -0
  215. package/dist/esm-node/commands/dev.js +72 -0
  216. package/dist/{js/modern → esm-node}/commands/index.js +0 -0
  217. package/dist/esm-node/commands/inspect.js +18 -0
  218. package/dist/{js/modern → esm-node}/commands/serve.js +8 -28
  219. package/dist/{js/modern → esm-node}/config/default.js +15 -28
  220. package/dist/{js/modern → esm-node}/config/index.js +0 -0
  221. package/dist/{js/modern → esm-node}/config/initialize/index.js +0 -0
  222. package/dist/{js/modern → esm-node}/config/initialize/inits.js +4 -22
  223. package/dist/{js/modern → esm-node}/config/legacy/createHtmlConfig.js +0 -0
  224. package/dist/{js/modern → esm-node}/config/legacy/createOutputConfig.js +0 -0
  225. package/dist/{js/modern → esm-node}/config/legacy/createSourceConfig.js +0 -0
  226. package/dist/{js/modern → esm-node}/config/legacy/createToolsConfig.js +0 -0
  227. package/dist/{js/modern → esm-node}/config/legacy/index.js +0 -0
  228. package/dist/esm-node/defineConfig.js +9 -0
  229. package/dist/{js/modern → esm-node}/exports/server.js +0 -0
  230. package/dist/{js/modern → esm-node}/hooks.js +0 -0
  231. package/dist/esm-node/index.js +172 -0
  232. package/dist/esm-node/initialize/index.js +91 -0
  233. package/dist/{js/modern → esm-node}/locale/en.js +0 -0
  234. package/dist/{js/modern → esm-node}/locale/index.js +0 -0
  235. package/dist/{js/modern → esm-node}/locale/zh.js +0 -0
  236. package/dist/{js/modern → esm-node}/schema/Schema.js +0 -0
  237. package/dist/{js/modern → esm-node}/schema/index.js +0 -0
  238. package/dist/{js/modern → esm-node}/schema/legacy.js +0 -0
  239. package/dist/{js/modern → esm-node}/types/config/deploy.js +0 -0
  240. package/dist/{js/modern → esm-node}/types/config/dev.js +0 -0
  241. package/dist/{js/modern → esm-node}/types/config/experiments.js +0 -0
  242. package/dist/{js/modern → esm-node}/types/config/html.js +0 -0
  243. package/dist/{js/modern → esm-node}/types/config/index.js +0 -0
  244. package/dist/{js/modern → esm-node}/types/config/output.js +0 -0
  245. package/dist/{js/modern → esm-node}/types/config/performance.js +0 -0
  246. package/dist/{js/modern → esm-node}/types/config/security.js +0 -0
  247. package/dist/{js/modern → esm-node}/types/config/source.js +0 -0
  248. package/dist/{js/modern → esm-node}/types/config/tools.js +0 -0
  249. package/dist/{js/modern → esm-node}/types/hooks.js +0 -0
  250. package/dist/{js/modern → esm-node}/types/index.js +0 -0
  251. package/dist/{js/modern → esm-node}/types/legacyConfig/deploy.js +0 -0
  252. package/dist/{js/modern → esm-node}/types/legacyConfig/dev.js +0 -0
  253. package/dist/{js/modern → esm-node}/types/legacyConfig/index.js +0 -0
  254. package/dist/{js/modern → esm-node}/types/legacyConfig/output.js +0 -0
  255. package/dist/{js/modern → esm-node}/types/legacyConfig/source.js +0 -0
  256. package/dist/{js/modern → esm-node}/types/legacyConfig/tools.js +0 -0
  257. package/dist/{js/modern → esm-node}/types/utils.js +0 -0
  258. package/dist/esm-node/utils/config.js +88 -0
  259. package/dist/esm-node/utils/createServer.js +37 -0
  260. package/dist/{js/modern → esm-node}/utils/env.js +0 -0
  261. package/dist/esm-node/utils/generateWatchFiles.js +33 -0
  262. package/dist/{js/modern → esm-node}/utils/getSelectedEntries.js +3 -23
  263. package/dist/esm-node/utils/getServerInternalPlugins.js +18 -0
  264. package/dist/{js/modern → esm-node}/utils/language.js +0 -0
  265. package/dist/esm-node/utils/printInstructions.js +11 -0
  266. package/dist/esm-node/utils/restart.js +22 -0
  267. package/dist/esm-node/utils/routes.js +10 -0
  268. package/dist/{js/modern → esm-node}/utils/types.js +0 -0
  269. package/dist/types/types/config/tools.d.ts +1 -1
  270. package/dist/types/types/hooks.d.ts +5 -4
  271. package/dist/types/types/index.d.ts +3 -1
  272. package/package.json +30 -31
  273. package/dist/js/modern/analyze/generateCode.js +0 -247
  274. package/dist/js/modern/analyze/index.js +0 -329
  275. package/dist/js/modern/builder/builder-webpack/index.js +0 -93
  276. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
  277. package/dist/js/modern/builder/generator/index.js +0 -53
  278. package/dist/js/modern/builder/index.js +0 -39
  279. package/dist/js/modern/commands/build.js +0 -91
  280. package/dist/js/modern/commands/deploy.js +0 -28
  281. package/dist/js/modern/commands/dev.js +0 -109
  282. package/dist/js/modern/commands/inspect.js +0 -38
  283. package/dist/js/modern/defineConfig.js +0 -27
  284. package/dist/js/modern/index.js +0 -221
  285. package/dist/js/modern/initialize/index.js +0 -132
  286. package/dist/js/modern/utils/config.js +0 -128
  287. package/dist/js/modern/utils/createServer.js +0 -75
  288. package/dist/js/modern/utils/generateWatchFiles.js +0 -55
  289. package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
  290. package/dist/js/modern/utils/printInstructions.js +0 -31
  291. package/dist/js/modern/utils/restart.js +0 -44
  292. package/dist/js/modern/utils/routes.js +0 -30
  293. package/dist/js/node/analyze/generateCode.js +0 -271
  294. package/dist/js/node/analyze/index.js +0 -336
  295. package/dist/js/node/builder/generator/index.js +0 -82
  296. package/dist/js/node/commands/deploy.js +0 -51
  297. package/dist/js/node/defineConfig.js +0 -49
  298. package/dist/js/node/index.js +0 -245
  299. package/dist/js/node/initialize/index.js +0 -141
  300. package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
  301. package/dist/js/node/utils/restart.js +0 -67
  302. package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
@@ -21,26 +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 __async = (__this, __arguments, generator) => {
25
- return new Promise((resolve, reject) => {
26
- var fulfilled = (value) => {
27
- try {
28
- step(generator.next(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var rejected = (value) => {
34
- try {
35
- step(generator.throw(value));
36
- } catch (e) {
37
- reject(e);
38
- }
39
- };
40
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
- step((generator = generator.apply(__this, __arguments)).next());
42
- });
43
- };
44
24
  var routes_exports = {};
45
25
  __export(routes_exports, {
46
26
  generateRoutes: () => generateRoutes
@@ -48,11 +28,11 @@ __export(routes_exports, {
48
28
  module.exports = __toCommonJS(routes_exports);
49
29
  var import_path = __toESM(require("path"));
50
30
  var import_utils = require("@modern-js/utils");
51
- const generateRoutes = (appContext) => __async(void 0, null, function* () {
31
+ const generateRoutes = async (appContext) => {
52
32
  const { serverRoutes, distDirectory } = appContext;
53
33
  const output = JSON.stringify({ routes: serverRoutes }, null, 2);
54
- yield import_utils.fs.outputFile(import_path.default.join(distDirectory, import_utils.ROUTE_SPEC_FILE), output);
55
- });
34
+ await import_utils.fs.outputFile(import_path.default.join(distDirectory, import_utils.ROUTE_SPEC_FILE), output);
35
+ };
56
36
  // Annotate the CommonJS export names for ESM import in node:
57
37
  0 && (module.exports = {
58
38
  generateRoutes
File without changes
@@ -161,7 +161,7 @@ var createImportSpecifier = function(specifiers) {
161
161
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
162
162
  try {
163
163
  for(var _iterator = specifiers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
164
- var _value = _step.value, local = _value.local, imported = _value.imported;
164
+ var _step_value = _step.value, local = _step_value.local, imported = _step_value.imported;
165
165
  if (local && imported) {
166
166
  named.push("".concat(imported, " as ").concat(local));
167
167
  } else if (local) {
@@ -198,7 +198,7 @@ var createImportStatements = function(statements) {
198
198
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
199
199
  try {
200
200
  var _loop = function() {
201
- var _value = _step.value, value = _value.value, specifiers = _value.specifiers, initialize = _value.initialize;
201
+ var _step_value = _step.value, value = _step_value.value, specifiers = _step_value.specifiers, initialize = _step_value.initialize;
202
202
  if (!seen.has(value)) {
203
203
  deDuplicated.push({
204
204
  value: value,
@@ -207,14 +207,14 @@ var createImportStatements = function(statements) {
207
207
  });
208
208
  seen.set(value, specifiers);
209
209
  } else {
210
- var _instance;
211
- var ref;
212
- (_instance = seen.get(value)).push.apply(_instance, _toConsumableArray(specifiers));
210
+ var _seen_get;
211
+ var _deDuplicated_modifyIndex;
212
+ (_seen_get = seen.get(value)).push.apply(_seen_get, _toConsumableArray(specifiers));
213
213
  var modifyIndex = deDuplicated.findIndex(function(v) {
214
214
  return v.value === value;
215
215
  });
216
- var ref1;
217
- var originInitialize = (ref1 = (ref = deDuplicated[modifyIndex]) === null || ref === void 0 ? void 0 : ref.initialize) !== null && ref1 !== void 0 ? ref1 : "";
216
+ var _deDuplicated_modifyIndex_initialize;
217
+ var 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 : "";
218
218
  deDuplicated[modifyIndex].initialize = originInitialize.concat("\n".concat(initialize || ""));
219
219
  }
220
220
  };
@@ -240,13 +240,13 @@ var createImportStatements = function(statements) {
240
240
  };
241
241
  var generateCode = function() {
242
242
  var _ref = _asyncToGenerator(function(appContext, config, entrypoints, api) {
243
- var ref, ref1, ref2, internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
243
+ var _config_runtime, _config_runtime1, _config_runtime_router, internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
244
244
  function generateEntryCode(entrypoint) {
245
245
  return _generateEntryCode.apply(this, arguments);
246
246
  }
247
247
  function _generateEntryCode() {
248
248
  _generateEntryCode = _asyncToGenerator(function(entrypoint) {
249
- var entryName, isAutoMount, customBootstrap, fileSystemRoutes, initialRoutes, nestedRoute, routes, config2, ssr, mode, hasPageRoute, ref, code2, _, _tmp, routesServerFile, code3, ref1, importStatements, plugins, ref2, renderFunction, exportStatement, code, entryFile, ref3, asyncEntryCode, bootstrapFile;
249
+ var entryName, isAutoMount, customBootstrap, fileSystemRoutes, initialRoutes, nestedRoute, routes, config2, ssr, mode, hasPageRoute, _ref, code2, _, _tmp, routesServerFile, code3, _ref1, importStatements, plugins, _ref2, renderFunction, exportStatement, code, entryFile, _ref3, asyncEntryCode, bootstrapFile;
250
250
  return __generator(this, function(_state) {
251
251
  switch(_state.label){
252
252
  case 0:
@@ -346,7 +346,7 @@ var generateCode = function() {
346
346
  ])
347
347
  ];
348
348
  case 6:
349
- ref = _state.sent(), code2 = ref.code;
349
+ _ref = _state.sent(), code2 = _ref.code;
350
350
  if (!(entrypoint.nestedRoutesEntry && mode)) return [
351
351
  3,
352
352
  9
@@ -386,7 +386,7 @@ var generateCode = function() {
386
386
  })
387
387
  ];
388
388
  case 11:
389
- ref1 = _state.sent(), importStatements = ref1.imports;
389
+ _ref1 = _state.sent(), importStatements = _ref1.imports;
390
390
  return [
391
391
  4,
392
392
  hookRunners.modifyEntryRuntimePlugins({
@@ -408,7 +408,7 @@ var generateCode = function() {
408
408
  })
409
409
  ];
410
410
  case 13:
411
- ref2 = _state.sent(), renderFunction = ref2.code;
411
+ _ref2 = _state.sent(), renderFunction = _ref2.code;
412
412
  return [
413
413
  4,
414
414
  hookRunners.modifyEntryExport({
@@ -438,7 +438,7 @@ var generateCode = function() {
438
438
  })
439
439
  ];
440
440
  case 15:
441
- ref3 = _state.sent(), asyncEntryCode = ref3.code;
441
+ _ref3 = _state.sent(), asyncEntryCode = _ref3.code;
442
442
  fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
443
443
  bootstrapFile = path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_BOOTSTRAP_FILE_NAME));
444
444
  fs.outputFileSync(bootstrapFile, code, "utf8");
@@ -463,7 +463,7 @@ var generateCode = function() {
463
463
  case 0:
464
464
  internalDirectory = appContext.internalDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias, packageName = appContext.packageName;
465
465
  hookRunners = api.useHookRunners();
466
- isV5 = typeof ((ref = config.runtime) === null || ref === void 0 ? void 0 : ref.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (ref1 = config.runtime) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.router) === null || ref2 === void 0 ? void 0 : ref2.mode) === "react-router-5";
466
+ isV5 = typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
467
467
  mountId = config.html.mountId;
468
468
  getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
469
469
  return [
@@ -24,7 +24,7 @@ var ifAlreadyExists = function(entrypoints, checked) {
24
24
  };
25
25
  var getBundleEntry = function(appContext, config) {
26
26
  var appDirectory = appContext.appDirectory, packageName = appContext.packageName;
27
- var _source = config.source, disableDefaultEntries = _source.disableDefaultEntries, entries = _source.entries, entriesDir = _source.entriesDir;
27
+ var _config_source = config.source, disableDefaultEntries = _config_source.disableDefaultEntries, entries = _config_source.entries, entriesDir = _config_source.entriesDir;
28
28
  var defaults = disableDefaultEntries ? [] : getFileSystemEntry(appContext, config);
29
29
  if (entries) {
30
30
  Object.keys(entries).forEach(function(name) {
@@ -32,11 +32,13 @@ var getBundleEntry = function(appContext, config) {
32
32
  var entrypoint = typeof value === "string" ? {
33
33
  entryName: name,
34
34
  entry: ensureAbsolutePath(appDirectory, value),
35
+ absoluteEntryDir: path.dirname(ensureAbsolutePath(appDirectory, value)),
35
36
  isAutoMount: true,
36
37
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value)).isDirectory() ? {} : void 0
37
38
  } : {
38
39
  entryName: name,
39
40
  entry: ensureAbsolutePath(appDirectory, value.entry),
41
+ absoluteEntryDir: path.dirname(ensureAbsolutePath(appDirectory, value.entry)),
40
42
  isAutoMount: !value.disableMount,
41
43
  customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
42
44
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
@@ -52,7 +54,7 @@ var getBundleEntry = function(appContext, config) {
52
54
  if (!disableDefaultEntries) {
53
55
  var entriesDirAbs = ensureAbsolutePath(appDirectory, entriesDir || "");
54
56
  var found = defaults.find(function(param) {
55
- var entryName = param.entryName, entry = param.entry, _nestedRoutesEntry = param.nestedRoutesEntry, nestedRoutesEntry = _nestedRoutesEntry === void 0 ? "" : _nestedRoutesEntry;
57
+ var entryName = param.entryName, entry = param.entry, _param_nestedRoutesEntry = param.nestedRoutesEntry, nestedRoutesEntry = _param_nestedRoutesEntry === void 0 ? "" : _param_nestedRoutesEntry;
56
58
  return entryName === packageName || path.dirname(entry) === entriesDirAbs || path.dirname(nestedRoutesEntry) === entriesDirAbs;
57
59
  });
58
60
  found && (found.entryName = MAIN_ENTRY_NAME);
@@ -67,7 +67,7 @@ var layoutNameAbbr = function(filePath) {
67
67
  };
68
68
  var parents = [];
69
69
  var recursiveReadDir = function(param) {
70
- var dir = param.dir, routes = param.routes, _basePath = param.basePath, basePath = _basePath === void 0 ? "/" : _basePath, srcDirectory = param.srcDirectory, srcAlias = param.srcAlias;
70
+ var dir = param.dir, routes = param.routes, _param_basePath = param.basePath, basePath = _param_basePath === void 0 ? "/" : _param_basePath, srcDirectory = param.srcDirectory, srcAlias = param.srcAlias;
71
71
  var hasDynamicRoute = false;
72
72
  var resetParent = false;
73
73
  var parent = parents[parents.length - 1];
@@ -67,7 +67,7 @@ var layoutNameAbbr = function(filePath) {
67
67
  };
68
68
  var parents = [];
69
69
  var recursiveReadDirLegacy = function(param) {
70
- var dir = param.dir, routes = param.routes, _basePath = param.basePath, basePath = _basePath === void 0 ? "/" : _basePath, srcDirectory = param.srcDirectory, srcAlias = param.srcAlias;
70
+ var dir = param.dir, routes = param.routes, _param_basePath = param.basePath, basePath = _param_basePath === void 0 ? "/" : _param_basePath, srcDirectory = param.srcDirectory, srcAlias = param.srcAlias;
71
71
  var hasDynamicRoute = false;
72
72
  var resetParent = false;
73
73
  var parent = parents[parents.length - 1];
@@ -80,7 +80,7 @@ var scanDir = function(dirs) {
80
80
  };
81
81
  var getFileSystemEntry = function(appContext, config) {
82
82
  var appDirectory = appContext.appDirectory;
83
- var _source = config.source, entriesDir = _source.entriesDir, disableEntryDirs = _source.disableEntryDirs;
83
+ var _config_source = config.source, entriesDir = _config_source.entriesDir, disableEntryDirs = _config_source.disableEntryDirs;
84
84
  var disabledDirs = [];
85
85
  if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
86
86
  disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map(function(dir) {
@@ -104,7 +104,7 @@ function _unsupportedIterableToArray(o, minLen) {
104
104
  }
105
105
  import path from "path";
106
106
  import fs from "fs";
107
- import { urlJoin, isPlainObject, removeLeadingSlash, getEntryOptions, SERVER_BUNDLE_DIRECTORY, MAIN_ENTRY_NAME, removeTailSlash } from "@modern-js/utils";
107
+ import { urlJoin, isPlainObject, removeLeadingSlash, getEntryOptions, SERVER_BUNDLE_DIRECTORY, MAIN_ENTRY_NAME, removeTailSlash, SERVER_WORKER_BUNDLE_DIRECTORY } from "@modern-js/utils";
108
108
  import { walkDirectory } from "./utils";
109
109
  var applyBaseUrl = function(baseUrl, routes) {
110
110
  if (baseUrl) {
@@ -130,8 +130,8 @@ var applyRouteOptions = function(original, routeOptions) {
130
130
  var routes;
131
131
  if (route) {
132
132
  if (Array.isArray(route)) {
133
- var _tmp;
134
- _tmp = route.map(function(url) {
133
+ var _route_map;
134
+ _route_map = route.map(function(url) {
135
135
  if (isPlainObject(url)) {
136
136
  var urlPath = url.path, other = _objectWithoutProperties(url, [
137
137
  "path"
@@ -144,7 +144,7 @@ var applyRouteOptions = function(original, routeOptions) {
144
144
  urlPath: url
145
145
  });
146
146
  }
147
- }), routes = _tmp, _tmp;
147
+ }), routes = _route_map, _route_map;
148
148
  } else if (isPlainObject(route)) {
149
149
  var urlPath = route.path, other = _objectWithoutProperties(route, [
150
150
  "path"
@@ -169,12 +169,13 @@ var applyRouteOptions = function(original, routeOptions) {
169
169
  return routes;
170
170
  };
171
171
  var collectHtmlRoutes = function(entrypoints, appContext, config) {
172
- var disableHtmlFolder = config.html.disableHtmlFolder, _output = config.output, tmp = _output.distPath, ref = tmp === void 0 ? {} : tmp, htmlPath = ref.html, _server = config.server, baseUrl = _server.baseUrl, routes = _server.routes, ssr = _server.ssr, ssrByEntries = _server.ssrByEntries;
172
+ var disableHtmlFolder = config.html.disableHtmlFolder, _config_output = config.output, tmp = _config_output.distPath, _ref = tmp === void 0 ? {} : tmp, htmlPath = _ref.html, _config_server = config.server, baseUrl = _config_server.baseUrl, routes = _config_server.routes, ssr = _config_server.ssr, ssrByEntries = _config_server.ssrByEntries, worker = _config_server.worker;
173
173
  var packageName = appContext.packageName;
174
174
  var htmlRoutes = entrypoints.reduce(function(previous, param) {
175
175
  var entryName = param.entryName;
176
176
  var entryOptions = getEntryOptions(entryName, ssr, ssrByEntries, packageName);
177
177
  var isSSR = Boolean(entryOptions);
178
+ var isWorker = Boolean(worker);
178
179
  var resHeaders = ((routes === null || routes === void 0 ? void 0 : routes[entryName]) || {}).resHeaders;
179
180
  var route = {
180
181
  urlPath: "/".concat(entryName === MAIN_ENTRY_NAME ? "" : entryName),
@@ -183,6 +184,7 @@ var collectHtmlRoutes = function(entrypoints, appContext, config) {
183
184
  isSPA: true,
184
185
  isSSR: isSSR,
185
186
  responseHeaders: resHeaders,
187
+ worker: isWorker ? "".concat(SERVER_WORKER_BUNDLE_DIRECTORY, "/").concat(entryName, ".js") : void 0,
186
188
  bundle: isSSR ? "".concat(SERVER_BUNDLE_DIRECTORY, "/").concat(entryName, ".js") : void 0
187
189
  };
188
190
  if (routes === null || routes === void 0 ? void 0 : routes.hasOwnProperty(entryName)) {
@@ -200,7 +202,7 @@ var collectHtmlRoutes = function(entrypoints, appContext, config) {
200
202
  };
201
203
  var collectStaticRoutes = function(appContext, config) {
202
204
  var appDirectory = appContext.appDirectory;
203
- var configDir = config.source.configDir, _server = config.server, _publicRoutes = _server.publicRoutes, publicRoutes = _publicRoutes === void 0 ? {} : _publicRoutes;
205
+ var configDir = config.source.configDir, _config_server = config.server, _config_server_publicRoutes = _config_server.publicRoutes, publicRoutes = _config_server_publicRoutes === void 0 ? {} : _config_server_publicRoutes;
204
206
  var publicFolder = path.resolve(appDirectory, configDir || "", "public");
205
207
  return fs.existsSync(publicFolder) ? walkDirectory(publicFolder).map(function(filePath) {
206
208
  var urlPath = "".concat(urlJoin(toPosix(filePath).slice(toPosix(publicFolder).length)));
@@ -243,7 +243,7 @@ var analyze_default = function(param) {
243
243
  return {
244
244
  prepare: function prepare() {
245
245
  return _asyncToGenerator(function() {
246
- var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, createBuilderForModern, builder;
246
+ var _resolvedConfig_source, appContext, resolvedConfig, hookRunners, apiOnly, _ref, routes2, _ref1, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, createBuilderForModern, builder;
247
247
  return __generator(this, function(_state) {
248
248
  switch(_state.label){
249
249
  case 0:
@@ -255,7 +255,7 @@ var analyze_default = function(param) {
255
255
  } catch (e) {}
256
256
  return [
257
257
  4,
258
- isApiOnly(appContext.appDirectory, (ref = resolvedConfig.source) === null || ref === void 0 ? void 0 : ref.entriesDir)
258
+ isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir)
259
259
  ];
260
260
  case 1:
261
261
  apiOnly = _state.sent();
@@ -276,7 +276,7 @@ var analyze_default = function(param) {
276
276
  })
277
277
  ];
278
278
  case 3:
279
- ref1 = _state.sent(), routes2 = ref1.routes;
279
+ _ref = _state.sent(), routes2 = _ref.routes;
280
280
  debug("server routes: %o", routes2);
281
281
  appContext = _objectSpreadProps(_objectSpread({}, appContext), {
282
282
  apiOnly: apiOnly,
@@ -297,10 +297,10 @@ var analyze_default = function(param) {
297
297
  ])
298
298
  ];
299
299
  case 5:
300
- ref2 = _slicedToArray.apply(void 0, [
300
+ _ref1 = _slicedToArray.apply(void 0, [
301
301
  _state.sent(),
302
302
  4
303
- ]), getBundleEntry = ref2[0].getBundleEntry, getServerRoutes = ref2[1].getServerRoutes, generateCode = ref2[2].generateCode, getHtmlTemplate = ref2[3].getHtmlTemplate;
303
+ ]), getBundleEntry = _ref1[0].getBundleEntry, getServerRoutes = _ref1[1].getServerRoutes, generateCode = _ref1[2].generateCode, getHtmlTemplate = _ref1[3].getHtmlTemplate;
304
304
  entrypoints = getBundleEntry(appContext, resolvedConfig);
305
305
  debug("entrypoints: %o", entrypoints);
306
306
  initialRoutes = getServerRoutes(entrypoints, {
@@ -573,7 +573,7 @@ var analyze_default = function(param) {
573
573
  modifyEntryImports: function modifyEntryImports(param) {
574
574
  var entrypoint = param.entrypoint, imports = param.imports;
575
575
  return _asyncToGenerator(function() {
576
- var appContext, srcDirectory, internalSrcAlias, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
576
+ var appContext, srcDirectory, internalSrcAlias, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, _ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
577
577
  return __generator(this, function(_state) {
578
578
  switch(_state.label){
579
579
  case 0:
@@ -612,10 +612,10 @@ var analyze_default = function(param) {
612
612
  })
613
613
  ];
614
614
  case 2:
615
- ref = _slicedToArray.apply(void 0, [
615
+ _ref = _slicedToArray.apply(void 0, [
616
616
  _state.sent(),
617
617
  2
618
- ]), moduleExports = ref[1];
618
+ ]), moduleExports = _ref[1];
619
619
  hasAppConfig = moduleExports.some(function(e) {
620
620
  return e.n === APP_CONFIG_NAME;
621
621
  });
@@ -197,7 +197,7 @@ var createRoute = function(routeInfo, rootDir, filename, entryName) {
197
197
  };
198
198
  var walk = function() {
199
199
  var _ref = _asyncToGenerator(function(dirname, rootDir, alias, entryName) {
200
- var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, ref3, err, finalRoute, childRoute1, path2;
200
+ var _route_children, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, _route_children1, _route_children2, _route_children3, err, finalRoute, childRoute1, path2;
201
201
  return __generator(this, function(_state) {
202
202
  switch(_state.label){
203
203
  case 0:
@@ -288,7 +288,7 @@ var walk = function() {
288
288
  childRoute = _state.sent();
289
289
  if (childRoute) {
290
290
  ;
291
- (ref1 = route.children) === null || ref1 === void 0 ? void 0 : ref1.push(childRoute);
291
+ (_route_children1 = route.children) === null || _route_children1 === void 0 ? void 0 : _route_children1.push(childRoute);
292
292
  }
293
293
  _state.label = 8;
294
294
  case 8:
@@ -317,7 +317,7 @@ var walk = function() {
317
317
  if (pageLoaderFile) {
318
318
  pageRoute.loader = pageLoaderFile;
319
319
  }
320
- (ref2 = route.children) === null || ref2 === void 0 ? void 0 : ref2.push(pageRoute);
320
+ (_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(pageRoute);
321
321
  }
322
322
  if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
323
323
  splatLoaderFile = itemPath;
@@ -331,7 +331,7 @@ var walk = function() {
331
331
  if (splatLoaderFile) {
332
332
  splatRoute.loader = splatLoaderFile;
333
333
  }
334
- (ref3 = route.children) === null || ref3 === void 0 ? void 0 : ref3.push(splatRoute);
334
+ (_route_children3 = route.children) === null || _route_children3 === void 0 ? void 0 : _route_children3.push(splatRoute);
335
335
  }
336
336
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
337
337
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
@@ -377,7 +377,7 @@ var walk = function() {
377
377
  if (isPathlessLayout) {
378
378
  delete finalRoute.path;
379
379
  }
380
- route.children = (ref = route.children) === null || ref === void 0 ? void 0 : ref.filter(function(childRoute) {
380
+ route.children = (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.filter(function(childRoute) {
381
381
  return childRoute;
382
382
  });
383
383
  if (route.children && route.children.length === 0 && !route.index) {
@@ -229,10 +229,11 @@ var index = function(param) {
229
229
  };
230
230
  var renderFunction = function(param) {
231
231
  var plugins = param.plugins, customBootstrap = param.customBootstrap, fileSystemRoutes2 = param.fileSystemRoutes;
232
+ var bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
232
233
  return "\n const finalAppConfig = {\n ...App.config,\n ...typeof ".concat(APP_CONFIG_NAME, " === 'function' ? ").concat(APP_CONFIG_NAME, "() : {},\n }\n\n AppWrapper = createApp({\n plugins: [\n ").concat(plugins.map(function(param) {
233
234
  var name = param.name, options = param.options, args = param.args;
234
235
  return "".concat(name, "({...").concat(options, ", ...finalAppConfig?.").concat(args || name, "}),");
235
- }).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper);" : "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);", "\n }\n\n return AppWrapper\n");
236
+ }).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper, () => ".concat(bootstrap, ");") : "".concat(bootstrap, ";"), "\n }\n\n return AppWrapper\n");
236
237
  };
237
238
  var html = function(partials) {
238
239
  return "\n<!DOCTYPE html>\n<html>\n<head>\n <%= meta %>\n <title><%= title %></title>\n\n ".concat(partials.top.join("\n"), "\n\n <script>\n window.__assetPrefix__ = '<%= assetPrefix %>';\n </script>\n ").concat(partials.head.join("\n"), "\n\n <!--<?- chunksMap.css ?>-->\n</head>\n\n<body>\n <noscript>\n We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.\n </noscript>\n <div id=\"<%= mountId %>\"><!--<?- html ?>--></div>\n ").concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
@@ -243,8 +244,8 @@ var routesForServer = function(param) {
243
244
  var traverseRouteTree = function(route) {
244
245
  var children;
245
246
  if ("children" in route && route.children) {
246
- var ref;
247
- children = route === null || route === void 0 ? void 0 : (ref = route.children) === null || ref === void 0 ? void 0 : ref.map(traverseRouteTree);
247
+ var _route_children;
248
+ children = route === null || route === void 0 ? void 0 : (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
248
249
  }
249
250
  var loader;
250
251
  if (route.type === "nested") {
@@ -296,7 +297,7 @@ var routesForServer = function(param) {
296
297
  };
297
298
  var fileSystemRoutes = function() {
298
299
  var _ref = _asyncToGenerator(function(param) {
299
- var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
300
+ var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo;
300
301
  return __generator(this, function(_state) {
301
302
  switch(_state.label){
302
303
  case 0:
@@ -321,8 +322,8 @@ var fileSystemRoutes = function() {
321
322
  traverseRouteTree = function(route) {
322
323
  var children;
323
324
  if ("children" in route && route.children) {
324
- var ref;
325
- children = route === null || route === void 0 ? void 0 : (ref = route.children) === null || ref === void 0 ? void 0 : ref.map(traverseRouteTree);
325
+ var _route_children;
326
+ children = route === null || route === void 0 ? void 0 : (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
326
327
  }
327
328
  var loading;
328
329
  var error;
@@ -417,7 +418,7 @@ var fileSystemRoutes = function() {
417
418
  _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
418
419
  try {
419
420
  for(_iterator1 = Object.entries(loadersMap)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
420
- _value = _slicedToArray(_step1.value, 2), key = _value[0], loaderInfo = _value[1];
421
+ _step_value = _slicedToArray(_step1.value, 2), key = _step_value[0], loaderInfo = _step_value[1];
421
422
  if (loaderInfo.inline) {
422
423
  importLoadersCode += "import { loader as ".concat(key, ' } from "').concat(getDataLoaderPath(key)).concat(slash(loaderInfo.filePath), '";\n');
423
424
  } else {
@@ -333,7 +333,7 @@ var parseModule = function() {
333
333
  }();
334
334
  var hasLoader = function() {
335
335
  var _ref = _asyncToGenerator(function(filename) {
336
- var source, ref, moduleExports;
336
+ var source, _ref, moduleExports;
337
337
  return __generator(this, function(_state) {
338
338
  switch(_state.label){
339
339
  case 0:
@@ -351,10 +351,10 @@ var hasLoader = function() {
351
351
  })
352
352
  ];
353
353
  case 2:
354
- ref = _slicedToArray.apply(void 0, [
354
+ _ref = _slicedToArray.apply(void 0, [
355
355
  _state.sent(),
356
356
  2
357
- ]), moduleExports = ref[1];
357
+ ]), moduleExports = _ref[1];
358
358
  return [
359
359
  2,
360
360
  moduleExports.some(function(e) {
@@ -33,15 +33,15 @@ var PluginCompatModern = function(options) {
33
33
  var modernConfig = options.normalizedConfig, appContext = options.appContext;
34
34
  api.modifyWebpackChain(function(chain, param) {
35
35
  var CHAIN_ID = param.CHAIN_ID;
36
- var ref;
36
+ var _modernConfig_runtime;
37
37
  chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
38
38
  if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
39
39
  var defaultCopyPattern = createCopyPattern(appContext, modernConfig, "public", chain);
40
40
  chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(function(args) {
41
- var ref;
41
+ var _args_;
42
42
  return [
43
43
  {
44
- patterns: _toConsumableArray(((ref = args[0]) === null || ref === void 0 ? void 0 : ref.patterns) || []).concat([
44
+ patterns: _toConsumableArray(((_args_ = args[0]) === null || _args_ === void 0 ? void 0 : _args_.patterns) || []).concat([
45
45
  defaultCopyPattern
46
46
  ])
47
47
  }
@@ -52,7 +52,7 @@ var PluginCompatModern = function(options) {
52
52
  var existNestedRoutes = entrypoints.some(function(entrypoint) {
53
53
  return entrypoint.nestedRoutesEntry;
54
54
  });
55
- var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.runtime) === null || ref === void 0 ? void 0 : ref.router;
55
+ var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_runtime = modernConfig.runtime) === null || _modernConfig_runtime === void 0 ? void 0 : _modernConfig_runtime.router;
56
56
  var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
57
57
  if (existNestedRoutes || routerManifest) {
58
58
  chain.plugin("route-plugin").use(RouterPlugin);
@@ -248,7 +248,7 @@ function applyBuilderPlugins(builder, options) {
248
248
  }
249
249
  function _applyBuilderPlugins() {
250
250
  _applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
251
- var normalizedConfig, PluginNodePolyfill, _tools, esbuildOptions, PluginEsbuild;
251
+ var normalizedConfig, PluginNodePolyfill, _normalizedConfig_tools, esbuildOptions, PluginEsbuild;
252
252
  return __generator(this, function(_state) {
253
253
  switch(_state.label){
254
254
  case 0:
@@ -272,7 +272,7 @@ function _applyBuilderPlugins() {
272
272
  3,
273
273
  4
274
274
  ];
275
- _tools = normalizedConfig.tools, esbuildOptions = _tools.esbuild;
275
+ _normalizedConfig_tools = normalizedConfig.tools, esbuildOptions = _normalizedConfig_tools.esbuild;
276
276
  return [
277
277
  4,
278
278
  import("@modern-js/builder-plugin-esbuild")
@@ -215,6 +215,9 @@ var RouterPlugin = /*#__PURE__*/ function() {
215
215
  if (target === "node" || Array.isArray(target) && target.includes("node")) {
216
216
  return;
217
217
  }
218
+ if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
219
+ return;
220
+ }
218
221
  var webpack = compiler.webpack;
219
222
  var Compilation = webpack.Compilation, sources = webpack.sources;
220
223
  var RawSource = sources.RawSource;
@@ -232,7 +235,7 @@ var RouterPlugin = /*#__PURE__*/ function() {
232
235
  name: PLUGIN_NAME,
233
236
  stage: PROCESS_ASSETS_STAGE_REPORT
234
237
  }, /*#__PURE__*/ _asyncToGenerator(function() {
235
- var stats, publicPath, routeAssets, namedChunkGroups, assetsByChunkName, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, name, chunkGroup, manifest, injectedContent, entrypointsArray, entryChunkIds, entryChunks, entryChunkFiles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, file, asset, newContent, filename;
238
+ var stats, publicPath, routeAssets, namedChunkGroups, assetsByChunkName, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, manifest, injectedContent, entrypointsArray, entryChunkIds, entryChunks, entryChunkFiles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, file, asset, newContent, filename;
236
239
  return __generator(this, function(_state) {
237
240
  switch(_state.label){
238
241
  case 0:
@@ -252,7 +255,7 @@ var RouterPlugin = /*#__PURE__*/ function() {
252
255
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
253
256
  try {
254
257
  for(_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
255
- _value = _slicedToArray(_step.value, 2), name = _value[0], chunkGroup = _value[1];
258
+ _step_value = _slicedToArray(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
256
259
  if (assetsByChunkName[name]) {
257
260
  routeAssets[name] = {
258
261
  chunkIds: chunkGroup.chunks,
@@ -1,10 +1,10 @@
1
1
  function createBuilderOptions(target, appContext) {
2
2
  var entries = {};
3
- var _entrypoints = appContext.entrypoints, entrypoints = _entrypoints === void 0 ? [] : _entrypoints, checkedEntries = appContext.checkedEntries;
3
+ var _appContext_entrypoints = appContext.entrypoints, entrypoints = _appContext_entrypoints === void 0 ? [] : _appContext_entrypoints, checkedEntries = appContext.checkedEntries;
4
4
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5
5
  try {
6
6
  for(var _iterator = entrypoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7
- var _value = _step.value, entryName = _value.entryName, entry = _value.entry;
7
+ var _step_value = _step.value, entryName = _step_value.entryName, entry = _step_value.entry;
8
8
  if (checkedEntries && !checkedEntries.includes(entryName)) {
9
9
  continue;
10
10
  }
@@ -1,4 +1,4 @@
1
- import { isProd, isSSR, isUseSSRBundle } from "@modern-js/utils";
1
+ import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
2
2
  function getBuilderTargets(normalizedConfig) {
3
3
  var targets = [
4
4
  "web"
@@ -7,6 +7,10 @@ function getBuilderTargets(normalizedConfig) {
7
7
  if (useNodeTarget) {
8
8
  targets.push("node");
9
9
  }
10
+ var useWorkerTarget = isProd() ? isServiceWorker(normalizedConfig) : false;
11
+ if (useWorkerTarget) {
12
+ targets.push("service-worker");
13
+ }
10
14
  return targets;
11
15
  }
12
16
  export { getBuilderTargets };
@@ -131,12 +131,12 @@ function generateBuilder(options, generateProvider, utils) {
131
131
  }
132
132
  function _generateBuilder() {
133
133
  _generateBuilder = _asyncToGenerator(function(options, generateProvider, utils) {
134
- var normalizedConfig, appContext, ref, modifyBuilderConfig, modifyBuilderInstance, builderConfig, provider, target, builderOptions, builder;
134
+ var normalizedConfig, appContext, _ref, modifyBuilderConfig, modifyBuilderInstance, builderConfig, provider, target, builderOptions, builder;
135
135
  return __generator(this, function(_state) {
136
136
  switch(_state.label){
137
137
  case 0:
138
138
  normalizedConfig = options.normalizedConfig, appContext = options.appContext;
139
- ref = utils || {}, modifyBuilderConfig = ref.modifyBuilderConfig, modifyBuilderInstance = ref.modifyBuilderInstance;
139
+ _ref = utils || {}, modifyBuilderConfig = _ref.modifyBuilderConfig, modifyBuilderInstance = _ref.modifyBuilderInstance;
140
140
  builderConfig = createBuilderProviderConfig(normalizedConfig, appContext, modifyBuilderConfig);
141
141
  provider = generateProvider({
142
142
  builderConfig: builderConfig
File without changes