@modern-js/app-tools 2.58.1 → 2.58.2

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 (283) hide show
  1. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
  2. package/dist/cjs/builder/builder-webpack/index.js +1 -1
  3. package/dist/cjs/builder/generator/index.js +2 -2
  4. package/dist/cjs/builder/index.js +2 -2
  5. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -4
  6. package/dist/cjs/commands/build.js +19 -0
  7. package/dist/cjs/commands/dev.js +9 -0
  8. package/dist/cjs/commands/index.js +8 -8
  9. package/dist/cjs/config/initialize/inits.js +4 -4
  10. package/dist/cjs/esm/esbuild-loader.mjs +20 -0
  11. package/dist/cjs/esm/register-esm.mjs +67 -0
  12. package/dist/cjs/esm/ts-node-loader.mjs +21 -0
  13. package/dist/cjs/esm/utils.mjs +43 -0
  14. package/dist/cjs/index.js +1 -1
  15. package/dist/cjs/plugins/analyze/index.js +3 -3
  16. package/dist/cjs/plugins/deploy/dependencies/index.js +1 -0
  17. package/dist/cjs/plugins/deploy/dependencies/utils.js +11 -0
  18. package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
  19. package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  20. package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
  21. package/dist/cjs/plugins/deploy/platforms/netlify.js +14 -5
  22. package/dist/cjs/plugins/deploy/platforms/node.js +13 -4
  23. package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
  24. package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  25. package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
  26. package/dist/cjs/plugins/deploy/platforms/vercel.js +14 -5
  27. package/dist/cjs/utils/config.js +1 -1
  28. package/dist/cjs/utils/loadPlugins.js +1 -1
  29. package/dist/cjs/utils/register.js +50 -23
  30. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
  31. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  32. package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
  33. package/dist/types/builder/builder-webpack/index.d.ts +1 -1
  34. package/dist/types/builder/generator/index.d.ts +2 -2
  35. package/dist/types/builder/index.d.ts +1 -1
  36. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  37. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  38. package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
  39. package/dist/types/commands/build.d.ts +1 -1
  40. package/dist/types/commands/dev.d.ts +3 -3
  41. package/dist/types/commands/index.d.ts +3 -3
  42. package/dist/types/config/default.d.ts +1 -1
  43. package/dist/types/config/initialize/inits.d.ts +1 -1
  44. package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
  45. package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
  46. package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
  47. package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
  48. package/dist/types/esm/esbuild-loader.d.mts +6 -0
  49. package/dist/types/esm/register-esm.d.mts +5 -0
  50. package/dist/types/esm/ts-node-loader.d.mts +6 -0
  51. package/dist/types/esm/utils.d.mts +6 -0
  52. package/dist/types/exports/server.d.ts +1 -1
  53. package/dist/types/hooks.d.ts +1 -1
  54. package/dist/types/index.d.ts +2 -2
  55. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  56. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  57. package/dist/types/plugins/analyze/index.d.ts +1 -1
  58. package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -1
  59. package/dist/types/plugins/deploy/index.d.ts +2 -2
  60. package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
  61. package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
  62. package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
  63. package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
  64. package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
  65. package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
  66. package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
  67. package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
  68. package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
  69. package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
  70. package/dist/types/plugins/deploy/utils.d.ts +1 -1
  71. package/dist/types/plugins/serverBuild.d.ts +1 -1
  72. package/dist/types/types/hooks.d.ts +1 -1
  73. package/dist/types/types/index.d.ts +1 -1
  74. package/dist/types/utils/createServer.d.ts +1 -1
  75. package/dist/types/utils/generateWatchFiles.d.ts +1 -1
  76. package/dist/types/utils/getSelectedEntries.d.ts +1 -1
  77. package/dist/types/utils/loadPlugins.d.ts +3 -3
  78. package/dist/types/utils/register.d.ts +2 -2
  79. package/dist/types/utils/restart.d.ts +2 -2
  80. package/lib/types.d.ts +15 -0
  81. package/package.json +20 -20
  82. package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
  83. package/dist/esm/builder/builder-rspack/index.js +0 -34
  84. package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
  85. package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
  86. package/dist/esm/builder/builder-webpack/index.js +0 -52
  87. package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
  88. package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
  89. package/dist/esm/builder/generator/index.js +0 -94
  90. package/dist/esm/builder/index.js +0 -45
  91. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
  92. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
  93. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
  94. package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
  95. package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
  96. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
  97. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
  98. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -317
  99. package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
  100. package/dist/esm/builder/shared/createCopyInfo.js +0 -14
  101. package/dist/esm/builder/shared/index.js +0 -3
  102. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
  103. package/dist/esm/builder/shared/types.js +0 -0
  104. package/dist/esm/commands/build.js +0 -117
  105. package/dist/esm/commands/deploy.js +0 -48
  106. package/dist/esm/commands/dev.js +0 -169
  107. package/dist/esm/commands/index.js +0 -411
  108. package/dist/esm/commands/inspect.js +0 -28
  109. package/dist/esm/commands/serve.js +0 -93
  110. package/dist/esm/config/default.js +0 -190
  111. package/dist/esm/config/index.js +0 -3
  112. package/dist/esm/config/initialize/index.js +0 -9
  113. package/dist/esm/config/initialize/inits.js +0 -85
  114. package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
  115. package/dist/esm/config/legacy/createOutputConfig.js +0 -45
  116. package/dist/esm/config/legacy/createSourceConfig.js +0 -46
  117. package/dist/esm/config/legacy/createToolsConfig.js +0 -28
  118. package/dist/esm/config/legacy/index.js +0 -43
  119. package/dist/esm/defineConfig.js +0 -16
  120. package/dist/esm/exports/server.js +0 -4
  121. package/dist/esm/hooks.js +0 -34
  122. package/dist/esm/index.js +0 -239
  123. package/dist/esm/locale/en.js +0 -43
  124. package/dist/esm/locale/index.js +0 -12
  125. package/dist/esm/locale/zh.js +0 -43
  126. package/dist/esm/plugins/analyze/constants.js +0 -14
  127. package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
  128. package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
  129. package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
  130. package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
  131. package/dist/esm/plugins/analyze/index.js +0 -380
  132. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
  133. package/dist/esm/plugins/analyze/templates.js +0 -6
  134. package/dist/esm/plugins/analyze/utils.js +0 -101
  135. package/dist/esm/plugins/deploy/dependencies/index.js +0 -614
  136. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -394
  137. package/dist/esm/plugins/deploy/exports.js +0 -4
  138. package/dist/esm/plugins/deploy/index.js +0 -135
  139. package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
  140. package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
  141. package/dist/esm/plugins/deploy/platforms/node.js +0 -133
  142. package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
  143. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  144. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
  145. package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
  146. package/dist/esm/plugins/deploy/utils.js +0 -47
  147. package/dist/esm/plugins/initialize/index.js +0 -119
  148. package/dist/esm/plugins/serverBuild.js +0 -87
  149. package/dist/esm/types/config/deploy.js +0 -0
  150. package/dist/esm/types/config/dev.js +0 -0
  151. package/dist/esm/types/config/experiments.js +0 -0
  152. package/dist/esm/types/config/html.js +0 -0
  153. package/dist/esm/types/config/index.js +0 -1
  154. package/dist/esm/types/config/output.js +0 -0
  155. package/dist/esm/types/config/performance.js +0 -0
  156. package/dist/esm/types/config/security.js +0 -0
  157. package/dist/esm/types/config/source.js +0 -0
  158. package/dist/esm/types/config/testing.js +0 -0
  159. package/dist/esm/types/config/tools.js +0 -0
  160. package/dist/esm/types/hooks.js +0 -0
  161. package/dist/esm/types/index.js +0 -3
  162. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  163. package/dist/esm/types/legacyConfig/dev.js +0 -0
  164. package/dist/esm/types/legacyConfig/index.js +0 -0
  165. package/dist/esm/types/legacyConfig/output.js +0 -0
  166. package/dist/esm/types/legacyConfig/source.js +0 -0
  167. package/dist/esm/types/legacyConfig/testing.js +0 -0
  168. package/dist/esm/types/legacyConfig/tools.js +0 -0
  169. package/dist/esm/types/utils.js +0 -0
  170. package/dist/esm/utils/config.js +0 -122
  171. package/dist/esm/utils/createServer.js +0 -58
  172. package/dist/esm/utils/env.js +0 -16
  173. package/dist/esm/utils/generateWatchFiles.js +0 -71
  174. package/dist/esm/utils/getSelectedEntries.js +0 -67
  175. package/dist/esm/utils/loadPlugins.js +0 -69
  176. package/dist/esm/utils/printInstructions.js +0 -32
  177. package/dist/esm/utils/register.js +0 -129
  178. package/dist/esm/utils/restart.js +0 -67
  179. package/dist/esm/utils/routes.js +0 -42
  180. package/dist/esm/utils/types.js +0 -0
  181. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
  182. package/dist/esm-node/builder/builder-rspack/index.js +0 -12
  183. package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
  184. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
  185. package/dist/esm-node/builder/builder-webpack/index.js +0 -20
  186. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
  187. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
  188. package/dist/esm-node/builder/generator/index.js +0 -37
  189. package/dist/esm-node/builder/index.js +0 -11
  190. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
  191. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
  192. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
  193. package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
  194. package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
  195. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
  196. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
  197. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -231
  198. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
  199. package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
  200. package/dist/esm-node/builder/shared/index.js +0 -3
  201. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
  202. package/dist/esm-node/builder/shared/types.js +0 -0
  203. package/dist/esm-node/commands/build.js +0 -55
  204. package/dist/esm-node/commands/deploy.js +0 -12
  205. package/dist/esm-node/commands/dev.js +0 -95
  206. package/dist/esm-node/commands/index.js +0 -92
  207. package/dist/esm-node/commands/inspect.js +0 -15
  208. package/dist/esm-node/commands/serve.js +0 -51
  209. package/dist/esm-node/config/default.js +0 -197
  210. package/dist/esm-node/config/index.js +0 -3
  211. package/dist/esm-node/config/initialize/index.js +0 -9
  212. package/dist/esm-node/config/initialize/inits.js +0 -79
  213. package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
  214. package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
  215. package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
  216. package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
  217. package/dist/esm-node/config/legacy/index.js +0 -43
  218. package/dist/esm-node/defineConfig.js +0 -13
  219. package/dist/esm-node/exports/server.js +0 -4
  220. package/dist/esm-node/hooks.js +0 -34
  221. package/dist/esm-node/index.js +0 -124
  222. package/dist/esm-node/locale/en.js +0 -43
  223. package/dist/esm-node/locale/index.js +0 -12
  224. package/dist/esm-node/locale/zh.js +0 -43
  225. package/dist/esm-node/plugins/analyze/constants.js +0 -14
  226. package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
  227. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
  228. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
  229. package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
  230. package/dist/esm-node/plugins/analyze/index.js +0 -166
  231. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
  232. package/dist/esm-node/plugins/analyze/templates.js +0 -24
  233. package/dist/esm-node/plugins/analyze/utils.js +0 -68
  234. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -201
  235. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -126
  236. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  237. package/dist/esm-node/plugins/deploy/index.js +0 -44
  238. package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
  239. package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
  240. package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
  241. package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
  242. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  243. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
  244. package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
  245. package/dist/esm-node/plugins/deploy/utils.js +0 -44
  246. package/dist/esm-node/plugins/initialize/index.js +0 -84
  247. package/dist/esm-node/plugins/serverBuild.js +0 -58
  248. package/dist/esm-node/types/config/deploy.js +0 -0
  249. package/dist/esm-node/types/config/dev.js +0 -0
  250. package/dist/esm-node/types/config/experiments.js +0 -0
  251. package/dist/esm-node/types/config/html.js +0 -0
  252. package/dist/esm-node/types/config/index.js +0 -1
  253. package/dist/esm-node/types/config/output.js +0 -0
  254. package/dist/esm-node/types/config/performance.js +0 -0
  255. package/dist/esm-node/types/config/security.js +0 -0
  256. package/dist/esm-node/types/config/source.js +0 -0
  257. package/dist/esm-node/types/config/testing.js +0 -0
  258. package/dist/esm-node/types/config/tools.js +0 -0
  259. package/dist/esm-node/types/hooks.js +0 -0
  260. package/dist/esm-node/types/index.js +0 -3
  261. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  262. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  263. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  264. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  265. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  266. package/dist/esm-node/types/legacyConfig/testing.js +0 -0
  267. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  268. package/dist/esm-node/types/utils.js +0 -0
  269. package/dist/esm-node/utils/config.js +0 -49
  270. package/dist/esm-node/utils/createServer.js +0 -26
  271. package/dist/esm-node/utils/env.js +0 -16
  272. package/dist/esm-node/utils/generateWatchFiles.js +0 -30
  273. package/dist/esm-node/utils/getSelectedEntries.js +0 -34
  274. package/dist/esm-node/utils/loadPlugins.js +0 -22
  275. package/dist/esm-node/utils/printInstructions.js +0 -11
  276. package/dist/esm-node/utils/register.js +0 -69
  277. package/dist/esm-node/utils/restart.js +0 -22
  278. package/dist/esm-node/utils/routes.js +0 -21
  279. package/dist/esm-node/utils/types.js +0 -0
  280. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
  281. package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
  282. /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
  283. /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
package/dist/esm/index.js DELETED
@@ -1,239 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
- import path from "path";
6
- import { lintPlugin } from "@modern-js/plugin-lint";
7
- import { cleanRequireCache, emptyDir, getCommand, getArgv } from "@modern-js/utils";
8
- import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
9
- import initializePlugin from "./plugins/initialize";
10
- import analyzePlugin from "./plugins/analyze";
11
- import serverBuildPlugin from "./plugins/serverBuild";
12
- import deployPlugin from "./plugins/deploy";
13
- import { hooks } from "./hooks";
14
- import { i18n } from "./locale";
15
- import { restart } from "./utils/restart";
16
- import { generateWatchFiles } from "./utils/generateWatchFiles";
17
- import { buildCommand, deployCommand, devCommand, inspectCommand, newCommand, serverCommand, upgradeCommand } from "./commands";
18
- import { dev } from "./commands/dev";
19
- import { mergeConfig } from "@modern-js/core";
20
- export * from "./defineConfig";
21
- export * from "./types";
22
- var appTools = function() {
23
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
24
- bundler: "webpack"
25
- };
26
- return {
27
- name: "@modern-js/app-tools",
28
- post: [
29
- "@modern-js/plugin-initialize",
30
- "@modern-js/plugin-analyze",
31
- "@modern-js/plugin-ssr",
32
- "@modern-js/plugin-document",
33
- "@modern-js/plugin-state",
34
- "@modern-js/plugin-router",
35
- "@modern-js/plugin-router-v5",
36
- "@modern-js/plugin-polyfill"
37
- ],
38
- registerHook: hooks,
39
- usePlugins: [
40
- initializePlugin({
41
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
42
- }),
43
- analyzePlugin({
44
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
45
- }),
46
- serverBuildPlugin(),
47
- lintPlugin(),
48
- deployPlugin()
49
- ],
50
- setup: function(api) {
51
- var appContext = api.useAppContext();
52
- api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
53
- toolsType: "app-tools"
54
- }));
55
- var locale = getLocaleLanguage();
56
- i18n.changeLanguage({
57
- locale
58
- });
59
- return {
60
- beforeConfig: function beforeConfig() {
61
- return _async_to_generator(function() {
62
- var _userConfig_output, userConfig, appContext2;
63
- return _ts_generator(this, function(_state) {
64
- userConfig = api.useConfigContext();
65
- appContext2 = api.useAppContext();
66
- if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
67
- api.setAppContext(_object_spread_props(_object_spread({}, appContext2), {
68
- internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
69
- }));
70
- }
71
- return [
72
- 2
73
- ];
74
- });
75
- })();
76
- },
77
- commands: function commands(param) {
78
- var program = param.program;
79
- return _async_to_generator(function() {
80
- return _ts_generator(this, function(_state) {
81
- switch (_state.label) {
82
- case 0:
83
- return [
84
- 4,
85
- devCommand(program, api)
86
- ];
87
- case 1:
88
- _state.sent();
89
- return [
90
- 4,
91
- buildCommand(program, api)
92
- ];
93
- case 2:
94
- _state.sent();
95
- serverCommand(program, api);
96
- deployCommand(program, api);
97
- newCommand(program, locale);
98
- inspectCommand(program, api);
99
- upgradeCommand(program);
100
- return [
101
- 2
102
- ];
103
- }
104
- });
105
- })();
106
- },
107
- prepare: function prepare() {
108
- return _async_to_generator(function() {
109
- var command, isSkipBuild, resolvedConfig, appContext2;
110
- return _ts_generator(this, function(_state) {
111
- switch (_state.label) {
112
- case 0:
113
- command = getCommand();
114
- if (command === "deploy") {
115
- isSkipBuild = [
116
- "-s",
117
- "--skip-build"
118
- ].some(function(tag) {
119
- return getArgv().includes(tag);
120
- });
121
- if (isSkipBuild) {
122
- return [
123
- 2
124
- ];
125
- }
126
- }
127
- if (!(command === "dev" || command === "start" || command === "build" || command === "deploy"))
128
- return [
129
- 3,
130
- 2
131
- ];
132
- resolvedConfig = api.useResolvedConfigContext();
133
- if (!resolvedConfig.output.cleanDistPath)
134
- return [
135
- 3,
136
- 2
137
- ];
138
- appContext2 = api.useAppContext();
139
- return [
140
- 4,
141
- emptyDir(appContext2.distDirectory)
142
- ];
143
- case 1:
144
- _state.sent();
145
- _state.label = 2;
146
- case 2:
147
- return [
148
- 2
149
- ];
150
- }
151
- });
152
- })();
153
- },
154
- watchFiles: function watchFiles() {
155
- return _async_to_generator(function() {
156
- var appContext2, config;
157
- return _ts_generator(this, function(_state) {
158
- switch (_state.label) {
159
- case 0:
160
- appContext2 = api.useAppContext();
161
- config = api.useResolvedConfigContext();
162
- return [
163
- 4,
164
- generateWatchFiles(appContext2, config.source.configDir)
165
- ];
166
- case 1:
167
- return [
168
- 2,
169
- _state.sent()
170
- ];
171
- }
172
- });
173
- })();
174
- },
175
- fileChange: (
176
- // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
177
- function fileChange(e) {
178
- return _async_to_generator(function() {
179
- var filename, eventType, isPrivate, closeServer;
180
- return _ts_generator(this, function(_state) {
181
- switch (_state.label) {
182
- case 0:
183
- filename = e.filename, eventType = e.eventType, isPrivate = e.isPrivate;
184
- if (!(!isPrivate && (eventType === "change" || eventType === "unlink")))
185
- return [
186
- 3,
187
- 4
188
- ];
189
- return [
190
- 4,
191
- import("./utils/createServer")
192
- ];
193
- case 1:
194
- closeServer = _state.sent().closeServer;
195
- return [
196
- 4,
197
- closeServer()
198
- ];
199
- case 2:
200
- _state.sent();
201
- return [
202
- 4,
203
- restart(api.useHookRunners(), filename)
204
- ];
205
- case 3:
206
- _state.sent();
207
- _state.label = 4;
208
- case 4:
209
- return [
210
- 2
211
- ];
212
- }
213
- });
214
- })();
215
- }
216
- ),
217
- beforeRestart: function beforeRestart() {
218
- return _async_to_generator(function() {
219
- return _ts_generator(this, function(_state) {
220
- cleanRequireCache([
221
- require.resolve("./plugins/analyze")
222
- ]);
223
- return [
224
- 2
225
- ];
226
- });
227
- })();
228
- }
229
- };
230
- }
231
- };
232
- };
233
- var src_default = appTools;
234
- export {
235
- appTools,
236
- src_default as default,
237
- dev,
238
- mergeConfig
239
- };
@@ -1,43 +0,0 @@
1
- var EN_LOCALE = {
2
- command: {
3
- shared: {
4
- analyze: "analyze bundle size",
5
- config: "specify the configuration file, which can be a relative or absolute path",
6
- skipBuild: "skip the build phase",
7
- noNeedInstall: "not run install command"
8
- },
9
- dev: {
10
- describe: "starting the dev server",
11
- entry: "compiler by entry",
12
- apiOnly: "start api server only",
13
- webOnly: "start web server only",
14
- selectEntry: "Please select the entry that needs to be built",
15
- requireEntry: "You must choose at least one entry"
16
- },
17
- build: {
18
- describe: "build the app for production"
19
- },
20
- serve: {
21
- describe: "preview the production build locally"
22
- },
23
- deploy: {
24
- describe: "deploy the application"
25
- },
26
- new: {
27
- describe: "enable optional features or add a new entry",
28
- debug: "using debug mode to log something",
29
- config: "set default generator config(json string)",
30
- distTag: "use specified tag version for it's generator",
31
- registry: "set npm registry url to run npm command",
32
- lang: "set new command language(en or zh)"
33
- },
34
- inspect: {
35
- env: "specify env mode",
36
- output: "specify inspect content output path",
37
- verbose: "show full function definitions in output"
38
- }
39
- }
40
- };
41
- export {
42
- EN_LOCALE
43
- };
@@ -1,12 +0,0 @@
1
- import { I18n } from "@modern-js/plugin-i18n";
2
- import { ZH_LOCALE } from "./zh";
3
- import { EN_LOCALE } from "./en";
4
- var i18n = new I18n();
5
- var localeKeys = i18n.init("en", {
6
- zh: ZH_LOCALE,
7
- en: EN_LOCALE
8
- });
9
- export {
10
- i18n,
11
- localeKeys
12
- };
@@ -1,43 +0,0 @@
1
- var ZH_LOCALE = {
2
- command: {
3
- shared: {
4
- analyze: "分析构建产物体积,查看各个模块打包后的大小",
5
- config: "指定配置文件路径,可以为相对路径或绝对路径",
6
- skipBuild: "跳过构建阶段",
7
- noNeedInstall: "无需安装依赖"
8
- },
9
- dev: {
10
- describe: "启动开发服务器",
11
- entry: "指定入口,编译特定的页面",
12
- apiOnly: "仅启动 API 接口服务",
13
- webOnly: "仅启动 Web 服务",
14
- selectEntry: "请选择需要构建的入口",
15
- requireEntry: "请至少选择一个入口"
16
- },
17
- build: {
18
- describe: "构建生产环境产物"
19
- },
20
- serve: {
21
- describe: "启动生产环境服务"
22
- },
23
- deploy: {
24
- describe: "部署应用"
25
- },
26
- new: {
27
- describe: "Web App 项目中执行生成器",
28
- debug: "开启 Debug 模式,打印调试日志信息",
29
- config: "生成器运行默认配置(JSON 字符串)",
30
- distTag: "生成器使用特殊的 npm Tag 版本",
31
- registry: "生成器运行过程中定制 npm Registry",
32
- lang: "设置 new 命令执行语言(zh 或者 en)"
33
- },
34
- inspect: {
35
- env: "查看指定环境下的配置",
36
- output: "指定在 dist 目录下输出的路径",
37
- verbose: "在结果中展示函数的完整内容"
38
- }
39
- }
40
- };
41
- export {
42
- ZH_LOCALE
43
- };
@@ -1,14 +0,0 @@
1
- var INDEX_FILE_NAME = "index";
2
- var ENTRY_FILE_NAME = "entry";
3
- var HTML_PARTIALS_FOLDER = "html";
4
- var HTML_PARTIALS_EXTENSIONS = [
5
- ".htm",
6
- ".html",
7
- ".ejs"
8
- ];
9
- export {
10
- ENTRY_FILE_NAME,
11
- HTML_PARTIALS_EXTENSIONS,
12
- HTML_PARTIALS_FOLDER,
13
- INDEX_FILE_NAME
14
- };
@@ -1,102 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import path from "path";
4
- import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME, JS_EXTENSIONS } from "@modern-js/utils";
5
- import { getFileSystemEntry } from "./getFileSystemEntry";
6
- import { isSubDirOrEqual } from "./utils";
7
- var ensureExtensions = function(file) {
8
- if (!path.extname(file)) {
9
- return findExists(JS_EXTENSIONS.map(function(ext) {
10
- return "".concat(file).concat(ext);
11
- })) || file;
12
- }
13
- return file;
14
- };
15
- var isDirectory = function(file) {
16
- return !path.extname(file);
17
- };
18
- var ifAlreadyExists = function(entrypoints, checked) {
19
- return entrypoints.some(function(entrypoint) {
20
- if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
21
- checked.entryName = entrypoint.entryName;
22
- return true;
23
- }
24
- if (isSubDirOrEqual(entrypoint.entry, checked.entry) || isSubDirOrEqual(checked.entry, entrypoint.entry)) {
25
- throw new Error("Entry configuration conflicts\n Your configuration: ".concat(checked.entry, ".\n Default entrypoint: ").concat(entrypoint.entry, "\n Please reset source.entries or set source.disableDefaultEntries to disable the default entry rules."));
26
- }
27
- return false;
28
- });
29
- };
30
- var getBundleEntry = function() {
31
- var _ref = _async_to_generator(function(hookRunners, appContext, config) {
32
- var appDirectory, packageName, _config_source, disableDefaultEntries, entries, entriesDir, mainEntryName, defaults, _tmp, entriesDirAbs, found;
33
- return _ts_generator(this, function(_state) {
34
- switch (_state.label) {
35
- case 0:
36
- appDirectory = appContext.appDirectory, packageName = appContext.packageName;
37
- _config_source = config.source, disableDefaultEntries = _config_source.disableDefaultEntries, entries = _config_source.entries, entriesDir = _config_source.entriesDir, mainEntryName = _config_source.mainEntryName;
38
- if (!disableDefaultEntries)
39
- return [
40
- 3,
41
- 1
42
- ];
43
- _tmp = [];
44
- return [
45
- 3,
46
- 3
47
- ];
48
- case 1:
49
- return [
50
- 4,
51
- getFileSystemEntry(hookRunners, appContext, config)
52
- ];
53
- case 2:
54
- _tmp = _state.sent();
55
- _state.label = 3;
56
- case 3:
57
- defaults = _tmp;
58
- if (entries) {
59
- Object.keys(entries).forEach(function(name) {
60
- var value = entries[name];
61
- var entryName = typeof value === "string" ? value : value.entry;
62
- var isAutoMount = typeof value === "string" ? true : !value.disableMount;
63
- var entrypoint = {
64
- entryName: name,
65
- isMainEntry: false,
66
- entry: ensureAbsolutePath(appDirectory, entryName),
67
- absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, entryName)) ? ensureAbsolutePath(appDirectory, entryName) : path.dirname(ensureAbsolutePath(appDirectory, entryName)),
68
- isAutoMount,
69
- customBootstrap: typeof value === "string" ? false : value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
70
- fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, entryName)).isDirectory() ? {} : void 0,
71
- isCustomSourceEntry: true
72
- };
73
- if (!ifAlreadyExists(defaults, entrypoint)) {
74
- defaults.push(entrypoint);
75
- }
76
- });
77
- }
78
- if (!disableDefaultEntries) {
79
- entriesDirAbs = ensureAbsolutePath(appDirectory, entriesDir || "");
80
- found = defaults.find(function(param) {
81
- var entryName = param.entryName, entry = param.entry, _param_nestedRoutesEntry = param.nestedRoutesEntry, nestedRoutesEntry = _param_nestedRoutesEntry === void 0 ? "" : _param_nestedRoutesEntry;
82
- return entryName === packageName || path.dirname(entry) === entriesDirAbs || path.dirname(nestedRoutesEntry) === entriesDirAbs;
83
- });
84
- if (found) {
85
- found.entryName = mainEntryName || MAIN_ENTRY_NAME;
86
- found.isMainEntry = true;
87
- }
88
- }
89
- return [
90
- 2,
91
- defaults
92
- ];
93
- }
94
- });
95
- });
96
- return function getBundleEntry2(hookRunners, appContext, config) {
97
- return _ref.apply(this, arguments);
98
- };
99
- }();
100
- export {
101
- getBundleEntry
102
- };
@@ -1,238 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import fs from "fs";
4
- import path from "path";
5
- import { findExists, ensureAbsolutePath, JS_EXTENSIONS } from "@modern-js/utils";
6
- import { ENTRY_FILE_NAME, INDEX_FILE_NAME } from "./constants";
7
- import { isDefaultExportFunction } from "./isDefaultExportFunction";
8
- var hasIndex = function(dir) {
9
- return findExists(JS_EXTENSIONS.map(function(ext) {
10
- return path.resolve(dir, "".concat(INDEX_FILE_NAME).concat(ext));
11
- }));
12
- };
13
- var hasEntry = function(dir) {
14
- return findExists(JS_EXTENSIONS.map(function(ext) {
15
- return path.resolve(dir, "".concat(ENTRY_FILE_NAME).concat(ext));
16
- }));
17
- };
18
- var hasServerEntry = function(dir) {
19
- return findExists(JS_EXTENSIONS.map(function(ext) {
20
- return path.resolve(dir, "".concat(ENTRY_FILE_NAME, ".server").concat(ext));
21
- }));
22
- };
23
- var isBundleEntry = function() {
24
- var _ref = _async_to_generator(function(hookRunners, dir, enableCustomEntry) {
25
- var entry, customEntry;
26
- return _ts_generator(this, function(_state) {
27
- switch (_state.label) {
28
- case 0:
29
- return [
30
- 4,
31
- hookRunners.checkEntryPoint({
32
- path: dir,
33
- entry: false
34
- })
35
- ];
36
- case 1:
37
- entry = _state.sent().entry;
38
- if (entry) {
39
- return [
40
- 2,
41
- entry
42
- ];
43
- }
44
- customEntry = hasEntry(dir);
45
- if (enableCustomEntry && customEntry) {
46
- return [
47
- 2,
48
- customEntry
49
- ];
50
- }
51
- return [
52
- 2,
53
- hasIndex(dir)
54
- ];
55
- }
56
- });
57
- });
58
- return function isBundleEntry2(hookRunners, dir, enableCustomEntry) {
59
- return _ref.apply(this, arguments);
60
- };
61
- }();
62
- var scanDir = function(hookRunners, dirs, enableCustomEntry) {
63
- return Promise.all(dirs.map(function() {
64
- var _ref = _async_to_generator(function(dir) {
65
- var indexFile, customBootstrap, entryName, customEntryFile, customServerEntry, entryFile;
66
- return _ts_generator(this, function(_state) {
67
- switch (_state.label) {
68
- case 0:
69
- indexFile = hasIndex(dir);
70
- customBootstrap = isDefaultExportFunction(indexFile) ? indexFile : false;
71
- entryName = path.basename(dir);
72
- customEntryFile = hasEntry(dir);
73
- customServerEntry = hasServerEntry(dir);
74
- if (indexFile && !customBootstrap) {
75
- return [
76
- 2,
77
- {
78
- entryName,
79
- isMainEntry: false,
80
- entry: indexFile,
81
- absoluteEntryDir: path.resolve(dir),
82
- isAutoMount: false,
83
- customBootstrap
84
- }
85
- ];
86
- }
87
- return [
88
- 4,
89
- hookRunners.checkEntryPoint({
90
- path: dir,
91
- entry: false
92
- })
93
- ];
94
- case 1:
95
- entryFile = _state.sent().entry;
96
- if (entryFile) {
97
- return [
98
- 2,
99
- {
100
- entryName,
101
- isMainEntry: false,
102
- entry: enableCustomEntry ? customEntryFile || entryFile : entryFile,
103
- customServerEntry,
104
- absoluteEntryDir: path.resolve(dir),
105
- isAutoMount: true,
106
- customBootstrap,
107
- customEntry: enableCustomEntry ? Boolean(customEntryFile) : false
108
- }
109
- ];
110
- }
111
- if (enableCustomEntry && customEntryFile) {
112
- return [
113
- 2,
114
- {
115
- entryName,
116
- isMainEntry: false,
117
- entry: customEntryFile,
118
- customServerEntry,
119
- absoluteEntryDir: path.resolve(dir),
120
- isAutoMount: false,
121
- customEntry: Boolean(customEntryFile)
122
- }
123
- ];
124
- }
125
- throw Error("There is no valid entry point in the current project!");
126
- }
127
- });
128
- });
129
- return function(dir) {
130
- return _ref.apply(this, arguments);
131
- };
132
- }()));
133
- };
134
- var getFileSystemEntry = function() {
135
- var _ref = _async_to_generator(function(hookRunners, appContext, config) {
136
- var appDirectory, _config_source, entriesDir, disableEntryDirs, enableCustomEntry, disabledDirs, src, dirs;
137
- return _ts_generator(this, function(_state) {
138
- switch (_state.label) {
139
- case 0:
140
- appDirectory = appContext.appDirectory;
141
- _config_source = config.source, entriesDir = _config_source.entriesDir, disableEntryDirs = _config_source.disableEntryDirs, enableCustomEntry = _config_source.enableCustomEntry;
142
- disabledDirs = [];
143
- if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
144
- disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map(function(dir) {
145
- return ensureAbsolutePath(appDirectory, dir);
146
- });
147
- }
148
- src = ensureAbsolutePath(appDirectory, entriesDir || "");
149
- if (!fs.existsSync(src))
150
- return [
151
- 3,
152
- 5
153
- ];
154
- if (!fs.statSync(src).isDirectory())
155
- return [
156
- 3,
157
- 3
158
- ];
159
- return [
160
- 4,
161
- isBundleEntry(hookRunners, src, enableCustomEntry)
162
- ];
163
- case 1:
164
- if (_state.sent()) {
165
- return [
166
- 2,
167
- scanDir(hookRunners, [
168
- src
169
- ], enableCustomEntry)
170
- ];
171
- }
172
- dirs = [];
173
- return [
174
- 4,
175
- Promise.all(fs.readdirSync(src).map(function() {
176
- var _ref2 = _async_to_generator(function(filename) {
177
- var file, _tmp;
178
- return _ts_generator(this, function(_state2) {
179
- switch (_state2.label) {
180
- case 0:
181
- file = path.join(src, filename);
182
- _tmp = fs.statSync(file).isDirectory();
183
- if (!_tmp)
184
- return [
185
- 3,
186
- 2
187
- ];
188
- return [
189
- 4,
190
- isBundleEntry(hookRunners, file, enableCustomEntry)
191
- ];
192
- case 1:
193
- _tmp = _state2.sent();
194
- _state2.label = 2;
195
- case 2:
196
- if (_tmp && !disabledDirs.includes(file)) {
197
- dirs.push(file);
198
- }
199
- return [
200
- 2
201
- ];
202
- }
203
- });
204
- });
205
- return function(filename) {
206
- return _ref2.apply(this, arguments);
207
- };
208
- }()))
209
- ];
210
- case 2:
211
- _state.sent();
212
- return [
213
- 2,
214
- scanDir(hookRunners, dirs, enableCustomEntry)
215
- ];
216
- case 3:
217
- throw Error("source.entriesDir accept a directory.");
218
- case 4:
219
- return [
220
- 3,
221
- 6
222
- ];
223
- case 5:
224
- throw Error("src dir ".concat(entriesDir, " not found."));
225
- case 6:
226
- return [
227
- 2
228
- ];
229
- }
230
- });
231
- });
232
- return function getFileSystemEntry2(hookRunners, appContext, config) {
233
- return _ref.apply(this, arguments);
234
- };
235
- }();
236
- export {
237
- getFileSystemEntry
238
- };