@modern-js/app-tools 2.10.1-alpha.0 → 2.11.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 (255) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/cjs/analyze/index.js +1 -1
  3. package/dist/cjs/builder/index.js +2 -2
  4. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +1 -1
  5. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +17 -12
  6. package/dist/cjs/utils/restart.js +1 -1
  7. package/dist/esm/analyze/index.js +2 -2
  8. package/dist/esm/builder/index.js +14 -9
  9. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +1 -1
  10. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +20 -13
  11. package/dist/esm/utils/restart.js +2 -2
  12. package/dist/esm-node/analyze/index.js +3 -2
  13. package/dist/esm-node/builder/index.js +1 -1
  14. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +1 -1
  15. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +17 -12
  16. package/dist/esm-node/utils/restart.js +8 -2
  17. package/dist/types/types/config/source.d.ts +2 -2
  18. package/package.json +24 -24
  19. package/dist/js/modern/analyze/constants.js +0 -54
  20. package/dist/js/modern/analyze/generateCode.js +0 -247
  21. package/dist/js/modern/analyze/getBundleEntry.js +0 -71
  22. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +0 -220
  23. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +0 -216
  24. package/dist/js/modern/analyze/getClientRoutes/index.js +0 -6
  25. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -31
  26. package/dist/js/modern/analyze/getFileSystemEntry.js +0 -109
  27. package/dist/js/modern/analyze/getHtmlTemplate.js +0 -115
  28. package/dist/js/modern/analyze/getServerRoutes.js +0 -175
  29. package/dist/js/modern/analyze/index.js +0 -332
  30. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -42
  31. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -13
  32. package/dist/js/modern/analyze/nestedRoutes.js +0 -157
  33. package/dist/js/modern/analyze/templates.js +0 -334
  34. package/dist/js/modern/analyze/utils.js +0 -141
  35. package/dist/js/modern/builder/builderPlugins/compatModern.js +0 -233
  36. package/dist/js/modern/builder/index.js +0 -159
  37. package/dist/js/modern/builder/loaders/routerLoader.js +0 -17
  38. package/dist/js/modern/builder/loaders/serverModuleLoader.js +0 -7
  39. package/dist/js/modern/builder/share.js +0 -46
  40. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
  41. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
  42. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +0 -113
  43. package/dist/js/modern/commands/build.js +0 -91
  44. package/dist/js/modern/commands/deploy.js +0 -28
  45. package/dist/js/modern/commands/dev.js +0 -109
  46. package/dist/js/modern/commands/index.js +0 -3
  47. package/dist/js/modern/commands/inspect.js +0 -38
  48. package/dist/js/modern/commands/serve.js +0 -54
  49. package/dist/js/modern/config/default.js +0 -175
  50. package/dist/js/modern/config/index.js +0 -8
  51. package/dist/js/modern/config/initial/createHtmlConfig.js +0 -35
  52. package/dist/js/modern/config/initial/createOutputConfig.js +0 -68
  53. package/dist/js/modern/config/initial/createSourceConfig.js +0 -39
  54. package/dist/js/modern/config/initial/createToolsConfig.js +0 -42
  55. package/dist/js/modern/config/initial/index.js +0 -16
  56. package/dist/js/modern/config/initial/inits.js +0 -152
  57. package/dist/js/modern/config/initial/transformNormalizedConfig.js +0 -47
  58. package/dist/js/modern/defineConfig.js +0 -27
  59. package/dist/js/modern/exports/server.js +0 -4
  60. package/dist/js/modern/hooks.js +0 -35
  61. package/dist/js/modern/index.js +0 -211
  62. package/dist/js/modern/initialize/index.js +0 -124
  63. package/dist/js/modern/locale/en.js +0 -36
  64. package/dist/js/modern/locale/index.js +0 -9
  65. package/dist/js/modern/locale/zh.js +0 -36
  66. package/dist/js/modern/schema/Schema.js +0 -40
  67. package/dist/js/modern/schema/index.js +0 -88
  68. package/dist/js/modern/schema/legacy.js +0 -148
  69. package/dist/js/modern/types/config/deploy.js +0 -0
  70. package/dist/js/modern/types/config/dev.js +0 -0
  71. package/dist/js/modern/types/config/experiments.js +0 -0
  72. package/dist/js/modern/types/config/html.js +0 -0
  73. package/dist/js/modern/types/config/index.js +0 -1
  74. package/dist/js/modern/types/config/output.js +0 -0
  75. package/dist/js/modern/types/config/performance.js +0 -0
  76. package/dist/js/modern/types/config/security.js +0 -0
  77. package/dist/js/modern/types/config/source.js +0 -0
  78. package/dist/js/modern/types/config/tools.js +0 -0
  79. package/dist/js/modern/types/hooks.js +0 -0
  80. package/dist/js/modern/types/index.js +0 -3
  81. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  82. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  83. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  84. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  85. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  86. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  87. package/dist/js/modern/utils/config.js +0 -128
  88. package/dist/js/modern/utils/createServer.js +0 -75
  89. package/dist/js/modern/utils/env.js +0 -15
  90. package/dist/js/modern/utils/generateWatchFiles.js +0 -55
  91. package/dist/js/modern/utils/getSelectedEntries.js +0 -58
  92. package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
  93. package/dist/js/modern/utils/language.js +0 -8
  94. package/dist/js/modern/utils/printInstructions.js +0 -31
  95. package/dist/js/modern/utils/restart.js +0 -44
  96. package/dist/js/modern/utils/routes.js +0 -30
  97. package/dist/js/modern/utils/types.js +0 -0
  98. package/dist/js/node/analyze/constants.js +0 -98
  99. package/dist/js/node/analyze/generateCode.js +0 -271
  100. package/dist/js/node/analyze/getBundleEntry.js +0 -95
  101. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +0 -242
  102. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +0 -238
  103. package/dist/js/node/analyze/getClientRoutes/index.js +0 -30
  104. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -58
  105. package/dist/js/node/analyze/getFileSystemEntry.js +0 -131
  106. package/dist/js/node/analyze/getHtmlTemplate.js +0 -144
  107. package/dist/js/node/analyze/getServerRoutes.js +0 -194
  108. package/dist/js/node/analyze/index.js +0 -339
  109. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -71
  110. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -36
  111. package/dist/js/node/analyze/nestedRoutes.js +0 -184
  112. package/dist/js/node/analyze/templates.js +0 -365
  113. package/dist/js/node/analyze/utils.js +0 -172
  114. package/dist/js/node/builder/builderPlugins/compatModern.js +0 -258
  115. package/dist/js/node/builder/index.js +0 -177
  116. package/dist/js/node/builder/loaders/routerLoader.js +0 -38
  117. package/dist/js/node/builder/loaders/serverModuleLoader.js +0 -28
  118. package/dist/js/node/builder/share.js +0 -75
  119. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -53
  120. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +0 -60
  121. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +0 -135
  122. package/dist/js/node/commands/build.js +0 -112
  123. package/dist/js/node/commands/deploy.js +0 -51
  124. package/dist/js/node/commands/dev.js +0 -126
  125. package/dist/js/node/commands/index.js +0 -19
  126. package/dist/js/node/commands/inspect.js +0 -61
  127. package/dist/js/node/commands/serve.js +0 -83
  128. package/dist/js/node/config/default.js +0 -197
  129. package/dist/js/node/config/index.js +0 -34
  130. package/dist/js/node/config/initial/createHtmlConfig.js +0 -58
  131. package/dist/js/node/config/initial/createOutputConfig.js +0 -91
  132. package/dist/js/node/config/initial/createSourceConfig.js +0 -62
  133. package/dist/js/node/config/initial/createToolsConfig.js +0 -65
  134. package/dist/js/node/config/initial/index.js +0 -41
  135. package/dist/js/node/config/initial/inits.js +0 -175
  136. package/dist/js/node/config/initial/transformNormalizedConfig.js +0 -70
  137. package/dist/js/node/defineConfig.js +0 -49
  138. package/dist/js/node/exports/server.js +0 -27
  139. package/dist/js/node/hooks.js +0 -54
  140. package/dist/js/node/index.js +0 -235
  141. package/dist/js/node/initialize/index.js +0 -134
  142. package/dist/js/node/locale/en.js +0 -59
  143. package/dist/js/node/locale/index.js +0 -33
  144. package/dist/js/node/locale/zh.js +0 -59
  145. package/dist/js/node/schema/Schema.js +0 -63
  146. package/dist/js/node/schema/index.js +0 -118
  147. package/dist/js/node/schema/legacy.js +0 -169
  148. package/dist/js/node/types/config/deploy.js +0 -15
  149. package/dist/js/node/types/config/dev.js +0 -15
  150. package/dist/js/node/types/config/experiments.js +0 -15
  151. package/dist/js/node/types/config/html.js +0 -15
  152. package/dist/js/node/types/config/index.js +0 -17
  153. package/dist/js/node/types/config/output.js +0 -15
  154. package/dist/js/node/types/config/performance.js +0 -15
  155. package/dist/js/node/types/config/security.js +0 -15
  156. package/dist/js/node/types/config/source.js +0 -15
  157. package/dist/js/node/types/config/tools.js +0 -15
  158. package/dist/js/node/types/hooks.js +0 -15
  159. package/dist/js/node/types/index.js +0 -19
  160. package/dist/js/node/types/legacyConfig/deploy.js +0 -15
  161. package/dist/js/node/types/legacyConfig/dev.js +0 -15
  162. package/dist/js/node/types/legacyConfig/index.js +0 -15
  163. package/dist/js/node/types/legacyConfig/output.js +0 -15
  164. package/dist/js/node/types/legacyConfig/source.js +0 -15
  165. package/dist/js/node/types/legacyConfig/tools.js +0 -15
  166. package/dist/js/node/utils/config.js +0 -153
  167. package/dist/js/node/utils/createServer.js +0 -106
  168. package/dist/js/node/utils/env.js +0 -38
  169. package/dist/js/node/utils/generateWatchFiles.js +0 -85
  170. package/dist/js/node/utils/getSelectedEntries.js +0 -81
  171. package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
  172. package/dist/js/node/utils/language.js +0 -31
  173. package/dist/js/node/utils/printInstructions.js +0 -54
  174. package/dist/js/node/utils/restart.js +0 -67
  175. package/dist/js/node/utils/routes.js +0 -59
  176. package/dist/js/node/utils/types.js +0 -15
  177. package/dist/js/treeshaking/analyze/constants.js +0 -40
  178. package/dist/js/treeshaking/analyze/generateCode.js +0 -485
  179. package/dist/js/treeshaking/analyze/getBundleEntry.js +0 -62
  180. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +0 -233
  181. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +0 -231
  182. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +0 -3
  183. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -23
  184. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +0 -107
  185. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +0 -302
  186. package/dist/js/treeshaking/analyze/getServerRoutes.js +0 -222
  187. package/dist/js/treeshaking/analyze/index.js +0 -697
  188. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -47
  189. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -13
  190. package/dist/js/treeshaking/analyze/nestedRoutes.js +0 -384
  191. package/dist/js/treeshaking/analyze/templates.js +0 -468
  192. package/dist/js/treeshaking/analyze/utils.js +0 -374
  193. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +0 -304
  194. package/dist/js/treeshaking/builder/index.js +0 -374
  195. package/dist/js/treeshaking/builder/loaders/routerLoader.js +0 -13
  196. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +0 -5
  197. package/dist/js/treeshaking/builder/share.js +0 -40
  198. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -110
  199. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +0 -72
  200. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +0 -343
  201. package/dist/js/treeshaking/commands/build.js +0 -291
  202. package/dist/js/treeshaking/commands/deploy.js +0 -154
  203. package/dist/js/treeshaking/commands/dev.js +0 -301
  204. package/dist/js/treeshaking/commands/index.js +0 -3
  205. package/dist/js/treeshaking/commands/inspect.js +0 -149
  206. package/dist/js/treeshaking/commands/serve.js +0 -199
  207. package/dist/js/treeshaking/config/default.js +0 -210
  208. package/dist/js/treeshaking/config/index.js +0 -3
  209. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +0 -19
  210. package/dist/js/treeshaking/config/initial/createOutputConfig.js +0 -41
  211. package/dist/js/treeshaking/config/initial/createSourceConfig.js +0 -42
  212. package/dist/js/treeshaking/config/initial/createToolsConfig.js +0 -23
  213. package/dist/js/treeshaking/config/initial/index.js +0 -12
  214. package/dist/js/treeshaking/config/initial/inits.js +0 -209
  215. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +0 -35
  216. package/dist/js/treeshaking/defineConfig.js +0 -61
  217. package/dist/js/treeshaking/exports/server.js +0 -2
  218. package/dist/js/treeshaking/hooks.js +0 -29
  219. package/dist/js/treeshaking/index.js +0 -706
  220. package/dist/js/treeshaking/initialize/index.js +0 -276
  221. package/dist/js/treeshaking/locale/en.js +0 -38
  222. package/dist/js/treeshaking/locale/index.js +0 -9
  223. package/dist/js/treeshaking/locale/zh.js +0 -38
  224. package/dist/js/treeshaking/schema/Schema.js +0 -273
  225. package/dist/js/treeshaking/schema/index.js +0 -181
  226. package/dist/js/treeshaking/schema/legacy.js +0 -337
  227. package/dist/js/treeshaking/types/config/deploy.js +0 -1
  228. package/dist/js/treeshaking/types/config/dev.js +0 -1
  229. package/dist/js/treeshaking/types/config/experiments.js +0 -1
  230. package/dist/js/treeshaking/types/config/html.js +0 -1
  231. package/dist/js/treeshaking/types/config/index.js +0 -1
  232. package/dist/js/treeshaking/types/config/output.js +0 -1
  233. package/dist/js/treeshaking/types/config/performance.js +0 -1
  234. package/dist/js/treeshaking/types/config/security.js +0 -1
  235. package/dist/js/treeshaking/types/config/source.js +0 -1
  236. package/dist/js/treeshaking/types/config/tools.js +0 -1
  237. package/dist/js/treeshaking/types/hooks.js +0 -1
  238. package/dist/js/treeshaking/types/index.js +0 -3
  239. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -1
  240. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -1
  241. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -1
  242. package/dist/js/treeshaking/types/legacyConfig/output.js +0 -1
  243. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -1
  244. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -1
  245. package/dist/js/treeshaking/utils/config.js +0 -302
  246. package/dist/js/treeshaking/utils/createServer.js +0 -258
  247. package/dist/js/treeshaking/utils/env.js +0 -13
  248. package/dist/js/treeshaking/utils/generateWatchFiles.js +0 -214
  249. package/dist/js/treeshaking/utils/getSelectedEntries.js +0 -186
  250. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +0 -210
  251. package/dist/js/treeshaking/utils/language.js +0 -6
  252. package/dist/js/treeshaking/utils/printInstructions.js +0 -152
  253. package/dist/js/treeshaking/utils/restart.js +0 -187
  254. package/dist/js/treeshaking/utils/routes.js +0 -153
  255. package/dist/js/treeshaking/utils/types.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.11.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 415bee6: fix: load chunk while can not load all css asset, when streaming ssr.
8
+ fix: 使用 streaming ssr 时,不能加载当前 chunk 的所有 css 资源
9
+ - c0ba89b: feat: 控制台输出 rspack 版本
10
+ feat: Print the version of rspack in the console.
11
+ - 0bd018b: feat: support use node api run dev & build & deploy command
12
+ feat: 支持通过 node api 运行 dev & build & deploy 命令
13
+ - 5d624fd: feat: assets and data prefetching is supported
14
+ feat: 支持资源和数据预加载
15
+ - 7017909: fix: distpath.root not take effect when serve
16
+
17
+ fix: 修复 distpath.root 在 run serve 时不生效的问题
18
+
19
+ - 381a3b9: feat(utils): move universal utils to the universal folder
20
+
21
+ feat(utils): 将运行时使用的 utils 移动到 universal 目录
22
+
23
+ - a47543a: fix: should hide publicPath in injected manifest
24
+ fix: 应该隐藏 publicPath 在注入的 manifest 中
25
+ - Updated dependencies [adcedad]
26
+ - Updated dependencies [cfb058f]
27
+ - Updated dependencies [a9c6083]
28
+ - Updated dependencies [55b07fd]
29
+ - Updated dependencies [c0ba89b]
30
+ - Updated dependencies [0bd018b]
31
+ - Updated dependencies [8b90c79]
32
+ - Updated dependencies [a8c08c3]
33
+ - Updated dependencies [3aa318d]
34
+ - Updated dependencies [5d624fd]
35
+ - Updated dependencies [e2466a1]
36
+ - Updated dependencies [58faba2]
37
+ - Updated dependencies [53b0a63]
38
+ - Updated dependencies [02bb383]
39
+ - Updated dependencies [3171c9d]
40
+ - Updated dependencies [381a3b9]
41
+ - Updated dependencies [7a60f10]
42
+ - Updated dependencies [73cfc9b]
43
+ - Updated dependencies [cd1040f]
44
+ - Updated dependencies [e262a99]
45
+ - Updated dependencies [7178795]
46
+ - Updated dependencies [1140a69]
47
+ - Updated dependencies [b71cef1]
48
+ - Updated dependencies [274b2e5]
49
+ - Updated dependencies [b9e1c54]
50
+ - @modern-js/builder-shared@2.11.0
51
+ - @modern-js/builder-webpack-provider@2.11.0
52
+ - @modern-js/builder@2.11.0
53
+ - @modern-js/utils@2.11.0
54
+ - @modern-js/builder-rspack-provider@2.11.0
55
+ - @modern-js/core@2.11.0
56
+ - @modern-js/builder-plugin-node-polyfill@2.11.0
57
+ - @modern-js/plugin-data-loader@2.11.0
58
+ - @modern-js/plugin-lint@2.11.0
59
+ - @modern-js/prod-server@2.11.0
60
+ - @modern-js/server@2.11.0
61
+ - @modern-js/builder-plugin-esbuild@2.11.0
62
+ - @modern-js/plugin-i18n@2.11.0
63
+ - @modern-js/new-action@2.11.0
64
+ - @modern-js/node-bundle-require@2.11.0
65
+ - @modern-js/upgrade@2.11.0
66
+ - @modern-js/plugin@2.11.0
67
+ - @modern-js/types@2.11.0
68
+
3
69
  ## 2.10.0
4
70
 
5
71
  ### Patch Changes
@@ -118,7 +118,7 @@ var analyze_default = ({
118
118
  debug(`add Define Types`);
119
119
  let checkedEntries = entrypoints.map((point) => point.entryName);
120
120
  if ((0, import_utils.isDevCommand)()) {
121
- const { entry } = (0, import_utils.minimist)(process.argv.slice(2));
121
+ const { entry } = (0, import_utils.minimist)((0, import_utils.getArgv)());
122
122
  checkedEntries = await (0, import_getSelectedEntries.getSelectedEntries)(
123
123
  typeof entry === "string" ? entry.split(",") : entry,
124
124
  entrypoints
@@ -31,12 +31,12 @@ __export(builder_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(builder_exports);
33
33
  var import_utils = require("@modern-js/utils");
34
- var import_builder_rspack_provider = require("@modern-js/builder-rspack-provider");
35
34
  async function createBuilderGenerator(bundler) {
36
35
  if (bundler === "rspack") {
37
36
  try {
38
37
  const { createRspackBuilderForModern } = await Promise.resolve().then(() => __toESM(require("./builder-rspack")));
39
- const version = await (0, import_builder_rspack_provider.getRspackVersion)();
38
+ const { getRspackVersion } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-rspack-provider")));
39
+ const version = await getRspackVersion();
40
40
  import_utils.logger.info(`Using Rspack v${version} 🦀`);
41
41
  return createRspackBuilderForModern;
42
42
  } catch (_) {
@@ -43,8 +43,8 @@ const builderPluginAdapterSSR = (options) => ({
43
43
  async (chain, { target, CHAIN_ID, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
44
44
  const builderConfig = api.getNormalizedConfig();
45
45
  const { normalizedConfig: normalizedConfig2 } = options;
46
+ applyRouterPlugin(chain, options);
46
47
  if ((0, import_utils.isSSR)(normalizedConfig2)) {
47
- applyRouterPlugin(chain, options);
48
48
  await applySSRLoaderEntry(chain, options, isServer);
49
49
  }
50
50
  if (["node", "service-worker"].includes(target)) {
@@ -71,9 +71,9 @@ class RouterPlugin {
71
71
  chunks: true,
72
72
  ids: true
73
73
  });
74
- const { publicPath, chunks = [] } = stats;
74
+ const { publicPath, chunks = [], assetsByChunkName } = stats;
75
75
  const routeAssets = {};
76
- const { namedChunkGroups, assetsByChunkName } = stats;
76
+ const { namedChunkGroups } = stats;
77
77
  if (!namedChunkGroups || !assetsByChunkName) {
78
78
  import_utils.logger.warn(
79
79
  "Route manifest does not exist, performance will be affected"
@@ -81,14 +81,17 @@ class RouterPlugin {
81
81
  return;
82
82
  }
83
83
  for (const [name, chunkGroup] of Object.entries(namedChunkGroups)) {
84
- if (assetsByChunkName[name]) {
85
- routeAssets[name] = {
86
- chunkIds: chunkGroup.chunks,
87
- assets: assetsByChunkName[name].map(
88
- (item) => publicPath ? normalizePath(publicPath) + item : item
89
- )
90
- };
91
- }
84
+ const referenceCssAssets = chunkGroup.assets.filter((asset) => /\.css$/.test(asset.name)).map((asset) => {
85
+ const item = asset.name;
86
+ return publicPath ? normalizePath(publicPath) + item : item;
87
+ });
88
+ routeAssets[name] = {
89
+ chunkIds: chunkGroup.chunks,
90
+ assets: assetsByChunkName[name].map(
91
+ (item) => publicPath ? normalizePath(publicPath) + item : item
92
+ ),
93
+ referenceCssAssets
94
+ };
92
95
  }
93
96
  const manifest = {
94
97
  routeAssets
@@ -96,8 +99,10 @@ class RouterPlugin {
96
99
  const injectedContent = `
97
100
  ;(function(){
98
101
  window.${import_constants2.ROUTE_MANIFEST} = ${JSON.stringify(manifest, (k, v) => {
99
- if (k === "assets") {
100
- return void 0;
102
+ if (k === "assets" && Array.isArray(v)) {
103
+ return v.map((item) => {
104
+ return item.replace(publicPath, "");
105
+ });
101
106
  }
102
107
  return v;
103
108
  })};
@@ -35,7 +35,7 @@ async function restart(hooksRunner, filename) {
35
35
  hasGetError = true;
36
36
  } finally {
37
37
  if (!hasGetError) {
38
- import_utils.program.parse(process.argv);
38
+ import_utils.program.parse((0, import_utils.getArgv)());
39
39
  }
40
40
  }
41
41
  }
@@ -221,7 +221,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
221
221
  }
222
222
  };
223
223
  import * as path from "path";
224
- import { createDebugger, findExists, fs, isApiOnly, minimist, getCommand, isDevCommand } from "@modern-js/utils";
224
+ import { createDebugger, findExists, fs, isApiOnly, minimist, getCommand, isDevCommand, getArgv } from "@modern-js/utils";
225
225
  import { cloneDeep } from "@modern-js/utils/lodash";
226
226
  import { printInstructions } from "../utils/printInstructions";
227
227
  import { generateRoutes } from "../utils/routes";
@@ -358,7 +358,7 @@ var analyze_default = function(param) {
358
358
  3,
359
359
  11
360
360
  ];
361
- entry = minimist(process.argv.slice(2)).entry;
361
+ entry = minimist(getArgv()).entry;
362
362
  return [
363
363
  4,
364
364
  getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints)
@@ -123,27 +123,26 @@ var __generator = this && this.__generator || function(thisArg, body) {
123
123
  }
124
124
  };
125
125
  import { logger } from "@modern-js/utils";
126
- import { getRspackVersion } from "@modern-js/builder-rspack-provider";
127
126
  function createBuilderGenerator(bundler) {
128
127
  return _createBuilderGenerator.apply(this, arguments);
129
128
  }
130
129
  function _createBuilderGenerator() {
131
130
  _createBuilderGenerator = _asyncToGenerator(function(bundler) {
132
- var createRspackBuilderForModern, version, _, createWebpackBuilderForModern;
131
+ var createRspackBuilderForModern, getRspackVersion, version, _, createWebpackBuilderForModern;
133
132
  return __generator(this, function(_state) {
134
133
  switch(_state.label){
135
134
  case 0:
136
135
  if (!(bundler === "rspack")) return [
137
136
  3,
138
- 5
137
+ 6
139
138
  ];
140
139
  _state.label = 1;
141
140
  case 1:
142
141
  _state.trys.push([
143
142
  1,
144
- 4,
143
+ 5,
145
144
  ,
146
- 5
145
+ 6
147
146
  ]);
148
147
  return [
149
148
  4,
@@ -153,24 +152,30 @@ function _createBuilderGenerator() {
153
152
  createRspackBuilderForModern = _state.sent().createRspackBuilderForModern;
154
153
  return [
155
154
  4,
156
- getRspackVersion()
155
+ import("@modern-js/builder-rspack-provider")
157
156
  ];
158
157
  case 3:
158
+ getRspackVersion = _state.sent().getRspackVersion;
159
+ return [
160
+ 4,
161
+ getRspackVersion()
162
+ ];
163
+ case 4:
159
164
  version = _state.sent();
160
165
  logger.info("Using Rspack v".concat(version, " \uD83E\uDD80"));
161
166
  return [
162
167
  2,
163
168
  createRspackBuilderForModern
164
169
  ];
165
- case 4:
170
+ case 5:
166
171
  _ = _state.sent();
167
172
  throw new Error("Failed to use Rspack, please check if you have `@modern-js/builder-rspack-provider` installed");
168
- case 5:
173
+ case 6:
169
174
  return [
170
175
  4,
171
176
  import("./builder-webpack")
172
177
  ];
173
- case 6:
178
+ case 7:
174
179
  createWebpackBuilderForModern = _state.sent().createWebpackBuilderForModern;
175
180
  return [
176
181
  2,
@@ -151,11 +151,11 @@ var builderPluginAdapterSSR = function(options) {
151
151
  target = param.target, CHAIN_ID = param.CHAIN_ID, isProd = param.isProd, HtmlBundlerPlugin = param.HtmlPlugin, isServer = param.isServer;
152
152
  builderConfig = api.getNormalizedConfig();
153
153
  normalizedConfig2 = options.normalizedConfig;
154
+ applyRouterPlugin(chain, options);
154
155
  if (!isSSR(normalizedConfig2)) return [
155
156
  3,
156
157
  2
157
158
  ];
158
- applyRouterPlugin(chain, options);
159
159
  return [
160
160
  4,
161
161
  applySSRLoaderEntry(chain, options, isServer)
@@ -237,7 +237,7 @@ var RouterPlugin = /*#__PURE__*/ function() {
237
237
  name: PLUGIN_NAME,
238
238
  stage: PROCESS_ASSETS_STAGE_REPORT
239
239
  }, /*#__PURE__*/ _asyncToGenerator(function() {
240
- var stats, publicPath, _stats_chunks, chunks, 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;
240
+ var stats, publicPath, _stats_chunks, chunks, assetsByChunkName, routeAssets, namedChunkGroups, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, referenceCssAssets, manifest, injectedContent, entrypointsArray, entryChunkIds, entryChunks, entryChunkFiles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, file, asset, newContent, filename;
241
241
  return __generator(this, function(_state) {
242
242
  switch(_state.label){
243
243
  case 0:
@@ -249,9 +249,9 @@ var RouterPlugin = /*#__PURE__*/ function() {
249
249
  chunks: true,
250
250
  ids: true
251
251
  });
252
- publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks;
252
+ publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, assetsByChunkName = stats.assetsByChunkName;
253
253
  routeAssets = {};
254
- namedChunkGroups = stats.namedChunkGroups, assetsByChunkName = stats.assetsByChunkName;
254
+ namedChunkGroups = stats.namedChunkGroups;
255
255
  if (!namedChunkGroups || !assetsByChunkName) {
256
256
  logger.warn("Route manifest does not exist, performance will be affected");
257
257
  return [
@@ -262,14 +262,19 @@ var RouterPlugin = /*#__PURE__*/ function() {
262
262
  try {
263
263
  for(_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
264
264
  _step_value = _slicedToArray(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
265
- if (assetsByChunkName[name]) {
266
- routeAssets[name] = {
267
- chunkIds: chunkGroup.chunks,
268
- assets: assetsByChunkName[name].map(function(item) {
269
- return publicPath ? normalizePath(publicPath) + item : item;
270
- })
271
- };
272
- }
265
+ referenceCssAssets = chunkGroup.assets.filter(function(asset) {
266
+ return /\.css$/.test(asset.name);
267
+ }).map(function(asset) {
268
+ var item = asset.name;
269
+ return publicPath ? normalizePath(publicPath) + item : item;
270
+ });
271
+ routeAssets[name] = {
272
+ chunkIds: chunkGroup.chunks,
273
+ assets: assetsByChunkName[name].map(function(item) {
274
+ return publicPath ? normalizePath(publicPath) + item : item;
275
+ }),
276
+ referenceCssAssets: referenceCssAssets
277
+ };
273
278
  }
274
279
  } catch (err) {
275
280
  _didIteratorError = true;
@@ -289,8 +294,10 @@ var RouterPlugin = /*#__PURE__*/ function() {
289
294
  routeAssets: routeAssets
290
295
  };
291
296
  injectedContent = "\n ;(function(){\n window.".concat(ROUTE_MANIFEST, " = ").concat(JSON.stringify(manifest, function(k, v) {
292
- if (k === "assets") {
293
- return void 0;
297
+ if (k === "assets" && Array.isArray(v)) {
298
+ return v.map(function(item) {
299
+ return item.replace(publicPath, "");
300
+ });
294
301
  }
295
302
  return v;
296
303
  }), ";\n })();\n ");
@@ -123,7 +123,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
123
123
  }
124
124
  };
125
125
  import { cli } from "@modern-js/core";
126
- import { chalk, clearConsole, logger, program } from "@modern-js/utils";
126
+ import { chalk, clearConsole, getArgv, logger, program } from "@modern-js/utils";
127
127
  function restart(hooksRunner, filename) {
128
128
  return _restart.apply(this, arguments);
129
129
  }
@@ -170,7 +170,7 @@ function _restart() {
170
170
  ];
171
171
  case 5:
172
172
  if (!hasGetError) {
173
- program.parse(process.argv);
173
+ program.parse(getArgv());
174
174
  }
175
175
  return [
176
176
  7
@@ -6,7 +6,8 @@ import {
6
6
  isApiOnly,
7
7
  minimist,
8
8
  getCommand,
9
- isDevCommand
9
+ isDevCommand,
10
+ getArgv
10
11
  } from "@modern-js/utils";
11
12
  import { cloneDeep } from "@modern-js/utils/lodash";
12
13
  import { printInstructions } from "../utils/printInstructions";
@@ -98,7 +99,7 @@ var analyze_default = ({
98
99
  debug(`add Define Types`);
99
100
  let checkedEntries = entrypoints.map((point) => point.entryName);
100
101
  if (isDevCommand()) {
101
- const { entry } = minimist(process.argv.slice(2));
102
+ const { entry } = minimist(getArgv());
102
103
  checkedEntries = await getSelectedEntries(
103
104
  typeof entry === "string" ? entry.split(",") : entry,
104
105
  entrypoints
@@ -1,9 +1,9 @@
1
1
  import { logger } from "@modern-js/utils";
2
- import { getRspackVersion } from "@modern-js/builder-rspack-provider";
3
2
  async function createBuilderGenerator(bundler) {
4
3
  if (bundler === "rspack") {
5
4
  try {
6
5
  const { createRspackBuilderForModern } = await import("./builder-rspack");
6
+ const { getRspackVersion } = await import("@modern-js/builder-rspack-provider");
7
7
  const version = await getRspackVersion();
8
8
  logger.info(`Using Rspack v${version} 🦀`);
9
9
  return createRspackBuilderForModern;
@@ -23,8 +23,8 @@ const builderPluginAdapterSSR = (options) => ({
23
23
  async (chain, { target, CHAIN_ID, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
24
24
  const builderConfig = api.getNormalizedConfig();
25
25
  const { normalizedConfig: normalizedConfig2 } = options;
26
+ applyRouterPlugin(chain, options);
26
27
  if (isSSR(normalizedConfig2)) {
27
- applyRouterPlugin(chain, options);
28
28
  await applySSRLoaderEntry(chain, options, isServer);
29
29
  }
30
30
  if (["node", "service-worker"].includes(target)) {
@@ -39,9 +39,9 @@ class RouterPlugin {
39
39
  chunks: true,
40
40
  ids: true
41
41
  });
42
- const { publicPath, chunks = [] } = stats;
42
+ const { publicPath, chunks = [], assetsByChunkName } = stats;
43
43
  const routeAssets = {};
44
- const { namedChunkGroups, assetsByChunkName } = stats;
44
+ const { namedChunkGroups } = stats;
45
45
  if (!namedChunkGroups || !assetsByChunkName) {
46
46
  logger.warn(
47
47
  "Route manifest does not exist, performance will be affected"
@@ -49,14 +49,17 @@ class RouterPlugin {
49
49
  return;
50
50
  }
51
51
  for (const [name, chunkGroup] of Object.entries(namedChunkGroups)) {
52
- if (assetsByChunkName[name]) {
53
- routeAssets[name] = {
54
- chunkIds: chunkGroup.chunks,
55
- assets: assetsByChunkName[name].map(
56
- (item) => publicPath ? normalizePath(publicPath) + item : item
57
- )
58
- };
59
- }
52
+ const referenceCssAssets = chunkGroup.assets.filter((asset) => /\.css$/.test(asset.name)).map((asset) => {
53
+ const item = asset.name;
54
+ return publicPath ? normalizePath(publicPath) + item : item;
55
+ });
56
+ routeAssets[name] = {
57
+ chunkIds: chunkGroup.chunks,
58
+ assets: assetsByChunkName[name].map(
59
+ (item) => publicPath ? normalizePath(publicPath) + item : item
60
+ ),
61
+ referenceCssAssets
62
+ };
60
63
  }
61
64
  const manifest = {
62
65
  routeAssets
@@ -64,8 +67,10 @@ class RouterPlugin {
64
67
  const injectedContent = `
65
68
  ;(function(){
66
69
  window.${ROUTE_MANIFEST} = ${JSON.stringify(manifest, (k, v) => {
67
- if (k === "assets") {
68
- return void 0;
70
+ if (k === "assets" && Array.isArray(v)) {
71
+ return v.map((item) => {
72
+ return item.replace(publicPath, "");
73
+ });
69
74
  }
70
75
  return v;
71
76
  })};
@@ -1,5 +1,11 @@
1
1
  import { cli } from "@modern-js/core";
2
- import { chalk, clearConsole, logger, program } from "@modern-js/utils";
2
+ import {
3
+ chalk,
4
+ clearConsole,
5
+ getArgv,
6
+ logger,
7
+ program
8
+ } from "@modern-js/utils";
3
9
  async function restart(hooksRunner, filename) {
4
10
  clearConsole();
5
11
  logger.info(`Restart because ${chalk.yellow(filename)} is changed...
@@ -13,7 +19,7 @@ async function restart(hooksRunner, filename) {
13
19
  hasGetError = true;
14
20
  } finally {
15
21
  if (!hasGetError) {
16
- program.parse(process.argv);
22
+ program.parse(getArgv());
17
23
  }
18
24
  }
19
25
  }
@@ -24,5 +24,5 @@ export interface SharedSourceConfig extends BuilderSharedSourceConfig {
24
24
 
25
25
  designSystem?: Record<string, any>;
26
26
  }
27
- export interface SourceUserConfig extends BuilderSourceConfig, SharedSourceConfig {}
28
- export interface RsSourceUserConfig extends RsBuilderSourceConfig, SharedSourceConfig {}
27
+ export type SourceUserConfig = BuilderSourceConfig & SharedSourceConfig;
28
+ export type RsSourceUserConfig = RsBuilderSourceConfig & SharedSourceConfig;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.10.1-alpha.0",
14
+ "version": "2.11.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/cjs/index.js",
@@ -68,23 +68,23 @@
68
68
  "@babel/types": "^7.18.0",
69
69
  "es-module-lexer": "^1.1.0",
70
70
  "esbuild": "0.15.7",
71
- "@modern-js/builder": "2.10.0",
72
- "@modern-js/builder-shared": "2.10.0",
73
- "@modern-js/builder-plugin-node-polyfill": "2.10.0",
74
- "@modern-js/builder-webpack-provider": "2.10.0",
75
- "@modern-js/core": "2.10.0",
76
- "@modern-js/new-action": "2.10.0",
77
- "@modern-js/node-bundle-require": "2.10.0",
78
- "@modern-js/plugin-data-loader": "2.10.0",
79
- "@modern-js/plugin-i18n": "2.10.0",
80
- "@modern-js/plugin-lint": "2.10.0",
81
- "@modern-js/plugin": "2.10.0",
82
- "@modern-js/types": "2.10.0",
83
- "@modern-js/server": "2.10.0",
84
- "@modern-js/prod-server": "2.10.0",
85
- "@modern-js/upgrade": "2.10.0",
86
- "@modern-js/utils": "2.10.0",
87
- "@modern-js/builder-plugin-esbuild": "2.10.0"
71
+ "@modern-js/builder": "2.11.0",
72
+ "@modern-js/builder-plugin-esbuild": "2.11.0",
73
+ "@modern-js/builder-plugin-node-polyfill": "2.11.0",
74
+ "@modern-js/builder-shared": "2.11.0",
75
+ "@modern-js/builder-webpack-provider": "2.11.0",
76
+ "@modern-js/core": "2.11.0",
77
+ "@modern-js/new-action": "2.11.0",
78
+ "@modern-js/node-bundle-require": "2.11.0",
79
+ "@modern-js/plugin": "2.11.0",
80
+ "@modern-js/plugin-data-loader": "2.11.0",
81
+ "@modern-js/plugin-i18n": "2.11.0",
82
+ "@modern-js/plugin-lint": "2.11.0",
83
+ "@modern-js/prod-server": "2.11.0",
84
+ "@modern-js/server": "2.11.0",
85
+ "@modern-js/types": "2.11.0",
86
+ "@modern-js/upgrade": "2.11.0",
87
+ "@modern-js/utils": "2.11.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@types/babel__traverse": "^7.14.2",
@@ -93,14 +93,14 @@
93
93
  "jest": "^29",
94
94
  "typescript": "^4",
95
95
  "webpack": "^5.76.2",
96
- "@modern-js/server-core": "2.10.0",
97
- "@modern-js/builder-rspack-provider": "2.10.0",
98
- "@scripts/build": "2.10.0",
99
- "@modern-js/builder-plugin-swc": "2.10.0",
100
- "@scripts/jest-config": "2.10.0"
96
+ "@modern-js/builder-plugin-swc": "2.11.0",
97
+ "@modern-js/builder-rspack-provider": "2.11.0",
98
+ "@modern-js/server-core": "2.11.0",
99
+ "@scripts/build": "2.11.0",
100
+ "@scripts/jest-config": "2.11.0"
101
101
  },
102
102
  "peerDependencies": {
103
- "@modern-js/builder-rspack-provider": "^2.10.0"
103
+ "@modern-js/builder-rspack-provider": "^2.11.0"
104
104
  },
105
105
  "peerDependenciesMeta": {
106
106
  "@modern-js/builder-rspack-provider": {
@@ -1,54 +0,0 @@
1
- const JS_EXTENSIONS = [".js", ".ts", ".jsx", ".tsx"];
2
- const INDEX_FILE_NAME = "index";
3
- const APP_FILE_NAME = "App";
4
- const PAGES_DIR_NAME = "pages";
5
- const NESTED_ROUTES_DIR = "routes";
6
- const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
7
- const LOADER_EXPORT_NAME = "loader";
8
- const TEMP_LOADERS_DIR = "__loaders__";
9
- const ENTRY_POINT_FILE_NAME = "index.js";
10
- const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.js";
11
- const FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = /^\[(\S+)\]([*+?]?)$/;
12
- const FILE_SYSTEM_ROUTES_LAYOUT = "_layout";
13
- const FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = "_app";
14
- const FILE_SYSTEM_ROUTES_INDEX = "index";
15
- const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/;
16
- const HTML_PARTIALS_FOLDER = "html";
17
- const HTML_PARTIALS_EXTENSIONS = [".htm", ".html", ".ejs"];
18
- const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
19
- const NESTED_ROUTE = {
20
- LAYOUT_FILE: "layout",
21
- LAYOUT_LOADER_FILE: "layout.loader",
22
- PAGE_FILE: "page",
23
- PAGE_LOADER_FILE: "page.loader",
24
- LOADING_FILE: "loading",
25
- ERROR_FILE: "error",
26
- LOADER_FILE: "loader"
27
- };
28
- const APP_CONFIG_NAME = "config";
29
- const APP_INIT_EXPORTED = "init";
30
- const APP_INIT_IMPORTED = "appInit";
31
- export {
32
- APP_CONFIG_NAME,
33
- APP_FILE_NAME,
34
- APP_INIT_EXPORTED,
35
- APP_INIT_IMPORTED,
36
- ENTRY_BOOTSTRAP_FILE_NAME,
37
- ENTRY_POINT_FILE_NAME,
38
- FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
39
- FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
40
- FILE_SYSTEM_ROUTES_FILE_NAME,
41
- FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
42
- FILE_SYSTEM_ROUTES_IGNORED_REGEX,
43
- FILE_SYSTEM_ROUTES_INDEX,
44
- FILE_SYSTEM_ROUTES_LAYOUT,
45
- HTML_PARTIALS_EXTENSIONS,
46
- HTML_PARTIALS_FOLDER,
47
- INDEX_FILE_NAME,
48
- JS_EXTENSIONS,
49
- LOADER_EXPORT_NAME,
50
- NESTED_ROUTE,
51
- NESTED_ROUTES_DIR,
52
- PAGES_DIR_NAME,
53
- TEMP_LOADERS_DIR
54
- };