@modern-js/app-tools 2.63.1-alpha.0 → 2.63.1

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 (99) hide show
  1. package/bin/modern.js +1 -1
  2. package/dist/cjs/commands/build.js +13 -19
  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/hooks.js +60 -0
  9. package/dist/cjs/index.js +5 -154
  10. package/dist/cjs/{compat → new/compat}/hooks.js +5 -5
  11. package/dist/cjs/{compat → new/compat}/index.js +1 -4
  12. package/dist/cjs/{utils/initAppContext.js → new/context.js} +3 -3
  13. package/dist/cjs/{utils → new}/getConfigFile.js +1 -1
  14. package/dist/cjs/new/index.js +79 -0
  15. package/dist/cjs/new/loadPlugins.js +57 -0
  16. package/dist/cjs/{run/index.js → new/run.js} +6 -6
  17. package/dist/cjs/{utils/isAutoLoadPlugins.js → new/utils/index.js} +6 -6
  18. package/dist/cjs/old.js +179 -0
  19. package/dist/cjs/plugins/serverBuild.js +32 -30
  20. package/dist/cjs/utils/loadPlugins.js +4 -35
  21. package/dist/cjs/utils/printInstructions.js +11 -2
  22. package/dist/cjs/utils/restart.js +2 -2
  23. package/dist/esm/commands/build.js +12 -18
  24. package/dist/esm/commands/deploy.js +6 -6
  25. package/dist/esm/commands/dev.js +11 -11
  26. package/dist/esm/commands/index.js +8 -8
  27. package/dist/esm/commands/inspect.js +1 -1
  28. package/dist/esm/commands/serve.js +6 -6
  29. package/dist/esm/hooks.js +36 -0
  30. package/dist/esm/index.js +2 -245
  31. package/dist/esm/{compat → new/compat}/hooks.js +25 -15
  32. package/dist/esm/{compat → new/compat}/index.js +1 -4
  33. package/dist/esm/{utils → new}/getConfigFile.js +1 -1
  34. package/dist/esm/new/index.js +55 -0
  35. package/dist/esm/new/loadPlugins.js +94 -0
  36. package/dist/esm/{run/index.js → new/run.js} +6 -6
  37. package/dist/esm/{utils/isAutoLoadPlugins.js → new/utils/index.js} +6 -6
  38. package/dist/esm/old.js +258 -0
  39. package/dist/esm/plugins/serverBuild.js +56 -52
  40. package/dist/esm/utils/loadPlugins.js +7 -95
  41. package/dist/esm/utils/printInstructions.js +28 -1
  42. package/dist/esm/utils/restart.js +3 -3
  43. package/dist/esm-node/commands/build.js +13 -19
  44. package/dist/esm-node/commands/deploy.js +5 -5
  45. package/dist/esm-node/commands/dev.js +12 -12
  46. package/dist/esm-node/commands/index.js +6 -6
  47. package/dist/esm-node/commands/inspect.js +1 -1
  48. package/dist/esm-node/commands/serve.js +5 -5
  49. package/dist/esm-node/hooks.js +36 -0
  50. package/dist/esm-node/index.js +2 -140
  51. package/dist/esm-node/{compat → new/compat}/hooks.js +5 -5
  52. package/dist/esm-node/{compat → new/compat}/index.js +1 -4
  53. package/dist/esm-node/{utils → new}/getConfigFile.js +1 -1
  54. package/dist/esm-node/new/index.js +52 -0
  55. package/dist/esm-node/new/loadPlugins.js +33 -0
  56. package/dist/esm-node/{run/index.js → new/run.js} +6 -6
  57. package/dist/esm-node/{utils/isAutoLoadPlugins.js → new/utils/index.js} +2 -2
  58. package/dist/esm-node/old.js +140 -0
  59. package/dist/esm-node/plugins/serverBuild.js +32 -30
  60. package/dist/esm-node/utils/loadPlugins.js +4 -34
  61. package/dist/esm-node/utils/printInstructions.js +9 -1
  62. package/dist/esm-node/utils/restart.js +2 -2
  63. package/dist/types/commands/build.d.ts +2 -2
  64. package/dist/types/commands/deploy.d.ts +2 -2
  65. package/dist/types/commands/dev.d.ts +2 -2
  66. package/dist/types/commands/index.d.ts +6 -6
  67. package/dist/types/commands/inspect.d.ts +2 -2
  68. package/dist/types/commands/serve.d.ts +2 -2
  69. package/dist/types/hooks.d.ts +2 -0
  70. package/dist/types/index.d.ts +3 -5
  71. package/dist/types/{compat → new/compat}/hooks.d.ts +2 -2
  72. package/dist/types/new/compat/index.d.ts +2 -0
  73. package/dist/types/new/index.d.ts +6 -0
  74. package/dist/types/new/loadPlugins.d.ts +9 -0
  75. package/dist/types/new/utils/index.d.ts +1 -0
  76. package/dist/types/old.d.ts +13 -0
  77. package/dist/types/plugins/serverBuild.d.ts +2 -2
  78. package/dist/types/types/index.d.ts +0 -2
  79. package/dist/types/types/new.d.ts +16 -11
  80. package/dist/types/utils/generateWatchFiles.d.ts +2 -2
  81. package/dist/types/utils/loadPlugins.d.ts +3 -13
  82. package/dist/types/utils/printInstructions.d.ts +3 -1
  83. package/dist/types/utils/restart.d.ts +3 -2
  84. package/package.json +23 -22
  85. package/dist/types/compat/index.d.ts +0 -2
  86. package/dist/types/utils/isAutoLoadPlugins.d.ts +0 -1
  87. /package/dist/cjs/{compat → new/compat}/utils.js +0 -0
  88. /package/dist/cjs/{constants.js → new/constants.js} +0 -0
  89. /package/dist/esm/{compat → new/compat}/utils.js +0 -0
  90. /package/dist/esm/{constants.js → new/constants.js} +0 -0
  91. /package/dist/esm/{utils/initAppContext.js → new/context.js} +0 -0
  92. /package/dist/esm-node/{compat → new/compat}/utils.js +0 -0
  93. /package/dist/esm-node/{constants.js → new/constants.js} +0 -0
  94. /package/dist/esm-node/{utils/initAppContext.js → new/context.js} +0 -0
  95. /package/dist/types/{compat → new/compat}/utils.d.ts +0 -0
  96. /package/dist/types/{constants.d.ts → new/constants.d.ts} +0 -0
  97. /package/dist/types/{utils/initAppContext.d.ts → new/context.d.ts} +0 -0
  98. /package/dist/types/{utils → new}/getConfigFile.d.ts +0 -0
  99. /package/dist/types/{run/index.d.ts → new/run.d.ts} +0 -0
@@ -0,0 +1,258 @@
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
+ };
@@ -21,59 +21,63 @@ function serverBuild_default() {
21
21
  return {
22
22
  name: "@modern-js/server-build",
23
23
  setup: function setup(api) {
24
- api.onAfterBuild(/* @__PURE__ */ _async_to_generator(function() {
25
- var _api_getAppContext, appDirectory, distDirectory, metaName, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
26
- return _ts_generator(this, function(_state) {
27
- switch (_state.label) {
28
- case 0:
29
- _api_getAppContext = api.getAppContext(), appDirectory = _api_getAppContext.appDirectory, distDirectory = _api_getAppContext.distDirectory, metaName = _api_getAppContext.metaName;
30
- if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) {
31
- return [
32
- 2
33
- ];
24
+ return {
25
+ afterBuild: function afterBuild() {
26
+ return _async_to_generator(function() {
27
+ var _api_useAppContext, appDirectory, distDirectory, metaName, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
28
+ return _ts_generator(this, function(_state) {
29
+ switch (_state.label) {
30
+ case 0:
31
+ _api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory, metaName = _api_useAppContext.metaName;
32
+ if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) {
33
+ return [
34
+ 2
35
+ ];
36
+ }
37
+ modernConfig = api.useResolvedConfigContext();
38
+ distDir = path.resolve(distDirectory);
39
+ serverDir = path.resolve(appDirectory, SERVER_DIR);
40
+ sharedDir = path.resolve(appDirectory, SHARED_DIR);
41
+ tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
42
+ sourceDirs = [];
43
+ if (fs.existsSync(serverDir)) {
44
+ sourceDirs.push(serverDir);
45
+ if (fs.existsSync(sharedDir)) {
46
+ sourceDirs.push(sharedDir);
47
+ }
48
+ }
49
+ server = modernConfig.server;
50
+ alias = modernConfig.source.alias;
51
+ babel = modernConfig.tools.babel;
52
+ if (!(sourceDirs.length > 0))
53
+ return [
54
+ 3,
55
+ 2
56
+ ];
57
+ return [
58
+ 4,
59
+ compile(appDirectory, {
60
+ server,
61
+ alias,
62
+ babelConfig: babel
63
+ }, {
64
+ sourceDirs,
65
+ distDir,
66
+ tsconfigPath
67
+ })
68
+ ];
69
+ case 1:
70
+ _state.sent();
71
+ _state.label = 2;
72
+ case 2:
73
+ return [
74
+ 2
75
+ ];
34
76
  }
35
- modernConfig = api.getNormalizedConfig();
36
- distDir = path.resolve(distDirectory);
37
- serverDir = path.resolve(appDirectory, SERVER_DIR);
38
- sharedDir = path.resolve(appDirectory, SHARED_DIR);
39
- tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
40
- sourceDirs = [];
41
- if (fs.existsSync(serverDir)) {
42
- sourceDirs.push(serverDir);
43
- if (fs.existsSync(sharedDir)) {
44
- sourceDirs.push(sharedDir);
45
- }
46
- }
47
- server = modernConfig.server;
48
- alias = modernConfig.source.alias;
49
- babel = modernConfig.tools.babel;
50
- if (!(sourceDirs.length > 0))
51
- return [
52
- 3,
53
- 2
54
- ];
55
- return [
56
- 4,
57
- compile(appDirectory, {
58
- server,
59
- alias,
60
- babelConfig: babel
61
- }, {
62
- sourceDirs,
63
- distDir,
64
- tsconfigPath
65
- })
66
- ];
67
- case 1:
68
- _state.sent();
69
- _state.label = 2;
70
- case 2:
71
- return [
72
- 2
73
- ];
74
- }
75
- });
76
- }));
77
+ });
78
+ })();
79
+ }
80
+ };
77
81
  }
78
82
  };
79
83
  }
@@ -1,24 +1,23 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
5
  import { loadServerPlugins as loadServerPluginInstances } from "@modern-js/prod-server";
5
- import { compatibleRequire, createDebugger, dynamicImport, getInternalPlugins, tryResolve } from "@modern-js/utils";
6
- var debug = createDebugger("load-plugins");
7
6
  function getServerPlugins(api) {
8
7
  return _getServerPlugins.apply(this, arguments);
9
8
  }
10
9
  function _getServerPlugins() {
11
10
  _getServerPlugins = _async_to_generator(function(api) {
12
- var metaName, hooks, plugins, filtedPlugins;
11
+ var metaName, runner, plugins, filtedPlugins;
13
12
  var _arguments = arguments;
14
13
  return _ts_generator(this, function(_state) {
15
14
  switch (_state.label) {
16
15
  case 0:
17
16
  metaName = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "modern-js";
18
- hooks = api.getHooks();
17
+ runner = api.useHookRunners();
19
18
  return [
20
19
  4,
21
- hooks._internalServerPlugins.call({
20
+ runner._internalServerPlugins({
22
21
  plugins: []
23
22
  })
24
23
  ];
@@ -27,9 +26,9 @@ function _getServerPlugins() {
27
26
  filtedPlugins = plugins.filter(function(plugin) {
28
27
  return plugin.name.includes(metaName);
29
28
  });
30
- api.updateAppContext({
29
+ api.setAppContext(_object_spread_props(_object_spread({}, api.useAppContext()), {
31
30
  serverPlugins: filtedPlugins
32
- });
31
+ }));
33
32
  return [
34
33
  2,
35
34
  filtedPlugins
@@ -69,94 +68,7 @@ function _loadServerPlugins() {
69
68
  });
70
69
  return _loadServerPlugins.apply(this, arguments);
71
70
  }
72
- var resolveCliPlugin = function() {
73
- var _ref = _async_to_generator(function(p, appDirectory) {
74
- var pkg, pluginOptions, path, module, e, ref, result;
75
- return _ts_generator(this, function(_state) {
76
- switch (_state.label) {
77
- case 0:
78
- pkg = typeof p === "string" ? p : p[0];
79
- pluginOptions = typeof p === "string" ? void 0 : p[1];
80
- path = tryResolve(pkg, appDirectory);
81
- _state.label = 1;
82
- case 1:
83
- _state.trys.push([
84
- 1,
85
- 3,
86
- ,
87
- 5
88
- ]);
89
- return [
90
- 4,
91
- compatibleRequire(path)
92
- ];
93
- case 2:
94
- module = _state.sent();
95
- return [
96
- 3,
97
- 5
98
- ];
99
- case 3:
100
- e = _state.sent();
101
- return [
102
- 4,
103
- dynamicImport(path)
104
- ];
105
- case 4:
106
- ref = _state.sent(), module = ref.default, ref;
107
- return [
108
- 3,
109
- 5
110
- ];
111
- case 5:
112
- if (typeof module === "function") {
113
- result = module(pluginOptions);
114
- return [
115
- 2,
116
- result
117
- ];
118
- }
119
- return [
120
- 2,
121
- module
122
- ];
123
- }
124
- });
125
- });
126
- return function resolveCliPlugin2(p, appDirectory) {
127
- return _ref.apply(this, arguments);
128
- };
129
- }();
130
- var loadInternalPlugins = function() {
131
- var _ref = _async_to_generator(function(appDirectory, internalPlugins, autoLoad, autoLoadPlugins) {
132
- var plugins, loadedPlugins;
133
- return _ts_generator(this, function(_state) {
134
- switch (_state.label) {
135
- case 0:
136
- plugins = _to_consumable_array(autoLoadPlugins ? getInternalPlugins(appDirectory, internalPlugins) : []).concat(_to_consumable_array(autoLoad ? getInternalPlugins(appDirectory, autoLoad) : []));
137
- return [
138
- 4,
139
- Promise.all(plugins.map(function(plugin) {
140
- var loadedPlugin = resolveCliPlugin(plugin, appDirectory);
141
- debug("resolve plugin %s: %s", plugin, loadedPlugin);
142
- return loadedPlugin;
143
- }))
144
- ];
145
- case 1:
146
- loadedPlugins = _state.sent();
147
- return [
148
- 2,
149
- loadedPlugins
150
- ];
151
- }
152
- });
153
- });
154
- return function loadInternalPlugins2(appDirectory, internalPlugins, autoLoad, autoLoadPlugins) {
155
- return _ref.apply(this, arguments);
156
- };
157
- }();
158
71
  export {
159
72
  getServerPlugins,
160
- loadInternalPlugins,
161
73
  loadServerPlugins
162
74
  };
@@ -27,6 +27,33 @@ var printInstructions = function() {
27
27
  return _ref.apply(this, arguments);
28
28
  };
29
29
  }();
30
+ var printInstructionsCompat = function() {
31
+ var _ref = _async_to_generator(function(hookRunners, appContext, config) {
32
+ var message, instructions;
33
+ return _ts_generator(this, function(_state) {
34
+ switch (_state.label) {
35
+ case 0:
36
+ message = prettyInstructions(appContext, config);
37
+ return [
38
+ 4,
39
+ hookRunners.beforePrintInstructions({
40
+ instructions: message
41
+ })
42
+ ];
43
+ case 1:
44
+ instructions = _state.sent().instructions;
45
+ logger.log(instructions);
46
+ return [
47
+ 2
48
+ ];
49
+ }
50
+ });
51
+ });
52
+ return function printInstructionsCompat2(hookRunners, appContext, config) {
53
+ return _ref.apply(this, arguments);
54
+ };
55
+ }();
30
56
  export {
31
- printInstructions
57
+ printInstructions,
58
+ printInstructionsCompat
32
59
  };
@@ -3,11 +3,11 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { cli } from "@modern-js/plugin-v2/cli";
4
4
  import { chalk, clearConsole, getFullArgv, logger } from "@modern-js/utils";
5
5
  import { program } from "@modern-js/utils/commander";
6
- function restart(hooks, filename) {
6
+ function restart(hooksRunner, filename) {
7
7
  return _restart.apply(this, arguments);
8
8
  }
9
9
  function _restart() {
10
- _restart = _async_to_generator(function(hooks, filename) {
10
+ _restart = _async_to_generator(function(hooksRunner, filename) {
11
11
  var hasGetError, err;
12
12
  return _ts_generator(this, function(_state) {
13
13
  switch (_state.label) {
@@ -17,7 +17,7 @@ function _restart() {
17
17
  hasGetError = false;
18
18
  return [
19
19
  4,
20
- hooks.onBeforeRestart.call()
20
+ hooksRunner.beforeRestart()
21
21
  ];
22
22
  case 1:
23
23
  _state.sent();
@@ -1,3 +1,4 @@
1
+ import { ResolvedConfigContext } from "@modern-js/core";
1
2
  import { logger } from "@modern-js/utils";
2
3
  import { buildServerConfig } from "../utils/config";
3
4
  import { loadServerPlugins } from "../utils/loadPlugins";
@@ -8,9 +9,9 @@ const build = async (api, options) => {
8
9
  if (options === null || options === void 0 ? void 0 : options.analyze) {
9
10
  process.env.BUNDLE_ANALYZE = "true";
10
11
  }
11
- const resolvedConfig = api.getNormalizedConfig();
12
- const appContext = api.getAppContext();
13
- const hooks = api.getHooks();
12
+ let resolvedConfig = api.useResolvedConfigContext();
13
+ const appContext = api.useAppContext();
14
+ const hookRunners = api.useHookRunners();
14
15
  await loadServerPlugins(api, appContext.appDirectory, appContext.metaName);
15
16
  if (appContext.moduleType && appContext.moduleType === "module") {
16
17
  var _resolvedConfig_source1;
@@ -25,12 +26,9 @@ const build = async (api, options) => {
25
26
  const { apiOnly } = appContext;
26
27
  if (apiOnly) {
27
28
  const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
28
- await hooks.onBeforeBuild.call({
29
- environments: {},
29
+ await hookRunners.beforeBuild({
30
30
  // "null" bundlerConfigs
31
- bundlerConfigs: void 0,
32
- isFirstCompile: false,
33
- isWatch: false
31
+ bundlerConfigs: void 0
34
32
  });
35
33
  await buildServerConfig({
36
34
  appDirectory: appDirectory2,
@@ -38,21 +36,17 @@ const build = async (api, options) => {
38
36
  configFile: serverConfigFile2
39
37
  });
40
38
  await generateRoutes(appContext);
41
- await hooks.onAfterBuild.call({
42
- environments: {},
39
+ await hookRunners.afterBuild({
43
40
  // "null" stats
44
- stats: void 0,
45
- isFirstCompile: false,
46
- isWatch: false
41
+ stats: void 0
47
42
  });
48
43
  return;
49
44
  }
50
- api.modifyResolvedConfig((config) => {
51
- return {
52
- ...config,
53
- cliOptions: options
54
- };
55
- });
45
+ resolvedConfig = {
46
+ ...resolvedConfig,
47
+ cliOptions: options
48
+ };
49
+ ResolvedConfigContext.set(resolvedConfig);
56
50
  const { distDirectory, appDirectory, serverConfigFile } = appContext;
57
51
  await buildServerConfig({
58
52
  appDirectory,
@@ -1,11 +1,11 @@
1
1
  import { getServerPlugins } from "../utils/loadPlugins";
2
2
  const deploy = async (api, options) => {
3
- const hooks = api.getHooks();
4
- const { metaName } = api.getAppContext();
3
+ const hookRunners = api.useHookRunners();
4
+ const { metaName } = api.useAppContext();
5
5
  await getServerPlugins(api, metaName);
6
- await hooks.onBeforeDeploy.call(options);
7
- await hooks.deploy.call();
8
- await hooks.onAfterDeploy.call(options);
6
+ await hookRunners.beforeDeploy(options);
7
+ await hookRunners.deploy(options);
8
+ await hookRunners.afterDeploy(options);
9
9
  };
10
10
  export {
11
11
  deploy