@modern-js/app-tools 2.63.5 → 2.63.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.
@@ -115,6 +115,7 @@ const dev = async (api, options, devServerOptions) => {
115
115
  }, () => {
116
116
  (0, import_printInstructions.printInstructions)(hooks, appContext, normalizedConfig);
117
117
  });
118
+ (0, import_createServer.setServer)(server);
118
119
  } else {
119
120
  const { server, afterListen } = await (0, import_server.createDevServer)({
120
121
  ...serverOptions,
@@ -42,6 +42,7 @@ const start = async (api) => {
42
42
  const userConfig = api.getNormalizedConfig();
43
43
  const hooks = api.getHooks();
44
44
  const { distDirectory, appDirectory, internalDirectory, port, metaName, serverRoutes, serverConfigFile } = appContext;
45
+ const { isCrossProjectServer } = (userConfig === null || userConfig === void 0 ? void 0 : userConfig.bff) || {};
45
46
  import_utils.logger.info(`Starting production server...`);
46
47
  const apiOnly = await (0, import_utils.isApiOnly)(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
47
48
  let runMode;
@@ -71,8 +72,8 @@ const start = async (api) => {
71
72
  appDirectory,
72
73
  internalDirectory,
73
74
  sharedDirectory: (0, import_utils.getTargetDir)(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
74
- apiDirectory: (0, import_utils.getTargetDir)(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
75
- lambdaDirectory: (0, import_utils.getTargetDir)(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
75
+ apiDirectory: isCrossProjectServer ? appContext.apiDirectory : (0, import_utils.getTargetDir)(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
76
+ lambdaDirectory: isCrossProjectServer ? appContext.lambdaDirectory : (0, import_utils.getTargetDir)(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
76
77
  },
77
78
  runMode
78
79
  });
@@ -30,9 +30,6 @@ function getHookRunners(context) {
30
30
  /**
31
31
  * app tools hooks
32
32
  */
33
- beforeConfig: async () => {
34
- return hooks.onBeforeConfig.call();
35
- },
36
33
  afterPrepare: async () => {
37
34
  return hooks.onAfterPrepare.call();
38
35
  },
@@ -125,7 +122,7 @@ function getHookRunners(context) {
125
122
  return hooks.onBeforeDev.call();
126
123
  },
127
124
  afterDev: async (params) => {
128
- return hooks.onAfterDev.call(params);
125
+ return hooks.onDevCompileDone.call(params);
129
126
  },
130
127
  beforeDeploy: async (options) => {
131
128
  return hooks.onBeforeDeploy.call(options);
@@ -167,7 +164,7 @@ function handleSetupResult(setupResult, api) {
167
164
  const fn = setupResult[key];
168
165
  if (typeof fn === "function") {
169
166
  const newAPI = (0, import_utils.transformHookRunner)(key);
170
- if (api[newAPI]) {
167
+ if (newAPI && api[newAPI]) {
171
168
  api[newAPI](async (...params) => {
172
169
  const { isMultiple, params: transformParams } = (0, import_utils.transformHookParams)(key, params);
173
170
  if (isMultiple) {
@@ -27,7 +27,8 @@ var import_getHtmlTemplate = require("../plugins/analyze/getHtmlTemplate");
27
27
  function transformHookRunner(hookRunnerName) {
28
28
  switch (hookRunnerName) {
29
29
  case "beforeConfig":
30
- return "onBeforeConfig";
30
+ console.error("The `beforeConfig` hook has been deprecated. Please define your code directly in the setup function instead.");
31
+ return void 0;
31
32
  case "prepare":
32
33
  return "onPrepare";
33
34
  case "afterPrepare":
@@ -55,7 +56,7 @@ function transformHookRunner(hookRunnerName) {
55
56
  case "beforeDev":
56
57
  return "onBeforeDev";
57
58
  case "afterDev":
58
- return "onAfterDev";
59
+ return "onDevCompileDone";
59
60
  case "beforeDeploy":
60
61
  return "onBeforeDeploy";
61
62
  case "afterDeploy":
package/dist/cjs/index.js CHANGED
@@ -34,10 +34,12 @@ __export(src_exports, {
34
34
  defineConfig: () => import_defineConfig.defineConfig,
35
35
  defineLegacyConfig: () => import_defineConfig.defineLegacyConfig,
36
36
  dev: () => import_dev.dev,
37
+ generateWatchFiles: () => import_generateWatchFiles2.generateWatchFiles,
37
38
  initAppContext: () => import_initAppContext.initAppContext,
38
39
  mergeConfig: () => import_core.mergeConfig
39
40
  });
40
41
  module.exports = __toCommonJS(src_exports);
42
+ var import_path = __toESM(require("path"));
41
43
  var import_language_detector = require("@modern-js/plugin-i18n/language-detector");
42
44
  var import_plugin_v2 = require("@modern-js/plugin-v2");
43
45
  var import_uni_builder = require("@modern-js/uni-builder");
@@ -57,6 +59,7 @@ __reExport(src_exports, require("./defineConfig"), module.exports);
57
59
  var import_defineConfig = require("./defineConfig");
58
60
  var import_core = require("@modern-js/core");
59
61
  var import_dev = require("./commands/dev");
62
+ var import_generateWatchFiles2 = require("./utils/generateWatchFiles");
60
63
  __reExport(src_exports, require("./types"), module.exports);
61
64
  const appTools = (options = {
62
65
  // default webpack to be compatible with original projects
@@ -91,7 +94,6 @@ const appTools = (options = {
91
94
  "@modern-js/plugin-polyfill"
92
95
  ],
93
96
  registryHooks: {
94
- onBeforeConfig: (0, import_plugin_v2.createAsyncHook)(),
95
97
  onAfterPrepare: (0, import_plugin_v2.createAsyncHook)(),
96
98
  deploy: (0, import_plugin_v2.createAsyncHook)(),
97
99
  _internalRuntimePlugins: (0, import_plugin_v2.createAsyncHook)(),
@@ -169,7 +171,10 @@ const appTools = (options = {
169
171
  });
170
172
  api.onFileChanged(async (e) => {
171
173
  const { filename, eventType, isPrivate } = e;
172
- if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
174
+ const { appDirectory, apiDirectory } = api.getAppContext();
175
+ const relativeApiPath = import_path.default.relative(appDirectory, apiDirectory);
176
+ const isApiProject = filename.startsWith(`${relativeApiPath}/`);
177
+ if (!isPrivate && (eventType === "change" || eventType === "unlink") && !isApiProject) {
173
178
  const { closeServer } = await import("./utils/createServer.js");
174
179
  await closeServer();
175
180
  await (0, import_restart.restart)(api.getHooks(), filename);
@@ -189,6 +194,7 @@ var src_default = appTools;
189
194
  defineConfig,
190
195
  defineLegacyConfig,
191
196
  dev,
197
+ generateWatchFiles,
192
198
  initAppContext,
193
199
  mergeConfig,
194
200
  ...require("./defineConfig"),
@@ -166,9 +166,11 @@ var analyze_default = ({ bundler }) => ({
166
166
  });
167
167
  await (0, import_config2.emitResolvedConfig)(appContext.appDirectory, normalizedConfig);
168
168
  });
169
- builder.onDevCompileDone(async ({ isFirstCompile }) => {
170
- hooks.onAfterDev.call({
171
- isFirstCompile
169
+ builder.onDevCompileDone(async ({ isFirstCompile, stats, environments }) => {
170
+ hooks.onDevCompileDone.call({
171
+ isFirstCompile,
172
+ stats,
173
+ environments
172
174
  });
173
175
  if (isFirstCompile) {
174
176
  (0, import_printInstructions.printInstructions)(hooks, appContext, normalizedConfig);
@@ -186,6 +188,11 @@ var analyze_default = ({ bundler }) => ({
186
188
  compiler
187
189
  });
188
190
  });
191
+ builder.onAfterStartDevServer(async ({ port }) => {
192
+ await hooks.onAfterDev.call({
193
+ port
194
+ });
195
+ });
189
196
  builder.addPlugins(resolvedConfig.builderPlugins);
190
197
  api.updateAppContext({
191
198
  builder
@@ -134,6 +134,7 @@ var dev = function() {
134
134
  }, function() {
135
135
  printInstructions(hooks, appContext, normalizedConfig);
136
136
  });
137
+ setServer(server);
137
138
  return [
138
139
  3,
139
140
  12
@@ -9,7 +9,7 @@ import { loadServerPlugins } from "../utils/loadPlugins";
9
9
  import { printInstructions } from "../utils/printInstructions";
10
10
  var start = function() {
11
11
  var _ref = _async_to_generator(function(api) {
12
- var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hooks, distDirectory, appDirectory, internalDirectory, port, metaName, serverRoutes, serverConfigFile, apiOnly, runMode, meta, serverConfigPath, pluginInstances, app;
12
+ var _userConfig_source, _userConfig_output_distPath, appContext, userConfig, hooks, distDirectory, appDirectory, internalDirectory, port, metaName, serverRoutes, serverConfigFile, isCrossProjectServer, apiOnly, runMode, meta, serverConfigPath, pluginInstances, app;
13
13
  return _ts_generator(this, function(_state) {
14
14
  switch (_state.label) {
15
15
  case 0:
@@ -17,6 +17,7 @@ var start = function() {
17
17
  userConfig = api.getNormalizedConfig();
18
18
  hooks = api.getHooks();
19
19
  distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, internalDirectory = appContext.internalDirectory, port = appContext.port, metaName = appContext.metaName, serverRoutes = appContext.serverRoutes, serverConfigFile = appContext.serverConfigFile;
20
+ isCrossProjectServer = ((userConfig === null || userConfig === void 0 ? void 0 : userConfig.bff) || {}).isCrossProjectServer;
20
21
  logger.info("Starting production server...");
21
22
  return [
22
23
  4,
@@ -55,8 +56,8 @@ var start = function() {
55
56
  appDirectory,
56
57
  internalDirectory,
57
58
  sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
58
- apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
59
- lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
59
+ apiDirectory: isCrossProjectServer ? appContext.apiDirectory : getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
60
+ lambdaDirectory: isCrossProjectServer ? appContext.lambdaDirectory : getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
60
61
  },
61
62
  runMode
62
63
  })
@@ -9,14 +9,6 @@ function getHookRunners(context) {
9
9
  /**
10
10
  * app tools hooks
11
11
  */
12
- beforeConfig: /* @__PURE__ */ _async_to_generator(function() {
13
- return _ts_generator(this, function(_state) {
14
- return [
15
- 2,
16
- hooks.onBeforeConfig.call()
17
- ];
18
- });
19
- }),
20
12
  afterPrepare: /* @__PURE__ */ _async_to_generator(function() {
21
13
  return _ts_generator(this, function(_state) {
22
14
  return [
@@ -356,7 +348,7 @@ function getHookRunners(context) {
356
348
  return _ts_generator(this, function(_state) {
357
349
  return [
358
350
  2,
359
- hooks.onAfterDev.call(params)
351
+ hooks.onDevCompileDone.call(params)
360
352
  ];
361
353
  });
362
354
  });
@@ -449,7 +441,7 @@ function handleSetupResult(setupResult, api) {
449
441
  var fn = setupResult[key];
450
442
  if (typeof fn === "function") {
451
443
  var newAPI = transformHookRunner(key);
452
- if (api[newAPI]) {
444
+ if (newAPI && api[newAPI]) {
453
445
  api[newAPI](/* @__PURE__ */ _async_to_generator(function() {
454
446
  var _len, params, _key, _transformHookParams, isMultiple, transformParams, _tmp, _tmp1;
455
447
  var _arguments = arguments;
@@ -2,7 +2,8 @@ import { getModifyHtmlPartials } from "../plugins/analyze/getHtmlTemplate";
2
2
  function transformHookRunner(hookRunnerName) {
3
3
  switch (hookRunnerName) {
4
4
  case "beforeConfig":
5
- return "onBeforeConfig";
5
+ console.error("The `beforeConfig` hook has been deprecated. Please define your code directly in the setup function instead.");
6
+ return void 0;
6
7
  case "prepare":
7
8
  return "onPrepare";
8
9
  case "afterPrepare":
@@ -30,7 +31,7 @@ function transformHookRunner(hookRunnerName) {
30
31
  case "beforeDev":
31
32
  return "onBeforeDev";
32
33
  case "afterDev":
33
- return "onAfterDev";
34
+ return "onDevCompileDone";
34
35
  case "beforeDeploy":
35
36
  return "onBeforeDeploy";
36
37
  case "afterDeploy":
package/dist/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
3
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
+ import path from "path";
4
5
  import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
5
6
  import { createAsyncHook, createCollectAsyncHook } from "@modern-js/plugin-v2";
6
7
  import { castArray } from "@modern-js/uni-builder";
@@ -52,7 +53,6 @@ var appTools = function() {
52
53
  "@modern-js/plugin-polyfill"
53
54
  ],
54
55
  registryHooks: {
55
- onBeforeConfig: createAsyncHook(),
56
56
  onAfterPrepare: createAsyncHook(),
57
57
  deploy: createAsyncHook(),
58
58
  _internalRuntimePlugins: createAsyncHook(),
@@ -195,12 +195,15 @@ var appTools = function() {
195
195
  }));
196
196
  api.onFileChanged(function() {
197
197
  var _ref = _async_to_generator(function(e) {
198
- var filename, eventType, isPrivate, closeServer;
198
+ var filename, eventType, isPrivate, _api_getAppContext, appDirectory, apiDirectory, relativeApiPath, isApiProject, closeServer;
199
199
  return _ts_generator(this, function(_state) {
200
200
  switch (_state.label) {
201
201
  case 0:
202
202
  filename = e.filename, eventType = e.eventType, isPrivate = e.isPrivate;
203
- if (!(!isPrivate && (eventType === "change" || eventType === "unlink")))
203
+ _api_getAppContext = api.getAppContext(), appDirectory = _api_getAppContext.appDirectory, apiDirectory = _api_getAppContext.apiDirectory;
204
+ relativeApiPath = path.relative(appDirectory, apiDirectory);
205
+ isApiProject = filename.startsWith("".concat(relativeApiPath, "/"));
206
+ if (!(!isPrivate && (eventType === "change" || eventType === "unlink") && !isApiProject))
204
207
  return [
205
208
  3,
206
209
  4
@@ -246,6 +249,7 @@ var appTools = function() {
246
249
  import { defineConfig, defineLegacyConfig } from "./defineConfig";
247
250
  import { mergeConfig } from "@modern-js/core";
248
251
  import { dev } from "./commands/dev";
252
+ import { generateWatchFiles as generateWatchFiles2 } from "./utils/generateWatchFiles";
249
253
  export * from "./types";
250
254
  var src_default = appTools;
251
255
  export {
@@ -254,6 +258,7 @@ export {
254
258
  defineConfig,
255
259
  defineLegacyConfig,
256
260
  dev,
261
+ generateWatchFiles2 as generateWatchFiles,
257
262
  initAppContext,
258
263
  mergeConfig
259
264
  };
@@ -310,11 +310,13 @@ function analyze_default(param) {
310
310
  }());
311
311
  builder.onDevCompileDone(function() {
312
312
  var _ref5 = _async_to_generator(function(param2) {
313
- var isFirstCompile;
313
+ var isFirstCompile, stats, environments;
314
314
  return _ts_generator(this, function(_state2) {
315
- isFirstCompile = param2.isFirstCompile;
316
- hooks.onAfterDev.call({
317
- isFirstCompile
315
+ isFirstCompile = param2.isFirstCompile, stats = param2.stats, environments = param2.environments;
316
+ hooks.onDevCompileDone.call({
317
+ isFirstCompile,
318
+ stats,
319
+ environments
318
320
  });
319
321
  if (isFirstCompile) {
320
322
  printInstructions(hooks, appContext, normalizedConfig);
@@ -380,6 +382,31 @@ function analyze_default(param) {
380
382
  return _ref5.apply(this, arguments);
381
383
  };
382
384
  }());
385
+ builder.onAfterStartDevServer(function() {
386
+ var _ref5 = _async_to_generator(function(param2) {
387
+ var port;
388
+ return _ts_generator(this, function(_state2) {
389
+ switch (_state2.label) {
390
+ case 0:
391
+ port = param2.port;
392
+ return [
393
+ 4,
394
+ hooks.onAfterDev.call({
395
+ port
396
+ })
397
+ ];
398
+ case 1:
399
+ _state2.sent();
400
+ return [
401
+ 2
402
+ ];
403
+ }
404
+ });
405
+ });
406
+ return function(_2) {
407
+ return _ref5.apply(this, arguments);
408
+ };
409
+ }());
383
410
  builder.addPlugins(resolvedConfig.builderPlugins);
384
411
  api.updateAppContext({
385
412
  builder
@@ -82,6 +82,7 @@ const dev = async (api, options, devServerOptions) => {
82
82
  }, () => {
83
83
  printInstructions(hooks, appContext, normalizedConfig);
84
84
  });
85
+ setServer(server);
85
86
  } else {
86
87
  const { server, afterListen } = await createDevServer({
87
88
  ...serverOptions,
@@ -9,6 +9,7 @@ const start = async (api) => {
9
9
  const userConfig = api.getNormalizedConfig();
10
10
  const hooks = api.getHooks();
11
11
  const { distDirectory, appDirectory, internalDirectory, port, metaName, serverRoutes, serverConfigFile } = appContext;
12
+ const { isCrossProjectServer } = (userConfig === null || userConfig === void 0 ? void 0 : userConfig.bff) || {};
12
13
  logger.info(`Starting production server...`);
13
14
  const apiOnly = await isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
14
15
  let runMode;
@@ -38,8 +39,8 @@ const start = async (api) => {
38
39
  appDirectory,
39
40
  internalDirectory,
40
41
  sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
41
- apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
42
- lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
42
+ apiDirectory: isCrossProjectServer ? appContext.apiDirectory : getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
43
+ lambdaDirectory: isCrossProjectServer ? appContext.lambdaDirectory : getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
43
44
  },
44
45
  runMode
45
46
  });
@@ -6,9 +6,6 @@ function getHookRunners(context) {
6
6
  /**
7
7
  * app tools hooks
8
8
  */
9
- beforeConfig: async () => {
10
- return hooks.onBeforeConfig.call();
11
- },
12
9
  afterPrepare: async () => {
13
10
  return hooks.onAfterPrepare.call();
14
11
  },
@@ -101,7 +98,7 @@ function getHookRunners(context) {
101
98
  return hooks.onBeforeDev.call();
102
99
  },
103
100
  afterDev: async (params) => {
104
- return hooks.onAfterDev.call(params);
101
+ return hooks.onDevCompileDone.call(params);
105
102
  },
106
103
  beforeDeploy: async (options) => {
107
104
  return hooks.onBeforeDeploy.call(options);
@@ -143,7 +140,7 @@ function handleSetupResult(setupResult, api) {
143
140
  const fn = setupResult[key];
144
141
  if (typeof fn === "function") {
145
142
  const newAPI = transformHookRunner(key);
146
- if (api[newAPI]) {
143
+ if (newAPI && api[newAPI]) {
147
144
  api[newAPI](async (...params) => {
148
145
  const { isMultiple, params: transformParams } = transformHookParams(key, params);
149
146
  if (isMultiple) {
@@ -2,7 +2,8 @@ import { getModifyHtmlPartials } from "../plugins/analyze/getHtmlTemplate";
2
2
  function transformHookRunner(hookRunnerName) {
3
3
  switch (hookRunnerName) {
4
4
  case "beforeConfig":
5
- return "onBeforeConfig";
5
+ console.error("The `beforeConfig` hook has been deprecated. Please define your code directly in the setup function instead.");
6
+ return void 0;
6
7
  case "prepare":
7
8
  return "onPrepare";
8
9
  case "afterPrepare":
@@ -30,7 +31,7 @@ function transformHookRunner(hookRunnerName) {
30
31
  case "beforeDev":
31
32
  return "onBeforeDev";
32
33
  case "afterDev":
33
- return "onAfterDev";
34
+ return "onDevCompileDone";
34
35
  case "beforeDeploy":
35
36
  return "onBeforeDeploy";
36
37
  case "afterDeploy":
@@ -1,3 +1,4 @@
1
+ import path from "path";
1
2
  import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
2
3
  import { createAsyncHook, createCollectAsyncHook } from "@modern-js/plugin-v2";
3
4
  import { castArray } from "@modern-js/uni-builder";
@@ -47,7 +48,6 @@ const appTools = (options = {
47
48
  "@modern-js/plugin-polyfill"
48
49
  ],
49
50
  registryHooks: {
50
- onBeforeConfig: createAsyncHook(),
51
51
  onAfterPrepare: createAsyncHook(),
52
52
  deploy: createAsyncHook(),
53
53
  _internalRuntimePlugins: createAsyncHook(),
@@ -125,7 +125,10 @@ const appTools = (options = {
125
125
  });
126
126
  api.onFileChanged(async (e) => {
127
127
  const { filename, eventType, isPrivate } = e;
128
- if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
128
+ const { appDirectory, apiDirectory } = api.getAppContext();
129
+ const relativeApiPath = path.relative(appDirectory, apiDirectory);
130
+ const isApiProject = filename.startsWith(`${relativeApiPath}/`);
131
+ if (!isPrivate && (eventType === "change" || eventType === "unlink") && !isApiProject) {
129
132
  const { closeServer } = await import("./utils/createServer.js");
130
133
  await closeServer();
131
134
  await restart(api.getHooks(), filename);
@@ -141,6 +144,7 @@ const appTools = (options = {
141
144
  import { defineConfig, defineLegacyConfig } from "./defineConfig";
142
145
  import { mergeConfig } from "@modern-js/core";
143
146
  import { dev } from "./commands/dev";
147
+ import { generateWatchFiles as generateWatchFiles2 } from "./utils/generateWatchFiles";
144
148
  export * from "./types";
145
149
  var src_default = appTools;
146
150
  export {
@@ -149,6 +153,7 @@ export {
149
153
  defineConfig,
150
154
  defineLegacyConfig,
151
155
  dev,
156
+ generateWatchFiles2 as generateWatchFiles,
152
157
  initAppContext,
153
158
  mergeConfig
154
159
  };
@@ -133,9 +133,11 @@ var analyze_default = ({ bundler }) => ({
133
133
  });
134
134
  await emitResolvedConfig(appContext.appDirectory, normalizedConfig);
135
135
  });
136
- builder.onDevCompileDone(async ({ isFirstCompile }) => {
137
- hooks.onAfterDev.call({
138
- isFirstCompile
136
+ builder.onDevCompileDone(async ({ isFirstCompile, stats, environments }) => {
137
+ hooks.onDevCompileDone.call({
138
+ isFirstCompile,
139
+ stats,
140
+ environments
139
141
  });
140
142
  if (isFirstCompile) {
141
143
  printInstructions(hooks, appContext, normalizedConfig);
@@ -153,6 +155,11 @@ var analyze_default = ({ bundler }) => ({
153
155
  compiler
154
156
  });
155
157
  });
158
+ builder.onAfterStartDevServer(async ({ port }) => {
159
+ await hooks.onAfterDev.call({
160
+ port
161
+ });
162
+ });
156
163
  builder.addPlugins(resolvedConfig.builderPlugins);
157
164
  api.updateAppContext({
158
165
  builder
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Maps old plugin hook function names to new plugin API names
3
3
  */
4
- export declare function transformHookRunner(hookRunnerName: string): string;
4
+ export declare function transformHookRunner(hookRunnerName: string): string | undefined;
5
5
  /**
6
6
  * Note:
7
7
  * isMultiple Indicates whether the function parameter represents multiple values.
@@ -7,6 +7,7 @@ export { mergeConfig } from '@modern-js/core';
7
7
  export type { RuntimeUserConfig } from './types/config';
8
8
  export { dev } from './commands/dev';
9
9
  export type { DevOptions } from './utils/types';
10
+ export { generateWatchFiles } from './utils/generateWatchFiles';
10
11
  export * from './types';
11
12
  export { initAppContext };
12
13
  export default appTools;
@@ -7,7 +7,6 @@ import type { getHookRunners } from '../compat/hooks';
7
7
  import type { AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
8
8
  import type { RuntimePlugin } from './hooks';
9
9
  import type { Bundler } from './utils';
10
- export type BeforeConfigFn = () => Promise<void> | void;
11
10
  export type AfterPrepareFn = () => Promise<void> | void;
12
11
  export type InternalRuntimePluginsFn = TransformFunction<{
13
12
  entrypoint: Entrypoint;
@@ -45,7 +44,6 @@ export type RegisterDevFn = () => Promise<DevToolData> | DevToolData;
45
44
  export type RegisterBuildPlatformFn = () => Promise<RegisterBuildPlatformResult> | RegisterBuildPlatformResult;
46
45
  export type AddRuntimeExportsFn = () => Promise<void> | void;
47
46
  export interface AppToolsExtendAPI<B extends Bundler = 'webpack'> {
48
- onBeforeConfig: PluginHookTap<BeforeConfigFn>;
49
47
  onAfterPrepare: PluginHookTap<AfterPrepareFn>;
50
48
  deploy: PluginHookTap<DeplpoyFn>;
51
49
  _internalRuntimePlugins: PluginHookTap<InternalRuntimePluginsFn>;
@@ -90,7 +88,6 @@ export interface AppToolsExtendAPI<B extends Bundler = 'webpack'> {
90
88
  useHookRunners: () => ReturnType<typeof getHookRunners>;
91
89
  }
92
90
  export interface AppToolsExtendHooks extends Record<string, PluginHook<(...args: any[]) => any>> {
93
- onBeforeConfig: AsyncHook<BeforeConfigFn>;
94
91
  onAfterPrepare: AsyncHook<AfterPrepareFn>;
95
92
  deploy: AsyncHook<DeplpoyFn>;
96
93
  _internalRuntimePlugins: AsyncHook<InternalRuntimePluginsFn>;
@@ -155,4 +152,4 @@ export interface AppToolsExtendContext<B extends Bundler = 'webpack'> {
155
152
  toolsType?: string;
156
153
  }
157
154
  export type AppToolsContext<B extends Bundler = 'webpack'> = AppContext<AppTools<B>> & AppToolsExtendContext<B>;
158
- export type AppToolsHooks<B extends Bundler = 'webpack'> = Hooks<AppToolsUserConfig<B>, AppToolsNormalizedConfig> & AppToolsExtendHooks;
155
+ export type AppToolsHooks<B extends Bundler = 'webpack'> = Hooks<AppToolsUserConfig<B>, AppToolsNormalizedConfig, {}> & AppToolsExtendHooks;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.63.5",
18
+ "version": "2.63.7",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -90,22 +90,22 @@
90
90
  "flatted": "^3.2.9",
91
91
  "mlly": "^1.6.1",
92
92
  "pkg-types": "^1.1.0",
93
- "ndepe": "0.1.4",
93
+ "ndepe": "0.1.5",
94
94
  "std-env": "^3.7.0",
95
- "@modern-js/core": "2.63.5",
96
- "@modern-js/node-bundle-require": "2.63.5",
97
- "@modern-js/plugin": "2.63.5",
98
- "@modern-js/plugin-data-loader": "2.63.5",
99
- "@modern-js/plugin-i18n": "2.63.5",
100
- "@modern-js/prod-server": "2.63.5",
101
- "@modern-js/plugin-v2": "2.63.5",
102
- "@modern-js/server": "2.63.5",
103
- "@modern-js/rsbuild-plugin-esbuild": "2.63.5",
104
- "@modern-js/server-utils": "2.63.5",
105
- "@modern-js/types": "2.63.5",
106
- "@modern-js/uni-builder": "2.63.5",
107
- "@modern-js/server-core": "2.63.5",
108
- "@modern-js/utils": "2.63.5"
95
+ "@modern-js/core": "2.63.7",
96
+ "@modern-js/node-bundle-require": "2.63.7",
97
+ "@modern-js/plugin-data-loader": "2.63.7",
98
+ "@modern-js/plugin-i18n": "2.63.7",
99
+ "@modern-js/plugin-v2": "2.63.7",
100
+ "@modern-js/plugin": "2.63.7",
101
+ "@modern-js/prod-server": "2.63.7",
102
+ "@modern-js/rsbuild-plugin-esbuild": "2.63.7",
103
+ "@modern-js/server": "2.63.7",
104
+ "@modern-js/server-core": "2.63.7",
105
+ "@modern-js/server-utils": "2.63.7",
106
+ "@modern-js/uni-builder": "2.63.7",
107
+ "@modern-js/utils": "2.63.7",
108
+ "@modern-js/types": "2.63.7"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@rsbuild/plugin-webpack-swc": "1.0.9",
@@ -117,8 +117,8 @@
117
117
  "tsconfig-paths": "^4.2.0",
118
118
  "typescript": "^5",
119
119
  "webpack": "^5.97.1",
120
- "@scripts/build": "2.63.5",
121
- "@scripts/jest-config": "2.63.5"
120
+ "@scripts/build": "2.63.7",
121
+ "@scripts/jest-config": "2.63.7"
122
122
  },
123
123
  "peerDependencies": {
124
124
  "ts-node": "^10.7.0",