@modern-js/plugin-v2 2.63.6 → 2.63.7-alpha.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.
- package/dist/cjs/cli/api.js +3 -1
- package/dist/cjs/cli/hooks.js +1 -0
- package/dist/cjs/cli/index.js +2 -0
- package/dist/cjs/cli/run/create.js +2 -2
- package/dist/cjs/cli/run/index.js +2 -0
- package/dist/esm-node/cli/api.js +3 -1
- package/dist/esm-node/cli/hooks.js +1 -0
- package/dist/esm-node/cli/index.js +2 -1
- package/dist/esm-node/cli/run/create.js +2 -2
- package/dist/esm-node/cli/run/index.js +1 -0
- package/dist/types/cli/api.d.ts +1 -1
- package/dist/types/cli/hooks.d.ts +11 -9
- package/dist/types/cli/index.d.ts +2 -2
- package/dist/types/cli/run/index.d.ts +3 -1
- package/dist/types/types/cli/api.d.ts +10 -8
- package/dist/types/types/cli/context.d.ts +1 -1
- package/dist/types/types/cli/hooks.d.ts +13 -1
- package/dist/types/types/cli/plugin.d.ts +2 -1
- package/package.json +4 -5
package/dist/cjs/cli/api.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(api_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(api_exports);
|
|
24
24
|
var import_lodash = require("@modern-js/utils/lodash");
|
|
25
|
-
function initPluginAPI({ context }) {
|
|
25
|
+
function initPluginAPI({ context, pluginManager }) {
|
|
26
26
|
const { hooks, extendsHooks, plugins } = context;
|
|
27
27
|
function getAppContext() {
|
|
28
28
|
if (context) {
|
|
@@ -66,6 +66,7 @@ function initPluginAPI({ context }) {
|
|
|
66
66
|
context = (0, import_lodash.merge)(context, updateContext);
|
|
67
67
|
}
|
|
68
68
|
return {
|
|
69
|
+
isPluginExists: pluginManager.isPluginExists,
|
|
69
70
|
getAppContext,
|
|
70
71
|
getConfig,
|
|
71
72
|
getNormalizedConfig,
|
|
@@ -86,6 +87,7 @@ function initPluginAPI({ context }) {
|
|
|
86
87
|
onFileChanged: hooks.onFileChanged.tap,
|
|
87
88
|
onBeforeRestart: hooks.onBeforeRestart.tap,
|
|
88
89
|
onBeforeCreateCompiler: hooks.onBeforeCreateCompiler.tap,
|
|
90
|
+
onDevCompileDone: hooks.onDevCompileDone.tap,
|
|
89
91
|
onAfterCreateCompiler: hooks.onAfterCreateCompiler.tap,
|
|
90
92
|
onBeforeBuild: hooks.onBeforeBuild.tap,
|
|
91
93
|
onAfterBuild: hooks.onAfterBuild.tap,
|
package/dist/cjs/cli/hooks.js
CHANGED
|
@@ -50,6 +50,7 @@ function initHooks() {
|
|
|
50
50
|
onBeforeRestart: (0, import_hooks.createAsyncHook)(),
|
|
51
51
|
onBeforeCreateCompiler: (0, import_hooks.createAsyncHook)(),
|
|
52
52
|
onAfterCreateCompiler: (0, import_hooks.createAsyncHook)(),
|
|
53
|
+
onDevCompileDone: (0, import_hooks.createAsyncHook)(),
|
|
53
54
|
onBeforeBuild: (0, import_hooks.createAsyncHook)(),
|
|
54
55
|
onAfterBuild: (0, import_hooks.createAsyncHook)(),
|
|
55
56
|
onBeforeDev: (0, import_hooks.createAsyncHook)(),
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var cli_exports = {};
|
|
20
20
|
__export(cli_exports, {
|
|
21
21
|
cli: () => import_run.cli,
|
|
22
|
+
createCli: () => import_run.createCli,
|
|
22
23
|
createContext: () => import_context.createContext,
|
|
23
24
|
createLoadedConfig: () => import_run.createLoadedConfig,
|
|
24
25
|
initAppContext: () => import_context.initAppContext,
|
|
@@ -34,6 +35,7 @@ var import_run = require("./run");
|
|
|
34
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
36
|
0 && (module.exports = {
|
|
36
37
|
cli,
|
|
38
|
+
createCli,
|
|
37
39
|
createContext,
|
|
38
40
|
createLoadedConfig,
|
|
39
41
|
initAppContext,
|
|
@@ -37,7 +37,7 @@ const createCli = () => {
|
|
|
37
37
|
let initOptions;
|
|
38
38
|
const pluginManager = (0, import_manager.createPluginManager)();
|
|
39
39
|
async function init(options) {
|
|
40
|
-
var _context_hooks;
|
|
40
|
+
var _context_hooks_onAfterPrepare, _context_hooks;
|
|
41
41
|
pluginManager.clear();
|
|
42
42
|
initOptions = options;
|
|
43
43
|
const { metaName = "MODERN", configFile, command, version, packageJsonConfig, internalPlugins, handleSetupResult } = options;
|
|
@@ -103,7 +103,7 @@ const createCli = () => {
|
|
|
103
103
|
context.normalizedConfig = resolved || normalizedConfig;
|
|
104
104
|
await pluginAPI.updateAppContext(context);
|
|
105
105
|
await context.hooks.onPrepare.call();
|
|
106
|
-
await ((_context_hooks = context.hooks) === null || _context_hooks === void 0 ? void 0 : _context_hooks.onAfterPrepare.call());
|
|
106
|
+
await ((_context_hooks = context.hooks) === null || _context_hooks === void 0 ? void 0 : (_context_hooks_onAfterPrepare = _context_hooks.onAfterPrepare) === null || _context_hooks_onAfterPrepare === void 0 ? void 0 : _context_hooks_onAfterPrepare.call());
|
|
107
107
|
return {
|
|
108
108
|
appContext: context
|
|
109
109
|
};
|
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var run_exports = {};
|
|
20
20
|
__export(run_exports, {
|
|
21
21
|
cli: () => cli,
|
|
22
|
+
createCli: () => import_create.createCli,
|
|
22
23
|
createLoadedConfig: () => import_createLoadedConfig.createLoadedConfig,
|
|
23
24
|
initAppDir: () => import_initAppDir.initAppDir
|
|
24
25
|
});
|
|
@@ -30,6 +31,7 @@ const cli = (0, import_create.createCli)();
|
|
|
30
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
32
|
0 && (module.exports = {
|
|
32
33
|
cli,
|
|
34
|
+
createCli,
|
|
33
35
|
createLoadedConfig,
|
|
34
36
|
initAppDir
|
|
35
37
|
});
|
package/dist/esm-node/cli/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { merge } from "@modern-js/utils/lodash";
|
|
2
|
-
function initPluginAPI({ context }) {
|
|
2
|
+
function initPluginAPI({ context, pluginManager }) {
|
|
3
3
|
const { hooks, extendsHooks, plugins } = context;
|
|
4
4
|
function getAppContext() {
|
|
5
5
|
if (context) {
|
|
@@ -43,6 +43,7 @@ function initPluginAPI({ context }) {
|
|
|
43
43
|
context = merge(context, updateContext);
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
46
|
+
isPluginExists: pluginManager.isPluginExists,
|
|
46
47
|
getAppContext,
|
|
47
48
|
getConfig,
|
|
48
49
|
getNormalizedConfig,
|
|
@@ -63,6 +64,7 @@ function initPluginAPI({ context }) {
|
|
|
63
64
|
onFileChanged: hooks.onFileChanged.tap,
|
|
64
65
|
onBeforeRestart: hooks.onBeforeRestart.tap,
|
|
65
66
|
onBeforeCreateCompiler: hooks.onBeforeCreateCompiler.tap,
|
|
67
|
+
onDevCompileDone: hooks.onDevCompileDone.tap,
|
|
66
68
|
onAfterCreateCompiler: hooks.onAfterCreateCompiler.tap,
|
|
67
69
|
onBeforeBuild: hooks.onBeforeBuild.tap,
|
|
68
70
|
onAfterBuild: hooks.onAfterBuild.tap,
|
|
@@ -27,6 +27,7 @@ function initHooks() {
|
|
|
27
27
|
onBeforeRestart: createAsyncHook(),
|
|
28
28
|
onBeforeCreateCompiler: createAsyncHook(),
|
|
29
29
|
onAfterCreateCompiler: createAsyncHook(),
|
|
30
|
+
onDevCompileDone: createAsyncHook(),
|
|
30
31
|
onBeforeBuild: createAsyncHook(),
|
|
31
32
|
onAfterBuild: createAsyncHook(),
|
|
32
33
|
onBeforeDev: createAsyncHook(),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { initPluginAPI } from "./api";
|
|
2
2
|
import { initAppContext, createContext } from "./context";
|
|
3
3
|
import { initHooks } from "./hooks";
|
|
4
|
-
import { cli, createLoadedConfig, initAppDir } from "./run";
|
|
4
|
+
import { cli, createLoadedConfig, initAppDir, createCli } from "./run";
|
|
5
5
|
export {
|
|
6
6
|
cli,
|
|
7
|
+
createCli,
|
|
7
8
|
createContext,
|
|
8
9
|
createLoadedConfig,
|
|
9
10
|
initAppContext,
|
|
@@ -14,7 +14,7 @@ const createCli = () => {
|
|
|
14
14
|
let initOptions;
|
|
15
15
|
const pluginManager = createPluginManager();
|
|
16
16
|
async function init(options) {
|
|
17
|
-
var _context_hooks;
|
|
17
|
+
var _context_hooks_onAfterPrepare, _context_hooks;
|
|
18
18
|
pluginManager.clear();
|
|
19
19
|
initOptions = options;
|
|
20
20
|
const { metaName = "MODERN", configFile, command, version, packageJsonConfig, internalPlugins, handleSetupResult } = options;
|
|
@@ -80,7 +80,7 @@ const createCli = () => {
|
|
|
80
80
|
context.normalizedConfig = resolved || normalizedConfig;
|
|
81
81
|
await pluginAPI.updateAppContext(context);
|
|
82
82
|
await context.hooks.onPrepare.call();
|
|
83
|
-
await ((_context_hooks = context.hooks) === null || _context_hooks === void 0 ? void 0 : _context_hooks.onAfterPrepare.call());
|
|
83
|
+
await ((_context_hooks = context.hooks) === null || _context_hooks === void 0 ? void 0 : (_context_hooks_onAfterPrepare = _context_hooks.onAfterPrepare) === null || _context_hooks_onAfterPrepare === void 0 ? void 0 : _context_hooks_onAfterPrepare.call());
|
|
84
84
|
return {
|
|
85
85
|
appContext: context
|
|
86
86
|
};
|
package/dist/types/cli/api.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { CLIPluginAPI } from '../types/cli/api';
|
|
|
2
2
|
import type { InternalContext } from '../types/cli/context';
|
|
3
3
|
import type { CLIPluginExtends } from '../types/cli/plugin';
|
|
4
4
|
import type { PluginManager } from '../types/plugin';
|
|
5
|
-
export declare function initPluginAPI<Extends extends CLIPluginExtends>({ context, }: {
|
|
5
|
+
export declare function initPluginAPI<Extends extends CLIPluginExtends>({ context, pluginManager, }: {
|
|
6
6
|
context: InternalContext<Extends>;
|
|
7
7
|
pluginManager: PluginManager;
|
|
8
8
|
}): CLIPluginAPI<Extends>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AddCommandFn, AddWatchFilesFn, ConfigFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, OnAfterDeployFn, OnAfterDevFn, OnBeforeDeployFn, OnBeforeDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn } from '../types/cli/hooks';
|
|
1
|
+
import type { OnAfterBuildFn, OnAfterCreateCompilerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn } from '@rsbuild/core';
|
|
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
|
-
export
|
|
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
6
|
/**
|
|
6
7
|
* add config for this cli plugin
|
|
7
8
|
*/
|
|
@@ -15,11 +16,11 @@ export declare function initHooks<Config, NormalizedConfig>(): {
|
|
|
15
16
|
* modify final config
|
|
16
17
|
*/
|
|
17
18
|
modifyResolvedConfig: import("..").AsyncHook<ModifyResolvedConfigFn<NormalizedConfig>>;
|
|
18
|
-
modifyRsbuildConfig: import("..").AsyncHook<ModifyRsbuildConfigFn
|
|
19
|
-
modifyBundlerChain: import("..").AsyncHook<ModifyBundlerChainFn
|
|
20
|
-
modifyRspackConfig: import("..").AsyncHook<ModifyRspackConfigFn
|
|
21
|
-
modifyWebpackChain: import("..").AsyncHook<ModifyWebpackChainFn
|
|
22
|
-
modifyWebpackConfig: import("..").AsyncHook<ModifyWebpackConfigFn
|
|
19
|
+
modifyRsbuildConfig: import("..").AsyncHook<ModifyRsbuildConfigFn<ExtendBuildUtils>>;
|
|
20
|
+
modifyBundlerChain: import("..").AsyncHook<ModifyBundlerChainFn<ExtendBuildUtils>>;
|
|
21
|
+
modifyRspackConfig: import("..").AsyncHook<ModifyRspackConfigFn<ExtendBuildUtils>>;
|
|
22
|
+
modifyWebpackChain: import("..").AsyncHook<ModifyWebpackChainFn<ExtendBuildUtils>>;
|
|
23
|
+
modifyWebpackConfig: import("..").AsyncHook<ModifyWebpackConfigFn<ExtendBuildUtils>>;
|
|
23
24
|
modifyHtmlPartials: import("..").AsyncHook<ModifyHtmlPartialsFn>;
|
|
24
25
|
addCommand: import("..").AsyncHook<AddCommandFn>;
|
|
25
26
|
addWatchFiles: import("..").CollectAsyncHook<AddWatchFilesFn>;
|
|
@@ -28,6 +29,7 @@ export declare function initHooks<Config, NormalizedConfig>(): {
|
|
|
28
29
|
onBeforeRestart: import("..").AsyncHook<OnBeforeRestartFn>;
|
|
29
30
|
onBeforeCreateCompiler: import("..").AsyncHook<OnBeforeCreateCompilerFn>;
|
|
30
31
|
onAfterCreateCompiler: import("..").AsyncHook<OnAfterCreateCompilerFn>;
|
|
32
|
+
onDevCompileDone: import("..").AsyncHook<OnDevCompileDoneFn>;
|
|
31
33
|
onBeforeBuild: import("..").AsyncHook<OnBeforeBuildFn>;
|
|
32
34
|
onAfterBuild: import("..").AsyncHook<OnAfterBuildFn>;
|
|
33
35
|
onBeforeDev: import("..").AsyncHook<OnBeforeDevFn>;
|
|
@@ -36,4 +38,4 @@ export declare function initHooks<Config, NormalizedConfig>(): {
|
|
|
36
38
|
onAfterDeploy: import("..").AsyncHook<OnAfterDeployFn>;
|
|
37
39
|
onBeforeExit: import("..").AsyncHook<OnBeforeExitFn>;
|
|
38
40
|
};
|
|
39
|
-
export type Hooks<Config, NormalizedConfig> = ReturnType<typeof initHooks<Config, NormalizedConfig>>;
|
|
41
|
+
export type Hooks<Config, NormalizedConfig, ExtendBuildUtils> = ReturnType<typeof initHooks<Config, NormalizedConfig, ExtendBuildUtils>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { initPluginAPI } from './api';
|
|
2
2
|
export { initAppContext, createContext } from './context';
|
|
3
|
-
export { initHooks, type Hooks } from './hooks';
|
|
4
|
-
export { cli, createLoadedConfig, initAppDir } from './run';
|
|
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';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { createCli } from './create';
|
|
1
2
|
export { createLoadedConfig } from './config/createLoadedConfig';
|
|
2
3
|
export { initAppDir } from './utils/initAppDir';
|
|
4
|
+
export { createCli };
|
|
3
5
|
export declare const cli: {
|
|
4
6
|
init: (options: import("./types").CLIRunOptions) => Promise<{
|
|
5
|
-
appContext: import("../..").InternalContext<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}>>;
|
|
7
|
+
appContext: import("../..").InternalContext<import("../..").CLIPluginExtends<{}, {}, {}, {}, {}, {}>>;
|
|
6
8
|
}>;
|
|
7
9
|
run: (options: import("./types").CLIRunOptions) => Promise<void>;
|
|
8
10
|
getPrevInitOptions: () => import("./types").CLIRunOptions;
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OnAfterBuildFn, OnAfterCreateCompilerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn } from '@rsbuild/core';
|
|
2
2
|
import type { Hooks } from '../../cli/hooks';
|
|
3
3
|
import type { PluginHookTap } from '../hooks';
|
|
4
4
|
import type { DeepPartial } from '../utils';
|
|
5
5
|
import type { AppContext } from './context';
|
|
6
|
-
import type { AddCommandFn, AddWatchFilesFn, ConfigFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, OnAfterDeployFn, OnAfterDevFn, OnBeforeDeployFn, OnBeforeDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn } from './hooks';
|
|
6
|
+
import type { AddCommandFn, AddWatchFilesFn, ConfigFn, ModifyBundlerChainFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterDeployFn, OnAfterDevFn, OnBeforeDeployFn, OnBeforeDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn } from './hooks';
|
|
7
7
|
import type { CLIPluginExtends } from './plugin';
|
|
8
8
|
/**
|
|
9
9
|
* Define a generic CLI plugin API that provider can extend as needed.
|
|
10
10
|
*/
|
|
11
11
|
export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
|
|
12
|
+
isPluginExists: (name: string) => boolean;
|
|
12
13
|
getAppContext: () => Readonly<AppContext<Extends> & Extends['extendContext']>;
|
|
13
14
|
getConfig: () => Readonly<Extends['config']>;
|
|
14
15
|
getNormalizedConfig: () => Readonly<Extends['normalizedConfig']>;
|
|
15
|
-
getHooks: () => Readonly<Hooks<Extends['config'], Extends['normalizedConfig']> & Extends['extendHooks']>;
|
|
16
|
+
getHooks: () => Readonly<Hooks<Extends['config'], Extends['normalizedConfig'], Extends['extendBuildUtils']> & Extends['extendHooks']>;
|
|
16
17
|
updateAppContext: (appContext: DeepPartial<AppContext<Extends> & Extends['extendContext']>) => void;
|
|
17
18
|
config: PluginHookTap<ConfigFn<DeepPartial<Extends['config']>>>;
|
|
18
19
|
modifyConfig: PluginHookTap<ModifyConfigFn<Extends['config']>>;
|
|
19
20
|
modifyResolvedConfig: PluginHookTap<ModifyResolvedConfigFn<Extends['normalizedConfig']>>;
|
|
20
|
-
modifyRsbuildConfig: PluginHookTap<ModifyRsbuildConfigFn
|
|
21
|
-
modifyBundlerChain: PluginHookTap<ModifyBundlerChainFn
|
|
21
|
+
modifyRsbuildConfig: PluginHookTap<ModifyRsbuildConfigFn<Extends['extendBuildUtils']>>;
|
|
22
|
+
modifyBundlerChain: PluginHookTap<ModifyBundlerChainFn<Extends['extendBuildUtils']>>;
|
|
22
23
|
/** Only works when bundler is Rspack */
|
|
23
|
-
modifyRspackConfig: PluginHookTap<ModifyRspackConfigFn
|
|
24
|
+
modifyRspackConfig: PluginHookTap<ModifyRspackConfigFn<Extends['extendBuildUtils']>>;
|
|
24
25
|
/** Only works when bundler is Webpack */
|
|
25
|
-
modifyWebpackChain: PluginHookTap<ModifyWebpackChainFn
|
|
26
|
+
modifyWebpackChain: PluginHookTap<ModifyWebpackChainFn<Extends['extendBuildUtils']>>;
|
|
26
27
|
/** Only works when bundler is Webpack */
|
|
27
|
-
modifyWebpackConfig: PluginHookTap<ModifyWebpackConfigFn
|
|
28
|
+
modifyWebpackConfig: PluginHookTap<ModifyWebpackConfigFn<Extends['extendBuildUtils']>>;
|
|
28
29
|
modifyHtmlPartials: PluginHookTap<ModifyHtmlPartialsFn>;
|
|
29
30
|
addCommand: PluginHookTap<AddCommandFn>;
|
|
30
31
|
onPrepare: PluginHookTap<OnPrepareFn>;
|
|
@@ -33,6 +34,7 @@ export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
|
|
|
33
34
|
onBeforeRestart: PluginHookTap<OnBeforeRestartFn>;
|
|
34
35
|
onBeforeCreateCompiler: PluginHookTap<OnBeforeCreateCompilerFn>;
|
|
35
36
|
onAfterCreateCompiler: PluginHookTap<OnAfterCreateCompilerFn>;
|
|
37
|
+
onDevCompileDone: PluginHookTap<OnDevCompileDoneFn>;
|
|
36
38
|
onBeforeBuild: PluginHookTap<OnBeforeBuildFn>;
|
|
37
39
|
onAfterBuild: PluginHookTap<OnAfterBuildFn>;
|
|
38
40
|
onBeforeDev: PluginHookTap<OnBeforeDevFn>;
|
|
@@ -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['extendHooks'];
|
|
31
|
+
hooks: Hooks<Extends['config'], Extends['normalizedConfig'], Extends['extendBuildUtils']> & Extends['extendHooks'];
|
|
32
32
|
/** All plugin registry hooks */
|
|
33
33
|
extendsHooks: Extends['extendHooks'];
|
|
34
34
|
/** Current App config. */
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { WebpackConfig } from '@modern-js/uni-builder';
|
|
1
2
|
import type { Command } from '@modern-js/utils/commander';
|
|
3
|
+
import type { ModifyBundlerChainUtils, ModifyRspackConfigUtils, ModifyWebpackChainUtils, ModifyWebpackConfigUtils, RsbuildConfig, Rspack, RspackChain } from '@rsbuild/core';
|
|
2
4
|
import type { TransformFunction } from '../plugin';
|
|
5
|
+
import type { MaybePromise } from '../utils';
|
|
3
6
|
import type { Entrypoint } from './context';
|
|
4
7
|
declare module '@modern-js/utils/commander' {
|
|
5
8
|
interface Command {
|
|
@@ -39,9 +42,18 @@ export type OnFileChangedFn = (params: {
|
|
|
39
42
|
export type OnBeforeRestartFn = () => Promise<void> | void;
|
|
40
43
|
export type OnBeforeDevFn = () => Promise<void> | void;
|
|
41
44
|
export type OnAfterDevFn = (params: {
|
|
42
|
-
|
|
45
|
+
port: number;
|
|
43
46
|
}) => Promise<void> | void;
|
|
44
47
|
export type OnBeforeDeployFn = (options: Record<string, any>) => Promise<void> | void;
|
|
45
48
|
export type OnAfterDeployFn = (options: Record<string, any>) => Promise<void> | void;
|
|
46
49
|
export type OnBeforeExitFn = () => void;
|
|
50
|
+
export type ModifyBundlerChainFn<ExtendsUtils> = (chain: RspackChain, utils: ModifyBundlerChainUtils & ExtendsUtils) => MaybePromise<void>;
|
|
51
|
+
export type ModifyRsbuildConfigUtils = {
|
|
52
|
+
/** Merge multiple Rsbuild config objects into one. */
|
|
53
|
+
mergeRsbuildConfig: (...configs: RsbuildConfig[]) => RsbuildConfig;
|
|
54
|
+
};
|
|
55
|
+
export type ModifyRsbuildConfigFn<ExtendsUtils> = (config: RsbuildConfig, utils: ModifyRsbuildConfigUtils & ExtendsUtils) => MaybePromise<RsbuildConfig | void>;
|
|
56
|
+
export type ModifyRspackConfigFn<ExtendsUtils> = (config: Rspack.Configuration, utils: ModifyRspackConfigUtils & ExtendsUtils) => MaybePromise<Rspack.Configuration | void>;
|
|
57
|
+
export type ModifyWebpackChainFn<ExtendsUtils> = (chain: RspackChain, utils: ModifyWebpackChainUtils & ExtendsUtils) => Promise<void> | void;
|
|
58
|
+
export type ModifyWebpackConfigFn<ExtendsUtils> = (config: WebpackConfig, utils: ModifyWebpackConfigUtils & ExtendsUtils) => Promise<WebpackConfig | void> | WebpackConfig | void;
|
|
47
59
|
export {};
|
|
@@ -2,12 +2,13 @@ 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>> = {}> {
|
|
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> = {}> {
|
|
6
6
|
config?: Config;
|
|
7
7
|
normalizedConfig?: NormalizedConfig;
|
|
8
8
|
extendContext?: ExtendContext;
|
|
9
9
|
extendApi?: ExtendAPI;
|
|
10
10
|
extendHooks?: ExtendHook;
|
|
11
|
+
extendBuildUtils?: ExtendBuildUtils;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* The type of the CLI plugin object.
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.63.
|
|
18
|
+
"version": "2.63.7-alpha.1",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -71,15 +71,14 @@
|
|
|
71
71
|
"jest": "^29",
|
|
72
72
|
"typescript": "^5",
|
|
73
73
|
"@modern-js/types": "2.63.6",
|
|
74
|
-
"@modern-js/uni-builder": "2.63.6",
|
|
75
74
|
"@scripts/build": "2.63.6",
|
|
76
|
-
"@scripts/jest-config": "2.63.6"
|
|
75
|
+
"@scripts/jest-config": "2.63.6",
|
|
76
|
+
"@modern-js/uni-builder": "2.63.6"
|
|
77
77
|
},
|
|
78
78
|
"sideEffects": false,
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"registry": "https://registry.npmjs.org/",
|
|
81
|
-
"access": "public"
|
|
82
|
-
"provenance": true
|
|
81
|
+
"access": "public"
|
|
83
82
|
},
|
|
84
83
|
"scripts": {
|
|
85
84
|
"new": "modern-lib new",
|