@modern-js/plugin-v2 2.64.1-alpha.2 → 2.64.1-alpha.3

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.
@@ -97,6 +97,8 @@ function initPluginAPI({ context, pluginManager }) {
97
97
  onBeforeDeploy: hooks.onBeforeDeploy.tap,
98
98
  onAfterDeploy: hooks.onAfterDeploy.tap,
99
99
  onBeforeExit: hooks.onBeforeExit.tap,
100
+ _internalRuntimePlugins: hooks._internalRuntimePlugins.tap,
101
+ _internalServerPlugins: hooks._internalServerPlugins.tap,
100
102
  ...extendsPluginApi
101
103
  };
102
104
  return new Proxy(pluginAPI, {
@@ -57,7 +57,9 @@ function initHooks() {
57
57
  onAfterDev: (0, import_hooks.createAsyncHook)(),
58
58
  onBeforeDeploy: (0, import_hooks.createAsyncHook)(),
59
59
  onAfterDeploy: (0, import_hooks.createAsyncHook)(),
60
- onBeforeExit: (0, import_hooks.createAsyncHook)()
60
+ onBeforeExit: (0, import_hooks.createAsyncHook)(),
61
+ _internalRuntimePlugins: (0, import_hooks.createAsyncHook)(),
62
+ _internalServerPlugins: (0, import_hooks.createAsyncHook)()
61
63
  };
62
64
  }
63
65
  // Annotate the CommonJS export names for ESM import in node:
@@ -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
  });
@@ -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
  });
@@ -82,7 +82,9 @@ function initPluginAPI(param) {
82
82
  onAfterDev: hooks.onAfterDev.tap,
83
83
  onBeforeDeploy: hooks.onBeforeDeploy.tap,
84
84
  onAfterDeploy: hooks.onAfterDeploy.tap,
85
- onBeforeExit: hooks.onBeforeExit.tap
85
+ onBeforeExit: hooks.onBeforeExit.tap,
86
+ _internalRuntimePlugins: hooks._internalRuntimePlugins.tap,
87
+ _internalServerPlugins: hooks._internalServerPlugins.tap
86
88
  }, extendsPluginApi);
87
89
  return new Proxy(pluginAPI, {
88
90
  get: function get(target, prop) {
@@ -34,7 +34,9 @@ function initHooks() {
34
34
  onAfterDev: createAsyncHook(),
35
35
  onBeforeDeploy: createAsyncHook(),
36
36
  onAfterDeploy: createAsyncHook(),
37
- onBeforeExit: createAsyncHook()
37
+ onBeforeExit: createAsyncHook(),
38
+ _internalRuntimePlugins: createAsyncHook(),
39
+ _internalServerPlugins: createAsyncHook()
38
40
  };
39
41
  }
40
42
  export {
@@ -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
  };
@@ -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
  };
@@ -74,6 +74,8 @@ function initPluginAPI({ context, pluginManager }) {
74
74
  onBeforeDeploy: hooks.onBeforeDeploy.tap,
75
75
  onAfterDeploy: hooks.onAfterDeploy.tap,
76
76
  onBeforeExit: hooks.onBeforeExit.tap,
77
+ _internalRuntimePlugins: hooks._internalRuntimePlugins.tap,
78
+ _internalServerPlugins: hooks._internalServerPlugins.tap,
77
79
  ...extendsPluginApi
78
80
  };
79
81
  return new Proxy(pluginAPI, {
@@ -34,7 +34,9 @@ function initHooks() {
34
34
  onAfterDev: createAsyncHook(),
35
35
  onBeforeDeploy: createAsyncHook(),
36
36
  onAfterDeploy: createAsyncHook(),
37
- onBeforeExit: createAsyncHook()
37
+ onBeforeExit: createAsyncHook(),
38
+ _internalRuntimePlugins: createAsyncHook(),
39
+ _internalServerPlugins: createAsyncHook()
38
40
  };
39
41
  }
40
42
  export {
@@ -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
  };
@@ -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
  };
@@ -1,7 +1,7 @@
1
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';
2
+ import type { AddCommandFn, AddWatchFilesFn, ConfigFn, InternalRuntimePluginsFn, InternalServerPluginsFn, ModifyBundlerChainFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterDeployFn, OnAfterDevFn, OnBeforeDeployFn, OnBeforeDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn, RuntimePluginConfig, ServerPluginConfig } from '../types/cli/hooks';
3
3
  import type { DeepPartial } from '../types/utils';
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, };
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, InternalRuntimePluginsFn, InternalServerPluginsFn, RuntimePluginConfig, ServerPluginConfig, };
5
5
  export declare function initHooks<Config, NormalizedConfig, ExtendBuildUtils, ExtendConfigUtils>(): {
6
6
  /**
7
7
  * add config for this cli plugin
@@ -37,5 +37,7 @@ export declare function initHooks<Config, NormalizedConfig, ExtendBuildUtils, Ex
37
37
  onBeforeDeploy: import("..").AsyncHook<OnBeforeDeployFn>;
38
38
  onAfterDeploy: import("..").AsyncHook<OnAfterDeployFn>;
39
39
  onBeforeExit: import("..").AsyncHook<OnBeforeExitFn>;
40
+ _internalRuntimePlugins: import("..").AsyncHook<InternalRuntimePluginsFn>;
41
+ _internalServerPlugins: import("..").AsyncHook<InternalServerPluginsFn>;
40
42
  };
41
43
  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
- 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';
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, type InternalRuntimePluginsFn, type InternalServerPluginsFn, type RuntimePluginConfig, type ServerPluginConfig, } from './hooks';
4
+ export { cli, createLoadedConfig, initAppDir, createCli, loadEnv } from './run';
@@ -1,5 +1,6 @@
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: {
@@ -1,6 +1,6 @@
1
1
  export { createPluginManager } from './manager';
2
2
  export { createSyncHook, createAsyncHook, createCollectSyncHook, createCollectAsyncHook, createAsyncInterruptHook, } from './hooks';
3
3
  export type { Plugin, PluginManager, TransformFunction, } from './types/plugin';
4
- export type { CLIPluginAPI, AppContext, InternalContext, Entrypoint, CLIPlugin, CLIPluginExtends, } from './types/cli';
4
+ export type { CLIPluginAPI, AppContext, InternalContext, Entrypoint, CLIPlugin, CLIPluginExtends, RuntimePluginConfig, ServerPluginConfig, } from './types/cli';
5
5
  export type { RuntimePluginAPI, RuntimeContext, InternalRuntimeContext, RuntimePlugin, RuntimePluginExtends, } from './types/runtime';
6
6
  export type { AsyncHook, CollectAsyncHook, PluginHook, PluginHookTap, } from './types/hooks';
@@ -3,7 +3,7 @@ import type { Hooks } from '../../cli/hooks';
3
3
  import type { PluginHook, PluginHookTap } from '../hooks';
4
4
  import type { DeepPartial } from '../utils';
5
5
  import type { AppContext } from './context';
6
- import type { AddCommandFn, AddWatchFilesFn, ConfigFn, ModifyBundlerChainFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterDeployFn, OnAfterDevFn, OnBeforeDeployFn, OnBeforeDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn } from './hooks';
6
+ import type { AddCommandFn, AddWatchFilesFn, ConfigFn, InternalRuntimePluginsFn, InternalServerPluginsFn, 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.
@@ -42,6 +42,8 @@ export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
42
42
  onBeforeDeploy: PluginHookTap<OnBeforeDeployFn>;
43
43
  onAfterDeploy: PluginHookTap<OnAfterDeployFn>;
44
44
  onBeforeExit: PluginHookTap<OnBeforeExitFn>;
45
+ _internalRuntimePlugins: PluginHookTap<InternalRuntimePluginsFn>;
46
+ _internalServerPlugins: PluginHookTap<InternalServerPluginsFn>;
45
47
  } & CLIPluginExtendsAPI<Extends>>;
46
48
  export type CLIPluginExtendsAPI<Extends extends CLIPluginExtends> = {
47
49
  [K in keyof Extends['extendHooks']]: PluginHookTap<Extends['extendHooks'][K] extends PluginHook<infer Args> ? Args extends (...args: any[]) => any ? Args : (...args: any[]) => any : (...args: any[]) => any>;
@@ -4,6 +4,7 @@ import type { Hooks } from '../../cli/hooks';
4
4
  import type { CLIPluginAPI } from './api';
5
5
  import type { CLIPlugin, CLIPluginExtends } from './plugin';
6
6
  export interface Entrypoint {
7
+ isMainEntry?: boolean;
7
8
  entryName: string;
8
9
  entry: string;
9
10
  }
@@ -1,6 +1,8 @@
1
+ import type { ServerPlugin as ServerPluginConfig } from '@modern-js/types';
1
2
  import type { WebpackConfig } from '@modern-js/uni-builder';
2
3
  import type { Command } from '@modern-js/utils/commander';
3
4
  import type { ModifyBundlerChainUtils, ModifyRspackConfigUtils, ModifyWebpackChainUtils, ModifyWebpackConfigUtils, RsbuildConfig, Rspack, RspackChain } from '@rsbuild/core';
5
+ import type { TransformFunction } from '../plugin';
4
6
  import type { MaybePromise } from '../utils';
5
7
  import type { Entrypoint } from './context';
6
8
  declare module '@modern-js/utils/commander' {
@@ -8,6 +10,12 @@ declare module '@modern-js/utils/commander' {
8
10
  commandsMap: Map<string, Command>;
9
11
  }
10
12
  }
13
+ export interface RuntimePluginConfig {
14
+ name: string;
15
+ path: string;
16
+ config: Record<string, any>;
17
+ }
18
+ export type { ServerPluginConfig };
11
19
  export type ConfigFn<Config> = () => Config | Promise<Config>;
12
20
  export type ModifyConfigFn<Config, ExtendConfigUtils> = (arg: Config, utils?: ExtendConfigUtils) => Config | Promise<Config>;
13
21
  export type ModifyResolvedConfigFn<NormalizedConfig, ExtendConfigUtils> = (arg: NormalizedConfig, utils?: ExtendConfigUtils) => NormalizedConfig | Promise<NormalizedConfig>;
@@ -55,4 +63,10 @@ export type ModifyRsbuildConfigFn<ExtendsUtils> = (config: RsbuildConfig, utils:
55
63
  export type ModifyRspackConfigFn<ExtendsUtils> = (config: Rspack.Configuration, utils: ModifyRspackConfigUtils & ExtendsUtils) => MaybePromise<Rspack.Configuration | void>;
56
64
  export type ModifyWebpackChainFn<ExtendsUtils> = (chain: RspackChain, utils: ModifyWebpackChainUtils & ExtendsUtils) => Promise<void> | void;
57
65
  export type ModifyWebpackConfigFn<ExtendsUtils> = (config: WebpackConfig, utils: ModifyWebpackConfigUtils & ExtendsUtils) => Promise<WebpackConfig | void> | WebpackConfig | void;
58
- export {};
66
+ export type InternalRuntimePluginsFn = TransformFunction<{
67
+ entrypoint: Entrypoint;
68
+ plugins: RuntimePluginConfig[];
69
+ }>;
70
+ export type InternalServerPluginsFn = TransformFunction<{
71
+ plugins: ServerPluginConfig[];
72
+ }>;
@@ -1,3 +1,4 @@
1
1
  export type { CLIPluginAPI } from './api';
2
2
  export type { AppContext, InternalContext, Entrypoint } from './context';
3
3
  export type { CLIPlugin, CLIPluginExtends } from './plugin';
4
+ export type { RuntimePluginConfig, ServerPluginConfig } from './hooks';
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.64.1-alpha.2",
18
+ "version": "2.64.1-alpha.3",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -65,8 +65,8 @@
65
65
  "dependencies": {
66
66
  "jiti": "1.21.7",
67
67
  "@swc/helpers": "0.5.13",
68
- "@modern-js/runtime-utils": "2.64.0",
69
- "@modern-js/utils": "2.64.0"
68
+ "@modern-js/utils": "2.64.0",
69
+ "@modern-js/runtime-utils": "2.64.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@rsbuild/core": "1.1.13",
@@ -76,9 +76,9 @@
76
76
  "jest": "^29",
77
77
  "typescript": "^5",
78
78
  "@modern-js/types": "2.64.0",
79
- "@scripts/build": "2.64.0",
79
+ "@modern-js/uni-builder": "2.64.0",
80
80
  "@scripts/jest-config": "2.64.0",
81
- "@modern-js/uni-builder": "2.64.0"
81
+ "@scripts/build": "2.64.0"
82
82
  },
83
83
  "sideEffects": false,
84
84
  "publishConfig": {