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

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