@modern-js/app-tools 2.58.1-alpha.6 → 2.58.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
  2. package/dist/cjs/builder/builder-webpack/index.js +1 -1
  3. package/dist/cjs/builder/generator/index.js +2 -2
  4. package/dist/cjs/builder/index.js +2 -2
  5. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +13 -4
  6. package/dist/cjs/commands/build.js +19 -0
  7. package/dist/cjs/commands/dev.js +9 -0
  8. package/dist/cjs/commands/index.js +8 -8
  9. package/dist/cjs/commands/inspect.js +1 -1
  10. package/dist/cjs/config/initialize/inits.js +4 -4
  11. package/dist/cjs/esm/esbuild-loader.mjs +20 -0
  12. package/dist/cjs/esm/register-esm.mjs +67 -0
  13. package/dist/cjs/esm/ts-node-loader.mjs +21 -0
  14. package/dist/cjs/esm/utils.mjs +43 -0
  15. package/dist/cjs/index.js +1 -1
  16. package/dist/cjs/plugins/analyze/index.js +3 -3
  17. package/dist/cjs/plugins/deploy/dependencies/index.js +2 -15
  18. package/dist/cjs/plugins/deploy/dependencies/utils.js +13 -78
  19. package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
  20. package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  21. package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
  22. package/dist/cjs/plugins/deploy/platforms/netlify.js +14 -5
  23. package/dist/cjs/plugins/deploy/platforms/node.js +13 -4
  24. package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
  25. package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  26. package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
  27. package/dist/cjs/plugins/deploy/platforms/vercel.js +14 -5
  28. package/dist/cjs/utils/config.js +1 -1
  29. package/dist/cjs/utils/loadPlugins.js +1 -1
  30. package/dist/cjs/utils/register.js +50 -23
  31. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
  32. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  33. package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
  34. package/dist/types/builder/builder-webpack/index.d.ts +1 -1
  35. package/dist/types/builder/generator/index.d.ts +2 -2
  36. package/dist/types/builder/index.d.ts +1 -1
  37. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  38. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  39. package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
  40. package/dist/types/commands/build.d.ts +1 -1
  41. package/dist/types/commands/dev.d.ts +3 -3
  42. package/dist/types/commands/index.d.ts +3 -3
  43. package/dist/types/config/default.d.ts +1 -1
  44. package/dist/types/config/initialize/inits.d.ts +1 -1
  45. package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
  46. package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
  47. package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
  48. package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
  49. package/dist/types/esm/esbuild-loader.d.mts +6 -0
  50. package/dist/types/esm/register-esm.d.mts +5 -0
  51. package/dist/types/esm/ts-node-loader.d.mts +6 -0
  52. package/dist/types/esm/utils.d.mts +6 -0
  53. package/dist/types/exports/server.d.ts +1 -1
  54. package/dist/types/hooks.d.ts +1 -1
  55. package/dist/types/index.d.ts +2 -2
  56. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  57. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  58. package/dist/types/plugins/analyze/index.d.ts +1 -1
  59. package/dist/types/plugins/deploy/dependencies/index.d.ts +3 -5
  60. package/dist/types/plugins/deploy/dependencies/utils.d.ts +2 -9
  61. package/dist/types/plugins/deploy/index.d.ts +2 -2
  62. package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
  63. package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
  64. package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
  65. package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
  66. package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
  67. package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
  68. package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
  69. package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
  70. package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
  71. package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
  72. package/dist/types/plugins/deploy/utils.d.ts +1 -1
  73. package/dist/types/plugins/serverBuild.d.ts +1 -1
  74. package/dist/types/types/hooks.d.ts +1 -1
  75. package/dist/types/types/index.d.ts +1 -1
  76. package/dist/types/utils/createServer.d.ts +1 -1
  77. package/dist/types/utils/generateWatchFiles.d.ts +1 -1
  78. package/dist/types/utils/getSelectedEntries.d.ts +1 -1
  79. package/dist/types/utils/loadPlugins.d.ts +3 -3
  80. package/dist/types/utils/register.d.ts +2 -2
  81. package/dist/types/utils/restart.d.ts +2 -2
  82. package/lib/types.d.ts +15 -0
  83. package/package.json +20 -21
  84. package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
  85. package/dist/esm/builder/builder-rspack/index.js +0 -34
  86. package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
  87. package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
  88. package/dist/esm/builder/builder-webpack/index.js +0 -52
  89. package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
  90. package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
  91. package/dist/esm/builder/generator/index.js +0 -94
  92. package/dist/esm/builder/index.js +0 -45
  93. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
  94. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
  95. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
  96. package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
  97. package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
  98. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
  99. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
  100. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -288
  101. package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
  102. package/dist/esm/builder/shared/createCopyInfo.js +0 -14
  103. package/dist/esm/builder/shared/index.js +0 -3
  104. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
  105. package/dist/esm/builder/shared/types.js +0 -0
  106. package/dist/esm/commands/build.js +0 -117
  107. package/dist/esm/commands/deploy.js +0 -48
  108. package/dist/esm/commands/dev.js +0 -169
  109. package/dist/esm/commands/index.js +0 -411
  110. package/dist/esm/commands/inspect.js +0 -28
  111. package/dist/esm/commands/serve.js +0 -93
  112. package/dist/esm/config/default.js +0 -190
  113. package/dist/esm/config/index.js +0 -3
  114. package/dist/esm/config/initialize/index.js +0 -9
  115. package/dist/esm/config/initialize/inits.js +0 -85
  116. package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
  117. package/dist/esm/config/legacy/createOutputConfig.js +0 -45
  118. package/dist/esm/config/legacy/createSourceConfig.js +0 -46
  119. package/dist/esm/config/legacy/createToolsConfig.js +0 -28
  120. package/dist/esm/config/legacy/index.js +0 -43
  121. package/dist/esm/defineConfig.js +0 -16
  122. package/dist/esm/exports/server.js +0 -4
  123. package/dist/esm/hooks.js +0 -34
  124. package/dist/esm/index.js +0 -239
  125. package/dist/esm/locale/en.js +0 -43
  126. package/dist/esm/locale/index.js +0 -12
  127. package/dist/esm/locale/zh.js +0 -43
  128. package/dist/esm/plugins/analyze/constants.js +0 -14
  129. package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
  130. package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
  131. package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
  132. package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
  133. package/dist/esm/plugins/analyze/index.js +0 -380
  134. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
  135. package/dist/esm/plugins/analyze/templates.js +0 -6
  136. package/dist/esm/plugins/analyze/utils.js +0 -101
  137. package/dist/esm/plugins/deploy/dependencies/index.js +0 -629
  138. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -643
  139. package/dist/esm/plugins/deploy/exports.js +0 -4
  140. package/dist/esm/plugins/deploy/index.js +0 -135
  141. package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
  142. package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
  143. package/dist/esm/plugins/deploy/platforms/node.js +0 -133
  144. package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
  145. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  146. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
  147. package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
  148. package/dist/esm/plugins/deploy/utils.js +0 -47
  149. package/dist/esm/plugins/initialize/index.js +0 -119
  150. package/dist/esm/plugins/serverBuild.js +0 -87
  151. package/dist/esm/types/config/deploy.js +0 -0
  152. package/dist/esm/types/config/dev.js +0 -0
  153. package/dist/esm/types/config/experiments.js +0 -0
  154. package/dist/esm/types/config/html.js +0 -0
  155. package/dist/esm/types/config/index.js +0 -1
  156. package/dist/esm/types/config/output.js +0 -0
  157. package/dist/esm/types/config/performance.js +0 -0
  158. package/dist/esm/types/config/security.js +0 -0
  159. package/dist/esm/types/config/source.js +0 -0
  160. package/dist/esm/types/config/testing.js +0 -0
  161. package/dist/esm/types/config/tools.js +0 -0
  162. package/dist/esm/types/hooks.js +0 -0
  163. package/dist/esm/types/index.js +0 -3
  164. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  165. package/dist/esm/types/legacyConfig/dev.js +0 -0
  166. package/dist/esm/types/legacyConfig/index.js +0 -0
  167. package/dist/esm/types/legacyConfig/output.js +0 -0
  168. package/dist/esm/types/legacyConfig/source.js +0 -0
  169. package/dist/esm/types/legacyConfig/testing.js +0 -0
  170. package/dist/esm/types/legacyConfig/tools.js +0 -0
  171. package/dist/esm/types/utils.js +0 -0
  172. package/dist/esm/utils/config.js +0 -122
  173. package/dist/esm/utils/createServer.js +0 -58
  174. package/dist/esm/utils/env.js +0 -16
  175. package/dist/esm/utils/generateWatchFiles.js +0 -71
  176. package/dist/esm/utils/getSelectedEntries.js +0 -67
  177. package/dist/esm/utils/loadPlugins.js +0 -69
  178. package/dist/esm/utils/printInstructions.js +0 -32
  179. package/dist/esm/utils/register.js +0 -129
  180. package/dist/esm/utils/restart.js +0 -67
  181. package/dist/esm/utils/routes.js +0 -42
  182. package/dist/esm/utils/types.js +0 -0
  183. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
  184. package/dist/esm-node/builder/builder-rspack/index.js +0 -12
  185. package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
  186. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
  187. package/dist/esm-node/builder/builder-webpack/index.js +0 -20
  188. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
  189. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
  190. package/dist/esm-node/builder/generator/index.js +0 -37
  191. package/dist/esm-node/builder/index.js +0 -11
  192. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
  193. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
  194. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
  195. package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
  196. package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
  197. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
  198. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
  199. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -219
  200. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
  201. package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
  202. package/dist/esm-node/builder/shared/index.js +0 -3
  203. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
  204. package/dist/esm-node/builder/shared/types.js +0 -0
  205. package/dist/esm-node/commands/build.js +0 -55
  206. package/dist/esm-node/commands/deploy.js +0 -12
  207. package/dist/esm-node/commands/dev.js +0 -95
  208. package/dist/esm-node/commands/index.js +0 -92
  209. package/dist/esm-node/commands/inspect.js +0 -15
  210. package/dist/esm-node/commands/serve.js +0 -51
  211. package/dist/esm-node/config/default.js +0 -197
  212. package/dist/esm-node/config/index.js +0 -3
  213. package/dist/esm-node/config/initialize/index.js +0 -9
  214. package/dist/esm-node/config/initialize/inits.js +0 -79
  215. package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
  216. package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
  217. package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
  218. package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
  219. package/dist/esm-node/config/legacy/index.js +0 -43
  220. package/dist/esm-node/defineConfig.js +0 -13
  221. package/dist/esm-node/exports/server.js +0 -4
  222. package/dist/esm-node/hooks.js +0 -34
  223. package/dist/esm-node/index.js +0 -124
  224. package/dist/esm-node/locale/en.js +0 -43
  225. package/dist/esm-node/locale/index.js +0 -12
  226. package/dist/esm-node/locale/zh.js +0 -43
  227. package/dist/esm-node/plugins/analyze/constants.js +0 -14
  228. package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
  229. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
  230. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
  231. package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
  232. package/dist/esm-node/plugins/analyze/index.js +0 -166
  233. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
  234. package/dist/esm-node/plugins/analyze/templates.js +0 -24
  235. package/dist/esm-node/plugins/analyze/utils.js +0 -68
  236. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -215
  237. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -202
  238. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  239. package/dist/esm-node/plugins/deploy/index.js +0 -44
  240. package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
  241. package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
  242. package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
  243. package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
  244. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  245. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
  246. package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
  247. package/dist/esm-node/plugins/deploy/utils.js +0 -44
  248. package/dist/esm-node/plugins/initialize/index.js +0 -84
  249. package/dist/esm-node/plugins/serverBuild.js +0 -58
  250. package/dist/esm-node/types/config/deploy.js +0 -0
  251. package/dist/esm-node/types/config/dev.js +0 -0
  252. package/dist/esm-node/types/config/experiments.js +0 -0
  253. package/dist/esm-node/types/config/html.js +0 -0
  254. package/dist/esm-node/types/config/index.js +0 -1
  255. package/dist/esm-node/types/config/output.js +0 -0
  256. package/dist/esm-node/types/config/performance.js +0 -0
  257. package/dist/esm-node/types/config/security.js +0 -0
  258. package/dist/esm-node/types/config/source.js +0 -0
  259. package/dist/esm-node/types/config/testing.js +0 -0
  260. package/dist/esm-node/types/config/tools.js +0 -0
  261. package/dist/esm-node/types/hooks.js +0 -0
  262. package/dist/esm-node/types/index.js +0 -3
  263. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  264. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  265. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  266. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  267. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  268. package/dist/esm-node/types/legacyConfig/testing.js +0 -0
  269. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  270. package/dist/esm-node/types/utils.js +0 -0
  271. package/dist/esm-node/utils/config.js +0 -49
  272. package/dist/esm-node/utils/createServer.js +0 -26
  273. package/dist/esm-node/utils/env.js +0 -16
  274. package/dist/esm-node/utils/generateWatchFiles.js +0 -30
  275. package/dist/esm-node/utils/getSelectedEntries.js +0 -34
  276. package/dist/esm-node/utils/loadPlugins.js +0 -22
  277. package/dist/esm-node/utils/printInstructions.js +0 -11
  278. package/dist/esm-node/utils/register.js +0 -69
  279. package/dist/esm-node/utils/restart.js +0 -22
  280. package/dist/esm-node/utils/routes.js +0 -21
  281. package/dist/esm-node/utils/types.js +0 -0
  282. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
  283. package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
  284. /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
  285. /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,288 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
3
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
- import { createHash } from "crypto";
7
- import { mergeWith } from "@modern-js/utils/lodash";
8
- import { ROUTE_MANIFEST_FILE } from "@modern-js/utils";
9
- import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
10
- var PLUGIN_NAME = "ModernjsRoutePlugin";
11
- var generateContentHash = function(content) {
12
- return createHash("md5").update(content).digest("hex").slice(0, 8);
13
- };
14
- var RouterPlugin = /* @__PURE__ */ function() {
15
- "use strict";
16
- function RouterPlugin2(param) {
17
- var _param_staticJsDir = param.staticJsDir, staticJsDir = _param_staticJsDir === void 0 ? "static/js" : _param_staticJsDir, HtmlBundlerPlugin = param.HtmlBundlerPlugin, enableInlineRouteManifests = param.enableInlineRouteManifests, _param_disableFilenameHash = param.disableFilenameHash, disableFilenameHash = _param_disableFilenameHash === void 0 ? false : _param_disableFilenameHash, _param_scriptLoading = param.scriptLoading, scriptLoading = _param_scriptLoading === void 0 ? "defer" : _param_scriptLoading, nonce = param.nonce;
18
- _class_call_check(this, RouterPlugin2);
19
- this.name = "RouterPlugin";
20
- this.HtmlBundlerPlugin = HtmlBundlerPlugin;
21
- this.enableInlineRouteManifests = enableInlineRouteManifests;
22
- this.staticJsDir = staticJsDir;
23
- this.disableFilenameHash = disableFilenameHash;
24
- this.scriptLoading = scriptLoading;
25
- this.nonce = nonce;
26
- }
27
- var _proto = RouterPlugin2.prototype;
28
- _proto.isTargetNodeOrWebWorker = function isTargetNodeOrWebWorker(target) {
29
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
30
- return true;
31
- }
32
- if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
33
- return true;
34
- }
35
- return false;
36
- };
37
- _proto.getEntryChunks = function getEntryChunks(compilation, chunks) {
38
- var entrypointsArray = Array.from(compilation.entrypoints.entries());
39
- var entryChunkIds = entrypointsArray.map(function(entrypoint) {
40
- return entrypoint[0];
41
- });
42
- var entryChunks = _to_consumable_array(chunks).filter(function(chunk) {
43
- var _chunk_names;
44
- return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some(function(name) {
45
- return entryChunkIds.includes(name);
46
- });
47
- });
48
- return entryChunks;
49
- };
50
- _proto.getEntryChunkFiles = function getEntryChunkFiles(entryChunks) {
51
- return entryChunks.map(function(chunk) {
52
- return _to_consumable_array(chunk.files || []).find(function(fname) {
53
- return fname.includes(".js");
54
- });
55
- });
56
- };
57
- _proto.apply = function apply(compiler) {
58
- var _this = this;
59
- var target = compiler.options.target;
60
- if (this.isTargetNodeOrWebWorker(target)) {
61
- return;
62
- }
63
- var webpack = compiler.webpack;
64
- var isRspack = "rspackVersion" in webpack;
65
- var Compilation = webpack.Compilation, sources = webpack.sources;
66
- var RawSource = sources.RawSource;
67
- var normalizePath = function(path) {
68
- if (!path.endsWith("/")) {
69
- return "".concat(path, "/");
70
- }
71
- return path;
72
- };
73
- var chunksToHtmlName = /* @__PURE__ */ new Map();
74
- var ROUTE_MANIFEST_HOLDER = "route-manifest";
75
- var placeholder = "<!--<?- ".concat(ROUTE_MANIFEST_HOLDER, " ?>-->");
76
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, function(compilation) {
77
- _this.HtmlBundlerPlugin.getHooks(compilation).beforeEmit.tapAsync("RouterManifestPlugin", function(data, callback) {
78
- var outputName = data.outputName;
79
- var chunks = data.plugin.options.chunks;
80
- chunksToHtmlName.set(chunks, outputName);
81
- data.html = data.html.replace("</script>", "</script>".concat(placeholder));
82
- callback(null, data);
83
- });
84
- var _this1 = _this;
85
- compilation.hooks.processAssets.tapPromise({
86
- name: PLUGIN_NAME,
87
- stage: Compilation.PROCESS_ASSETS_STAGE_REPORT
88
- }, /* @__PURE__ */ _async_to_generator(function() {
89
- var _loop, stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, prevManifestAsset, prevManifestStr, prevManifest, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, manifest, entryNames, entryChunks, orignalEntryIds, entryChunkFiles, entryChunkFileIds, i;
90
- return _ts_generator(this, function(_state) {
91
- _loop = function(i2) {
92
- var entryName = entryNames[i2];
93
- var file = entryChunkFiles[i2];
94
- var chunkNames = entryChunks[i2].names;
95
- var chunkId = entryChunkFileIds[i2];
96
- var asset = compilation.assets[file];
97
- if (!asset || !chunkId) {
98
- return "continue";
99
- }
100
- var relatedAssets = {};
101
- if (entryChunkFiles.length > 1) {
102
- Object.keys(routeAssets).forEach(function(routeId) {
103
- var segments = routeId.split("_");
104
- var chunkName = segments[0];
105
- if (chunkNames === null || chunkNames === void 0 ? void 0 : chunkNames.includes(chunkName)) {
106
- relatedAssets[routeId] = routeAssets[routeId];
107
- }
108
- });
109
- } else {
110
- relatedAssets = routeAssets;
111
- }
112
- var manifest2 = {
113
- routeAssets: relatedAssets
114
- };
115
- var injectedContent = "\n ;(function(){\n window.".concat(ROUTE_MANIFEST, " = ").concat(JSON.stringify(manifest2, function(k, v) {
116
- if ((k === "assets" || k === "referenceCssAssets") && Array.isArray(v)) {
117
- return v.map(function(item) {
118
- return item.replace(publicPath, "");
119
- });
120
- }
121
- return v;
122
- }), ";\n })();\n ");
123
- var htmlName = void 0;
124
- var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
125
- try {
126
- var _loop2 = function() {
127
- var _step_value2 = _sliced_to_array(_step2.value, 2), chunks2 = _step_value2[0], name2 = _step_value2[1];
128
- if (Array.isArray(chunkNames) && Array.isArray(chunks2) && chunkNames.every(function(value, index) {
129
- return value === chunks2[index];
130
- })) {
131
- htmlName = name2;
132
- return "break";
133
- }
134
- };
135
- for (var _iterator2 = chunksToHtmlName.entries()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
136
- var _ret = _loop2();
137
- if (_ret === "break")
138
- break;
139
- }
140
- } catch (err) {
141
- _didIteratorError2 = true;
142
- _iteratorError2 = err;
143
- } finally {
144
- try {
145
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
146
- _iterator2.return();
147
- }
148
- } finally {
149
- if (_didIteratorError2) {
150
- throw _iteratorError2;
151
- }
152
- }
153
- }
154
- var oldHtml = compilation.assets[htmlName];
155
- var enableInlineRouteManifests = _this1.enableInlineRouteManifests, disableFilenameHash = _this1.disableFilenameHash, staticJsDir = _this1.staticJsDir, scriptLoading = _this1.scriptLoading, nonce = _this1.nonce;
156
- var nonceAttr = nonce ? 'nonce="'.concat(nonce, '"') : "";
157
- if (oldHtml) {
158
- if (enableInlineRouteManifests) {
159
- compilation.updateAsset(
160
- htmlName,
161
- new RawSource(oldHtml.source().toString().replace(placeholder, "<script ".concat(nonceAttr, ">").concat(injectedContent, "</script>"))),
162
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
163
- void 0
164
- );
165
- } else {
166
- var scriptPath = "".concat(staticJsDir, "/").concat(ROUTE_MANIFEST_HOLDER, "-").concat(entryName).concat(disableFilenameHash ? ".js" : ".".concat(generateContentHash(injectedContent), ".js"));
167
- var scriptUrl = "".concat(publicPath).concat(scriptPath);
168
- var scriptLoadingAttr = (
169
- // eslint-disable-next-line no-nested-ternary
170
- scriptLoading === "defer" ? scriptLoading : scriptLoading === "module" ? 'type="module"' : ""
171
- );
172
- var script = "<script ".concat(scriptLoadingAttr, " ").concat(nonceAttr, ' src="').concat(scriptUrl, '"></script>');
173
- compilation.updateAsset(
174
- htmlName,
175
- new RawSource(oldHtml.source().toString().replace(placeholder, script)),
176
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
177
- void 0
178
- );
179
- compilation.emitAsset(scriptPath, new RawSource(injectedContent));
180
- }
181
- }
182
- };
183
- stats = compilation.getStats().toJson({
184
- all: false,
185
- publicPath: true,
186
- assets: true,
187
- chunkGroups: true,
188
- chunks: true,
189
- ids: true
190
- });
191
- publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
192
- routeAssets = {};
193
- if (!namedChunkGroups) {
194
- return [
195
- 2
196
- ];
197
- }
198
- prevManifestAsset = compilation.getAsset(ROUTE_MANIFEST_FILE);
199
- prevManifestStr = prevManifestAsset ? prevManifestAsset.source.source().toString() : JSON.stringify({
200
- routeAssets: {}
201
- });
202
- prevManifest = JSON.parse(prevManifestStr);
203
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
204
- try {
205
- for (_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
206
- _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
207
- assets = chunkGroup.assets.map(function(asset) {
208
- var filename = asset.name;
209
- return publicPath ? normalizePath(publicPath) + filename : filename;
210
- });
211
- referenceCssAssets = assets.filter(function(asset) {
212
- return /\.css$/.test(asset);
213
- });
214
- routeAssets[name] = {
215
- chunkIds: chunkGroup.chunks,
216
- assets,
217
- referenceCssAssets
218
- };
219
- if (prevManifest.routeAssets[name]) {
220
- mergeWith(routeAssets[name], prevManifest.routeAssets[name], function(obj, source) {
221
- if (Array.isArray(obj)) {
222
- return obj.concat(source);
223
- }
224
- return Object.assign(source, obj);
225
- });
226
- }
227
- }
228
- } catch (err) {
229
- _didIteratorError = true;
230
- _iteratorError = err;
231
- } finally {
232
- try {
233
- if (!_iteratorNormalCompletion && _iterator.return != null) {
234
- _iterator.return();
235
- }
236
- } finally {
237
- if (_didIteratorError) {
238
- throw _iteratorError;
239
- }
240
- }
241
- }
242
- manifest = {
243
- routeAssets
244
- };
245
- entryNames = Array.from(compilation.entrypoints.keys());
246
- entryChunks = [];
247
- if (isRspack) {
248
- entryChunks = _this1.getEntryChunks(compilation, chunks);
249
- } else {
250
- orignalEntryIds = Object.keys(compilation.options.entry).map(function(entryName) {
251
- var chunk = compilation.namedChunks.get(entryName);
252
- if (chunk) {
253
- return chunk.id;
254
- }
255
- return entryName;
256
- });
257
- entryChunks = _this1.getEntryChunks(compilation, chunks).filter(function(chunk) {
258
- return orignalEntryIds.includes(chunk.id);
259
- });
260
- }
261
- entryChunkFiles = _this1.getEntryChunkFiles(entryChunks);
262
- entryChunkFileIds = entryChunks.map(function(chunk) {
263
- return chunk.id;
264
- });
265
- for (i = 0; i < entryChunkFiles.length; i++)
266
- _loop(i);
267
- if (prevManifestAsset) {
268
- compilation.updateAsset(
269
- ROUTE_MANIFEST_FILE,
270
- new RawSource(JSON.stringify(manifest, null, 2)),
271
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
272
- void 0
273
- );
274
- } else {
275
- compilation.emitAsset(ROUTE_MANIFEST_FILE, new RawSource(JSON.stringify(manifest, null, 2)));
276
- }
277
- return [
278
- 2
279
- ];
280
- });
281
- }));
282
- });
283
- };
284
- return RouterPlugin2;
285
- }();
286
- export {
287
- RouterPlugin
288
- };
@@ -1,3 +0,0 @@
1
- export * from "./HtmlAsyncChunkPlugin";
2
- export * from "./HtmlBottomTemplate";
3
- export * from "./RouterPlugin";
@@ -1,14 +0,0 @@
1
- import path from "path";
2
- function createCopyInfo(appContext, config) {
3
- var configDir = path.resolve(appContext.appDirectory, config.source.configDir || "./config");
4
- var uploadDir = path.posix.join(configDir.replace(/\\/g, "/"), "upload");
5
- var publicDir = path.posix.join(configDir.replace(/\\/g, "/"), "public");
6
- return {
7
- configDir,
8
- uploadDir,
9
- publicDir
10
- };
11
- }
12
- export {
13
- createCopyInfo
14
- };
@@ -1,3 +0,0 @@
1
- export * from "./types";
2
- export * from "./builderPlugins";
3
- export * from "./createCopyInfo";
@@ -1,7 +0,0 @@
1
- function loader() {
2
- return "module.exports = {}";
3
- }
4
- var serverModuleLoader_default = loader;
5
- export {
6
- serverModuleLoader_default as default
7
- };
File without changes
@@ -1,117 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
- import { ResolvedConfigContext } from "@modern-js/core";
6
- import { logger } from "@modern-js/utils";
7
- import { loadServerPlugins } from "../utils/loadPlugins";
8
- import { generateRoutes } from "../utils/routes";
9
- import { buildServerConfig } from "../utils/config";
10
- import { registerCompiler } from "../utils/register";
11
- var build = function() {
12
- var _ref = _async_to_generator(function(api, options) {
13
- var _resolvedConfig_source, resolvedConfig, appContext, hookRunners, apiOnly, appDirectory, distDirectory, serverConfigFile, distDirectory1, appDirectory1, serverConfigFile1;
14
- return _ts_generator(this, function(_state) {
15
- switch (_state.label) {
16
- case 0:
17
- if (options === null || options === void 0 ? void 0 : options.analyze) {
18
- process.env.BUNDLE_ANALYZE = "true";
19
- }
20
- resolvedConfig = api.useResolvedConfigContext();
21
- appContext = api.useAppContext();
22
- hookRunners = api.useHookRunners();
23
- return [
24
- 4,
25
- loadServerPlugins(api, appContext.appDirectory, appContext.metaName)
26
- ];
27
- case 1:
28
- _state.sent();
29
- return [
30
- 4,
31
- registerCompiler(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias)
32
- ];
33
- case 2:
34
- _state.sent();
35
- apiOnly = appContext.apiOnly;
36
- if (!apiOnly)
37
- return [
38
- 3,
39
- 7
40
- ];
41
- appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverConfigFile = appContext.serverConfigFile;
42
- return [
43
- 4,
44
- hookRunners.beforeBuild({
45
- // "null" bundlerConfigs
46
- bundlerConfigs: void 0
47
- })
48
- ];
49
- case 3:
50
- _state.sent();
51
- return [
52
- 4,
53
- buildServerConfig({
54
- appDirectory,
55
- distDirectory,
56
- configFile: serverConfigFile
57
- })
58
- ];
59
- case 4:
60
- _state.sent();
61
- return [
62
- 4,
63
- generateRoutes(appContext)
64
- ];
65
- case 5:
66
- _state.sent();
67
- return [
68
- 4,
69
- hookRunners.afterBuild({
70
- // "null" stats
71
- stats: void 0
72
- })
73
- ];
74
- case 6:
75
- _state.sent();
76
- return [
77
- 2
78
- ];
79
- case 7:
80
- resolvedConfig = _object_spread_props(_object_spread({}, resolvedConfig), {
81
- cliOptions: options
82
- });
83
- ResolvedConfigContext.set(resolvedConfig);
84
- distDirectory1 = appContext.distDirectory, appDirectory1 = appContext.appDirectory, serverConfigFile1 = appContext.serverConfigFile;
85
- return [
86
- 4,
87
- buildServerConfig({
88
- appDirectory: appDirectory1,
89
- distDirectory: distDirectory1,
90
- configFile: serverConfigFile1
91
- })
92
- ];
93
- case 8:
94
- _state.sent();
95
- logger.info("Starting production build...");
96
- if (!appContext.builder) {
97
- throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
98
- }
99
- return [
100
- 4,
101
- appContext.builder.build()
102
- ];
103
- case 9:
104
- _state.sent();
105
- return [
106
- 2
107
- ];
108
- }
109
- });
110
- });
111
- return function build2(api, options) {
112
- return _ref.apply(this, arguments);
113
- };
114
- }();
115
- export {
116
- build
117
- };
@@ -1,48 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { getServerPlugins } from "../utils/loadPlugins";
4
- var deploy = function() {
5
- var _ref = _async_to_generator(function(api, options) {
6
- var hookRunners, metaName;
7
- return _ts_generator(this, function(_state) {
8
- switch (_state.label) {
9
- case 0:
10
- hookRunners = api.useHookRunners();
11
- metaName = api.useAppContext().metaName;
12
- return [
13
- 4,
14
- getServerPlugins(api, metaName)
15
- ];
16
- case 1:
17
- _state.sent();
18
- return [
19
- 4,
20
- hookRunners.beforeDeploy(options)
21
- ];
22
- case 2:
23
- _state.sent();
24
- return [
25
- 4,
26
- hookRunners.deploy(options)
27
- ];
28
- case 3:
29
- _state.sent();
30
- return [
31
- 4,
32
- hookRunners.afterDeploy(options)
33
- ];
34
- case 4:
35
- _state.sent();
36
- return [
37
- 2
38
- ];
39
- }
40
- });
41
- });
42
- return function deploy2(api, options) {
43
- return _ref.apply(this, arguments);
44
- };
45
- }();
46
- export {
47
- deploy
48
- };
@@ -1,169 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
- import path from "node:path";
6
- import { ResolvedConfigContext } from "@modern-js/core";
7
- import { DEFAULT_DEV_HOST, SERVER_DIR, getMeta, logger } from "@modern-js/utils";
8
- import { createDevServer } from "@modern-js/server";
9
- import { applyPlugins } from "@modern-js/prod-server";
10
- import { loadServerPlugins } from "../utils/loadPlugins";
11
- import { registerCompiler } from "../utils/register";
12
- import { printInstructions } from "../utils/printInstructions";
13
- import { setServer } from "../utils/createServer";
14
- import { generateRoutes } from "../utils/routes";
15
- import { buildServerConfig } from "../utils/config";
16
- var dev = function() {
17
- var _ref = _async_to_generator(function(api, options, devServerOptions) {
18
- var _normalizedConfig_source, _normalizedConfig_tools, _normalizedConfig_dev, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes, meta, serverConfigPath, pluginInstances, serverOptions, host, server, _ref2, server1, afterListen;
19
- return _ts_generator(this, function(_state) {
20
- switch (_state.label) {
21
- case 0:
22
- if (options.analyze) {
23
- process.env.BUNDLE_ANALYZE = "true";
24
- }
25
- normalizedConfig = api.useResolvedConfigContext();
26
- appContext = api.useAppContext();
27
- hookRunners = api.useHookRunners();
28
- return [
29
- 4,
30
- registerCompiler(appContext.appDirectory, appContext.distDirectory, normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_source = normalizedConfig.source) === null || _normalizedConfig_source === void 0 ? void 0 : _normalizedConfig_source.alias)
31
- ];
32
- case 1:
33
- _state.sent();
34
- normalizedConfig = _object_spread_props(_object_spread({}, normalizedConfig), {
35
- cliOptions: options
36
- });
37
- ResolvedConfigContext.set(normalizedConfig);
38
- appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, port = appContext.port, apiOnly = appContext.apiOnly, serverConfigFile = appContext.serverConfigFile, metaName = appContext.metaName, serverRoutes = appContext.serverRoutes;
39
- return [
40
- 4,
41
- buildServerConfig({
42
- appDirectory,
43
- distDirectory,
44
- configFile: serverConfigFile,
45
- watch: true
46
- })
47
- ];
48
- case 2:
49
- _state.sent();
50
- meta = getMeta(metaName);
51
- serverConfigPath = path.resolve(appDirectory, SERVER_DIR, "".concat(meta, ".server"));
52
- return [
53
- 4,
54
- hookRunners.beforeDev()
55
- ];
56
- case 3:
57
- _state.sent();
58
- if (!appContext.builder && !apiOnly) {
59
- throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
60
- }
61
- return [
62
- 4,
63
- generateRoutes(appContext)
64
- ];
65
- case 4:
66
- _state.sent();
67
- return [
68
- 4,
69
- loadServerPlugins(api, appDirectory, metaName)
70
- ];
71
- case 5:
72
- pluginInstances = _state.sent();
73
- serverOptions = _object_spread({
74
- metaName,
75
- dev: _object_spread({
76
- port,
77
- https: normalizedConfig.dev.https,
78
- host: normalizedConfig.dev.host
79
- }, (_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer),
80
- appContext: {
81
- appDirectory,
82
- apiDirectory: appContext.apiDirectory,
83
- lambdaDirectory: appContext.lambdaDirectory,
84
- sharedDirectory: appContext.sharedDirectory
85
- },
86
- serverConfigPath,
87
- routes: serverRoutes,
88
- pwd: appDirectory,
89
- config: normalizedConfig,
90
- serverConfigFile,
91
- plugins: pluginInstances
92
- }, devServerOptions);
93
- host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
94
- if (!apiOnly)
95
- return [
96
- 3,
97
- 7
98
- ];
99
- return [
100
- 4,
101
- createDevServer(_object_spread_props(_object_spread({}, serverOptions), {
102
- runCompile: false
103
- }), (devServerOptions === null || devServerOptions === void 0 ? void 0 : devServerOptions.applyPlugins) || applyPlugins)
104
- ];
105
- case 6:
106
- server = _state.sent().server;
107
- server.listen({
108
- port,
109
- host
110
- }, function() {
111
- printInstructions(hookRunners, appContext, normalizedConfig);
112
- });
113
- return [
114
- 3,
115
- 9
116
- ];
117
- case 7:
118
- return [
119
- 4,
120
- createDevServer(_object_spread_props(_object_spread({}, serverOptions), {
121
- builder: appContext.builder
122
- }), (devServerOptions === null || devServerOptions === void 0 ? void 0 : devServerOptions.applyPlugins) || applyPlugins)
123
- ];
124
- case 8:
125
- _ref2 = _state.sent(), server1 = _ref2.server, afterListen = _ref2.afterListen;
126
- server1.listen({
127
- port,
128
- host
129
- }, function() {
130
- var _ref3 = _async_to_generator(function(err) {
131
- return _ts_generator(this, function(_state2) {
132
- switch (_state2.label) {
133
- case 0:
134
- if (err) {
135
- logger.error("Occur error %s, when start dev server", err);
136
- }
137
- logger.debug("listen dev server done");
138
- return [
139
- 4,
140
- afterListen()
141
- ];
142
- case 1:
143
- _state2.sent();
144
- return [
145
- 2
146
- ];
147
- }
148
- });
149
- });
150
- return function(err) {
151
- return _ref3.apply(this, arguments);
152
- };
153
- }());
154
- setServer(server1);
155
- _state.label = 9;
156
- case 9:
157
- return [
158
- 2
159
- ];
160
- }
161
- });
162
- });
163
- return function dev2(api, options, devServerOptions) {
164
- return _ref.apply(this, arguments);
165
- };
166
- }();
167
- export {
168
- dev
169
- };