@modern-js/plugin-v2 0.0.0-nightly-20250123160326 → 0.0.0-nightly-20250127160318

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.
@@ -25,7 +25,8 @@ __export(cli_exports, {
25
25
  initAppContext: () => import_context.initAppContext,
26
26
  initAppDir: () => import_run.initAppDir,
27
27
  initHooks: () => import_hooks.initHooks,
28
- initPluginAPI: () => import_api.initPluginAPI
28
+ initPluginAPI: () => import_api.initPluginAPI,
29
+ loadEnv: () => import_run.loadEnv
29
30
  });
30
31
  module.exports = __toCommonJS(cli_exports);
31
32
  var import_api = require("./api");
@@ -41,5 +42,6 @@ var import_run = require("./run");
41
42
  initAppContext,
42
43
  initAppDir,
43
44
  initHooks,
44
- initPluginAPI
45
+ initPluginAPI,
46
+ loadEnv
45
47
  });
@@ -37,6 +37,23 @@ const debug = (0, import_utils.createDebugger)("plugin-v2");
37
37
  const createCli = () => {
38
38
  let initOptions;
39
39
  const pluginManager = (0, import_manager.createPluginManager)();
40
+ const existListenerMap = /* @__PURE__ */ new Map();
41
+ function createExistListener(event, context) {
42
+ return async function(err) {
43
+ await context.hooks.onBeforeExit.call();
44
+ let hasError = false;
45
+ if (err instanceof Error) {
46
+ import_utils.logger.error(err.stack);
47
+ hasError = true;
48
+ } else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
49
+ console.trace("Unknown Error", err);
50
+ hasError = true;
51
+ }
52
+ process.nextTick(() => {
53
+ process.exit(hasError ? 1 : 0);
54
+ });
55
+ };
56
+ }
40
57
  async function init(options) {
41
58
  var _context_hooks_onAfterPrepare, _context_hooks;
42
59
  pluginManager.clear();
@@ -84,20 +101,12 @@ const createCli = () => {
84
101
  "unhandledRejection",
85
102
  "uncaughtException"
86
103
  ].forEach((event) => {
87
- process.on(event, async (err) => {
88
- await context.hooks.onBeforeExit.call();
89
- let hasError = false;
90
- if (err instanceof Error) {
91
- import_utils.logger.error(err.stack);
92
- hasError = true;
93
- } else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
94
- console.trace("Unknown Error", err);
95
- hasError = true;
96
- }
97
- process.nextTick(() => {
98
- process.exit(hasError ? 1 : 0);
99
- });
100
- });
104
+ if (existListenerMap.get(event)) {
105
+ process.off(event, existListenerMap.get(event));
106
+ }
107
+ const existListener = createExistListener(event, context);
108
+ existListenerMap.set(event, existListener);
109
+ process.on(event, existListener);
101
110
  });
102
111
  const extraConfigs = await context.hooks.config.call();
103
112
  const normalizedConfig = await (0, import_createResolvedConfig.createResolveConfig)(loaded, extraConfigs);
@@ -21,11 +21,13 @@ __export(run_exports, {
21
21
  cli: () => cli,
22
22
  createCli: () => import_create.createCli,
23
23
  createLoadedConfig: () => import_createLoadedConfig.createLoadedConfig,
24
- initAppDir: () => import_initAppDir.initAppDir
24
+ initAppDir: () => import_initAppDir.initAppDir,
25
+ loadEnv: () => import_loadEnv.loadEnv
25
26
  });
26
27
  module.exports = __toCommonJS(run_exports);
27
28
  var import_create = require("./create");
28
29
  var import_createLoadedConfig = require("./config/createLoadedConfig");
30
+ var import_loadEnv = require("./utils/loadEnv");
29
31
  var import_initAppDir = require("./utils/initAppDir");
30
32
  const cli = (0, import_create.createCli)();
31
33
  // Annotate the CommonJS export names for ESM import in node:
@@ -33,5 +35,6 @@ const cli = (0, import_create.createCli)();
33
35
  cli,
34
36
  createCli,
35
37
  createLoadedConfig,
36
- initAppDir
38
+ initAppDir,
39
+ loadEnv
37
40
  });
@@ -1,7 +1,7 @@
1
1
  import { initPluginAPI } from "./api";
2
2
  import { initAppContext, createContext } from "./context";
3
3
  import { initHooks } from "./hooks";
4
- import { cli, createLoadedConfig, initAppDir, createCli } from "./run";
4
+ import { cli, createLoadedConfig, initAppDir, createCli, loadEnv } from "./run";
5
5
  export {
6
6
  cli,
7
7
  createCli,
@@ -10,5 +10,6 @@ export {
10
10
  initAppContext,
11
11
  initAppDir,
12
12
  initHooks,
13
- initPluginAPI
13
+ initPluginAPI,
14
+ loadEnv
14
15
  };
@@ -16,6 +16,41 @@ import { initAppDir } from "./utils/initAppDir";
16
16
  import { loadEnv } from "./utils/loadEnv";
17
17
  var debug = createDebugger("plugin-v2");
18
18
  var createCli = function() {
19
+ var createExistListener = function createExistListener2(event, context) {
20
+ return function() {
21
+ var _ref = _async_to_generator(function(err) {
22
+ var hasError;
23
+ return _ts_generator(this, function(_state) {
24
+ switch (_state.label) {
25
+ case 0:
26
+ return [
27
+ 4,
28
+ context.hooks.onBeforeExit.call()
29
+ ];
30
+ case 1:
31
+ _state.sent();
32
+ hasError = false;
33
+ if (_instanceof(err, Error)) {
34
+ logger.error(err.stack);
35
+ hasError = true;
36
+ } else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
37
+ console.trace("Unknown Error", err);
38
+ hasError = true;
39
+ }
40
+ process.nextTick(function() {
41
+ process.exit(hasError ? 1 : 0);
42
+ });
43
+ return [
44
+ 2
45
+ ];
46
+ }
47
+ });
48
+ });
49
+ return function(err) {
50
+ return _ref.apply(this, arguments);
51
+ };
52
+ }();
53
+ };
19
54
  var init = function init2(options) {
20
55
  return _init.apply(this, arguments);
21
56
  };
@@ -24,6 +59,7 @@ var createCli = function() {
24
59
  };
25
60
  var initOptions;
26
61
  var pluginManager = createPluginManager();
62
+ var existListenerMap = /* @__PURE__ */ new Map();
27
63
  function _init() {
28
64
  _init = _async_to_generator(function(options) {
29
65
  var _context_hooks_onAfterPrepare, _context_hooks, _options_metaName, metaName, configFile, config, command, version, packageJsonConfig, internalPlugins, handleSetupResult, appDirectory, loaded, allPlugins, plugins, context, pluginAPI, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _plugin_setup, setupResult, err, extraConfigs, normalizedConfig, resolved;
@@ -158,39 +194,12 @@ var createCli = function() {
158
194
  "unhandledRejection",
159
195
  "uncaughtException"
160
196
  ].forEach(function(event) {
161
- process.on(event, function() {
162
- var _ref = _async_to_generator(function(err2) {
163
- var hasError;
164
- return _ts_generator(this, function(_state2) {
165
- switch (_state2.label) {
166
- case 0:
167
- return [
168
- 4,
169
- context.hooks.onBeforeExit.call()
170
- ];
171
- case 1:
172
- _state2.sent();
173
- hasError = false;
174
- if (_instanceof(err2, Error)) {
175
- logger.error(err2.stack);
176
- hasError = true;
177
- } else if (err2 && (event === "unhandledRejection" || event === "uncaughtException")) {
178
- console.trace("Unknown Error", err2);
179
- hasError = true;
180
- }
181
- process.nextTick(function() {
182
- process.exit(hasError ? 1 : 0);
183
- });
184
- return [
185
- 2
186
- ];
187
- }
188
- });
189
- });
190
- return function(err2) {
191
- return _ref.apply(this, arguments);
192
- };
193
- }());
197
+ if (existListenerMap.get(event)) {
198
+ process.off(event, existListenerMap.get(event));
199
+ }
200
+ var existListener = createExistListener(event, context);
201
+ existListenerMap.set(event, existListener);
202
+ process.on(event, existListener);
194
203
  });
195
204
  return [
196
205
  4,
@@ -1,10 +1,12 @@
1
1
  import { createCli } from "./create";
2
2
  import { createLoadedConfig } from "./config/createLoadedConfig";
3
+ import { loadEnv } from "./utils/loadEnv";
3
4
  import { initAppDir } from "./utils/initAppDir";
4
5
  var cli = createCli();
5
6
  export {
6
7
  cli,
7
8
  createCli,
8
9
  createLoadedConfig,
9
- initAppDir
10
+ initAppDir,
11
+ loadEnv
10
12
  };
@@ -1,7 +1,7 @@
1
1
  import { initPluginAPI } from "./api";
2
2
  import { initAppContext, createContext } from "./context";
3
3
  import { initHooks } from "./hooks";
4
- import { cli, createLoadedConfig, initAppDir, createCli } from "./run";
4
+ import { cli, createLoadedConfig, initAppDir, createCli, loadEnv } from "./run";
5
5
  export {
6
6
  cli,
7
7
  createCli,
@@ -10,5 +10,6 @@ export {
10
10
  initAppContext,
11
11
  initAppDir,
12
12
  initHooks,
13
- initPluginAPI
13
+ initPluginAPI,
14
+ loadEnv
14
15
  };
@@ -14,6 +14,23 @@ const debug = createDebugger("plugin-v2");
14
14
  const createCli = () => {
15
15
  let initOptions;
16
16
  const pluginManager = createPluginManager();
17
+ const existListenerMap = /* @__PURE__ */ new Map();
18
+ function createExistListener(event, context) {
19
+ return async function(err) {
20
+ await context.hooks.onBeforeExit.call();
21
+ let hasError = false;
22
+ if (err instanceof Error) {
23
+ logger.error(err.stack);
24
+ hasError = true;
25
+ } else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
26
+ console.trace("Unknown Error", err);
27
+ hasError = true;
28
+ }
29
+ process.nextTick(() => {
30
+ process.exit(hasError ? 1 : 0);
31
+ });
32
+ };
33
+ }
17
34
  async function init(options) {
18
35
  var _context_hooks_onAfterPrepare, _context_hooks;
19
36
  pluginManager.clear();
@@ -61,20 +78,12 @@ const createCli = () => {
61
78
  "unhandledRejection",
62
79
  "uncaughtException"
63
80
  ].forEach((event) => {
64
- process.on(event, async (err) => {
65
- await context.hooks.onBeforeExit.call();
66
- let hasError = false;
67
- if (err instanceof Error) {
68
- logger.error(err.stack);
69
- hasError = true;
70
- } else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
71
- console.trace("Unknown Error", err);
72
- hasError = true;
73
- }
74
- process.nextTick(() => {
75
- process.exit(hasError ? 1 : 0);
76
- });
77
- });
81
+ if (existListenerMap.get(event)) {
82
+ process.off(event, existListenerMap.get(event));
83
+ }
84
+ const existListener = createExistListener(event, context);
85
+ existListenerMap.set(event, existListener);
86
+ process.on(event, existListener);
78
87
  });
79
88
  const extraConfigs = await context.hooks.config.call();
80
89
  const normalizedConfig = await createResolveConfig(loaded, extraConfigs);
@@ -1,10 +1,12 @@
1
1
  import { createCli } from "./create";
2
2
  import { createLoadedConfig } from "./config/createLoadedConfig";
3
+ import { loadEnv } from "./utils/loadEnv";
3
4
  import { initAppDir } from "./utils/initAppDir";
4
5
  const cli = createCli();
5
6
  export {
6
7
  cli,
7
8
  createCli,
8
9
  createLoadedConfig,
9
- initAppDir
10
+ initAppDir,
11
+ loadEnv
10
12
  };
@@ -2,7 +2,7 @@ import type { OnAfterBuildFn, OnAfterCreateCompilerFn, OnBeforeBuildFn, OnBefore
2
2
  import type { AddCommandFn, AddWatchFilesFn, ConfigFn, ModifyBundlerChainFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterDeployFn, OnAfterDevFn, OnBeforeDeployFn, OnBeforeDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn } from '../types/cli/hooks';
3
3
  import type { DeepPartial } from '../types/utils';
4
4
  export type { OnAfterBuildFn, OnAfterCreateCompilerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, AddCommandFn, AddWatchFilesFn, ConfigFn, ModifyBundlerChainFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterDeployFn, OnBeforeDeployFn, OnBeforeDevFn, OnAfterDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn, };
5
- export declare function initHooks<Config, NormalizedConfig, ExtendBuildUtils>(): {
5
+ export declare function initHooks<Config, NormalizedConfig, ExtendBuildUtils, ExtendConfigUtils>(): {
6
6
  /**
7
7
  * add config for this cli plugin
8
8
  */
@@ -11,11 +11,11 @@ export declare function initHooks<Config, NormalizedConfig, ExtendBuildUtils>():
11
11
  * @private
12
12
  * modify config for this cli plugin
13
13
  */
14
- modifyConfig: import("..").AsyncHook<ModifyConfigFn<Config>>;
14
+ modifyConfig: import("..").AsyncHook<ModifyConfigFn<Config, ExtendConfigUtils>>;
15
15
  /**
16
16
  * modify final config
17
17
  */
18
- modifyResolvedConfig: import("..").AsyncHook<ModifyResolvedConfigFn<NormalizedConfig>>;
18
+ modifyResolvedConfig: import("..").AsyncHook<ModifyResolvedConfigFn<NormalizedConfig, ExtendConfigUtils>>;
19
19
  modifyRsbuildConfig: import("..").AsyncHook<ModifyRsbuildConfigFn<ExtendBuildUtils>>;
20
20
  modifyBundlerChain: import("..").AsyncHook<ModifyBundlerChainFn<ExtendBuildUtils>>;
21
21
  modifyRspackConfig: import("..").AsyncHook<ModifyRspackConfigFn<ExtendBuildUtils>>;
@@ -38,4 +38,4 @@ export declare function initHooks<Config, NormalizedConfig, ExtendBuildUtils>():
38
38
  onAfterDeploy: import("..").AsyncHook<OnAfterDeployFn>;
39
39
  onBeforeExit: import("..").AsyncHook<OnBeforeExitFn>;
40
40
  };
41
- export type Hooks<Config, NormalizedConfig, ExtendBuildUtils> = ReturnType<typeof initHooks<Config, NormalizedConfig, ExtendBuildUtils>>;
41
+ export type Hooks<Config, NormalizedConfig, ExtendBuildUtils, ExtendConfigUtils> = ReturnType<typeof initHooks<Config, NormalizedConfig, ExtendBuildUtils, ExtendConfigUtils>>;
@@ -1,4 +1,4 @@
1
1
  export { initPluginAPI } from './api';
2
2
  export { initAppContext, createContext } from './context';
3
3
  export { initHooks, type Hooks, type OnAfterBuildFn, type OnAfterCreateCompilerFn, type OnBeforeBuildFn, type OnBeforeCreateCompilerFn, type OnDevCompileDoneFn, type AddCommandFn, type AddWatchFilesFn, type ConfigFn, type ModifyBundlerChainFn, type ModifyConfigFn, type ModifyHtmlPartialsFn, type ModifyResolvedConfigFn, type ModifyRsbuildConfigFn, type ModifyRspackConfigFn, type ModifyWebpackChainFn, type ModifyWebpackConfigFn, type OnAfterDeployFn, type OnBeforeDeployFn, type OnBeforeDevFn, type OnAfterDevFn, type OnBeforeExitFn, type OnBeforeRestartFn, type OnFileChangedFn, type OnPrepareFn, } from './hooks';
4
- export { cli, createLoadedConfig, initAppDir, createCli } from './run';
4
+ export { cli, createLoadedConfig, initAppDir, createCli, loadEnv } from './run';
@@ -1,8 +1,9 @@
1
+ import type { InternalContext } from '../../types/cli/context';
1
2
  import type { CLIPluginExtends } from '../../types/cli/plugin';
2
3
  import type { CLIRunOptions } from './types';
3
4
  export declare const createCli: <Extends extends CLIPluginExtends>() => {
4
5
  init: (options: CLIRunOptions<Extends>) => Promise<{
5
- appContext: import("../..").InternalContext<Extends>;
6
+ appContext: InternalContext<Extends>;
6
7
  }>;
7
8
  run: (options: CLIRunOptions<Extends>) => Promise<void>;
8
9
  getPrevInitOptions: () => CLIRunOptions<Extends>;
@@ -1,11 +1,12 @@
1
1
  import { createCli } from './create';
2
2
  export { createLoadedConfig } from './config/createLoadedConfig';
3
+ export { loadEnv } from './utils/loadEnv';
3
4
  export { initAppDir } from './utils/initAppDir';
4
5
  export { createCli };
5
6
  export declare const cli: {
6
- init: (options: import("./types").CLIRunOptions<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}>>) => Promise<{
7
- appContext: import("../..").InternalContext<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}>>;
7
+ init: (options: import("./types").CLIRunOptions<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}, {}>>) => Promise<{
8
+ appContext: import("../..").InternalContext<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}, {}>>;
8
9
  }>;
9
- run: (options: import("./types").CLIRunOptions<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}>>) => Promise<void>;
10
- getPrevInitOptions: () => import("./types").CLIRunOptions<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}>>;
10
+ run: (options: import("./types").CLIRunOptions<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}, {}>>) => Promise<void>;
11
+ getPrevInitOptions: () => import("./types").CLIRunOptions<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}, {}>>;
11
12
  };
@@ -13,11 +13,11 @@ export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
13
13
  getAppContext: () => Readonly<AppContext<Extends> & Extends['extendContext']>;
14
14
  getConfig: () => Readonly<Extends['config']>;
15
15
  getNormalizedConfig: () => Readonly<Extends['normalizedConfig']>;
16
- getHooks: () => Readonly<Hooks<Extends['config'], Extends['normalizedConfig'], Extends['extendBuildUtils']> & Extends['extendHooks']>;
16
+ getHooks: () => Readonly<Hooks<Extends['config'], Extends['normalizedConfig'], Extends['extendBuildUtils'], Extends['extendConfigUtils']> & Extends['extendHooks']>;
17
17
  updateAppContext: (appContext: DeepPartial<AppContext<Extends> & Extends['extendContext']>) => void;
18
18
  config: PluginHookTap<ConfigFn<DeepPartial<Extends['config']>>>;
19
- modifyConfig: PluginHookTap<ModifyConfigFn<Extends['config']>>;
20
- modifyResolvedConfig: PluginHookTap<ModifyResolvedConfigFn<Extends['normalizedConfig']>>;
19
+ modifyConfig: PluginHookTap<ModifyConfigFn<Extends['config'], Extends['extendConfigUtils']>>;
20
+ modifyResolvedConfig: PluginHookTap<ModifyResolvedConfigFn<Extends['normalizedConfig'], Extends['extendConfigUtils']>>;
21
21
  modifyRsbuildConfig: PluginHookTap<ModifyRsbuildConfigFn<Extends['extendBuildUtils']>>;
22
22
  modifyBundlerChain: PluginHookTap<ModifyBundlerChainFn<Extends['extendBuildUtils']>>;
23
23
  /** Only works when bundler is Rspack */
@@ -28,7 +28,7 @@ export type AppContext<Extends extends CLIPluginExtends> = {
28
28
  /** The inner context. */
29
29
  export type InternalContext<Extends extends CLIPluginExtends> = AppContext<Extends> & {
30
30
  /** All hooks. */
31
- hooks: Hooks<Extends['config'], Extends['normalizedConfig'], Extends['extendBuildUtils']> & Extends['extendHooks'];
31
+ hooks: Hooks<Extends['config'], Extends['normalizedConfig'], Extends['extendBuildUtils'], Extends['extendConfigUtils']> & Extends['extendHooks'];
32
32
  /** All plugin registry hooks */
33
33
  extendsHooks: Extends['extendHooks'];
34
34
  /** Current App config. */
@@ -1,7 +1,6 @@
1
1
  import type { WebpackConfig } from '@modern-js/uni-builder';
2
2
  import type { Command } from '@modern-js/utils/commander';
3
3
  import type { ModifyBundlerChainUtils, ModifyRspackConfigUtils, ModifyWebpackChainUtils, ModifyWebpackConfigUtils, RsbuildConfig, Rspack, RspackChain } from '@rsbuild/core';
4
- import type { TransformFunction } from '../plugin';
5
4
  import type { MaybePromise } from '../utils';
6
5
  import type { Entrypoint } from './context';
7
6
  declare module '@modern-js/utils/commander' {
@@ -9,9 +8,9 @@ declare module '@modern-js/utils/commander' {
9
8
  commandsMap: Map<string, Command>;
10
9
  }
11
10
  }
12
- export type ConfigFn<Config> = () => Config;
13
- export type ModifyConfigFn<Config> = TransformFunction<Config>;
14
- export type ModifyResolvedConfigFn<NormalizedConfig> = TransformFunction<NormalizedConfig>;
11
+ export type ConfigFn<Config> = () => Config | Promise<Config>;
12
+ export type ModifyConfigFn<Config, ExtendConfigUtils> = (arg: Config, utils?: ExtendConfigUtils) => Config | Promise<Config>;
13
+ export type ModifyResolvedConfigFn<NormalizedConfig, ExtendConfigUtils> = (arg: NormalizedConfig, utils?: ExtendConfigUtils) => NormalizedConfig | Promise<NormalizedConfig>;
15
14
  type IPartialMethod = (...script: string[]) => void;
16
15
  export interface PartialMethod {
17
16
  append: IPartialMethod;
@@ -44,8 +43,8 @@ export type OnBeforeDevFn = () => Promise<void> | void;
44
43
  export type OnAfterDevFn = (params: {
45
44
  port: number;
46
45
  }) => Promise<void> | void;
47
- export type OnBeforeDeployFn = (options: Record<string, any>) => Promise<void> | void;
48
- export type OnAfterDeployFn = (options: Record<string, any>) => Promise<void> | void;
46
+ export type OnBeforeDeployFn = (options?: Record<string, any>) => Promise<void> | void;
47
+ export type OnAfterDeployFn = (options?: Record<string, any>) => Promise<void> | void;
49
48
  export type OnBeforeExitFn = () => void;
50
49
  export type ModifyBundlerChainFn<ExtendsUtils> = (chain: RspackChain, utils: ModifyBundlerChainUtils & ExtendsUtils) => MaybePromise<void>;
51
50
  export type ModifyRsbuildConfigUtils = {
@@ -2,13 +2,14 @@ import type { PluginHook } from '../hooks';
2
2
  import type { Plugin } from '../plugin';
3
3
  import type { CLIPluginAPI } from './api';
4
4
  import type { AppContext } from './context';
5
- export interface CLIPluginExtends<Config extends Record<string, any> = {}, NormalizedConfig extends Record<string, any> = {}, ExtendContext extends Record<string, any> = {}, ExtendAPI extends Record<string, any> = {}, ExtendHook extends Record<string, PluginHook<(...args: any[]) => any>> = {}, ExtendBuildUtils extends Record<string, any> = {}> {
5
+ export interface CLIPluginExtends<Config extends Record<string, any> = {}, NormalizedConfig extends Record<string, any> = {}, ExtendContext extends Record<string, any> = {}, ExtendAPI extends Record<string, any> = {}, ExtendHook extends Record<string, PluginHook<(...args: any[]) => any>> = {}, ExtendBuildUtils extends Record<string, any> = {}, ExtendConfigUtils extends Record<string, any> = {}> {
6
6
  config?: Config;
7
7
  normalizedConfig?: NormalizedConfig;
8
8
  extendContext?: ExtendContext;
9
9
  extendApi?: ExtendAPI;
10
10
  extendHooks?: ExtendHook;
11
11
  extendBuildUtils?: ExtendBuildUtils;
12
+ extendConfigUtils?: ExtendConfigUtils;
12
13
  }
13
14
  /**
14
15
  * The type of the CLI plugin object.
@@ -5,11 +5,11 @@ export type SyncHook<Callback extends (...args: any[]) => any> = {
5
5
  };
6
6
  export type AsyncHook<Callback extends (...args: any[]) => any> = {
7
7
  tap: (cb: Callback) => void;
8
- call: (...args: Parameters<Callback>) => Promise<ReturnType<Callback>>;
8
+ call: (...args: Parameters<Callback>) => Promise<UnwrapPromise<ReturnType<Callback>>>;
9
9
  };
10
10
  export type AsyncInterruptHook<Callback extends (...args: any[]) => any> = {
11
11
  tap: (cb: Callback) => void;
12
- call: (...args: Tail<Parameters<Callback>>) => Promise<ReturnType<Callback>>;
12
+ call: (...args: Tail<Parameters<Callback>>) => Promise<UnwrapPromise<ReturnType<Callback>>>;
13
13
  };
14
14
  export type CollectAsyncHook<Callback extends (...params: any[]) => any> = {
15
15
  tap: (cb: Callback) => void;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-nightly-20250123160326",
18
+ "version": "0.0.0-nightly-20250127160318",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -63,22 +63,22 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "jiti": "1.21.7",
67
66
  "@swc/helpers": "0.5.13",
68
- "@modern-js/utils": "0.0.0-nightly-20250123160326",
69
- "@modern-js/runtime-utils": "0.0.0-nightly-20250123160326"
67
+ "jiti": "1.21.7",
68
+ "@modern-js/runtime-utils": "0.0.0-nightly-20250127160318",
69
+ "@modern-js/utils": "0.0.0-nightly-20250127160318"
70
70
  },
71
71
  "devDependencies": {
72
- "@rsbuild/core": "1.1.13",
73
- "@types/react": "^18.3.11",
72
+ "@rsbuild/core": "1.2.3",
74
73
  "@types/jest": "^29",
75
74
  "@types/node": "^14",
75
+ "@types/react": "^18.3.11",
76
76
  "jest": "^29",
77
77
  "typescript": "^5",
78
- "@modern-js/types": "0.0.0-nightly-20250123160326",
79
- "@modern-js/uni-builder": "0.0.0-nightly-20250123160326",
80
- "@scripts/jest-config": "0.0.0-nightly-20250123160326",
81
- "@scripts/build": "0.0.0-nightly-20250123160326"
78
+ "@modern-js/types": "0.0.0-nightly-20250127160318",
79
+ "@modern-js/uni-builder": "0.0.0-nightly-20250127160318",
80
+ "@scripts/build": "0.0.0-nightly-20250127160318",
81
+ "@scripts/jest-config": "0.0.0-nightly-20250127160318"
82
82
  },
83
83
  "sideEffects": false,
84
84
  "publishConfig": {