@modern-js/app-tools 2.0.0-beta.4 → 2.0.0-beta.6

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 (146) hide show
  1. package/CHANGELOG.md +314 -0
  2. package/bin/modern.js +2 -0
  3. package/dist/js/modern/analyze/constants.js +10 -0
  4. package/dist/js/modern/analyze/generateCode.js +7 -9
  5. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +9 -6
  6. package/dist/js/modern/analyze/getFileSystemEntry.js +11 -3
  7. package/dist/js/modern/analyze/index.js +7 -5
  8. package/dist/js/modern/analyze/nestedRoutes.js +29 -22
  9. package/dist/js/modern/analyze/templates.js +8 -1
  10. package/dist/js/modern/analyze/utils.js +19 -3
  11. package/dist/js/modern/builder/builderPlugins/compatModern.js +8 -2
  12. package/dist/js/modern/builder/index.js +1 -7
  13. package/dist/js/modern/commands/dev.js +6 -9
  14. package/dist/js/modern/commands/index.js +1 -1
  15. package/dist/js/modern/commands/{start.js → serve.js} +3 -1
  16. package/dist/js/modern/config/default.js +38 -61
  17. package/dist/js/modern/config/initial/createOutputConfig.js +1 -3
  18. package/dist/js/modern/config/initial/createSourceConfig.js +5 -1
  19. package/dist/js/modern/config/initial/transformNormalizedConfig.js +5 -1
  20. package/dist/js/modern/hooks.js +1 -0
  21. package/dist/js/modern/index.js +5 -5
  22. package/dist/js/modern/initialize/index.js +5 -4
  23. package/dist/js/modern/locale/en.js +1 -1
  24. package/dist/js/modern/locale/zh.js +1 -1
  25. package/dist/js/modern/schema/index.js +3 -1
  26. package/dist/js/modern/utils/commands.js +6 -1
  27. package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
  28. package/dist/js/node/analyze/Builder.js +14 -8
  29. package/dist/js/node/analyze/constants.js +35 -3
  30. package/dist/js/node/analyze/generateCode.js +27 -24
  31. package/dist/js/node/analyze/getBundleEntry.js +7 -3
  32. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +33 -28
  33. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +24 -22
  34. package/dist/js/node/analyze/getClientRoutes/index.js +8 -3
  35. package/dist/js/node/analyze/getClientRoutes/utils.js +10 -3
  36. package/dist/js/node/analyze/getFileSystemEntry.js +18 -6
  37. package/dist/js/node/analyze/getHtmlTemplate.js +18 -14
  38. package/dist/js/node/analyze/getServerRoutes.js +36 -34
  39. package/dist/js/node/analyze/index.js +45 -59
  40. package/dist/js/node/analyze/isDefaultExportFunction.js +7 -3
  41. package/dist/js/node/analyze/makeLegalIdentifier.js +7 -3
  42. package/dist/js/node/analyze/nestedRoutes.js +58 -49
  43. package/dist/js/node/analyze/templates.js +45 -32
  44. package/dist/js/node/analyze/utils.js +39 -17
  45. package/dist/js/node/builder/builderPlugins/compatModern.js +32 -24
  46. package/dist/js/node/builder/index.js +36 -48
  47. package/dist/js/node/builder/loaders/routerLoader.js +5 -3
  48. package/dist/js/node/builder/loaders/serverModuleLoader.js +5 -3
  49. package/dist/js/node/builder/share.js +7 -3
  50. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +7 -3
  51. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +7 -3
  52. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +9 -7
  53. package/dist/js/node/commands/build.js +30 -28
  54. package/dist/js/node/commands/deploy.js +9 -5
  55. package/dist/js/node/commands/dev.js +39 -40
  56. package/dist/js/node/commands/index.js +5 -5
  57. package/dist/js/node/commands/inspect.js +10 -6
  58. package/dist/js/node/commands/{start.js → serve.js} +16 -10
  59. package/dist/js/node/config/default.js +44 -64
  60. package/dist/js/node/config/index.js +10 -3
  61. package/dist/js/node/config/initial/createHtmlConfig.js +7 -3
  62. package/dist/js/node/config/initial/createOutputConfig.js +8 -6
  63. package/dist/js/node/config/initial/createSourceConfig.js +12 -4
  64. package/dist/js/node/config/initial/createToolsConfig.js +7 -3
  65. package/dist/js/node/config/initial/index.js +9 -3
  66. package/dist/js/node/config/initial/inits.js +26 -22
  67. package/dist/js/node/config/initial/transformNormalizedConfig.js +12 -4
  68. package/dist/js/node/defineConfig.js +25 -22
  69. package/dist/js/node/exports/server.js +7 -3
  70. package/dist/js/node/hooks.js +8 -3
  71. package/dist/js/node/index.js +56 -69
  72. package/dist/js/node/initialize/index.js +33 -32
  73. package/dist/js/node/locale/en.js +8 -4
  74. package/dist/js/node/locale/index.js +8 -3
  75. package/dist/js/node/locale/zh.js +8 -4
  76. package/dist/js/node/schema/Schema.js +7 -3
  77. package/dist/js/node/schema/index.js +11 -4
  78. package/dist/js/node/schema/legacy.js +5 -3
  79. package/dist/js/node/types/config/deploy.js +15 -0
  80. package/dist/js/node/types/config/dev.js +15 -0
  81. package/dist/js/node/types/config/experiments.js +15 -0
  82. package/dist/js/node/types/config/html.js +15 -0
  83. package/dist/js/node/types/config/index.js +3 -3
  84. package/dist/js/node/types/config/output.js +15 -0
  85. package/dist/js/node/types/config/performance.js +15 -0
  86. package/dist/js/node/types/config/security.js +15 -0
  87. package/dist/js/node/types/config/source.js +15 -0
  88. package/dist/js/node/types/config/tools.js +15 -0
  89. package/dist/js/node/types/hooks.js +15 -0
  90. package/dist/js/node/types/index.js +5 -5
  91. package/dist/js/node/types/legacyConfig/deploy.js +15 -0
  92. package/dist/js/node/types/legacyConfig/dev.js +15 -0
  93. package/dist/js/node/types/legacyConfig/index.js +15 -0
  94. package/dist/js/node/types/legacyConfig/output.js +15 -0
  95. package/dist/js/node/types/legacyConfig/source.js +15 -0
  96. package/dist/js/node/types/legacyConfig/tools.js +15 -0
  97. package/dist/js/node/utils/commands.js +14 -4
  98. package/dist/js/node/utils/config.js +35 -30
  99. package/dist/js/node/utils/createFileWatcher.js +15 -10
  100. package/dist/js/node/utils/createServer.js +35 -29
  101. package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
  102. package/dist/js/node/utils/getSpecifiedEntries.js +10 -6
  103. package/dist/js/node/utils/language.js +7 -3
  104. package/dist/js/node/utils/printInstructions.js +10 -6
  105. package/dist/js/node/utils/restart.js +11 -7
  106. package/dist/js/node/utils/routes.js +11 -7
  107. package/dist/js/node/utils/types.js +15 -0
  108. package/dist/js/treeshaking/analyze/constants.js +10 -1
  109. package/dist/js/treeshaking/analyze/generateCode.js +7 -11
  110. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +9 -6
  111. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +11 -3
  112. package/dist/js/treeshaking/analyze/index.js +7 -4
  113. package/dist/js/treeshaking/analyze/nestedRoutes.js +30 -23
  114. package/dist/js/treeshaking/analyze/templates.js +6 -1
  115. package/dist/js/treeshaking/analyze/utils.js +12 -3
  116. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +6 -2
  117. package/dist/js/treeshaking/builder/index.js +1 -7
  118. package/dist/js/treeshaking/commands/dev.js +19 -24
  119. package/dist/js/treeshaking/commands/index.js +1 -1
  120. package/dist/js/treeshaking/commands/{start.js → serve.js} +10 -3
  121. package/dist/js/treeshaking/config/default.js +53 -56
  122. package/dist/js/treeshaking/config/initial/createOutputConfig.js +1 -3
  123. package/dist/js/treeshaking/config/initial/createSourceConfig.js +5 -1
  124. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +5 -1
  125. package/dist/js/treeshaking/hooks.js +1 -0
  126. package/dist/js/treeshaking/index.js +5 -5
  127. package/dist/js/treeshaking/initialize/index.js +6 -5
  128. package/dist/js/treeshaking/locale/en.js +1 -1
  129. package/dist/js/treeshaking/locale/zh.js +1 -1
  130. package/dist/js/treeshaking/schema/index.js +7 -1
  131. package/dist/js/treeshaking/utils/commands.js +5 -1
  132. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
  133. package/dist/types/analyze/constants.d.ts +10 -1
  134. package/dist/types/analyze/utils.d.ts +2 -1
  135. package/dist/types/commands/index.d.ts +1 -1
  136. package/dist/types/commands/{start.d.ts → serve.d.ts} +0 -0
  137. package/dist/types/index.d.ts +1 -0
  138. package/dist/types/locale/en.d.ts +1 -1
  139. package/dist/types/locale/index.d.ts +2 -2
  140. package/dist/types/locale/zh.d.ts +1 -1
  141. package/dist/types/types/config/index.d.ts +3 -0
  142. package/dist/types/types/config/source.d.ts +1 -0
  143. package/dist/types/types/hooks.d.ts +3 -0
  144. package/dist/types/utils/commands.d.ts +2 -1
  145. package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
  146. package/package.json +25 -22
package/CHANGELOG.md CHANGED
@@ -1,5 +1,319 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.0.0-beta.6
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Minor Changes
10
+
11
+ - df7ee2d: feat: runtime user config types extends
12
+ feat: runtime 用户配置类型扩展
13
+ - edd1cfb1af: feat: modernjs Access builder compiler
14
+ feat: modernjs 接入 builder 构建
15
+ - b710adb843: feat: extract the data loader
16
+ feat: 提取 data loader
17
+ - bbe4c4ab64: feat: add @modern-js/plugin-swc
18
+
19
+ feat: 新增 @modern-js/plugin-swc 插件
20
+
21
+ - e4558a0bc4: feat:
22
+
23
+ 1. add `runBin` function
24
+ 2. config internal plugins constants in the app/module/doc tools
25
+ 3. add app/module/doc tools internal plugins
26
+
27
+ feat:
28
+
29
+ 1. 添加 `runBin` 函数
30
+ 2. 在 app/module/doc tools 里配置内部插件
31
+ 3. 增加 app/module/doc tools 使用的插件常量
32
+
33
+ - 543be9558e: feat: compile server loader and support handle loader request
34
+ feat: 编译 server loader 并支持处理 loader 的请求
35
+
36
+ ### Patch Changes
37
+
38
+ - c9f912ca4d: feat(app-tools): improve build logs of dev and build command
39
+
40
+ feat(app-tools): 优化 dev 和 build 过程中的日志展示
41
+
42
+ - 0078da4c80: fix: remove webpack oneof rule in new config, save in legacy mode.
43
+ fix: 在新模式下删除 webpack oneof 规则,兼容模式下保留
44
+ - 103973cde9: fix: builder tools.webpackChain config args not match the Modernjs tools.webpackChain
45
+ fix: builder tools.webpackChain 配置传参无法匹配 Modernjs tools.webpackChain
46
+ - 7879e8f711: refactor: remove enableModernMode config
47
+
48
+ refactor: 不再支持 enableModernMode 配置项
49
+
50
+ - 0be536decc: fix(app-tools): html.template config not work
51
+
52
+ fix(app-tools): 修复 html.template 配置项不生效的问题
53
+
54
+ - d4e8e6fb90: fix: modernjs dev server can't start normaly
55
+ fix: modernjs dev 服务端不能正常启动
56
+ - 0b2d1ef02b: fix: repeat register `babel-plugin-lodash`
57
+ fix: 重复注册 `babel-plugin-lodash`
58
+ - 217c43a057: fix: should generate path correctly for data loader
59
+ fix: 应该生成正确的路径给 data loader
60
+ - 82cef85ed7: fix: specify builder compiler framework
61
+ fix: 指明 builder 构建时框架
62
+ - 1eeb052: fix: support set entry with file-system based router
63
+ fix: 约定式路由支持设置 entry
64
+ - e011faf484: fix: the esbuild watcher should be stoped when cli restart
65
+ fix: 当 cli 重启时,esbuild watcher 应该停止监听文件
66
+ - 3e57f2bd58: feat: add document feature with plugin
67
+
68
+ feat: 增加 document 功能插件
69
+
70
+ - 3941653375: fix: add esbuild to dependencies
71
+ fix: 将 esbuild 添加到依赖中
72
+ - 33aeb51544: feat: add manifest field for router config
73
+ feat: 为 router 配置添加 manifest 字段
74
+ - 85edee888c: feat(app-tools): support tools.htmlPlugin config
75
+
76
+ feat(app-tools): 支持 tools.htmlPlugin 配置项
77
+
78
+ - 2e6031955e: fix: some optimizations for router and loader
79
+ fix: 一些 router 和 loader 的优化
80
+ q
81
+ - 752480d: fix(app-tools): failed to copy public assets
82
+
83
+ fix(app-tools): 修复拷贝 public 下的静态文件失败的问题
84
+
85
+ - a55b9656c4: fix: rename "loader routes" file to avoid influence ssr
86
+ fix: 重命名 loader routes 避免影响 ssr
87
+ - 5402fdb0ca: feat(Builder): add output.disableTsChecker config
88
+
89
+ feat(Builder): 新增 output.disableTsChecker 配置项
90
+
91
+ - dc8eeb9cbb: fix: clear distDirectory in prepare hook & inject data loader plugin to server
92
+ fix: 在 prepare hook 中清理 dist 目录,并且向 server 中注入 data loader plugin
93
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
94
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
95
+ - 5b9049f2e9: feat: inject async js chunk when streaming ssr
96
+ feat: streaming ssr 时, 注入 async 类型的 js chunk
97
+ - d4a456659b: chore: rename plugin-jarvis to plugin-lint
98
+
99
+ chore: 重命名 plugin-jarvis 为 plugin-lint
100
+
101
+ - 6bda14ed71: feat: refactor router with react-router@6.4
102
+
103
+ feat: 使用 react-router@6.4 重构路由模块
104
+
105
+ - d36c6ee126: fix(app-tools): failed to run inspect command
106
+
107
+ fix(app-tools): 修复运行 inspect 命令失败的问题
108
+
109
+ - 92004d1906: feat: support load chunks parallelly
110
+ feat: 支持并行加载 chunks
111
+ - b8bbe036c7: feat: change type logic
112
+ feat: 修改类型相关的逻辑
113
+ - 40ed5874c6: feat: inject css chunk into html for streaming ssr
114
+ feat: streaming ssr 返回的 html 注入 css chunk
115
+ - af4422d67f: feat(builder): complete utils of tools.webpack
116
+
117
+ feat(builder): 补全 tools.webpack 提供的 utils 方法
118
+
119
+ - 4293748b9d: fix: router config maybe not defined
120
+ fix: router 配置可能不存在
121
+ - 87c1ff86b9: feat(app-tools): attach builder instance to appContext
122
+
123
+ feat(app-tools): 将 builder 实例挂载到 appContext 上
124
+
125
+ - c258e34202: fix: add builder hooks `beforeBuild` params
126
+ fix: 新增 builder hooks `beforeBuild` 的参数
127
+ - 3b3d709ee2: fix(app-tools): cli --analyze option not work
128
+
129
+ fix(app-tools): 修复 --analyze 命令行参数不生效的问题
130
+
131
+ - 8b8e1bb571: feat: support nested routes
132
+ feat: 支持嵌套路由
133
+ - f5178e19e0: fix(app-tools): dev.startUrl not work
134
+
135
+ fix(app-tools): 修复 dev.startUrl 不生效的问题
136
+
137
+ - 88eb147ae1: fix(app-tools): builder's onBeforeCreateDevServer hook not work
138
+
139
+ fix(app-tools): 修复 builder 的 onBeforeCreateDevServer hook 无法触发的问题
140
+
141
+ - 8c32dc4237: fix: builder should not be checked when apiOnly is true
142
+ fix: 当 apiOnly 为 true 时,builder 不应该被校验
143
+ - a2c8cc3eb5: fix: change tools define userconfig type
144
+ fix: 修改工程定义的 UserConfig 类型
145
+ - b7a96c35fc: fix(app-tools): loose CLI init options after restart
146
+
147
+ fix(app-tools): 修复重启 CLI 后丢失 init options 的问题
148
+
149
+ - df62445d1b: fix: fix generateCode logic for windows
150
+ fix: 兼容 generateCode 的逻辑在 windows 平台
151
+ - 7de97ae24f: fix: `deploy` command has't load `builder` instance
152
+ fix: `deploy` 命令没有加载 builder 实例
153
+ - cce8ecee2d: fix: handle some `TODO` & `FIXME`, change some tests
154
+ fix: 处理一些 `TODO` 和 `FIXME`, 修改了一些 tests
155
+ - c3b7de4bfb: fix(app-tools): dev.assetPrefix not work
156
+
157
+ fix(app-tools): 修复 dev.assetPrefix 配置项不生效的问题
158
+
159
+ - 16a3441eea: fix(app-tools): remove duplicated port log
160
+
161
+ fix(app-tools): 修复 port 重复的日志输出两遍的问题
162
+
163
+ - 92004d1906: fix: use loadable lazy instead of loadable
164
+ fix: 使用 loadable lazy 组件替代 loadable
165
+ - ebf899f: feat(app-tools): support configure builder plugins
166
+
167
+ feat(app-tools): 支持配置 builder 插件
168
+
169
+ - c677befc22: fix(app-tools): compat legacy resolve behavior
170
+
171
+ fix(app-tools): 兼容旧版本 node_modules 解析逻辑
172
+
173
+ - f1b8e8a3da: fix(app-tools): failed to copy HTML from config/public dir
174
+
175
+ fix(app-tools): 修复从 config/public 拷贝 HTML 文件时可能出现编译错误的问题
176
+
177
+ - 3f7cde5caa: fix: builder plugin setup can't get config
178
+ fix: builder 插件在 setup 阶段无法拿到 config
179
+ - 99213e4bae: fix: process does't exit when exec command
180
+ fix: 修复执行命令时进程未退出的问题
181
+ - b16fd964da: fix: `modern-js/app-tools` pass error config to builder.
182
+ fix: `modern-js/app-tools` 传递错误的 config 给 builder.
183
+ - 16ef1a7c9b: fix(app-tools): should not increase port when restart
184
+
185
+ fix(app-tools): 修复 restart 时端口号会增加的问题
186
+
187
+ - 7eefedd7ca: fix: add html-webpack-plugin `__internal__` options, for bottom template
188
+ fix: 为了 bottom template, 增加 `html-webpack-plugin` `__internal__` 配置项,
189
+ - 14b712da84: fix: use consistent alias type and default value across packages
190
+
191
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
192
+
193
+ - Updated dependencies [c9f912ca4d]
194
+ - Updated dependencies [95be7cc49c]
195
+ - Updated dependencies [e439457a51]
196
+ - Updated dependencies [4d1545f8c0]
197
+ - Updated dependencies [4a7693fe6b]
198
+ - Updated dependencies [2bc090c089]
199
+ - Updated dependencies [ba5325731c]
200
+ - Updated dependencies [f0abb2e82f]
201
+ - Updated dependencies [f96a725211]
202
+ - Updated dependencies [7879e8f711]
203
+ - Updated dependencies [828f42f9ce]
204
+ - Updated dependencies [060abd4553]
205
+ - Updated dependencies [309cd71a1c]
206
+ - Updated dependencies [c7456864a8]
207
+ - Updated dependencies [c9e800d39a]
208
+ - Updated dependencies [d4e8e6fb90]
209
+ - Updated dependencies [0ff846fb56]
210
+ - Updated dependencies [3cf9633195]
211
+ - Updated dependencies [6604f1b8b3]
212
+ - Updated dependencies [57077b2c64]
213
+ - Updated dependencies [217c43a057]
214
+ - Updated dependencies [d032d49e09]
215
+ - Updated dependencies [6aca875011]
216
+ - Updated dependencies [2ff6167be0]
217
+ - Updated dependencies [287f298990]
218
+ - Updated dependencies [15bf09d9c8]
219
+ - Updated dependencies [423188db70]
220
+ - Updated dependencies [fd2d652c03]
221
+ - Updated dependencies [0c2d8dae31]
222
+ - Updated dependencies [2edad29dd7]
223
+ - Updated dependencies [85edee888c]
224
+ - Updated dependencies [2e6031955e]
225
+ - Updated dependencies [dc52ee8]
226
+ - Updated dependencies [a2509bfbdb]
227
+ - Updated dependencies [309f08bdf4]
228
+ - Updated dependencies [3998875791]
229
+ - Updated dependencies [752480d]
230
+ - Updated dependencies [b827e35aba]
231
+ - Updated dependencies [ab3924a70e]
232
+ - Updated dependencies [3998875791]
233
+ - Updated dependencies [ba86b8b711]
234
+ - Updated dependencies [61f21d1e77]
235
+ - Updated dependencies [7b7d12cf8f]
236
+ - Updated dependencies [5402fdb0ca]
237
+ - Updated dependencies [7efeed4]
238
+ - Updated dependencies [2ae58176fe]
239
+ - Updated dependencies [92f0eade39]
240
+ - Updated dependencies [edd1cfb1af]
241
+ - Updated dependencies [5d67c26cdb]
242
+ - Updated dependencies [cc971eabfc]
243
+ - Updated dependencies [5b9049f2e9]
244
+ - Updated dependencies [83ac356e15]
245
+ - Updated dependencies [a3af050486]
246
+ - Updated dependencies [d4a456659b]
247
+ - Updated dependencies [18360a38d7]
248
+ - Updated dependencies [6bda14ed71]
249
+ - Updated dependencies [0b314e6946]
250
+ - Updated dependencies [92004d1906]
251
+ - Updated dependencies [b8bbe036c7]
252
+ - Updated dependencies [5911154129]
253
+ - Updated dependencies [40ed5874c6]
254
+ - Updated dependencies [af4422d67f]
255
+ - Updated dependencies [705adc1dae]
256
+ - Updated dependencies [f680410886]
257
+ - Updated dependencies [87c1ff86b9]
258
+ - Updated dependencies [d5a31df781]
259
+ - Updated dependencies [dda38c9c3e]
260
+ - Updated dependencies [4f277fe288]
261
+ - Updated dependencies [102d32e4ba]
262
+ - Updated dependencies [c258e34202]
263
+ - Updated dependencies [812913ccdd]
264
+ - Updated dependencies [7248342e4d]
265
+ - Updated dependencies [568eab1e42]
266
+ - Updated dependencies [8b8e1bb571]
267
+ - Updated dependencies [3bbea92b2a]
268
+ - Updated dependencies [ae71096d45]
269
+ - Updated dependencies [73cd29dd9f]
270
+ - Updated dependencies [cd5cdd9]
271
+ - Updated dependencies [e06b9a2ec6]
272
+ - Updated dependencies [b710adb843]
273
+ - Updated dependencies [b7a96c35fc]
274
+ - Updated dependencies [a23010138d]
275
+ - Updated dependencies [75d1b2657c]
276
+ - Updated dependencies [cce8ecee2d]
277
+ - Updated dependencies [18aaf42249]
278
+ - Updated dependencies [f179749375]
279
+ - Updated dependencies [b8494ef33b]
280
+ - Updated dependencies [3fae2d03b3]
281
+ - Updated dependencies [ea7cf06257]
282
+ - Updated dependencies [8a6d45f105]
283
+ - Updated dependencies [143d8dd616]
284
+ - Updated dependencies [bbe4c4ab64]
285
+ - Updated dependencies [ebbeed1ece]
286
+ - Updated dependencies [6354cfa3ae]
287
+ - Updated dependencies [90e2879520]
288
+ - Updated dependencies [e4558a0bc4]
289
+ - Updated dependencies [df41d71ade]
290
+ - Updated dependencies [f727e5c6cc]
291
+ - Updated dependencies [5e3cecd523]
292
+ - Updated dependencies [92de772]
293
+ - Updated dependencies [abf3421a75]
294
+ - Updated dependencies [da2d1fc3c2]
295
+ - Updated dependencies [543be9558e]
296
+ - Updated dependencies [fd1d9fd3d3]
297
+ - Updated dependencies [14b712da84]
298
+ - Updated dependencies [a24f1c9058]
299
+ - @modern-js/builder-webpack-provider@2.0.0-beta.6
300
+ - @modern-js/builder-shared@2.0.0-beta.6
301
+ - @modern-js/prod-server@2.0.0-beta.6
302
+ - @modern-js/server@2.0.0-beta.6
303
+ - @modern-js/types@2.0.0-beta.6
304
+ - @modern-js/utils@2.0.0-beta.6
305
+ - @modern-js/core@2.0.0-beta.6
306
+ - @modern-js/builder-plugin-esbuild@2.0.0-beta.6
307
+ - @modern-js/plugin-data-loader@2.0.0-beta.6
308
+ - @modern-js/builder-plugin-node-polyfill@2.0.0-beta.6
309
+ - @modern-js/node-bundle-require@2.0.0-beta.6
310
+ - @modern-js/plugin-lint@2.0.0-beta.6
311
+ - @modern-js/plugin@2.0.0-beta.6
312
+ - @modern-js/builder@2.0.0-beta.6
313
+ - @modern-js/plugin-i18n@2.0.0-beta.6
314
+ - @modern-js/new-action@2.0.0-beta.6
315
+ - @modern-js/upgrade@2.0.0-beta.6
316
+
3
317
  ## 2.0.0-beta.4
4
318
 
5
319
  ### Major Changes
package/bin/modern.js CHANGED
@@ -2,12 +2,14 @@
2
2
  const {
3
3
  INTERNAL_APP_TOOLS_PLUGINS,
4
4
  INTERNAL_SERVER_PLUGINS,
5
+ INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
5
6
  } = require('@modern-js/utils');
6
7
 
7
8
  require('@modern-js/core/runBin').run({
8
9
  internalPlugins: {
9
10
  cli: INTERNAL_APP_TOOLS_PLUGINS,
10
11
  server: INTERNAL_SERVER_PLUGINS,
12
+ autoLoad: INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
11
13
  },
12
14
  toolsType: 'app-tools',
13
15
  });
@@ -16,6 +16,15 @@ const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/
16
16
  const HTML_PARTIALS_FOLDER = "html";
17
17
  const HTML_PARTIALS_EXTENSIONS = [".htm", ".html", ".ejs"];
18
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
+ };
19
28
  export {
20
29
  APP_FILE_NAME,
21
30
  ENTRY_BOOTSTRAP_FILE_NAME,
@@ -32,6 +41,7 @@ export {
32
41
  INDEX_FILE_NAME,
33
42
  JS_EXTENSIONS,
34
43
  LOADER_EXPORT_NAME,
44
+ NESTED_ROUTE,
35
45
  NESTED_ROUTES_DIR,
36
46
  PAGES_DIR_NAME,
37
47
  TEMP_LOADERS_DIR
@@ -28,7 +28,7 @@ import {
28
28
  import {
29
29
  useResolvedConfigContext
30
30
  } from "@modern-js/core";
31
- import { getCommand } from "../utils/commands";
31
+ import { isDevCommand } from "../utils/commands";
32
32
  import * as templates from "./templates";
33
33
  import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
34
34
  import {
@@ -93,13 +93,12 @@ ${initialize || ""}`
93
93
  ).join("\n");
94
94
  };
95
95
  const buildLoader = (entry, outfile) => __async(void 0, null, function* () {
96
- const command = getCommand();
97
96
  yield loaderBuilder.build({
98
97
  format: "esm",
99
98
  platform: "browser",
100
99
  target: "esnext",
101
100
  loader,
102
- watch: command === "dev" && {},
101
+ watch: isDevCommand() && {},
103
102
  bundle: true,
104
103
  logLevel: "error",
105
104
  entryPoints: [entry],
@@ -124,13 +123,12 @@ const buildLoader = (entry, outfile) => __async(void 0, null, function* () {
124
123
  });
125
124
  });
126
125
  const buildServerLoader = (entry, outfile) => __async(void 0, null, function* () {
127
- const command = getCommand();
128
126
  yield serverLoaderBuilder.build({
129
127
  format: "cjs",
130
128
  platform: "node",
131
129
  target: "esnext",
132
130
  loader,
133
- watch: command === "dev" && {},
131
+ watch: isDevCommand() && {},
134
132
  bundle: true,
135
133
  logLevel: "error",
136
134
  entryPoints: [entry],
@@ -138,7 +136,7 @@ const buildServerLoader = (entry, outfile) => __async(void 0, null, function* ()
138
136
  });
139
137
  });
140
138
  const generateCode = (appContext, config, entrypoints, api) => __async(void 0, null, function* () {
141
- var _a, _b;
139
+ var _a, _b, _c;
142
140
  const {
143
141
  internalDirectory,
144
142
  distDirectory,
@@ -148,9 +146,9 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
148
146
  packageName
149
147
  } = appContext;
150
148
  const hookRunners = api.useHookRunners();
151
- const islegacy = Boolean((_b = (_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.router) == null ? void 0 : _b.legacy);
149
+ const isV5 = typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
152
150
  const { mountId } = config.html;
153
- const getRoutes = islegacy ? getClientRoutesLegacy : getClientRoutes;
151
+ const getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
154
152
  yield Promise.all(entrypoints.map(generateEntryCode));
155
153
  function generateEntryCode(entrypoint) {
156
154
  return __async(this, null, function* () {
@@ -169,7 +167,7 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
169
167
  });
170
168
  }
171
169
  if (entrypoint.nestedRoutesEntry) {
172
- if (!islegacy) {
170
+ if (!isV5) {
173
171
  nestedRoute = yield walk(
174
172
  entrypoint.nestedRoutesEntry,
175
173
  entrypoint.nestedRoutesEntry,
@@ -171,20 +171,23 @@ const getClientRoutes = ({
171
171
  internalDirectory,
172
172
  internalDirAlias
173
173
  }) => {
174
- const { entry, entryName } = entrypoint;
175
- if (!fs.existsSync(entry)) {
174
+ const { entryName, pageRoutesEntry } = entrypoint;
175
+ if (!pageRoutesEntry) {
176
+ return [];
177
+ }
178
+ if (!fs.existsSync(pageRoutesEntry)) {
176
179
  throw new Error(
177
- `generate file system routes error, ${entry} directory not found.`
180
+ `generate file system routes error, ${pageRoutesEntry} directory not found.`
178
181
  );
179
182
  }
180
- if (!(fs.existsSync(entry) && fs.statSync(entry).isDirectory())) {
183
+ if (!(fs.existsSync(pageRoutesEntry) && fs.statSync(pageRoutesEntry).isDirectory())) {
181
184
  throw new Error(
182
- `generate file system routes error, ${entry} should be directory.`
185
+ `generate file system routes error, ${pageRoutesEntry} should be directory.`
183
186
  );
184
187
  }
185
188
  let routes = [];
186
189
  recursiveReadDir({
187
- dir: entry,
190
+ dir: pageRoutesEntry,
188
191
  routes,
189
192
  basePath: "/",
190
193
  srcDirectory,
@@ -63,9 +63,11 @@ const scanDir = (dirs) => dirs.map((dir) => {
63
63
  };
64
64
  if (isHasPages) {
65
65
  entrypoint.entry = path.join(dir, PAGES_DIR_NAME);
66
+ entrypoint.pageRoutesEntry = entrypoint.entry;
66
67
  }
67
68
  if (isHasNestedRoutes) {
68
- entrypoint.nestedRoutesEntry = path.join(dir, NESTED_ROUTES_DIR);
69
+ entrypoint.entry = path.join(dir, NESTED_ROUTES_DIR);
70
+ entrypoint.nestedRoutesEntry = entrypoint.entry;
69
71
  }
70
72
  return entrypoint;
71
73
  }
@@ -79,14 +81,20 @@ const scanDir = (dirs) => dirs.map((dir) => {
79
81
  const getFileSystemEntry = (appContext, config) => {
80
82
  const { appDirectory } = appContext;
81
83
  const {
82
- source: { entriesDir }
84
+ source: { entriesDir, disableEntryDirs }
83
85
  } = config;
86
+ let disabledDirs = [];
87
+ if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
88
+ disabledDirs = disableEntryDirs == null ? void 0 : disableEntryDirs.map(
89
+ (dir) => ensureAbsolutePath(appDirectory, dir)
90
+ );
91
+ }
84
92
  const src = ensureAbsolutePath(appDirectory, entriesDir || "");
85
93
  if (fs.existsSync(src)) {
86
94
  if (fs.statSync(src).isDirectory()) {
87
95
  return scanDir(
88
96
  isBundleEntry(src) ? [src] : fs.readdirSync(src).map((file) => path.join(src, file)).filter(
89
- (file) => fs.statSync(file).isDirectory() && isBundleEntry(file)
97
+ (file) => fs.statSync(file).isDirectory() && isBundleEntry(file) && !disabledDirs.includes(file)
90
98
  )
91
99
  );
92
100
  } else {
@@ -46,13 +46,14 @@ import { generateRoutes } from "../utils/routes";
46
46
  import { emitResolvedConfig } from "../utils/config";
47
47
  import { getCommand } from "../utils/commands";
48
48
  import { initialNormalizedConfig } from "../config";
49
- import { isRouteComponentFile } from "./utils";
49
+ import { isNestedRouteComponent, isPageComponentFile } from "./utils";
50
50
  import { loaderBuilder, serverLoaderBuilder } from "./Builder";
51
51
  const debug = createDebugger("plugin-analyze");
52
52
  var analyze_default = () => ({
53
53
  name: "@modern-js/plugin-analyze",
54
54
  setup: (api) => {
55
55
  let pagesDir = [];
56
+ let nestedRouteEntries = [];
56
57
  let originEntrypoints = [];
57
58
  return {
58
59
  prepare() {
@@ -109,7 +110,7 @@ var analyze_default = () => ({
109
110
  serverRoutes: routes
110
111
  });
111
112
  api.setAppContext(appContext);
112
- const nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
113
+ nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
113
114
  pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
114
115
  originEntrypoints = cloneDeep(entrypoints);
115
116
  yield generateCode(appContext, resolvedConfig, entrypoints, api);
@@ -129,7 +130,7 @@ var analyze_default = () => ({
129
130
  });
130
131
  api.setAppContext(appContext);
131
132
  const command = getCommand();
132
- const buildCommands = ["dev", "build", "inspect", "deploy"];
133
+ const buildCommands = ["dev", "start", "build", "inspect", "deploy"];
133
134
  if (buildCommands.includes(command)) {
134
135
  let _b;
135
136
  const normalizedConfig = api.useResolvedConfigContext();
@@ -185,6 +186,7 @@ var analyze_default = () => ({
185
186
  }
186
187
  }
187
188
  });
189
+ builder.addPlugins(resolvedConfig.builderPlugins);
188
190
  appContext = __spreadProps(__spreadValues({}, appContext), {
189
191
  builder
190
192
  });
@@ -215,8 +217,8 @@ var analyze_default = () => ({
215
217
  const { filename, eventType } = e;
216
218
  const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
217
219
  const absoluteFilePath = path.resolve(appDirectory, filename);
218
- const isRouteComponent = isPageFile(absoluteFilePath) && isRouteComponentFile(absoluteFilePath);
219
- if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
220
+ const isRouteComponent = isPageFile(absoluteFilePath) && isPageComponentFile(absoluteFilePath);
221
+ if (isRouteComponent && (eventType === "add" || eventType === "unlink") || isNestedRouteComponent(nestedRouteEntries, absoluteFilePath) && eventType === "change") {
220
222
  const resolvedConfig = api.useResolvedConfigContext();
221
223
  const { generateCode } = yield import("./generateCode");
222
224
  const entrypoints = cloneDeep(originEntrypoints);
@@ -39,20 +39,9 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
  import * as path from "path";
41
41
  import { fs, getRouteId } from "@modern-js/utils";
42
- import { JS_EXTENSIONS } from "./constants";
42
+ import { JS_EXTENSIONS, NESTED_ROUTE } from "./constants";
43
43
  import { hasLoader, replaceWithAlias } from "./utils";
44
- const LAYOUT_FILE = "layout";
45
- const PAGE_FILE = "page";
46
- const LOADING_FILE = "loading";
47
- const ERROR_FILE = "error";
48
- const LOADER_FILE = "loader";
49
- const conventionNames = [
50
- LAYOUT_FILE,
51
- PAGE_FILE,
52
- LOADING_FILE,
53
- ERROR_FILE,
54
- LOADER_FILE
55
- ];
44
+ const conventionNames = Object.values(NESTED_ROUTE);
56
45
  const getLoaderPath = (filename) => __async(void 0, null, function* () {
57
46
  if (yield hasLoader(filename)) {
58
47
  return filename;
@@ -105,6 +94,8 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
105
94
  children: [],
106
95
  isRoot
107
96
  };
97
+ let pageLoaderFile = "";
98
+ let pageRoute = null;
108
99
  const items = yield fs.readdir(dirname);
109
100
  for (const item of items) {
110
101
  const itemPath = path.join(dirname, item);
@@ -120,12 +111,23 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
120
111
  if (extname && (!JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt))) {
121
112
  continue;
122
113
  }
123
- if (itemWithoutExt === LAYOUT_FILE) {
114
+ if (itemWithoutExt === NESTED_ROUTE.LAYOUT_LOADER_FILE) {
115
+ if (!route.loader) {
116
+ route.loader = itemPath;
117
+ }
118
+ }
119
+ if (itemWithoutExt === NESTED_ROUTE.LAYOUT_FILE) {
124
120
  route._component = replaceWithAlias(alias.basename, itemPath, alias.name);
125
- route.loader = yield getLoaderPath(itemPath);
121
+ const loaderPath = yield getLoaderPath(itemPath);
122
+ if (loaderPath) {
123
+ route.loader = loaderPath;
124
+ }
126
125
  }
127
- if (itemWithoutExt === PAGE_FILE) {
128
- const childRoute = createIndexRoute(
126
+ if (itemWithoutExt === NESTED_ROUTE.PAGE_LOADER_FILE) {
127
+ pageLoaderFile = itemPath;
128
+ }
129
+ if (itemWithoutExt === NESTED_ROUTE.PAGE_FILE) {
130
+ pageRoute = createIndexRoute(
129
131
  {
130
132
  _component: replaceWithAlias(alias.basename, itemPath, alias.name)
131
133
  },
@@ -133,20 +135,25 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
133
135
  itemPath,
134
136
  entryName
135
137
  );
136
- childRoute.loader = yield getLoaderPath(itemPath);
137
- (_b = route.children) == null ? void 0 : _b.push(childRoute);
138
+ const loaderPath = yield getLoaderPath(itemPath);
139
+ if (loaderPath) {
140
+ pageRoute.loader = loaderPath;
141
+ } else if (pageLoaderFile) {
142
+ pageRoute.loader = pageLoaderFile;
143
+ }
144
+ (_b = route.children) == null ? void 0 : _b.push(pageRoute);
138
145
  }
139
- if (itemWithoutExt === LOADING_FILE) {
146
+ if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
140
147
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
141
148
  }
142
- if (itemWithoutExt === ERROR_FILE) {
149
+ if (itemWithoutExt === NESTED_ROUTE.ERROR_FILE) {
143
150
  route.error = replaceWithAlias(alias.basename, itemPath, alias.name);
144
151
  }
145
152
  }
146
153
  const finalRoute = createRoute(
147
154
  route,
148
155
  rootDir,
149
- path.join(dirname, `${LAYOUT_FILE}.ts`),
156
+ path.join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`),
150
157
  entryName
151
158
  );
152
159
  if (isPathlessLayout) {
@@ -315,9 +315,16 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
315
315
  TEMP_LOADERS_DIR,
316
316
  `${name}.js`
317
317
  );
318
- const code = `
318
+ let code = "";
319
+ if (loader.includes(".loader.")) {
320
+ code = `
321
+ export { default as ${name} } from '${slash(loader)}'
322
+ `;
323
+ } else {
324
+ code = `
319
325
  export { loader as ${name} } from '${slash(loader)}'
320
326
  `;
327
+ }
321
328
  yield fs.ensureFile(filename);
322
329
  yield fs.writeFile(filename, code);
323
330
  }))