@modern-js/plugin-v2 2.63.7 → 2.63.8-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/run/create.js +25 -14
- package/dist/cjs/hooks.js +74 -2
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/manager.js +3 -5
- package/dist/cjs/runtime/api.js +79 -0
- package/dist/cjs/runtime/context.js +51 -0
- package/dist/cjs/runtime/hooks.js +36 -0
- package/dist/cjs/runtime/index.js +39 -0
- package/dist/cjs/runtime/run/create.js +74 -0
- package/dist/cjs/runtime/run/index.js +29 -0
- package/dist/cjs/runtime/run/types.js +16 -0
- package/dist/cjs/types/runtime/api.js +16 -0
- package/dist/cjs/types/runtime/context.js +16 -0
- package/dist/cjs/types/runtime/hooks.js +16 -0
- package/dist/cjs/types/runtime/index.js +16 -0
- package/dist/cjs/types/runtime/plugin.js +16 -0
- package/dist/esm/cli/api.js +103 -0
- package/dist/esm/cli/context.js +53 -0
- package/dist/esm/cli/hooks.js +42 -0
- package/dist/esm/cli/index.js +14 -0
- package/dist/esm/cli/run/config/createLoadedConfig.js +190 -0
- package/dist/esm/cli/run/config/createResolvedConfig.js +30 -0
- package/dist/esm/cli/run/config/loadConfig.js +210 -0
- package/dist/esm/cli/run/create.js +300 -0
- package/dist/esm/cli/run/index.js +10 -0
- package/dist/esm/cli/run/run.js +60 -0
- package/dist/esm/cli/run/types.js +0 -0
- package/dist/esm/cli/run/utils/checkIsDuplicationPlugin.js +24 -0
- package/dist/esm/cli/run/utils/commander.js +42 -0
- package/dist/esm/cli/run/utils/createFileWatcher.js +110 -0
- package/dist/esm/cli/run/utils/debug.js +5 -0
- package/dist/esm/cli/run/utils/initAppDir.js +36 -0
- package/dist/esm/cli/run/utils/loadEnv.js +24 -0
- package/dist/esm/cli/run/utils/mergeConfig.js +43 -0
- package/dist/esm/hooks.js +378 -0
- package/dist/esm/index.js +6 -357
- package/dist/esm/manager.js +161 -0
- package/dist/esm/runtime/api.js +59 -0
- package/dist/esm/runtime/context.js +25 -0
- package/dist/esm/runtime/hooks.js +12 -0
- package/dist/esm/runtime/index.js +11 -0
- package/dist/esm/runtime/run/create.js +72 -0
- package/dist/esm/runtime/run/index.js +5 -0
- package/dist/esm/runtime/run/types.js +0 -0
- package/dist/esm/types/cli/api.js +0 -0
- package/dist/esm/types/cli/context.js +0 -0
- package/dist/esm/types/cli/hooks.js +0 -0
- package/dist/esm/types/cli/index.js +0 -0
- package/dist/esm/types/cli/plugin.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/types/plugin.js +0 -0
- package/dist/esm/types/runtime/api.js +0 -0
- package/dist/esm/types/runtime/context.js +0 -0
- package/dist/esm/types/runtime/hooks.js +0 -0
- package/dist/esm/types/runtime/index.js +0 -0
- package/dist/esm/types/runtime/plugin.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm-node/cli/run/create.js +26 -15
- package/dist/esm-node/hooks.js +70 -1
- package/dist/esm-node/index.js +5 -2
- package/dist/esm-node/manager.js +2 -4
- package/dist/esm-node/runtime/api.js +55 -0
- package/dist/esm-node/runtime/context.js +26 -0
- package/dist/esm-node/runtime/hooks.js +12 -0
- package/dist/esm-node/runtime/index.js +11 -0
- package/dist/esm-node/runtime/run/create.js +50 -0
- package/dist/esm-node/runtime/run/index.js +5 -0
- package/dist/esm-node/runtime/run/types.js +0 -0
- package/dist/esm-node/types/runtime/api.js +0 -0
- package/dist/esm-node/types/runtime/context.js +0 -0
- package/dist/esm-node/types/runtime/hooks.js +0 -0
- package/dist/esm-node/types/runtime/index.js +0 -0
- package/dist/esm-node/types/runtime/plugin.js +0 -0
- package/dist/types/cli/hooks.d.ts +3 -3
- package/dist/types/cli/run/create.d.ts +2 -1
- package/dist/types/cli/run/index.d.ts +4 -4
- package/dist/types/hooks.d.ts +4 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/manager.d.ts +3 -0
- package/dist/types/runtime/api.d.ts +9 -0
- package/dist/types/runtime/context.d.ts +11 -0
- package/dist/types/runtime/hooks.d.ts +2 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/run/create.d.ts +7 -0
- package/dist/types/runtime/run/index.d.ts +5 -0
- package/dist/types/runtime/run/types.d.ts +6 -0
- package/dist/types/types/cli/api.d.ts +2 -2
- package/dist/types/types/cli/context.d.ts +1 -1
- package/dist/types/types/cli/hooks.d.ts +3 -3
- package/dist/types/types/cli/plugin.d.ts +2 -1
- package/dist/types/types/hooks.d.ts +14 -2
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/plugin.d.ts +1 -1
- package/dist/types/types/runtime/api.d.ts +15 -0
- package/dist/types/types/runtime/context.d.ts +13 -0
- package/dist/types/types/runtime/hooks.d.ts +12 -0
- package/dist/types/types/runtime/index.d.ts +4 -0
- package/dist/types/types/runtime/plugin.d.ts +14 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/package.json +13 -9
|
@@ -10,7 +10,7 @@ declare module '@modern-js/utils/commander' {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export type ConfigFn<Config> = () => Config;
|
|
13
|
-
export type ModifyConfigFn<Config> =
|
|
13
|
+
export type ModifyConfigFn<Config, ExtendConfigUtils> = (arg: Config, utils?: ExtendConfigUtils) => Config | Promise<Config>;
|
|
14
14
|
export type ModifyResolvedConfigFn<NormalizedConfig> = TransformFunction<NormalizedConfig>;
|
|
15
15
|
type IPartialMethod = (...script: string[]) => void;
|
|
16
16
|
export interface PartialMethod {
|
|
@@ -44,8 +44,8 @@ export type OnBeforeDevFn = () => Promise<void> | void;
|
|
|
44
44
|
export type OnAfterDevFn = (params: {
|
|
45
45
|
port: number;
|
|
46
46
|
}) => Promise<void> | void;
|
|
47
|
-
export type OnBeforeDeployFn = (options
|
|
48
|
-
export type OnAfterDeployFn = (options
|
|
47
|
+
export type OnBeforeDeployFn = (options?: Record<string, any>) => Promise<void> | void;
|
|
48
|
+
export type OnAfterDeployFn = (options?: Record<string, any>) => Promise<void> | void;
|
|
49
49
|
export type OnBeforeExitFn = () => void;
|
|
50
50
|
export type ModifyBundlerChainFn<ExtendsUtils> = (chain: RspackChain, utils: ModifyBundlerChainUtils & ExtendsUtils) => MaybePromise<void>;
|
|
51
51
|
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.
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import type { UnwrapPromise } from './utils';
|
|
1
|
+
import type { Tail, UnwrapPromise } from './utils';
|
|
2
|
+
export type SyncHook<Callback extends (...args: any[]) => any> = {
|
|
3
|
+
tap: (cb: Callback) => void;
|
|
4
|
+
call: (...args: Parameters<Callback>) => ReturnType<Callback>;
|
|
5
|
+
};
|
|
2
6
|
export type AsyncHook<Callback extends (...args: any[]) => any> = {
|
|
3
7
|
tap: (cb: Callback) => void;
|
|
4
8
|
call: (...args: Parameters<Callback>) => Promise<ReturnType<Callback>>;
|
|
5
9
|
};
|
|
10
|
+
export type AsyncInterruptHook<Callback extends (...args: any[]) => any> = {
|
|
11
|
+
tap: (cb: Callback) => void;
|
|
12
|
+
call: (...args: Tail<Parameters<Callback>>) => Promise<ReturnType<Callback>>;
|
|
13
|
+
};
|
|
6
14
|
export type CollectAsyncHook<Callback extends (...params: any[]) => any> = {
|
|
7
15
|
tap: (cb: Callback) => void;
|
|
8
16
|
call: (...params: Parameters<Callback>) => Promise<UnwrapPromise<ReturnType<Callback>>[]>;
|
|
9
17
|
};
|
|
10
|
-
export type
|
|
18
|
+
export type CollectSyncHook<Callback extends (...params: any[]) => any> = {
|
|
19
|
+
tap: (cb: Callback) => void;
|
|
20
|
+
call: (...params: Parameters<Callback>) => ReturnType<Callback>[];
|
|
21
|
+
};
|
|
22
|
+
export type PluginHook<Callback extends (...args: any[]) => any> = SyncHook<Callback> | AsyncHook<Callback> | CollectSyncHook<Callback> | CollectAsyncHook<Callback> | AsyncInterruptHook<Callback>;
|
|
11
23
|
export type PluginHookTap<T extends (...args: any[]) => any> = (options: T) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { Plugin, PluginManager, TransformFunction, } from './plugin';
|
|
2
2
|
export type { CLIPluginAPI, AppContext, InternalContext, Entrypoint, CLIPlugin, } from './cli';
|
|
3
|
+
export type { RuntimePluginAPI, RuntimeContext, InternalRuntimeContext, RuntimePlugin, } from './runtime';
|
|
3
4
|
export type { AsyncHook, CollectAsyncHook, PluginHook, PluginHookTap, } from './hooks';
|
|
@@ -18,7 +18,7 @@ export type Plugin<PluginAPI = {}, Context = {}> = {
|
|
|
18
18
|
/**
|
|
19
19
|
* The plugins add new apis to the plugin manager.
|
|
20
20
|
*/
|
|
21
|
-
_registryApi?: (
|
|
21
|
+
_registryApi?: (...params: any[]) => Record<string, (...args: any[]) => any>;
|
|
22
22
|
/**
|
|
23
23
|
* The setup function of the plugin, which can be an async function.
|
|
24
24
|
* This function is called once when the plugin is initialized.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PluginHookTap } from '../hooks';
|
|
2
|
+
import type { DeepPartial } from '../utils';
|
|
3
|
+
import type { RuntimeContext } from './context';
|
|
4
|
+
import type { Hooks } from './hooks';
|
|
5
|
+
import type { ModifyRuntimeConfigFn, OnBeforeRenderFn, PickContextFn, WrapRootFn } from './hooks';
|
|
6
|
+
import type { RuntimePluginExtends } from './plugin';
|
|
7
|
+
export type RuntimePluginAPI<Extends extends RuntimePluginExtends> = Readonly<{
|
|
8
|
+
updateRuntimeContext: (updateContext: DeepPartial<RuntimeContext>) => void;
|
|
9
|
+
getHooks: () => Readonly<Hooks<Extends['config'], RuntimeContext & Extends['extendContext']> & Extends['extendHooks']>;
|
|
10
|
+
getRuntimeConfig: () => Readonly<Extends['config']>;
|
|
11
|
+
onBeforeRender: PluginHookTap<OnBeforeRenderFn<Extends['extendContext']>>;
|
|
12
|
+
wrapRoot: PluginHookTap<WrapRootFn>;
|
|
13
|
+
pickContext: PluginHookTap<PickContextFn<RuntimeContext>>;
|
|
14
|
+
modifyRuntimeConfig: PluginHookTap<ModifyRuntimeConfigFn<Extends['config']>>;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RuntimePluginAPI } from './api';
|
|
2
|
+
import type { Hooks } from './hooks';
|
|
3
|
+
import type { RuntimePluginExtends } from './plugin';
|
|
4
|
+
export type RuntimeContext = {};
|
|
5
|
+
export type InternalRuntimeContext<Extends extends RuntimePluginExtends> = RuntimeContext & {
|
|
6
|
+
/** All hooks. */
|
|
7
|
+
hooks: Hooks<Extends['config'], RuntimeContext & Extends['extendContext']> & Extends['extendHooks'];
|
|
8
|
+
/** All plugin registry hooks */
|
|
9
|
+
extendsHooks: Extends['extendHooks'];
|
|
10
|
+
config: Extends['config'];
|
|
11
|
+
pluginAPI?: RuntimePluginAPI<Extends>;
|
|
12
|
+
_internalContext?: InternalRuntimeContext<Extends>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { AsyncInterruptHook, CollectSyncHook, SyncHook } from '../hooks';
|
|
3
|
+
export type OnBeforeRenderFn<RuntimeContext> = (context: RuntimeContext, interrupt: (info: any) => any) => Promise<any> | any;
|
|
4
|
+
export type WrapRootFn = (root: React.ComponentType<any>) => React.ComponentType<any>;
|
|
5
|
+
export type PickContextFn<RuntimeContext> = (context: RuntimeContext) => RuntimeContext;
|
|
6
|
+
export type ModifyRuntimeConfigFn<RuntimeConfig> = (config: RuntimeConfig) => RuntimeConfig;
|
|
7
|
+
export type Hooks<RuntimeConfig, RuntimeContext> = {
|
|
8
|
+
onBeforeRender: AsyncInterruptHook<OnBeforeRenderFn<RuntimeContext>>;
|
|
9
|
+
wrapRoot: SyncHook<WrapRootFn>;
|
|
10
|
+
pickContext: SyncHook<PickContextFn<RuntimeContext>>;
|
|
11
|
+
modifyRuntimeConfig: CollectSyncHook<ModifyRuntimeConfigFn<RuntimeConfig>>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PluginHook } from '../hooks';
|
|
2
|
+
import type { Plugin } from '../plugin';
|
|
3
|
+
import type { RuntimePluginAPI } from './api';
|
|
4
|
+
import type { RuntimeContext } from './context';
|
|
5
|
+
export interface RuntimePluginExtends<Config extends Record<string, any> = {}, ExtendContext extends Record<string, any> = {}, ExtendAPI extends Record<string, any> = {}, ExtendHook extends Record<string, PluginHook<(...args: any[]) => any>> = {}> {
|
|
6
|
+
config?: Config;
|
|
7
|
+
extendContext?: ExtendContext;
|
|
8
|
+
extendApi?: ExtendAPI;
|
|
9
|
+
extendHooks?: ExtendHook;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The type of the Runtime plugin object.
|
|
13
|
+
*/
|
|
14
|
+
export type RuntimePlugin<Extends extends RuntimePluginExtends> = Plugin<RuntimePluginAPI<Extends> & Extends['extendApi'], RuntimeContext & Extends['extendContext']>;
|
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.8-alpha.1",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -30,11 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"default": "./dist/esm/index.js"
|
|
32
32
|
},
|
|
33
|
-
"./types": {
|
|
34
|
-
"types": "./dist/types/types/index.d.ts",
|
|
35
|
-
"jsnext:source": "./src/types/index.ts",
|
|
36
|
-
"default": "./dist/cjs/types/index.js"
|
|
37
|
-
},
|
|
38
33
|
"./run": {
|
|
39
34
|
"types": "./dist/types/cli/run/run.d.ts",
|
|
40
35
|
"jsnext:source": "./src/cli/run/run.ts",
|
|
@@ -44,6 +39,11 @@
|
|
|
44
39
|
"types": "./dist/types/cli/index.d.ts",
|
|
45
40
|
"jsnext:source": "./src/cli/index.ts",
|
|
46
41
|
"default": "./dist/cjs/cli/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./runtime": {
|
|
44
|
+
"types": "./dist/types/runtime/index.d.ts",
|
|
45
|
+
"jsnext:source": "./src/runtime/index.ts",
|
|
46
|
+
"default": "./dist/esm/runtime/index.js"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"typesVersions": {
|
|
@@ -56,16 +56,21 @@
|
|
|
56
56
|
],
|
|
57
57
|
"cli": [
|
|
58
58
|
"./dist/types/cli/index.d.ts"
|
|
59
|
+
],
|
|
60
|
+
"runtime": [
|
|
61
|
+
"./dist/types/runtime/index.d.ts"
|
|
59
62
|
]
|
|
60
63
|
}
|
|
61
64
|
},
|
|
62
65
|
"dependencies": {
|
|
63
66
|
"@swc/helpers": "0.5.13",
|
|
64
67
|
"@modern-js/node-bundle-require": "2.63.7",
|
|
65
|
-
"@modern-js/utils": "2.63.7"
|
|
68
|
+
"@modern-js/utils": "2.63.7",
|
|
69
|
+
"@modern-js/runtime-utils": "2.63.7"
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
72
|
"@rsbuild/core": "1.1.13",
|
|
73
|
+
"@types/react": "^18.3.11",
|
|
69
74
|
"@types/jest": "^29",
|
|
70
75
|
"@types/node": "^14",
|
|
71
76
|
"jest": "^29",
|
|
@@ -78,8 +83,7 @@
|
|
|
78
83
|
"sideEffects": false,
|
|
79
84
|
"publishConfig": {
|
|
80
85
|
"registry": "https://registry.npmjs.org/",
|
|
81
|
-
"access": "public"
|
|
82
|
-
"provenance": true
|
|
86
|
+
"access": "public"
|
|
83
87
|
},
|
|
84
88
|
"scripts": {
|
|
85
89
|
"new": "modern-lib new",
|