@modern-js/app-tools 2.63.1 → 2.63.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/bin/modern.js +1 -1
  2. package/dist/cjs/commands/build.js +19 -13
  3. package/dist/cjs/commands/deploy.js +5 -5
  4. package/dist/cjs/commands/dev.js +11 -11
  5. package/dist/cjs/commands/index.js +6 -6
  6. package/dist/cjs/commands/inspect.js +1 -1
  7. package/dist/cjs/commands/serve.js +4 -4
  8. package/dist/cjs/{new/compat → compat}/hooks.js +21 -6
  9. package/dist/cjs/{new/compat → compat}/index.js +7 -2
  10. package/dist/cjs/{new/compat → compat}/utils.js +29 -8
  11. package/dist/cjs/config/default.js +6 -1
  12. package/dist/cjs/config/legacy/index.js +0 -1
  13. package/dist/cjs/index.js +154 -5
  14. package/dist/cjs/plugins/analyze/getServerRoutes.js +12 -2
  15. package/dist/cjs/plugins/analyze/index.js +25 -10
  16. package/dist/cjs/plugins/analyze/utils.js +6 -0
  17. package/dist/cjs/plugins/deploy/platforms/netlify.js +7 -4
  18. package/dist/cjs/plugins/deploy/platforms/node.js +6 -3
  19. package/dist/cjs/plugins/deploy/platforms/vercel.js +7 -4
  20. package/dist/cjs/plugins/serverBuild.js +30 -32
  21. package/dist/cjs/{new/run.js → run/index.js} +6 -6
  22. package/dist/cjs/{new → utils}/getConfigFile.js +1 -1
  23. package/dist/cjs/{new/context.js → utils/initAppContext.js} +3 -3
  24. package/dist/cjs/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  25. package/dist/cjs/utils/loadPlugins.js +35 -4
  26. package/dist/cjs/utils/printInstructions.js +2 -11
  27. package/dist/cjs/utils/restart.js +2 -2
  28. package/dist/esm/commands/build.js +18 -12
  29. package/dist/esm/commands/deploy.js +6 -6
  30. package/dist/esm/commands/dev.js +11 -11
  31. package/dist/esm/commands/index.js +8 -8
  32. package/dist/esm/commands/inspect.js +1 -1
  33. package/dist/esm/commands/serve.js +6 -6
  34. package/dist/esm/{new/compat → compat}/hooks.js +98 -49
  35. package/dist/esm/{new/compat → compat}/index.js +8 -3
  36. package/dist/esm/{new/compat → compat}/utils.js +29 -8
  37. package/dist/esm/config/default.js +12 -1
  38. package/dist/esm/config/legacy/index.js +0 -1
  39. package/dist/esm/index.js +245 -2
  40. package/dist/esm/plugins/analyze/getServerRoutes.js +11 -2
  41. package/dist/esm/plugins/analyze/index.js +76 -34
  42. package/dist/esm/plugins/analyze/utils.js +5 -0
  43. package/dist/esm/plugins/deploy/platforms/netlify.js +6 -3
  44. package/dist/esm/plugins/deploy/platforms/node.js +5 -2
  45. package/dist/esm/plugins/deploy/platforms/vercel.js +6 -3
  46. package/dist/esm/plugins/serverBuild.js +52 -56
  47. package/dist/esm/{new/run.js → run/index.js} +6 -6
  48. package/dist/esm/{new → utils}/getConfigFile.js +1 -1
  49. package/dist/esm/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  50. package/dist/esm/utils/loadPlugins.js +95 -7
  51. package/dist/esm/utils/printInstructions.js +1 -28
  52. package/dist/esm/utils/restart.js +3 -3
  53. package/dist/esm-node/commands/build.js +19 -13
  54. package/dist/esm-node/commands/deploy.js +5 -5
  55. package/dist/esm-node/commands/dev.js +12 -12
  56. package/dist/esm-node/commands/index.js +6 -6
  57. package/dist/esm-node/commands/inspect.js +1 -1
  58. package/dist/esm-node/commands/serve.js +5 -5
  59. package/dist/esm-node/{new/compat → compat}/hooks.js +21 -6
  60. package/dist/esm-node/{new/compat → compat}/index.js +8 -3
  61. package/dist/esm-node/{new/compat → compat}/utils.js +29 -8
  62. package/dist/esm-node/config/default.js +6 -1
  63. package/dist/esm-node/config/legacy/index.js +0 -1
  64. package/dist/esm-node/index.js +140 -2
  65. package/dist/esm-node/plugins/analyze/getServerRoutes.js +11 -2
  66. package/dist/esm-node/plugins/analyze/index.js +26 -11
  67. package/dist/esm-node/plugins/analyze/utils.js +5 -0
  68. package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -3
  69. package/dist/esm-node/plugins/deploy/platforms/node.js +5 -2
  70. package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -3
  71. package/dist/esm-node/plugins/serverBuild.js +30 -32
  72. package/dist/esm-node/{new/run.js → run/index.js} +6 -6
  73. package/dist/esm-node/{new → utils}/getConfigFile.js +1 -1
  74. package/dist/esm-node/{new/utils/index.js → utils/isAutoLoadPlugins.js} +2 -2
  75. package/dist/esm-node/utils/loadPlugins.js +34 -4
  76. package/dist/esm-node/utils/printInstructions.js +1 -9
  77. package/dist/esm-node/utils/restart.js +2 -2
  78. package/dist/types/commands/build.d.ts +2 -2
  79. package/dist/types/commands/deploy.d.ts +2 -2
  80. package/dist/types/commands/dev.d.ts +2 -2
  81. package/dist/types/commands/index.d.ts +6 -6
  82. package/dist/types/commands/inspect.d.ts +2 -2
  83. package/dist/types/commands/serve.d.ts +2 -2
  84. package/dist/types/{new/compat → compat}/hooks.d.ts +2 -2
  85. package/dist/types/compat/index.d.ts +2 -0
  86. package/dist/types/{new/compat → compat}/utils.d.ts +8 -1
  87. package/dist/types/index.d.ts +5 -3
  88. package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
  89. package/dist/types/plugins/analyze/utils.d.ts +1 -0
  90. package/dist/types/plugins/serverBuild.d.ts +2 -2
  91. package/dist/types/types/config/index.d.ts +0 -1
  92. package/dist/types/types/index.d.ts +2 -0
  93. package/dist/types/types/new.d.ts +11 -16
  94. package/dist/types/utils/generateWatchFiles.d.ts +2 -2
  95. package/dist/types/utils/isAutoLoadPlugins.d.ts +1 -0
  96. package/dist/types/utils/loadPlugins.d.ts +13 -3
  97. package/dist/types/utils/printInstructions.d.ts +1 -3
  98. package/dist/types/utils/restart.d.ts +2 -3
  99. package/package.json +24 -28
  100. package/dist/cjs/hooks.js +0 -60
  101. package/dist/cjs/new/index.js +0 -79
  102. package/dist/cjs/new/loadPlugins.js +0 -57
  103. package/dist/cjs/old.js +0 -179
  104. package/dist/cjs/plugins/deploy/dependencies/index.js +0 -237
  105. package/dist/cjs/plugins/deploy/dependencies/utils.js +0 -179
  106. package/dist/cjs/plugins/deploy/exports.js +0 -28
  107. package/dist/esm/hooks.js +0 -36
  108. package/dist/esm/new/index.js +0 -55
  109. package/dist/esm/new/loadPlugins.js +0 -94
  110. package/dist/esm/old.js +0 -258
  111. package/dist/esm/plugins/deploy/dependencies/index.js +0 -615
  112. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -421
  113. package/dist/esm/plugins/deploy/exports.js +0 -4
  114. package/dist/esm-node/hooks.js +0 -36
  115. package/dist/esm-node/new/index.js +0 -52
  116. package/dist/esm-node/new/loadPlugins.js +0 -33
  117. package/dist/esm-node/old.js +0 -140
  118. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -202
  119. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -137
  120. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  121. package/dist/types/hooks.d.ts +0 -2
  122. package/dist/types/new/compat/index.d.ts +0 -2
  123. package/dist/types/new/index.d.ts +0 -6
  124. package/dist/types/new/loadPlugins.d.ts +0 -9
  125. package/dist/types/new/utils/index.d.ts +0 -1
  126. package/dist/types/old.d.ts +0 -13
  127. package/dist/types/plugins/deploy/dependencies/index.d.ts +0 -20
  128. package/dist/types/plugins/deploy/dependencies/utils.d.ts +0 -44
  129. package/dist/types/plugins/deploy/exports.d.ts +0 -1
  130. /package/dist/cjs/{new/constants.js → constants.js} +0 -0
  131. /package/dist/esm/{new/constants.js → constants.js} +0 -0
  132. /package/dist/esm/{new/context.js → utils/initAppContext.js} +0 -0
  133. /package/dist/esm-node/{new/constants.js → constants.js} +0 -0
  134. /package/dist/esm-node/{new/context.js → utils/initAppContext.js} +0 -0
  135. /package/dist/types/{new/constants.d.ts → constants.d.ts} +0 -0
  136. /package/dist/types/{new/run.d.ts → run/index.d.ts} +0 -0
  137. /package/dist/types/{new → utils}/getConfigFile.d.ts +0 -0
  138. /package/dist/types/{new/context.d.ts → utils/initAppContext.d.ts} +0 -0
package/dist/esm/old.js DELETED
@@ -1,258 +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 _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
- import path from "path";
7
- import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
8
- import { castArray } from "@modern-js/uni-builder";
9
- import { cleanRequireCache, deprecatedCommands, emptyDir, getArgv, getCommand } from "@modern-js/utils";
10
- import { hooks } from "./hooks";
11
- import { i18n } from "./locale";
12
- import analyzePlugin from "./plugins/analyze";
13
- import deployPlugin from "./plugins/deploy";
14
- import initializePlugin from "./plugins/initialize";
15
- import serverBuildPlugin from "./plugins/serverBuild";
16
- import { buildCommand, deployCommand, devCommand, inspectCommand, newCommand, serverCommand, upgradeCommand } from "./commands";
17
- import { generateWatchFiles } from "./utils/generateWatchFiles";
18
- import { restart } from "./utils/restart";
19
- import { dev } from "./commands/dev";
20
- import { mergeConfig } from "@modern-js/core";
21
- export * from "./defineConfig";
22
- export * from "./types";
23
- var appTools = function() {
24
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
25
- // default webpack to be compatible with original projects
26
- bundler: "webpack"
27
- };
28
- return {
29
- name: "@modern-js/app-tools-old",
30
- post: [
31
- "@modern-js/plugin-initialize",
32
- "@modern-js/plugin-analyze",
33
- "@modern-js/plugin-ssr",
34
- "@modern-js/plugin-document",
35
- "@modern-js/plugin-state",
36
- "@modern-js/plugin-router",
37
- "@modern-js/plugin-router-v5",
38
- "@modern-js/plugin-polyfill"
39
- ],
40
- registerHook: hooks,
41
- usePlugins: [
42
- initializePlugin({
43
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
44
- "rspack",
45
- "experimental-rspack"
46
- ].includes(options.bundler) ? "rspack" : "webpack"
47
- }),
48
- analyzePlugin({
49
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
50
- "rspack",
51
- "experimental-rspack"
52
- ].includes(options.bundler) ? "rspack" : "webpack"
53
- }),
54
- serverBuildPlugin(),
55
- deployPlugin()
56
- ],
57
- setup: function(api) {
58
- var appContext = api.useAppContext();
59
- api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
60
- toolsType: "app-tools"
61
- }));
62
- var locale = getLocaleLanguage();
63
- i18n.changeLanguage({
64
- locale
65
- });
66
- return {
67
- beforeConfig: function beforeConfig() {
68
- return _async_to_generator(function() {
69
- var _userConfig_output, userConfig, appContext2;
70
- return _ts_generator(this, function(_state) {
71
- userConfig = api.useConfigContext();
72
- appContext2 = api.useAppContext();
73
- if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
74
- api.setAppContext(_object_spread_props(_object_spread({}, appContext2), {
75
- internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
76
- }));
77
- }
78
- return [
79
- 2
80
- ];
81
- });
82
- })();
83
- },
84
- commands: function commands(param) {
85
- var program = param.program;
86
- return _async_to_generator(function() {
87
- return _ts_generator(this, function(_state) {
88
- switch (_state.label) {
89
- case 0:
90
- return [
91
- 4,
92
- devCommand(program, api)
93
- ];
94
- case 1:
95
- _state.sent();
96
- return [
97
- 4,
98
- buildCommand(program, api)
99
- ];
100
- case 2:
101
- _state.sent();
102
- serverCommand(program, api);
103
- deployCommand(program, api);
104
- newCommand(program, locale);
105
- inspectCommand(program, api);
106
- upgradeCommand(program);
107
- deprecatedCommands(program);
108
- return [
109
- 2
110
- ];
111
- }
112
- });
113
- })();
114
- },
115
- prepare: function prepare() {
116
- return _async_to_generator(function() {
117
- var command, isSkipBuild, resolvedConfig, appContext2;
118
- return _ts_generator(this, function(_state) {
119
- switch (_state.label) {
120
- case 0:
121
- command = getCommand();
122
- if (command === "deploy") {
123
- isSkipBuild = [
124
- "-s",
125
- "--skip-build"
126
- ].some(function(tag) {
127
- return getArgv().includes(tag);
128
- });
129
- if (isSkipBuild) {
130
- return [
131
- 2
132
- ];
133
- }
134
- }
135
- if (!(command === "dev" || command === "start" || command === "build" || command === "deploy"))
136
- return [
137
- 3,
138
- 2
139
- ];
140
- resolvedConfig = api.useResolvedConfigContext();
141
- if (!resolvedConfig.output.cleanDistPath)
142
- return [
143
- 3,
144
- 2
145
- ];
146
- appContext2 = api.useAppContext();
147
- return [
148
- 4,
149
- emptyDir(appContext2.distDirectory)
150
- ];
151
- case 1:
152
- _state.sent();
153
- _state.label = 2;
154
- case 2:
155
- return [
156
- 2
157
- ];
158
- }
159
- });
160
- })();
161
- },
162
- watchFiles: function watchFiles() {
163
- return _async_to_generator(function() {
164
- var appContext2, config, files, watchFiles2;
165
- return _ts_generator(this, function(_state) {
166
- switch (_state.label) {
167
- case 0:
168
- appContext2 = api.useAppContext();
169
- config = api.useResolvedConfigContext();
170
- return [
171
- 4,
172
- generateWatchFiles(appContext2, config.source.configDir)
173
- ];
174
- case 1:
175
- files = _state.sent();
176
- watchFiles2 = castArray(config.dev.watchFiles);
177
- watchFiles2.forEach(function(param) {
178
- var type = param.type, paths = param.paths;
179
- if (type === "reload-server") {
180
- var _files;
181
- (_files = files).push.apply(_files, _to_consumable_array(Array.isArray(paths) ? paths : [
182
- paths
183
- ]));
184
- }
185
- });
186
- return [
187
- 2,
188
- files
189
- ];
190
- }
191
- });
192
- })();
193
- },
194
- fileChange: (
195
- // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
196
- function fileChange(e) {
197
- return _async_to_generator(function() {
198
- var filename, eventType, isPrivate, closeServer;
199
- return _ts_generator(this, function(_state) {
200
- switch (_state.label) {
201
- case 0:
202
- filename = e.filename, eventType = e.eventType, isPrivate = e.isPrivate;
203
- if (!(!isPrivate && (eventType === "change" || eventType === "unlink")))
204
- return [
205
- 3,
206
- 4
207
- ];
208
- return [
209
- 4,
210
- import("./utils/createServer.js")
211
- ];
212
- case 1:
213
- closeServer = _state.sent().closeServer;
214
- return [
215
- 4,
216
- closeServer()
217
- ];
218
- case 2:
219
- _state.sent();
220
- return [
221
- 4,
222
- restart(api.useHookRunners(), filename)
223
- ];
224
- case 3:
225
- _state.sent();
226
- _state.label = 4;
227
- case 4:
228
- return [
229
- 2
230
- ];
231
- }
232
- });
233
- })();
234
- }
235
- ),
236
- beforeRestart: function beforeRestart() {
237
- return _async_to_generator(function() {
238
- return _ts_generator(this, function(_state) {
239
- cleanRequireCache([
240
- require.resolve("./plugins/analyze")
241
- ]);
242
- return [
243
- 2
244
- ];
245
- });
246
- })();
247
- }
248
- };
249
- }
250
- };
251
- };
252
- var old_default = appTools;
253
- export {
254
- appTools,
255
- old_default as default,
256
- dev,
257
- mergeConfig
258
- };