@modern-js/plugin-v2 2.67.1-alpha.5 → 2.67.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.
@@ -22,7 +22,6 @@ __export(api_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(api_exports);
24
24
  var import_lodash = require("@modern-js/utils/lodash");
25
- var import_context = require("./context");
26
25
  var import_debug = require("./run/utils/debug");
27
26
  function initPluginAPI({ context, pluginManager }) {
28
27
  const { hooks, extendsHooks, plugins } = context;
@@ -53,7 +52,7 @@ function initPluginAPI({ context, pluginManager }) {
53
52
  plugins.forEach((plugin) => {
54
53
  const { _registryApi } = plugin;
55
54
  if (_registryApi) {
56
- const apis = _registryApi(getAppContext, updateAppContext, _internal_resetAppContext);
55
+ const apis = _registryApi(getAppContext, updateAppContext);
57
56
  Object.keys(apis).forEach((apiName) => {
58
57
  extendsPluginApi[apiName] = apis[apiName];
59
58
  });
@@ -67,21 +66,6 @@ function initPluginAPI({ context, pluginManager }) {
67
66
  function updateAppContext(updateContext) {
68
67
  context = (0, import_lodash.assign)(context, updateContext);
69
68
  }
70
- function _internal_resetAppContext({ appContext, config, normalizedConfig }) {
71
- const { packageName, configFile, command, appDirectory, metaName } = context;
72
- context = (0, import_context.createContext)({
73
- appContext: (0, import_lodash.assign)({}, (0, import_context.initAppContext)({
74
- packageName,
75
- configFile,
76
- command,
77
- appDirectory,
78
- plugins,
79
- metaName
80
- }), appContext),
81
- config,
82
- normalizedConfig
83
- });
84
- }
85
69
  const pluginAPI = {
86
70
  isPluginExists: pluginManager.isPluginExists,
87
71
  getAppContext,
@@ -89,7 +73,6 @@ function initPluginAPI({ context, pluginManager }) {
89
73
  getNormalizedConfig,
90
74
  getHooks,
91
75
  updateAppContext,
92
- _internal_resetAppContext,
93
76
  config: hooks.config.tap,
94
77
  modifyConfig: hooks.modifyConfig.tap,
95
78
  modifyResolvedConfig: hooks.modifyResolvedConfig.tap,
@@ -49,7 +49,7 @@ function initAppContext(params) {
49
49
  plugins: params.plugins
50
50
  };
51
51
  }
52
- function createContext({ appContext, config, normalizedConfig }) {
52
+ async function createContext({ appContext, config, normalizedConfig }) {
53
53
  const { plugins } = appContext;
54
54
  const extendsHooks = {};
55
55
  plugins.forEach((plugin) => {
@@ -73,7 +73,7 @@ const createCli = () => {
73
73
  pluginManager.addPlugins(allPlugins);
74
74
  const plugins = await pluginManager.getPlugins();
75
75
  debug("CLI Plugins:", plugins.map((p) => p.name));
76
- const context = (0, import_context.createContext)({
76
+ const context = await (0, import_context.createContext)({
77
77
  appContext: (0, import_context.initAppContext)({
78
78
  packageName: loaded.packageName,
79
79
  configFile: loaded.configFile,
@@ -1,7 +1,6 @@
1
1
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
3
3
  import { assign } from "@modern-js/utils/lodash";
4
- import { createContext, initAppContext } from "./context";
5
4
  import { debug } from "./run/utils/debug";
6
5
  function initPluginAPI(param) {
7
6
  var context = param.context, pluginManager = param.pluginManager;
@@ -39,7 +38,7 @@ function initPluginAPI(param) {
39
38
  plugins.forEach(function(plugin) {
40
39
  var _registryApi = plugin._registryApi;
41
40
  if (_registryApi) {
42
- var apis = _registryApi(getAppContext, updateAppContext, _internal_resetAppContext);
41
+ var apis = _registryApi(getAppContext, updateAppContext);
43
42
  Object.keys(apis).forEach(function(apiName) {
44
43
  extendsPluginApi[apiName] = apis[apiName];
45
44
  });
@@ -53,22 +52,6 @@ function initPluginAPI(param) {
53
52
  function updateAppContext(updateContext) {
54
53
  context = assign(context, updateContext);
55
54
  }
56
- function _internal_resetAppContext(param2) {
57
- var appContext = param2.appContext, config = param2.config, normalizedConfig = param2.normalizedConfig;
58
- var packageName = context.packageName, configFile = context.configFile, command = context.command, appDirectory = context.appDirectory, metaName = context.metaName;
59
- context = createContext({
60
- appContext: assign({}, initAppContext({
61
- packageName,
62
- configFile,
63
- command,
64
- appDirectory,
65
- plugins,
66
- metaName
67
- }), appContext),
68
- config,
69
- normalizedConfig
70
- });
71
- }
72
55
  var pluginAPI = _object_spread({
73
56
  isPluginExists: pluginManager.isPluginExists,
74
57
  getAppContext,
@@ -76,7 +59,6 @@ function initPluginAPI(param) {
76
59
  getNormalizedConfig,
77
60
  getHooks,
78
61
  updateAppContext,
79
- _internal_resetAppContext,
80
62
  config: hooks.config.tap,
81
63
  modifyConfig: hooks.modifyConfig.tap,
82
64
  modifyResolvedConfig: hooks.modifyResolvedConfig.tap,
@@ -1,5 +1,7 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
1
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
5
  import path from "path";
4
6
  import { initHooks } from "./hooks";
5
7
  function initAppContext(params) {
@@ -17,22 +19,34 @@ function initAppContext(params) {
17
19
  plugins: params.plugins
18
20
  };
19
21
  }
20
- function createContext(param) {
21
- var appContext = param.appContext, config = param.config, normalizedConfig = param.normalizedConfig;
22
- var plugins = appContext.plugins;
23
- var extendsHooks = {};
24
- plugins.forEach(function(plugin) {
25
- var _plugin_registryHooks = plugin.registryHooks, registryHooks = _plugin_registryHooks === void 0 ? {} : _plugin_registryHooks;
26
- Object.keys(registryHooks).forEach(function(hookName) {
27
- extendsHooks[hookName] = registryHooks[hookName];
22
+ function createContext(_) {
23
+ return _createContext.apply(this, arguments);
24
+ }
25
+ function _createContext() {
26
+ _createContext = _async_to_generator(function(param) {
27
+ var appContext, config, normalizedConfig, plugins, extendsHooks;
28
+ return _ts_generator(this, function(_state) {
29
+ appContext = param.appContext, config = param.config, normalizedConfig = param.normalizedConfig;
30
+ plugins = appContext.plugins;
31
+ extendsHooks = {};
32
+ plugins.forEach(function(plugin) {
33
+ var _plugin_registryHooks = plugin.registryHooks, registryHooks = _plugin_registryHooks === void 0 ? {} : _plugin_registryHooks;
34
+ Object.keys(registryHooks).forEach(function(hookName) {
35
+ extendsHooks[hookName] = registryHooks[hookName];
36
+ });
37
+ });
38
+ return [
39
+ 2,
40
+ _object_spread_props(_object_spread({}, appContext), {
41
+ hooks: _object_spread({}, initHooks(), extendsHooks),
42
+ extendsHooks,
43
+ config,
44
+ normalizedConfig
45
+ })
46
+ ];
28
47
  });
29
48
  });
30
- return _object_spread_props(_object_spread({}, appContext), {
31
- hooks: _object_spread({}, initHooks(), extendsHooks),
32
- extendsHooks,
33
- config,
34
- normalizedConfig
35
- });
49
+ return _createContext.apply(this, arguments);
36
50
  }
37
51
  export {
38
52
  createContext,
@@ -99,79 +99,84 @@ var createCli = function() {
99
99
  debug("CLI Plugins:", plugins.map(function(p) {
100
100
  return p.name;
101
101
  }));
102
- context = createContext({
103
- appContext: initAppContext({
104
- packageName: loaded.packageName,
105
- configFile: loaded.configFile,
106
- command,
107
- appDirectory,
108
- plugins,
109
- metaName
110
- }),
111
- config: loaded.config,
112
- normalizedConfig: {}
113
- });
102
+ return [
103
+ 4,
104
+ createContext({
105
+ appContext: initAppContext({
106
+ packageName: loaded.packageName,
107
+ configFile: loaded.configFile,
108
+ command,
109
+ appDirectory,
110
+ plugins,
111
+ metaName
112
+ }),
113
+ config: loaded.config,
114
+ normalizedConfig: {}
115
+ })
116
+ ];
117
+ case 4:
118
+ context = _state.sent();
114
119
  pluginAPI = initPluginAPI({
115
120
  context,
116
121
  pluginManager
117
122
  });
118
123
  context.pluginAPI = pluginAPI;
119
124
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
120
- _state.label = 4;
121
- case 4:
125
+ _state.label = 5;
126
+ case 5:
122
127
  _state.trys.push([
123
- 4,
124
- 10,
128
+ 5,
125
129
  11,
126
- 12
130
+ 12,
131
+ 13
127
132
  ]);
128
133
  _iterator = plugins[Symbol.iterator]();
129
- _state.label = 5;
130
- case 5:
134
+ _state.label = 6;
135
+ case 6:
131
136
  if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
132
137
  return [
133
138
  3,
134
- 9
139
+ 10
135
140
  ];
136
141
  plugin = _step.value;
137
142
  return [
138
143
  4,
139
144
  (_plugin_setup = plugin.setup) === null || _plugin_setup === void 0 ? void 0 : _plugin_setup.call(plugin, pluginAPI)
140
145
  ];
141
- case 6:
146
+ case 7:
142
147
  setupResult = _state.sent();
143
148
  if (!handleSetupResult)
144
149
  return [
145
150
  3,
146
- 8
151
+ 9
147
152
  ];
148
153
  return [
149
154
  4,
150
155
  handleSetupResult(setupResult, pluginAPI)
151
156
  ];
152
- case 7:
153
- _state.sent();
154
- _state.label = 8;
155
157
  case 8:
158
+ _state.sent();
159
+ _state.label = 9;
160
+ case 9:
156
161
  _iteratorNormalCompletion = true;
157
162
  return [
158
163
  3,
159
- 5
164
+ 6
160
165
  ];
161
- case 9:
166
+ case 10:
162
167
  return [
163
168
  3,
164
- 12
169
+ 13
165
170
  ];
166
- case 10:
171
+ case 11:
167
172
  err = _state.sent();
168
173
  _didIteratorError = true;
169
174
  _iteratorError = err;
170
175
  return [
171
176
  3,
172
- 12
177
+ 13
173
178
  ];
174
- case 11:
179
+ case 12:
175
180
  try {
176
181
  if (!_iteratorNormalCompletion && _iterator.return != null) {
177
182
  _iterator.return();
@@ -184,7 +189,7 @@ var createCli = function() {
184
189
  return [
185
190
  7
186
191
  ];
187
- case 12:
192
+ case 13:
188
193
  [
189
194
  "SIGINT",
190
195
  "SIGTERM",
@@ -202,38 +207,38 @@ var createCli = function() {
202
207
  4,
203
208
  context.hooks.config.call()
204
209
  ];
205
- case 13:
210
+ case 14:
206
211
  extraConfigs = _state.sent();
207
212
  return [
208
213
  4,
209
214
  createResolveConfig(loaded, extraConfigs)
210
215
  ];
211
- case 14:
216
+ case 15:
212
217
  normalizedConfig = _state.sent();
213
218
  return [
214
219
  4,
215
220
  context.hooks.modifyResolvedConfig.call(normalizedConfig)
216
221
  ];
217
- case 15:
222
+ case 16:
218
223
  resolved = _state.sent();
219
224
  context.normalizedConfig = resolved || normalizedConfig;
220
225
  return [
221
226
  4,
222
227
  pluginAPI.updateAppContext(context)
223
228
  ];
224
- case 16:
229
+ case 17:
225
230
  _state.sent();
226
231
  return [
227
232
  4,
228
233
  context.hooks.onPrepare.call()
229
234
  ];
230
- case 17:
235
+ case 18:
231
236
  _state.sent();
232
237
  return [
233
238
  4,
234
239
  (_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()
235
240
  ];
236
- case 18:
241
+ case 19:
237
242
  _state.sent();
238
243
  return [
239
244
  2,
@@ -1,5 +1,4 @@
1
1
  import { assign } from "@modern-js/utils/lodash";
2
- import { createContext, initAppContext } from "./context";
3
2
  import { debug } from "./run/utils/debug";
4
3
  function initPluginAPI({ context, pluginManager }) {
5
4
  const { hooks, extendsHooks, plugins } = context;
@@ -30,7 +29,7 @@ function initPluginAPI({ context, pluginManager }) {
30
29
  plugins.forEach((plugin) => {
31
30
  const { _registryApi } = plugin;
32
31
  if (_registryApi) {
33
- const apis = _registryApi(getAppContext, updateAppContext, _internal_resetAppContext);
32
+ const apis = _registryApi(getAppContext, updateAppContext);
34
33
  Object.keys(apis).forEach((apiName) => {
35
34
  extendsPluginApi[apiName] = apis[apiName];
36
35
  });
@@ -44,21 +43,6 @@ function initPluginAPI({ context, pluginManager }) {
44
43
  function updateAppContext(updateContext) {
45
44
  context = assign(context, updateContext);
46
45
  }
47
- function _internal_resetAppContext({ appContext, config, normalizedConfig }) {
48
- const { packageName, configFile, command, appDirectory, metaName } = context;
49
- context = createContext({
50
- appContext: assign({}, initAppContext({
51
- packageName,
52
- configFile,
53
- command,
54
- appDirectory,
55
- plugins,
56
- metaName
57
- }), appContext),
58
- config,
59
- normalizedConfig
60
- });
61
- }
62
46
  const pluginAPI = {
63
47
  isPluginExists: pluginManager.isPluginExists,
64
48
  getAppContext,
@@ -66,7 +50,6 @@ function initPluginAPI({ context, pluginManager }) {
66
50
  getNormalizedConfig,
67
51
  getHooks,
68
52
  updateAppContext,
69
- _internal_resetAppContext,
70
53
  config: hooks.config.tap,
71
54
  modifyConfig: hooks.modifyConfig.tap,
72
55
  modifyResolvedConfig: hooks.modifyResolvedConfig.tap,
@@ -15,7 +15,7 @@ function initAppContext(params) {
15
15
  plugins: params.plugins
16
16
  };
17
17
  }
18
- function createContext({ appContext, config, normalizedConfig }) {
18
+ async function createContext({ appContext, config, normalizedConfig }) {
19
19
  const { plugins } = appContext;
20
20
  const extendsHooks = {};
21
21
  plugins.forEach((plugin) => {
@@ -50,7 +50,7 @@ const createCli = () => {
50
50
  pluginManager.addPlugins(allPlugins);
51
51
  const plugins = await pluginManager.getPlugins();
52
52
  debug("CLI Plugins:", plugins.map((p) => p.name));
53
- const context = createContext({
53
+ const context = await createContext({
54
54
  appContext: initAppContext({
55
55
  packageName: loaded.packageName,
56
56
  configFile: loaded.configFile,
@@ -1,6 +1,6 @@
1
1
  import type { AppContext, InternalContext } from '../types/cli/context';
2
2
  import type { CLIPlugin, CLIPluginExtends } from '../types/cli/plugin';
3
- export interface ContextParams<Extends extends CLIPluginExtends> {
3
+ interface ContextParams<Extends extends CLIPluginExtends> {
4
4
  appContext: AppContext<Extends>;
5
5
  config: Extends['config'];
6
6
  normalizedConfig: Extends['normalizedConfig'];
@@ -15,4 +15,5 @@ export declare function initAppContext<Extends extends CLIPluginExtends>(params:
15
15
  srcDir?: string;
16
16
  distDir?: string;
17
17
  }): AppContext<Extends>;
18
- export declare function createContext<Extends extends CLIPluginExtends>({ appContext, config, normalizedConfig, }: ContextParams<Extends>): InternalContext<Extends>;
18
+ export declare function createContext<Extends extends CLIPluginExtends>({ appContext, config, normalizedConfig, }: ContextParams<Extends>): Promise<InternalContext<Extends>>;
19
+ export {};
@@ -15,7 +15,6 @@ export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
15
15
  getNormalizedConfig: () => Readonly<Extends['normalizedConfig']>;
16
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
- _internal_resetAppContext: (appContext: AppContext<Extends> & Extends['extendContext']) => void;
19
18
  config: PluginHookTap<ConfigFn<DeepPartial<Extends['config']>>>;
20
19
  modifyConfig: PluginHookTap<ModifyConfigFn<Extends['config'], Extends['extendConfigUtils']>>;
21
20
  modifyResolvedConfig: PluginHookTap<ModifyResolvedConfigFn<Extends['normalizedConfig'], Extends['extendConfigUtils']>>;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.67.1-alpha.5",
18
+ "version": "2.67.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -81,19 +81,19 @@
81
81
  "dependencies": {
82
82
  "@swc/helpers": "0.5.13",
83
83
  "jiti": "1.21.7",
84
- "@modern-js/runtime-utils": "2.67.0",
85
- "@modern-js/utils": "2.67.0"
84
+ "@modern-js/runtime-utils": "2.67.1",
85
+ "@modern-js/utils": "2.67.1"
86
86
  },
87
87
  "devDependencies": {
88
- "@rsbuild/core": "1.3.2",
88
+ "@rsbuild/core": "1.3.5",
89
89
  "@types/jest": "^29",
90
90
  "@types/node": "^14",
91
91
  "@types/react": "^18.3.11",
92
92
  "jest": "^29",
93
93
  "typescript": "^5",
94
- "@modern-js/types": "2.67.0",
94
+ "@modern-js/types": "2.67.1",
95
+ "@modern-js/uni-builder": "2.67.1",
95
96
  "@scripts/build": "2.66.0",
96
- "@modern-js/uni-builder": "2.67.0",
97
97
  "@scripts/jest-config": "2.66.0"
98
98
  },
99
99
  "sideEffects": false,