@modern-js/core 1.4.5 → 1.6.0

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.
@@ -4,16 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
+ cli: true,
8
+ initAppDir: true,
9
+ initAppContext: true,
7
10
  manager: true,
8
- createPlugin: true,
9
- registerHook: true,
10
11
  mountHook: true,
11
12
  usePlugins: true,
12
- cli: true,
13
- initAppDir: true,
13
+ createPlugin: true,
14
+ registerHook: true,
14
15
  AppContext: true,
15
16
  ConfigContext: true,
16
- initAppContext: true,
17
17
  ResolvedConfigContext: true,
18
18
  useAppContext: true,
19
19
  useConfigContext: true,
@@ -22,46 +22,75 @@ var _exportNames = {
22
22
  Object.defineProperty(exports, "AppContext", {
23
23
  enumerable: true,
24
24
  get: function () {
25
- return _context.AppContext;
25
+ return _pluginAPI.AppContext;
26
26
  }
27
27
  });
28
28
  Object.defineProperty(exports, "ConfigContext", {
29
29
  enumerable: true,
30
30
  get: function () {
31
- return _context.ConfigContext;
31
+ return _pluginAPI.ConfigContext;
32
32
  }
33
33
  });
34
34
  Object.defineProperty(exports, "ResolvedConfigContext", {
35
35
  enumerable: true,
36
36
  get: function () {
37
- return _context.ResolvedConfigContext;
37
+ return _pluginAPI.ResolvedConfigContext;
38
+ }
39
+ });
40
+ exports.cli = void 0;
41
+ Object.defineProperty(exports, "createPlugin", {
42
+ enumerable: true,
43
+ get: function () {
44
+ return _manager.createPlugin;
38
45
  }
39
46
  });
40
- exports.createPlugin = exports.cli = void 0;
41
47
  Object.defineProperty(exports, "initAppContext", {
42
48
  enumerable: true,
43
49
  get: function () {
44
50
  return _context.initAppContext;
45
51
  }
46
52
  });
47
- exports.registerHook = exports.mountHook = exports.manager = exports.initAppDir = void 0;
53
+ exports.initAppDir = void 0;
54
+ Object.defineProperty(exports, "manager", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _manager.manager;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "mountHook", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _manager.mountHook;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "registerHook", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _manager.registerHook;
70
+ }
71
+ });
48
72
  Object.defineProperty(exports, "useAppContext", {
49
73
  enumerable: true,
50
74
  get: function () {
51
- return _context.useAppContext;
75
+ return _pluginAPI.useAppContext;
52
76
  }
53
77
  });
54
78
  Object.defineProperty(exports, "useConfigContext", {
55
79
  enumerable: true,
56
80
  get: function () {
57
- return _context.useConfigContext;
81
+ return _pluginAPI.useConfigContext;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "usePlugins", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _manager.usePlugins;
58
88
  }
59
89
  });
60
- exports.usePlugins = void 0;
61
90
  Object.defineProperty(exports, "useResolvedConfigContext", {
62
91
  enumerable: true,
63
92
  get: function () {
64
- return _context.useResolvedConfigContext;
93
+ return _pluginAPI.useResolvedConfigContext;
65
94
  }
66
95
  });
67
96
 
@@ -69,20 +98,6 @@ var _path = _interopRequireDefault(require("path"));
69
98
 
70
99
  var _utils = require("@modern-js/utils");
71
100
 
72
- var _plugin = require("@modern-js/plugin");
73
-
74
- Object.keys(_plugin).forEach(function (key) {
75
- if (key === "default" || key === "__esModule") return;
76
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
77
- if (key in exports && exports[key] === _plugin[key]) return;
78
- Object.defineProperty(exports, key, {
79
- enumerable: true,
80
- get: function () {
81
- return _plugin[key];
82
- }
83
- });
84
- });
85
-
86
101
  var _node = require("@modern-js/plugin/node");
87
102
 
88
103
  Object.keys(_node).forEach(function (key) {
@@ -121,6 +136,24 @@ var _initWatcher = require("./initWatcher");
121
136
 
122
137
  var _loadEnv = require("./loadEnv");
123
138
 
139
+ var _manager = require("./manager");
140
+
141
+ var _plugin = require("@modern-js/plugin");
142
+
143
+ Object.keys(_plugin).forEach(function (key) {
144
+ if (key === "default" || key === "__esModule") return;
145
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
146
+ if (key in exports && exports[key] === _plugin[key]) return;
147
+ Object.defineProperty(exports, key, {
148
+ enumerable: true,
149
+ get: function () {
150
+ return _plugin[key];
151
+ }
152
+ });
153
+ });
154
+
155
+ var _pluginAPI = require("./pluginAPI");
156
+
124
157
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
125
158
 
126
159
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -131,35 +164,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
131
164
 
132
165
  _commander.program.name('modern').usage('<command> [options]').version(process.env.MODERN_JS_VERSION || '0.1.0');
133
166
 
134
- const hooksMap = {
135
- config: (0, _plugin.createParallelWorkflow)(),
136
- resolvedConfig: (0, _plugin.createAsyncWaterfall)(),
137
- validateSchema: (0, _plugin.createParallelWorkflow)(),
138
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
139
- prepare: (0, _plugin.createAsyncWorkflow)(),
140
- commands: (0, _plugin.createAsyncWorkflow)(),
141
- watchFiles: (0, _plugin.createParallelWorkflow)(),
142
- fileChange: (0, _plugin.createAsyncWorkflow)(),
143
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
144
- beforeExit: (0, _plugin.createAsyncWorkflow)(),
145
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
146
- beforeRestart: (0, _plugin.createAsyncWorkflow)()
147
- };
148
- const manager = (0, _plugin.createAsyncManager)(hooksMap);
149
- exports.manager = manager;
150
- const {
151
- createPlugin,
152
- registe: registerHook,
153
- useRunner: mountHook
154
- } = manager;
155
- exports.mountHook = mountHook;
156
- exports.registerHook = registerHook;
157
- exports.createPlugin = createPlugin;
158
-
159
- const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin((0, _utils.compatRequire)(require.resolve(plugin))));
160
-
161
- exports.usePlugins = usePlugins;
162
-
163
167
  const initAppDir = async cwd => {
164
168
  if (!cwd) {
165
169
  // eslint-disable-next-line no-param-reassign
@@ -189,24 +193,27 @@ const createCli = () => {
189
193
  var _options$options$meta, _options$options;
190
194
 
191
195
  (0, _node.enable)();
192
- manager.clear();
196
+
197
+ _manager.manager.clear();
198
+
193
199
  restartOptions = options;
194
200
  const appDirectory = await initAppDir();
195
201
  const metaName = (_options$options$meta = options === null || options === void 0 ? void 0 : (_options$options = options.options) === null || _options$options === void 0 ? void 0 : _options$options.metaName) !== null && _options$options$meta !== void 0 ? _options$options$meta : 'MODERN';
196
202
  (0, _loadEnv.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
197
203
  const loaded = await (0, _config.loadUserConfig)(appDirectory, options === null || options === void 0 ? void 0 : options.configFile, options === null || options === void 0 ? void 0 : options.packageJsonConfig);
198
204
  const plugins = (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config, {
199
- internalPlugins: options === null || options === void 0 ? void 0 : options.plugins,
200
- transformPlugin: options === null || options === void 0 ? void 0 : options.transformPlugin
205
+ internalPlugins: options === null || options === void 0 ? void 0 : options.plugins
201
206
  });
202
- plugins.forEach(plugin => plugin.cli && manager.usePlugin(plugin.cli));
207
+ plugins.forEach(plugin => plugin.cli && _manager.manager.usePlugin(plugin.cli));
203
208
  const appContext = (0, _context.initAppContext)(appDirectory, plugins, loaded.filePath, options === null || options === void 0 ? void 0 : options.options);
204
- manager.run(() => {
209
+
210
+ _manager.manager.run(() => {
205
211
  _context.ConfigContext.set(loaded.config);
206
212
 
207
213
  _context.AppContext.set(appContext);
208
214
  });
209
- hooksRunner = await manager.init();
215
+
216
+ hooksRunner = await _manager.manager.init();
210
217
  ['SIGINT', 'SIGTERM', 'unhandledRejection', 'uncaughtException'].forEach(event => {
211
218
  process.on(event, async err => {
212
219
  await hooksRunner.beforeExit();
@@ -230,7 +237,7 @@ const createCli = () => {
230
237
  resolved: config
231
238
  }); // update context value
232
239
 
233
- manager.run(() => {
240
+ _manager.manager.run(() => {
234
241
  _context.ConfigContext.set(loaded.config);
235
242
 
236
243
  _context.ResolvedConfigContext.set(resolved);
@@ -240,6 +247,7 @@ const createCli = () => {
240
247
  distDirectory: (0, _utils.ensureAbsolutePath)(appDirectory, resolved.output.path)
241
248
  }));
242
249
  });
250
+
243
251
  await hooksRunner.prepare();
244
252
  return {
245
253
  loadedConfig: loaded,
@@ -258,7 +266,8 @@ const createCli = () => {
258
266
  program: _commander.program
259
267
  });
260
268
  (0, _initWatcher.initWatcher)(loadedConfig, appContext.appDirectory, resolved.source.configDir, hooksRunner, argv);
261
- manager.run(() => _commander.program.parse(process.argv));
269
+
270
+ _manager.manager.run(() => _commander.program.parse(process.argv));
262
271
  }
263
272
 
264
273
  async function restart() {
@@ -270,7 +279,9 @@ const createCli = () => {
270
279
  _utils.logger.info('Restart...\n');
271
280
 
272
281
  let hasGetError = false;
273
- const runner = manager.useRunner();
282
+
283
+ const runner = _manager.manager.useRunner();
284
+
274
285
  await runner.beforeRestart();
275
286
 
276
287
  try {
@@ -280,7 +291,7 @@ const createCli = () => {
280
291
  hasGetError = true;
281
292
  } finally {
282
293
  if (!hasGetError) {
283
- manager.run(() => _commander.program.parse(process.argv));
294
+ _manager.manager.run(() => _commander.program.parse(process.argv));
284
295
  }
285
296
  }
286
297
  }
@@ -8,11 +8,7 @@ exports.loadPlugins = void 0;
8
8
 
9
9
  var _utils = require("@modern-js/utils");
10
10
 
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
-
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
-
15
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ var _manager = require("./manager");
16
12
 
17
13
  const debug = (0, _utils.createDebugger)('load-plugins');
18
14
 
@@ -41,7 +37,7 @@ const tryResolve = (name, appDirectory) => {
41
37
  return filePath;
42
38
  };
43
39
 
44
- function getAppPlugins(appDirectory, pluginConfig, internalPlugins) {
40
+ function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
45
41
  const allPlugins = internalPlugins || _utils.INTERNAL_PLUGINS;
46
42
  const appPlugins = [...Object.keys(allPlugins).filter(name => {
47
43
  const config = allPlugins[name];
@@ -52,46 +48,44 @@ function getAppPlugins(appDirectory, pluginConfig, internalPlugins) {
52
48
  }
53
49
 
54
50
  return (0, _utils.isDepExists)(appDirectory, name);
55
- }).map(name => allPlugins[name]), ...pluginConfig];
51
+ }).map(name => allPlugins[name]), ...oldPluginConfig];
56
52
  return appPlugins;
57
53
  }
54
+
55
+ const resolveCliPlugin = (p, appDirectory) => {
56
+ const pkg = typeof p === 'string' ? p : p[0];
57
+ const path = tryResolve(pkg, appDirectory);
58
+ const module = (0, _utils.compatRequire)(path);
59
+
60
+ if (typeof module === 'function') {
61
+ const pluginOptions = Array.isArray(p) ? p[1] : undefined;
62
+ const result = module(pluginOptions);
63
+ return (0, _manager.createPlugin)(result.setup, result);
64
+ }
65
+
66
+ return module;
67
+ };
68
+
69
+ const isOldPluginConfig = config => Array.isArray(config) && config.some(item => {
70
+ if (typeof item === 'string' || Array.isArray(item)) {
71
+ return true;
72
+ }
73
+
74
+ return 'cli' in item || 'server' in item;
75
+ });
58
76
  /**
59
77
  * Load internal plugins which in @modern-js scope and user's custom plugins.
60
78
  * @param appDirectory - Application root directory.
61
79
  * @param userConfig - Resolved user config.
62
80
  * @param options.internalPlugins - Internal plugins.
63
- * @param options.transformPlugin - transform plugin before using it.
64
81
  * @returns Plugin Objects has been required.
65
82
  */
66
83
 
67
84
 
68
85
  const loadPlugins = (appDirectory, userConfig, options = {}) => {
69
- const {
70
- internalPlugins,
71
- transformPlugin
72
- } = options;
73
-
74
- const resolvePlugin = p => {
75
- const pkg = typeof p === 'string' ? p : p[0];
76
- const path = tryResolve(pkg, appDirectory);
77
- let module = (0, _utils.compatRequire)(path);
78
- const pluginOptions = Array.isArray(p) ? p[1] : undefined;
79
-
80
- if (transformPlugin) {
81
- module = transformPlugin(module, userConfig, pluginOptions);
82
- } else {
83
- module = typeof module === 'function' ? module(pluginOptions) : module;
84
- }
85
-
86
- return {
87
- pkg,
88
- path,
89
- module
90
- };
91
- };
92
-
93
- const plugins = getAppPlugins(appDirectory, userConfig.plugins || [], internalPlugins);
94
- return plugins.map(plugin => {
86
+ const pluginConfig = userConfig.plugins;
87
+ const plugins = getAppPlugins(appDirectory, isOldPluginConfig(pluginConfig) ? pluginConfig : [], options.internalPlugins);
88
+ const loadedPlugins = plugins.map(plugin => {
95
89
  const _plugin = typeof plugin === 'string' || Array.isArray(plugin) ? {
96
90
  cli: plugin
97
91
  } : plugin;
@@ -103,23 +97,12 @@ const loadPlugins = (appDirectory, userConfig, options = {}) => {
103
97
  const loadedPlugin = {};
104
98
 
105
99
  if (cli) {
106
- const {
107
- pkg,
108
- path,
109
- module
110
- } = resolvePlugin(cli);
111
- loadedPlugin.cli = _objectSpread(_objectSpread({}, module), {}, {
112
- pluginPath: path
113
- });
114
- loadedPlugin.cliPkg = pkg;
100
+ loadedPlugin.cli = resolveCliPlugin(cli, appDirectory);
115
101
  } // server plugins don't support to accept params
116
102
 
117
103
 
118
104
  if (server && typeof server === 'string') {
119
- const path = tryResolve(server, appDirectory);
120
- loadedPlugin.server = {
121
- pluginPath: path
122
- };
105
+ loadedPlugin.server = server;
123
106
  loadedPlugin.serverPkg = server;
124
107
  }
125
108
 
@@ -129,6 +112,18 @@ const loadPlugins = (appDirectory, userConfig, options = {}) => {
129
112
  });
130
113
  return loadedPlugin;
131
114
  });
115
+
116
+ if (!isOldPluginConfig(pluginConfig)) {
117
+ const cliPlugins = Array.isArray(pluginConfig) ? pluginConfig : pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.cli;
118
+
119
+ if (cliPlugins !== null && cliPlugins !== void 0 && cliPlugins.length) {
120
+ loadedPlugins.push(...cliPlugins.map(item => ({
121
+ cli: (0, _manager.createPlugin)(item.setup, item)
122
+ })));
123
+ }
124
+ }
125
+
126
+ return loadedPlugins;
132
127
  };
133
128
 
134
129
  exports.loadPlugins = loadPlugins;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.usePlugins = exports.registerHook = exports.mountHook = exports.manager = exports.createPlugin = void 0;
7
+
8
+ var _plugin = require("@modern-js/plugin");
9
+
10
+ var _utils = require("@modern-js/utils");
11
+
12
+ var _pluginAPI = require("./pluginAPI");
13
+
14
+ const baseHooks = {
15
+ config: (0, _plugin.createParallelWorkflow)(),
16
+ resolvedConfig: (0, _plugin.createAsyncWaterfall)(),
17
+ validateSchema: (0, _plugin.createParallelWorkflow)(),
18
+ prepare: (0, _plugin.createAsyncWorkflow)(),
19
+ commands: (0, _plugin.createAsyncWorkflow)(),
20
+ watchFiles: (0, _plugin.createParallelWorkflow)(),
21
+ fileChange: (0, _plugin.createAsyncWorkflow)(),
22
+ beforeExit: (0, _plugin.createAsyncWorkflow)(),
23
+ beforeRestart: (0, _plugin.createAsyncWorkflow)()
24
+ };
25
+ /** All hooks of cli plugin. */
26
+
27
+ const manager = (0, _plugin.createAsyncManager)(baseHooks, _pluginAPI.pluginAPI);
28
+ /** Plugin options of a cli plugin. */
29
+
30
+ exports.manager = manager;
31
+ const {
32
+ createPlugin,
33
+ registerHook,
34
+ useRunner: mountHook
35
+ } = manager;
36
+ exports.mountHook = mountHook;
37
+ exports.registerHook = registerHook;
38
+ exports.createPlugin = createPlugin;
39
+
40
+ const usePlugins = plugins => plugins.forEach(pluginPath => {
41
+ const module = (0, _utils.compatRequire)(require.resolve(pluginPath));
42
+ manager.usePlugin(module);
43
+ });
44
+
45
+ exports.usePlugins = usePlugins;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AppContext", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _context.AppContext;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ConfigContext", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _context.ConfigContext;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "ResolvedConfigContext", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _context.ResolvedConfigContext;
22
+ }
23
+ });
24
+ exports.pluginAPI = void 0;
25
+ Object.defineProperty(exports, "useAppContext", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _context.useAppContext;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "useConfigContext", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _context.useConfigContext;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "useResolvedConfigContext", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _context.useResolvedConfigContext;
41
+ }
42
+ });
43
+
44
+ var _context = require("./context");
45
+
46
+ const pluginAPI = {
47
+ setAppContext: _context.setAppContext,
48
+ useAppContext: _context.useAppContext,
49
+ useConfigContext: _context.useConfigContext,
50
+ useResolvedConfigContext: _context.useResolvedConfigContext
51
+ };
52
+ /** all apis for cli plugin */
53
+
54
+ exports.pluginAPI = pluginAPI;
@@ -22,4 +22,7 @@ export declare const defaults: {
22
22
  terser: undefined;
23
23
  minifyCss: undefined;
24
24
  };
25
+ plugins: never[];
26
+ runtime: {};
27
+ runtimeByEntries: {};
25
28
  };
@@ -1,5 +1,8 @@
1
+ /// <reference types="node" />
2
+ import http from 'http';
1
3
  import { ErrorObject } from 'ajv';
2
4
  import { MetaOptions } from '@modern-js/utils';
5
+ import type { NextFunction, ProxyOptions } from '@modern-js/types';
3
6
  import { PluginConfig } from '../loadPlugins';
4
7
  import { defaults } from './defaults';
5
8
  import { mergeConfig, NormalizedConfig } from './mergeConfig';
@@ -65,7 +68,7 @@ interface OutputConfig {
65
68
  enableTsLoader?: boolean;
66
69
  }
67
70
  interface ServerConfig {
68
- routes?: Record<string, string | {
71
+ routes?: Record<string, string | string[] | {
69
72
  route: string | string[];
70
73
  disableSpa?: boolean;
71
74
  }>;
@@ -76,8 +79,8 @@ interface ServerConfig {
76
79
  ssrByEntries?: Record<string, boolean | Record<string, unknown>>;
77
80
  baseUrl?: string | Array<string>;
78
81
  port?: number;
79
- logger?: Record<string, any>;
80
- metrics?: Record<string, any>;
82
+ logger?: boolean | Record<string, any>;
83
+ metrics?: boolean | Record<string, any>;
81
84
  enableMicroFrontendDebug?: boolean;
82
85
  }
83
86
  interface DevConfig {
@@ -95,6 +98,14 @@ interface DeployConfig {
95
98
  domainByEntries?: Record<string, string | Array<string>>;
96
99
  }
97
100
  declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>) => Record<string, unknown> | void);
101
+ declare type RequestHandler = (req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
102
+ declare type DevServerConfig = {
103
+ proxy?: ProxyOptions;
104
+ headers?: Record<string, string>;
105
+ before?: RequestHandler[];
106
+ after?: RequestHandler[];
107
+ [propsName: string]: any;
108
+ };
98
109
  interface ToolsConfig {
99
110
  webpack?: ConfigFunction;
100
111
  babel?: ConfigFunction;
@@ -102,7 +113,7 @@ interface ToolsConfig {
102
113
  postcss?: ConfigFunction;
103
114
  styledComponents?: ConfigFunction;
104
115
  lodash?: ConfigFunction;
105
- devServer?: Record<string, unknown>;
116
+ devServer?: DevServerConfig;
106
117
  tsLoader?: ConfigFunction;
107
118
  terser?: ConfigFunction;
108
119
  minifyCss?: ConfigFunction;
@@ -380,10 +380,10 @@ export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | P
380
380
  instanceof: string;
381
381
  };
382
382
  logger: {
383
- type: string;
383
+ type: string[];
384
384
  };
385
385
  metrics: {
386
- type: string;
386
+ type: string[];
387
387
  };
388
388
  proxy: {
389
389
  type: string;
@@ -167,10 +167,10 @@ export declare const server: {
167
167
  instanceof: string;
168
168
  };
169
169
  logger: {
170
- type: string;
170
+ type: string[];
171
171
  };
172
172
  metrics: {
173
- type: string;
173
+ type: string[];
174
174
  };
175
175
  proxy: {
176
176
  type: string;
@@ -6,10 +6,28 @@ export type { IAppContext };
6
6
  export declare const AppContext: import("@modern-js/plugin").Context<IAppContext>;
7
7
  export declare const ConfigContext: import("@modern-js/plugin").Context<UserConfig>;
8
8
  export declare const ResolvedConfigContext: import("@modern-js/plugin").Context<NormalizedConfig>;
9
+ /**
10
+ * Set app context.
11
+ * @param value new app context. It will override previous app context.
12
+ */
13
+
14
+ export declare const setAppContext: (value: IAppContext) => void;
15
+ /**
16
+ * Get app context, including directories, plugins and some static infos.
17
+ */
18
+
9
19
  export declare const useAppContext: () => IAppContext;
20
+ /**
21
+ * Get original content of user config.
22
+ */
23
+
10
24
  export declare const useConfigContext: () => UserConfig;
25
+ /**
26
+ * Get normalized content of user config.
27
+ */
28
+
11
29
  export declare const useResolvedConfigContext: () => NormalizedConfig;
12
- export declare const initAppContext: (appDirectory: string, plugins: Array<LoadedPlugin>, configFile: string | false, options?: {
30
+ export declare const initAppContext: (appDirectory: string, plugins: LoadedPlugin[], configFile: string | false, options?: {
13
31
  metaName?: string | undefined;
14
32
  srcDir?: string | undefined;
15
33
  distDir?: string | undefined;