@modern-js/core 1.4.6 → 1.6.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/.eslintrc.js +8 -0
- package/CHANGELOG.md +47 -0
- package/dist/js/modern/config/defaults.js +4 -1
- package/dist/js/modern/config/index.js +2 -1
- package/dist/js/modern/config/types/index.js +0 -0
- package/dist/js/modern/config/types/less.js +0 -0
- package/dist/js/modern/config/types/sass.js +0 -0
- package/dist/js/modern/config/types/ssg.js +0 -0
- package/dist/js/modern/config/types/test.js +0 -0
- package/dist/js/modern/config/types/unbundle.js +0 -0
- package/dist/js/modern/context.js +18 -0
- package/dist/js/modern/index.js +9 -28
- package/dist/js/modern/initWatcher.js +1 -0
- package/dist/js/modern/loadPlugins.js +43 -48
- package/dist/js/modern/manager.js +28 -0
- package/dist/js/modern/pluginAPI.js +11 -0
- package/dist/js/node/config/defaults.js +4 -1
- package/dist/js/node/config/index.js +22 -1
- package/dist/js/node/config/types/index.js +0 -0
- package/dist/js/node/config/types/less.js +0 -0
- package/dist/js/node/config/types/sass.js +0 -0
- package/dist/js/node/config/types/ssg.js +0 -0
- package/dist/js/node/config/types/test.js +0 -0
- package/dist/js/node/config/types/unbundle.js +0 -0
- package/dist/js/node/context.js +22 -1
- package/dist/js/node/index.js +78 -67
- package/dist/js/node/initWatcher.js +1 -0
- package/dist/js/node/loadPlugins.js +42 -47
- package/dist/js/node/manager.js +45 -0
- package/dist/js/node/pluginAPI.js +54 -0
- package/dist/types/config/defaults.d.ts +3 -0
- package/dist/types/config/index.d.ts +3 -129
- package/dist/types/config/types/index.d.ts +231 -0
- package/dist/types/config/types/less.d.ts +10 -0
- package/dist/types/config/types/sass.d.ts +8 -0
- package/dist/types/config/types/ssg.d.ts +13 -0
- package/dist/types/config/types/test.d.ts +15 -0
- package/dist/types/config/types/unbundle.d.ts +28 -0
- package/dist/types/context.d.ts +19 -1
- package/dist/types/index.d.ts +6 -95
- package/dist/types/initWatcher.d.ts +1 -1
- package/dist/types/loadPlugins.d.ts +24 -13
- package/dist/types/manager.d.ts +74 -0
- package/dist/types/pluginAPI.d.ts +13 -0
- package/jest.config.js +0 -1
- package/package.json +13 -8
- package/tests/config.test.ts +1 -1
- package/tests/initWatcher.test.ts +1 -1
- package/tests/loadPlugin.test.ts +32 -43
- package/tests/pluginAPI.test.ts +19 -0
package/.eslintrc.js
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 1.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ef28a4e6: fix: module-tools build error
|
|
8
|
+
- 132f7b53: feat: move config declarations to @modern-js/core
|
|
9
|
+
- 9d4a005b: fix: config babel via tools.babel
|
|
10
|
+
- Updated dependencies [132f7b53]
|
|
11
|
+
- @modern-js/utils@1.3.7
|
|
12
|
+
|
|
13
|
+
## 1.6.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 4e2026e4: feat: support new plugin config
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 05ce88a0: fix: set default value for type NormalizedConfig to ensure all config keys are required
|
|
22
|
+
- a8df060e: support setup dev middleware first step
|
|
23
|
+
- 6a7acb81: modify devServer type and name
|
|
24
|
+
- Updated dependencies [c2046f37]
|
|
25
|
+
- Updated dependencies [dc88abf9]
|
|
26
|
+
- Updated dependencies [0462ff77]
|
|
27
|
+
- @modern-js/utils@1.3.6
|
|
28
|
+
- @modern-js/plugin@1.3.2
|
|
29
|
+
|
|
30
|
+
## 1.5.0
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- 80d8ddfe: feat: add `CliPlugin` type to define new plugin
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- 80d3cfb7: fix: server.metrics type
|
|
39
|
+
- 42c6b136: feat: support api.setAppContext
|
|
40
|
+
- 4e7dcbd5: fix: server.logger type
|
|
41
|
+
- 9e8bc4ab: fix: server.routes type
|
|
42
|
+
- 0c556e59: fix: tools.less type
|
|
43
|
+
- 2008fdbd: convert two packages server part, support server load plugin itself
|
|
44
|
+
- Updated dependencies [5bf5868d]
|
|
45
|
+
- Updated dependencies [80d8ddfe]
|
|
46
|
+
- Updated dependencies [491145e3]
|
|
47
|
+
- @modern-js/utils@1.3.5
|
|
48
|
+
- @modern-js/plugin@1.3.0
|
|
49
|
+
|
|
3
50
|
## 1.4.6
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
|
@@ -19,6 +19,7 @@ import { patchSchema } from "./schema";
|
|
|
19
19
|
const debug = createDebugger('resolve-config');
|
|
20
20
|
export { defaults as defaultsConfig };
|
|
21
21
|
export { mergeConfig };
|
|
22
|
+
export * from "./types";
|
|
22
23
|
export const defineConfig = config => config;
|
|
23
24
|
export const loadUserConfig = async (appDirectory, filePath, packageJsonConfig) => {
|
|
24
25
|
const loaded = await loadConfig(appDirectory, filePath, packageJsonConfig);
|
|
@@ -42,7 +43,7 @@ const showAdditionalPropertiesError = error => {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
/* eslint-disable
|
|
46
|
+
/* eslint-disable max-statements, max-params */
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
export const resolveConfig = async (loaded, configs, schemas, restartWithExistingPort, argv, onSchemaError = showAdditionalPropertiesError) => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,8 +4,26 @@ import address from 'address';
|
|
|
4
4
|
export const AppContext = createContext({});
|
|
5
5
|
export const ConfigContext = createContext({});
|
|
6
6
|
export const ResolvedConfigContext = createContext({});
|
|
7
|
+
/**
|
|
8
|
+
* Set app context.
|
|
9
|
+
* @param value new app context. It will override previous app context.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const setAppContext = value => AppContext.set(value);
|
|
13
|
+
/**
|
|
14
|
+
* Get app context, including directories, plugins and some static infos.
|
|
15
|
+
*/
|
|
16
|
+
|
|
7
17
|
export const useAppContext = () => AppContext.use().value;
|
|
18
|
+
/**
|
|
19
|
+
* Get original content of user config.
|
|
20
|
+
*/
|
|
21
|
+
|
|
8
22
|
export const useConfigContext = () => ConfigContext.use().value;
|
|
23
|
+
/**
|
|
24
|
+
* Get normalized content of user config.
|
|
25
|
+
*/
|
|
26
|
+
|
|
9
27
|
export const useResolvedConfigContext = () => ResolvedConfigContext.use().value;
|
|
10
28
|
export const initAppContext = (appDirectory, plugins, configFile, options) => {
|
|
11
29
|
const {
|
package/dist/js/modern/index.js
CHANGED
|
@@ -5,41 +5,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
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; }
|
|
6
6
|
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import {
|
|
9
|
-
import { createAsyncManager, createAsyncWorkflow, createParallelWorkflow, createAsyncWaterfall } from '@modern-js/plugin';
|
|
8
|
+
import { pkgUp, ensureAbsolutePath, logger } from '@modern-js/utils';
|
|
10
9
|
import { enable } from '@modern-js/plugin/node';
|
|
11
10
|
import { program } from "./utils/commander";
|
|
12
11
|
import { resolveConfig, loadUserConfig } from "./config";
|
|
13
12
|
import { loadPlugins } from "./loadPlugins";
|
|
14
|
-
import { AppContext, ConfigContext, initAppContext, ResolvedConfigContext
|
|
13
|
+
import { AppContext, ConfigContext, initAppContext, ResolvedConfigContext } from "./context";
|
|
15
14
|
import { initWatcher } from "./initWatcher";
|
|
16
15
|
import { loadEnv } from "./loadEnv";
|
|
16
|
+
import { manager } from "./manager";
|
|
17
17
|
export * from "./config";
|
|
18
18
|
export * from '@modern-js/plugin';
|
|
19
|
-
export * from '@modern-js/plugin/node';
|
|
19
|
+
export * from '@modern-js/plugin/node'; // TODO: remove export after refactor all plugins
|
|
20
|
+
|
|
21
|
+
export { manager, mountHook, usePlugins, createPlugin, registerHook } from "./manager";
|
|
22
|
+
// TODO: remove export after refactor all plugins
|
|
23
|
+
export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext } from "./pluginAPI";
|
|
20
24
|
program.name('modern').usage('<command> [options]').version(process.env.MODERN_JS_VERSION || '0.1.0');
|
|
21
|
-
const hooksMap = {
|
|
22
|
-
config: createParallelWorkflow(),
|
|
23
|
-
resolvedConfig: createAsyncWaterfall(),
|
|
24
|
-
validateSchema: createParallelWorkflow(),
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
26
|
-
prepare: createAsyncWorkflow(),
|
|
27
|
-
commands: createAsyncWorkflow(),
|
|
28
|
-
watchFiles: createParallelWorkflow(),
|
|
29
|
-
fileChange: createAsyncWorkflow(),
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
31
|
-
beforeExit: createAsyncWorkflow(),
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
33
|
-
beforeRestart: createAsyncWorkflow()
|
|
34
|
-
};
|
|
35
|
-
export const manager = createAsyncManager(hooksMap);
|
|
36
|
-
export const {
|
|
37
|
-
createPlugin,
|
|
38
|
-
registe: registerHook,
|
|
39
|
-
useRunner: mountHook
|
|
40
|
-
} = manager;
|
|
41
|
-
export const usePlugins = plugins => plugins.forEach(plugin => manager.usePlugin(compatRequire(require.resolve(plugin))));
|
|
42
|
-
export { AppContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, ConfigContext };
|
|
43
25
|
|
|
44
26
|
const initAppDir = async cwd => {
|
|
45
27
|
if (!cwd) {
|
|
@@ -75,8 +57,7 @@ const createCli = () => {
|
|
|
75
57
|
loadEnv(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
|
|
76
58
|
const loaded = await loadUserConfig(appDirectory, options === null || options === void 0 ? void 0 : options.configFile, options === null || options === void 0 ? void 0 : options.packageJsonConfig);
|
|
77
59
|
const plugins = loadPlugins(appDirectory, loaded.config, {
|
|
78
|
-
internalPlugins: options === null || options === void 0 ? void 0 : options.plugins
|
|
79
|
-
transformPlugin: options === null || options === void 0 ? void 0 : options.transformPlugin
|
|
60
|
+
internalPlugins: options === null || options === void 0 ? void 0 : options.plugins
|
|
80
61
|
});
|
|
81
62
|
plugins.forEach(plugin => plugin.cli && manager.usePlugin(plugin.cli));
|
|
82
63
|
const appContext = initAppContext(appDirectory, plugins, loaded.filePath, options === null || options === void 0 ? void 0 : options.options);
|
|
@@ -17,6 +17,7 @@ export const initWatcher = async (loaded, appDirectory, configDir, hooksRunner,
|
|
|
17
17
|
debug(`watched: %o`, watched);
|
|
18
18
|
const watcher = chokidar.watch(watched, {
|
|
19
19
|
cwd: appDirectory,
|
|
20
|
+
ignoreInitial: true,
|
|
20
21
|
ignorePermissionErrors: true,
|
|
21
22
|
ignored: [/node_modules/, '**/__test__/**', '**/*.test.(js|jsx|ts|tsx)', '**/*.spec.(js|jsx|ts|tsx)', '**/*.stories.(js|jsx|ts|tsx)']
|
|
22
23
|
});
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
1
|
import { isDepExists, createDebugger, compatRequire, INTERNAL_PLUGINS } from '@modern-js/utils';
|
|
2
|
+
import { createPlugin } from "./manager";
|
|
8
3
|
const debug = createDebugger('load-plugins');
|
|
9
4
|
|
|
10
5
|
/**
|
|
@@ -32,7 +27,7 @@ const tryResolve = (name, appDirectory) => {
|
|
|
32
27
|
return filePath;
|
|
33
28
|
};
|
|
34
29
|
|
|
35
|
-
export function getAppPlugins(appDirectory,
|
|
30
|
+
export function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
|
|
36
31
|
const allPlugins = internalPlugins || INTERNAL_PLUGINS;
|
|
37
32
|
const appPlugins = [...Object.keys(allPlugins).filter(name => {
|
|
38
33
|
const config = allPlugins[name];
|
|
@@ -43,45 +38,44 @@ export function getAppPlugins(appDirectory, pluginConfig, internalPlugins) {
|
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
return isDepExists(appDirectory, name);
|
|
46
|
-
}).map(name => allPlugins[name]), ...
|
|
41
|
+
}).map(name => allPlugins[name]), ...oldPluginConfig];
|
|
47
42
|
return appPlugins;
|
|
48
43
|
}
|
|
44
|
+
|
|
45
|
+
const resolveCliPlugin = (p, appDirectory) => {
|
|
46
|
+
const pkg = typeof p === 'string' ? p : p[0];
|
|
47
|
+
const path = tryResolve(pkg, appDirectory);
|
|
48
|
+
const module = compatRequire(path);
|
|
49
|
+
|
|
50
|
+
if (typeof module === 'function') {
|
|
51
|
+
const pluginOptions = Array.isArray(p) ? p[1] : undefined;
|
|
52
|
+
const result = module(pluginOptions);
|
|
53
|
+
return createPlugin(result.setup, result);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return module;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const isOldPluginConfig = config => Array.isArray(config) && config.some(item => {
|
|
60
|
+
if (typeof item === 'string' || Array.isArray(item)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return 'cli' in item || 'server' in item;
|
|
65
|
+
});
|
|
49
66
|
/**
|
|
50
67
|
* Load internal plugins which in @modern-js scope and user's custom plugins.
|
|
51
68
|
* @param appDirectory - Application root directory.
|
|
52
69
|
* @param userConfig - Resolved user config.
|
|
53
70
|
* @param options.internalPlugins - Internal plugins.
|
|
54
|
-
* @param options.transformPlugin - transform plugin before using it.
|
|
55
71
|
* @returns Plugin Objects has been required.
|
|
56
72
|
*/
|
|
57
73
|
|
|
58
|
-
export const loadPlugins = (appDirectory, userConfig, options = {}) => {
|
|
59
|
-
const {
|
|
60
|
-
internalPlugins,
|
|
61
|
-
transformPlugin
|
|
62
|
-
} = options;
|
|
63
|
-
|
|
64
|
-
const resolvePlugin = p => {
|
|
65
|
-
const pkg = typeof p === 'string' ? p : p[0];
|
|
66
|
-
const path = tryResolve(pkg, appDirectory);
|
|
67
|
-
let module = compatRequire(path);
|
|
68
|
-
const pluginOptions = Array.isArray(p) ? p[1] : undefined;
|
|
69
|
-
|
|
70
|
-
if (transformPlugin) {
|
|
71
|
-
module = transformPlugin(module, userConfig, pluginOptions);
|
|
72
|
-
} else {
|
|
73
|
-
module = typeof module === 'function' ? module(pluginOptions) : module;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
pkg,
|
|
78
|
-
path,
|
|
79
|
-
module
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
74
|
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
export const loadPlugins = (appDirectory, userConfig, options = {}) => {
|
|
76
|
+
const pluginConfig = userConfig.plugins;
|
|
77
|
+
const plugins = getAppPlugins(appDirectory, isOldPluginConfig(pluginConfig) ? pluginConfig : [], options.internalPlugins);
|
|
78
|
+
const loadedPlugins = plugins.map(plugin => {
|
|
85
79
|
const _plugin = typeof plugin === 'string' || Array.isArray(plugin) ? {
|
|
86
80
|
cli: plugin
|
|
87
81
|
} : plugin;
|
|
@@ -93,23 +87,12 @@ export const loadPlugins = (appDirectory, userConfig, options = {}) => {
|
|
|
93
87
|
const loadedPlugin = {};
|
|
94
88
|
|
|
95
89
|
if (cli) {
|
|
96
|
-
|
|
97
|
-
pkg,
|
|
98
|
-
path,
|
|
99
|
-
module
|
|
100
|
-
} = resolvePlugin(cli);
|
|
101
|
-
loadedPlugin.cli = _objectSpread(_objectSpread({}, module), {}, {
|
|
102
|
-
pluginPath: path
|
|
103
|
-
});
|
|
104
|
-
loadedPlugin.cliPkg = pkg;
|
|
90
|
+
loadedPlugin.cli = resolveCliPlugin(cli, appDirectory);
|
|
105
91
|
} // server plugins don't support to accept params
|
|
106
92
|
|
|
107
93
|
|
|
108
94
|
if (server && typeof server === 'string') {
|
|
109
|
-
|
|
110
|
-
loadedPlugin.server = {
|
|
111
|
-
pluginPath: path
|
|
112
|
-
};
|
|
95
|
+
loadedPlugin.server = server;
|
|
113
96
|
loadedPlugin.serverPkg = server;
|
|
114
97
|
}
|
|
115
98
|
|
|
@@ -119,4 +102,16 @@ export const loadPlugins = (appDirectory, userConfig, options = {}) => {
|
|
|
119
102
|
});
|
|
120
103
|
return loadedPlugin;
|
|
121
104
|
});
|
|
105
|
+
|
|
106
|
+
if (!isOldPluginConfig(pluginConfig)) {
|
|
107
|
+
const cliPlugins = Array.isArray(pluginConfig) ? pluginConfig : pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.cli;
|
|
108
|
+
|
|
109
|
+
if (cliPlugins !== null && cliPlugins !== void 0 && cliPlugins.length) {
|
|
110
|
+
loadedPlugins.push(...cliPlugins.map(item => ({
|
|
111
|
+
cli: createPlugin(item.setup, item)
|
|
112
|
+
})));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return loadedPlugins;
|
|
122
117
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createAsyncManager, createAsyncWorkflow, createAsyncWaterfall, createParallelWorkflow } from '@modern-js/plugin';
|
|
2
|
+
import { compatRequire } from '@modern-js/utils';
|
|
3
|
+
import { pluginAPI } from "./pluginAPI";
|
|
4
|
+
const baseHooks = {
|
|
5
|
+
config: createParallelWorkflow(),
|
|
6
|
+
resolvedConfig: createAsyncWaterfall(),
|
|
7
|
+
validateSchema: createParallelWorkflow(),
|
|
8
|
+
prepare: createAsyncWorkflow(),
|
|
9
|
+
commands: createAsyncWorkflow(),
|
|
10
|
+
watchFiles: createParallelWorkflow(),
|
|
11
|
+
fileChange: createAsyncWorkflow(),
|
|
12
|
+
beforeExit: createAsyncWorkflow(),
|
|
13
|
+
beforeRestart: createAsyncWorkflow()
|
|
14
|
+
};
|
|
15
|
+
/** All hooks of cli plugin. */
|
|
16
|
+
|
|
17
|
+
export const manager = createAsyncManager(baseHooks, pluginAPI);
|
|
18
|
+
/** Plugin options of a cli plugin. */
|
|
19
|
+
|
|
20
|
+
export const {
|
|
21
|
+
createPlugin,
|
|
22
|
+
registerHook,
|
|
23
|
+
useRunner: mountHook
|
|
24
|
+
} = manager;
|
|
25
|
+
export const usePlugins = plugins => plugins.forEach(pluginPath => {
|
|
26
|
+
const module = compatRequire(require.resolve(pluginPath));
|
|
27
|
+
manager.usePlugin(module);
|
|
28
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppContext, ConfigContext, setAppContext, useAppContext, useConfigContext, ResolvedConfigContext, useResolvedConfigContext } from "./context";
|
|
2
|
+
export const pluginAPI = {
|
|
3
|
+
setAppContext,
|
|
4
|
+
useAppContext,
|
|
5
|
+
useConfigContext,
|
|
6
|
+
useResolvedConfigContext
|
|
7
|
+
};
|
|
8
|
+
/** all apis for cli plugin */
|
|
9
|
+
|
|
10
|
+
// TODO: only export types after refactor all plugins
|
|
11
|
+
export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext };
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
defineConfig: true,
|
|
8
|
+
loadUserConfig: true,
|
|
9
|
+
resolveConfig: true,
|
|
10
|
+
defaultsConfig: true,
|
|
11
|
+
mergeConfig: true
|
|
12
|
+
};
|
|
6
13
|
Object.defineProperty(exports, "defaultsConfig", {
|
|
7
14
|
enumerable: true,
|
|
8
15
|
get: function () {
|
|
@@ -42,6 +49,20 @@ var _mergeConfig = require("./mergeConfig");
|
|
|
42
49
|
|
|
43
50
|
var _schema = require("./schema");
|
|
44
51
|
|
|
52
|
+
var _types = require("./types");
|
|
53
|
+
|
|
54
|
+
Object.keys(_types).forEach(function (key) {
|
|
55
|
+
if (key === "default" || key === "__esModule") return;
|
|
56
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
57
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
58
|
+
Object.defineProperty(exports, key, {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return _types[key];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
45
66
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
46
67
|
|
|
47
68
|
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; }
|
|
@@ -80,7 +101,7 @@ const showAdditionalPropertiesError = error => {
|
|
|
80
101
|
}
|
|
81
102
|
}
|
|
82
103
|
};
|
|
83
|
-
/* eslint-disable
|
|
104
|
+
/* eslint-disable max-statements, max-params */
|
|
84
105
|
|
|
85
106
|
|
|
86
107
|
const resolveConfig = async (loaded, configs, schemas, restartWithExistingPort, argv, onSchemaError = showAdditionalPropertiesError) => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/js/node/context.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.initAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = void 0;
|
|
6
|
+
exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.setAppContext = exports.initAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = void 0;
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
@@ -18,13 +18,34 @@ exports.AppContext = AppContext;
|
|
|
18
18
|
const ConfigContext = (0, _plugin.createContext)({});
|
|
19
19
|
exports.ConfigContext = ConfigContext;
|
|
20
20
|
const ResolvedConfigContext = (0, _plugin.createContext)({});
|
|
21
|
+
/**
|
|
22
|
+
* Set app context.
|
|
23
|
+
* @param value new app context. It will override previous app context.
|
|
24
|
+
*/
|
|
25
|
+
|
|
21
26
|
exports.ResolvedConfigContext = ResolvedConfigContext;
|
|
22
27
|
|
|
28
|
+
const setAppContext = value => AppContext.set(value);
|
|
29
|
+
/**
|
|
30
|
+
* Get app context, including directories, plugins and some static infos.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
exports.setAppContext = setAppContext;
|
|
35
|
+
|
|
23
36
|
const useAppContext = () => AppContext.use().value;
|
|
37
|
+
/**
|
|
38
|
+
* Get original content of user config.
|
|
39
|
+
*/
|
|
40
|
+
|
|
24
41
|
|
|
25
42
|
exports.useAppContext = useAppContext;
|
|
26
43
|
|
|
27
44
|
const useConfigContext = () => ConfigContext.use().value;
|
|
45
|
+
/**
|
|
46
|
+
* Get normalized content of user config.
|
|
47
|
+
*/
|
|
48
|
+
|
|
28
49
|
|
|
29
50
|
exports.useConfigContext = useConfigContext;
|
|
30
51
|
|