@modern-js/plugin-v2 0.0.0-nightly-20250120062903 → 0.0.0-nightly-20250122164656

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.
@@ -26,7 +26,7 @@ function initPluginAPI({ context, plugins }) {
26
26
  const { hooks, extendsHooks } = context;
27
27
  function getRuntimeContext() {
28
28
  if (context) {
29
- const { hooks: hooks2, extendsHooks: extendsHooks2, config, pluginAPI, ...runtimeContext } = context;
29
+ const { hooks: hooks2, extendsHooks: extendsHooks2, config, pluginAPI: pluginAPI2, ...runtimeContext } = context;
30
30
  runtimeContext._internalContext = context;
31
31
  return runtimeContext;
32
32
  }
@@ -62,7 +62,7 @@ function initPluginAPI({ context, plugins }) {
62
62
  extendsPluginApi[hookName] = extendsHooks[hookName].tap;
63
63
  });
64
64
  }
65
- return {
65
+ const pluginAPI = {
66
66
  updateRuntimeContext,
67
67
  getHooks,
68
68
  getRuntimeConfig,
@@ -72,6 +72,19 @@ function initPluginAPI({ context, plugins }) {
72
72
  pickContext: hooks.pickContext.tap,
73
73
  ...extendsPluginApi
74
74
  };
75
+ return new Proxy(pluginAPI, {
76
+ get(target, prop) {
77
+ if (prop === "then") {
78
+ return void 0;
79
+ }
80
+ if (prop in target) {
81
+ return target[prop];
82
+ }
83
+ return () => {
84
+ console.warn(`api.${prop.toString()} not exist`);
85
+ };
86
+ }
87
+ });
75
88
  }
76
89
  // Annotate the CommonJS export names for ESM import in node:
77
90
  0 && (module.exports = {
@@ -6,7 +6,7 @@ function initPluginAPI(param) {
6
6
  var hooks = context.hooks, extendsHooks = context.extendsHooks;
7
7
  function getRuntimeContext() {
8
8
  if (context) {
9
- var hooks2 = context.hooks, extendsHooks2 = context.extendsHooks, config = context.config, pluginAPI = context.pluginAPI, runtimeContext = _object_without_properties(context, [
9
+ var hooks2 = context.hooks, extendsHooks2 = context.extendsHooks, config = context.config, pluginAPI2 = context.pluginAPI, runtimeContext = _object_without_properties(context, [
10
10
  "hooks",
11
11
  "extendsHooks",
12
12
  "config",
@@ -44,7 +44,7 @@ function initPluginAPI(param) {
44
44
  extendsPluginApi[hookName] = extendsHooks[hookName].tap;
45
45
  });
46
46
  }
47
- return _object_spread({
47
+ var pluginAPI = _object_spread({
48
48
  updateRuntimeContext,
49
49
  getHooks,
50
50
  getRuntimeConfig,
@@ -53,6 +53,19 @@ function initPluginAPI(param) {
53
53
  wrapRoot: hooks.wrapRoot.tap,
54
54
  pickContext: hooks.pickContext.tap
55
55
  }, extendsPluginApi);
56
+ return new Proxy(pluginAPI, {
57
+ get: function get(target, prop) {
58
+ if (prop === "then") {
59
+ return void 0;
60
+ }
61
+ if (prop in target) {
62
+ return target[prop];
63
+ }
64
+ return function() {
65
+ console.warn("api.".concat(prop.toString(), " not exist"));
66
+ };
67
+ }
68
+ });
56
69
  }
57
70
  export {
58
71
  initPluginAPI
@@ -3,7 +3,7 @@ function initPluginAPI({ context, plugins }) {
3
3
  const { hooks, extendsHooks } = context;
4
4
  function getRuntimeContext() {
5
5
  if (context) {
6
- const { hooks: hooks2, extendsHooks: extendsHooks2, config, pluginAPI, ...runtimeContext } = context;
6
+ const { hooks: hooks2, extendsHooks: extendsHooks2, config, pluginAPI: pluginAPI2, ...runtimeContext } = context;
7
7
  runtimeContext._internalContext = context;
8
8
  return runtimeContext;
9
9
  }
@@ -39,7 +39,7 @@ function initPluginAPI({ context, plugins }) {
39
39
  extendsPluginApi[hookName] = extendsHooks[hookName].tap;
40
40
  });
41
41
  }
42
- return {
42
+ const pluginAPI = {
43
43
  updateRuntimeContext,
44
44
  getHooks,
45
45
  getRuntimeConfig,
@@ -49,6 +49,19 @@ function initPluginAPI({ context, plugins }) {
49
49
  pickContext: hooks.pickContext.tap,
50
50
  ...extendsPluginApi
51
51
  };
52
+ return new Proxy(pluginAPI, {
53
+ get(target, prop) {
54
+ if (prop === "then") {
55
+ return void 0;
56
+ }
57
+ if (prop in target) {
58
+ return target[prop];
59
+ }
60
+ return () => {
61
+ console.warn(`api.${prop.toString()} not exist`);
62
+ };
63
+ }
64
+ });
52
65
  }
53
66
  export {
54
67
  initPluginAPI
@@ -1,6 +1,6 @@
1
1
  import type { OnAfterBuildFn, OnAfterCreateCompilerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn } from '@rsbuild/core';
2
2
  import type { Hooks } from '../../cli/hooks';
3
- import type { PluginHookTap } from '../hooks';
3
+ import type { PluginHook, PluginHookTap } from '../hooks';
4
4
  import type { DeepPartial } from '../utils';
5
5
  import type { AppContext } from './context';
6
6
  import type { AddCommandFn, AddWatchFilesFn, ConfigFn, ModifyBundlerChainFn, ModifyConfigFn, ModifyHtmlPartialsFn, ModifyResolvedConfigFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterDeployFn, OnAfterDevFn, OnBeforeDeployFn, OnBeforeDevFn, OnBeforeExitFn, OnBeforeRestartFn, OnFileChangedFn, OnPrepareFn } from './hooks';
@@ -42,4 +42,9 @@ export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
42
42
  onBeforeDeploy: PluginHookTap<OnBeforeDeployFn>;
43
43
  onAfterDeploy: PluginHookTap<OnAfterDeployFn>;
44
44
  onBeforeExit: PluginHookTap<OnBeforeExitFn>;
45
- }>;
45
+ } & CLIPluginExtendsAPI<Extends>>;
46
+ export type CLIPluginExtendsAPI<Extends extends CLIPluginExtends> = {
47
+ [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>;
48
+ } & Extends['extendApi'];
49
+ export type AllKeysForCLIPluginExtendsAPI<Extends extends CLIPluginExtends> = keyof CLIPluginExtendsAPI<Extends>;
50
+ export type AllValueForCLIPluginExtendsAPI<Extends extends CLIPluginExtends> = CLIPluginExtendsAPI<Extends>[AllKeysForCLIPluginExtendsAPI<Extends>];
@@ -1,4 +1,4 @@
1
- import type { PluginHookTap } from '../hooks';
1
+ import type { PluginHook, PluginHookTap } from '../hooks';
2
2
  import type { DeepPartial } from '../utils';
3
3
  import type { RuntimeContext } from './context';
4
4
  import type { Hooks } from './hooks';
@@ -12,4 +12,9 @@ export type RuntimePluginAPI<Extends extends RuntimePluginExtends> = Readonly<{
12
12
  wrapRoot: PluginHookTap<WrapRootFn>;
13
13
  pickContext: PluginHookTap<PickContextFn<RuntimeContext>>;
14
14
  modifyRuntimeConfig: PluginHookTap<ModifyRuntimeConfigFn<Extends['config']>>;
15
- }>;
15
+ } & RuntimePluginExtendsAPI<Extends>>;
16
+ export type RuntimePluginExtendsAPI<Extends extends RuntimePluginExtends> = {
17
+ [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>;
18
+ } & Extends['extendApi'];
19
+ export type AllKeysForRuntimePluginExtendsAPI<Extends extends RuntimePluginExtends> = keyof RuntimePluginExtendsAPI<Extends>;
20
+ export type AllValueForRuntimePluginExtendsAPI<Extends extends RuntimePluginExtends> = RuntimePluginExtendsAPI<Extends>[AllKeysForRuntimePluginExtendsAPI<Extends>];
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-nightly-20250120062903",
18
+ "version": "0.0.0-nightly-20250122164656",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -64,9 +64,9 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@swc/helpers": "0.5.13",
67
- "@modern-js/node-bundle-require": "0.0.0-nightly-20250120062903",
68
- "@modern-js/utils": "0.0.0-nightly-20250120062903",
69
- "@modern-js/runtime-utils": "0.0.0-nightly-20250120062903"
67
+ "@modern-js/node-bundle-require": "0.0.0-nightly-20250122164656",
68
+ "@modern-js/utils": "0.0.0-nightly-20250122164656",
69
+ "@modern-js/runtime-utils": "0.0.0-nightly-20250122164656"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@rsbuild/core": "1.1.13",
@@ -75,10 +75,10 @@
75
75
  "@types/node": "^14",
76
76
  "jest": "^29",
77
77
  "typescript": "^5",
78
- "@modern-js/types": "0.0.0-nightly-20250120062903",
79
- "@modern-js/uni-builder": "0.0.0-nightly-20250120062903",
80
- "@scripts/build": "0.0.0-nightly-20250120062903",
81
- "@scripts/jest-config": "0.0.0-nightly-20250120062903"
78
+ "@modern-js/types": "0.0.0-nightly-20250122164656",
79
+ "@modern-js/uni-builder": "0.0.0-nightly-20250122164656",
80
+ "@scripts/build": "0.0.0-nightly-20250122164656",
81
+ "@scripts/jest-config": "0.0.0-nightly-20250122164656"
82
82
  },
83
83
  "sideEffects": false,
84
84
  "publishConfig": {