@modern-js/core 2.9.0 → 2.11.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.
- package/CHANGELOG.md +53 -0
- package/dist/config/createLoadedConfig.d.ts +1 -1
- package/dist/config/createLoadedConfig.js +6 -2
- package/dist/config/loadConfig.d.ts +1 -1
- package/dist/config/loadConfig.js +5 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +19 -2
- package/dist/manager.d.ts +6 -6
- package/dist/manager.js +1 -1
- package/dist/node-api.d.ts +4 -0
- package/dist/node-api.js +16 -0
- package/dist/types/hooks.d.ts +2 -2
- package/dist/utils/checkIsDuplicationPlugin.d.ts +1 -0
- package/dist/utils/checkIsDuplicationPlugin.js +25 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +27 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 2.11.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0bd018b: feat: support use node api run dev & build & deploy command
|
|
8
|
+
feat: 支持通过 node api 运行 dev & build & deploy 命令
|
|
9
|
+
- 7178795: fix(core): beforeExit should be sync workflow
|
|
10
|
+
|
|
11
|
+
fix(core): beforeExit 需要使用同步的 workflow
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [cfb058f]
|
|
14
|
+
- Updated dependencies [0bd018b]
|
|
15
|
+
- Updated dependencies [5d624fd]
|
|
16
|
+
- Updated dependencies [e2466a1]
|
|
17
|
+
- Updated dependencies [02bb383]
|
|
18
|
+
- Updated dependencies [381a3b9]
|
|
19
|
+
- Updated dependencies [7a60f10]
|
|
20
|
+
- Updated dependencies [274b2e5]
|
|
21
|
+
- Updated dependencies [b9e1c54]
|
|
22
|
+
- @modern-js/utils@2.11.0
|
|
23
|
+
- @modern-js/node-bundle-require@2.11.0
|
|
24
|
+
- @modern-js/plugin@2.11.0
|
|
25
|
+
|
|
26
|
+
## 2.10.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- a16b9b0: feat: warning when user registe plugin duplication
|
|
31
|
+
feat: 当用户重复注册插件时进行 warning 提示
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 0da32d0: chore: upgrade jest and puppeteer
|
|
36
|
+
chore: 升级 jest 和 puppeteer 到 latest
|
|
37
|
+
- d3f0642: feat(core): throw warnings when config file is not found
|
|
38
|
+
|
|
39
|
+
feat(core): 找不到配置文件时抛出 warning
|
|
40
|
+
|
|
41
|
+
- 0d9962b: fix: add types field in package.json
|
|
42
|
+
fix: 添加 package.json 中的 types 字段
|
|
43
|
+
- fbefa7e: chore(deps): bump webpack from 5.75.0 to 5.76.2
|
|
44
|
+
|
|
45
|
+
chore(deps): 将 webpack 从 5.75.0 升级至 5.76.2
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [0da32d0]
|
|
48
|
+
- Updated dependencies [0d9962b]
|
|
49
|
+
- Updated dependencies [fbefa7e]
|
|
50
|
+
- Updated dependencies [4d54233]
|
|
51
|
+
- Updated dependencies [6db4864]
|
|
52
|
+
- @modern-js/node-bundle-require@2.10.0
|
|
53
|
+
- @modern-js/plugin@2.10.0
|
|
54
|
+
- @modern-js/utils@2.10.0
|
|
55
|
+
|
|
3
56
|
## 2.9.0
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
|
@@ -3,4 +3,4 @@ import { LoadedConfig, UserConfig } from '../types';
|
|
|
3
3
|
* Assign the pkg config into the user config.
|
|
4
4
|
*/
|
|
5
5
|
export declare const assignPkgConfig: (userConfig?: UserConfig, pkgConfig?: UserConfig) => UserConfig;
|
|
6
|
-
export declare function createLoadedConfig(appDirectory: string, filePath?: string, packageJsonConfig?: string): Promise<LoadedConfig<{}>>;
|
|
6
|
+
export declare function createLoadedConfig(appDirectory: string, filePath?: string, packageJsonConfig?: string, loadedConfig?: UserConfig): Promise<LoadedConfig<{}>>;
|
|
@@ -53,9 +53,13 @@ async function loadLocalConfig(appDirectory, configFile) {
|
|
|
53
53
|
}
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
|
-
async function createLoadedConfig(appDirectory, filePath, packageJsonConfig) {
|
|
56
|
+
async function createLoadedConfig(appDirectory, filePath, packageJsonConfig, loadedConfig) {
|
|
57
57
|
const configFile = (0, loadConfig_1.getConfigFilePath)(appDirectory, filePath);
|
|
58
|
-
const loaded = await (0, loadConfig_1.loadConfig)(appDirectory, configFile, packageJsonConfig);
|
|
58
|
+
const loaded = await (0, loadConfig_1.loadConfig)(appDirectory, configFile, packageJsonConfig, loadedConfig);
|
|
59
|
+
if (!loaded.config && !loaded.pkgConfig) {
|
|
60
|
+
utils_1.logger.warn(`Can not find any config file in the current project, please check if you have a correct config file.`);
|
|
61
|
+
utils_1.logger.warn(`Current project path: ${utils_1.chalk.yellow(appDirectory)}`);
|
|
62
|
+
}
|
|
59
63
|
const config = await getConfigObject(loaded.config);
|
|
60
64
|
let mergedConfig = config;
|
|
61
65
|
if (loaded.pkgConfig) {
|
|
@@ -27,7 +27,7 @@ export declare const getConfigFilePath: (appDirectory: string, filePath?: string
|
|
|
27
27
|
* @param configFile - Specific absolute config file path.
|
|
28
28
|
* @returns Object contain config file path, user config object and dependency files used by config file.
|
|
29
29
|
*/
|
|
30
|
-
export declare const loadConfig: <T>(appDirectory: string, configFile: string | false, packageJsonConfig?: string) => Promise<{
|
|
30
|
+
export declare const loadConfig: <T>(appDirectory: string, configFile: string | false, packageJsonConfig?: string, loadedConfig?: T | undefined) => Promise<{
|
|
31
31
|
path: string | false;
|
|
32
32
|
config?: T | undefined;
|
|
33
33
|
dependencies?: string[] | undefined;
|
|
@@ -101,13 +101,16 @@ exports.getConfigFilePath = getConfigFilePath;
|
|
|
101
101
|
* @param configFile - Specific absolute config file path.
|
|
102
102
|
* @returns Object contain config file path, user config object and dependency files used by config file.
|
|
103
103
|
*/
|
|
104
|
-
const loadConfig = async (appDirectory, configFile, packageJsonConfig) => {
|
|
104
|
+
const loadConfig = async (appDirectory, configFile, packageJsonConfig, loadedConfig) => {
|
|
105
105
|
const pkgConfig = (0, exports.getPackageConfig)(appDirectory, packageJsonConfig);
|
|
106
106
|
let config;
|
|
107
107
|
const dependencies = pkgConfig
|
|
108
108
|
? [path_1.default.resolve(appDirectory, './package.json')]
|
|
109
109
|
: [];
|
|
110
|
-
if (
|
|
110
|
+
if (loadedConfig) {
|
|
111
|
+
config = loadedConfig;
|
|
112
|
+
}
|
|
113
|
+
else if (configFile) {
|
|
111
114
|
delete require.cache[configFile];
|
|
112
115
|
const mod = await bundleRequireWithCatch(configFile, { appDirectory });
|
|
113
116
|
config = mod.default || mod;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ErrorObject } from '@modern-js/utils/ajv';
|
|
2
2
|
import { InternalPlugins } from '@modern-js/types';
|
|
3
3
|
import { initAppContext } from './context';
|
|
4
|
-
import type { ToolsType } from './types';
|
|
4
|
+
import type { ToolsType, UserConfig } from './types';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from '@modern-js/plugin';
|
|
7
7
|
export { manager, createPlugin, registerHook } from './manager';
|
|
@@ -28,6 +28,8 @@ export interface CoreOptions {
|
|
|
28
28
|
toolsType?: ToolsType;
|
|
29
29
|
/** force the modern-js core auto register plugin exist in the package.json */
|
|
30
30
|
forceAutoLoadPlugins?: boolean;
|
|
31
|
+
/** config for Node API */
|
|
32
|
+
loadedConfig?: UserConfig;
|
|
31
33
|
}
|
|
32
34
|
export declare const mergeOptions: (options?: CoreOptions) => {
|
|
33
35
|
cwd?: string | undefined;
|
|
@@ -49,6 +51,7 @@ export declare const mergeOptions: (options?: CoreOptions) => {
|
|
|
49
51
|
} | undefined;
|
|
50
52
|
toolsType?: ToolsType | undefined;
|
|
51
53
|
forceAutoLoadPlugins?: boolean | undefined;
|
|
54
|
+
loadedConfig?: UserConfig<{}, {}, {}, {}> | undefined;
|
|
52
55
|
};
|
|
53
56
|
export declare const cli: {
|
|
54
57
|
init: (options?: CoreOptions) => Promise<{
|
|
@@ -60,6 +63,7 @@ export declare const cli: {
|
|
|
60
63
|
coreOptions?: CoreOptions;
|
|
61
64
|
disableWatcher?: boolean;
|
|
62
65
|
}) => Promise<void>;
|
|
66
|
+
runCommand: (command: string, commandOptions?: string[], options?: CoreOptions) => Promise<void>;
|
|
63
67
|
getPrevInitOptions: () => CoreOptions | undefined;
|
|
64
68
|
};
|
|
65
69
|
export { initAppDir, initAppContext };
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "initAppContext", { enumerable: true, get: functi
|
|
|
27
27
|
const loadEnv_1 = require("./loadEnv");
|
|
28
28
|
const manager_1 = require("./manager");
|
|
29
29
|
const config_1 = require("./config");
|
|
30
|
+
const checkIsDuplicationPlugin_1 = require("./utils/checkIsDuplicationPlugin");
|
|
30
31
|
__exportStar(require("./types"), exports);
|
|
31
32
|
__exportStar(require("@modern-js/plugin"), exports);
|
|
32
33
|
var manager_2 = require("./manager");
|
|
@@ -78,12 +79,13 @@ const createCli = () => {
|
|
|
78
79
|
setProgramVersion(options === null || options === void 0 ? void 0 : options.version);
|
|
79
80
|
const metaName = (_b = (_a = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options) === null || _a === void 0 ? void 0 : _a.metaName) !== null && _b !== void 0 ? _b : 'MODERN';
|
|
80
81
|
(0, loadEnv_1.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
|
|
81
|
-
const loaded = await (0, config_1.createLoadedConfig)(appDirectory, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.configFile, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.packageJsonConfig);
|
|
82
|
+
const loaded = await (0, config_1.createLoadedConfig)(appDirectory, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.configFile, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.packageJsonConfig, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.loadedConfig);
|
|
82
83
|
const plugins = await (0, loadPlugins_1.loadPlugins)(appDirectory, loaded.config, {
|
|
83
84
|
internalPlugins: (_c = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _c === void 0 ? void 0 : _c.cli,
|
|
84
85
|
autoLoad: (_d = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.internalPlugins) === null || _d === void 0 ? void 0 : _d.autoLoad,
|
|
85
86
|
forceAutoLoadPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.forceAutoLoadPlugins,
|
|
86
87
|
});
|
|
88
|
+
(0, checkIsDuplicationPlugin_1.checkIsDuplicationPlugin)(plugins.map(plugin => plugin.name), loaded.config.autoLoadPlugins);
|
|
87
89
|
plugins.forEach(plugin => plugin && manager_1.manager.usePlugin(plugin));
|
|
88
90
|
const appContext = (0, context_1.initAppContext)({
|
|
89
91
|
toolsType: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.toolsType,
|
|
@@ -99,7 +101,7 @@ const createCli = () => {
|
|
|
99
101
|
hooksRunner = await manager_1.manager.init();
|
|
100
102
|
['SIGINT', 'SIGTERM', 'unhandledRejection', 'uncaughtException'].forEach(event => {
|
|
101
103
|
process.on(event, async (err) => {
|
|
102
|
-
|
|
104
|
+
hooksRunner.beforeExit();
|
|
103
105
|
if (err instanceof Error) {
|
|
104
106
|
utils_1.logger.error(err.stack);
|
|
105
107
|
}
|
|
@@ -131,6 +133,20 @@ const createCli = () => {
|
|
|
131
133
|
await hooksRunner.commands({ program: utils_1.program });
|
|
132
134
|
await (0, utils_2.createFileWatcher)(appContext, hooksRunner);
|
|
133
135
|
utils_1.program.parse(process.argv);
|
|
136
|
+
if (!utils_1.program.commands || !utils_1.program.commands.length) {
|
|
137
|
+
utils_1.logger.warn('No command found, please make sure you have registered plugins correctly.');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function runCommand(command, commandOptions = [], options) {
|
|
141
|
+
const argv = process.argv
|
|
142
|
+
.slice(0, 2)
|
|
143
|
+
.concat(command)
|
|
144
|
+
.concat(commandOptions);
|
|
145
|
+
process.env.MODERN_ARGV = argv.join(' ');
|
|
146
|
+
const { appContext } = await init(options);
|
|
147
|
+
await hooksRunner.commands({ program: utils_1.program });
|
|
148
|
+
await (0, utils_2.createFileWatcher)(appContext, hooksRunner);
|
|
149
|
+
utils_1.program.parse(argv);
|
|
134
150
|
}
|
|
135
151
|
async function test(argv, options) {
|
|
136
152
|
const newProgram = new utils_1.Command();
|
|
@@ -143,6 +159,7 @@ const createCli = () => {
|
|
|
143
159
|
init,
|
|
144
160
|
run,
|
|
145
161
|
test,
|
|
162
|
+
runCommand,
|
|
146
163
|
getPrevInitOptions: () => initOptions,
|
|
147
164
|
};
|
|
148
165
|
};
|
package/dist/manager.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const manager: import("@modern-js/plugin").AsyncManager<{
|
|
|
15
15
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
16
16
|
program: import("@modern-js/utils").Command;
|
|
17
17
|
}, void>;
|
|
18
|
-
beforeExit: import("@modern-js/plugin").
|
|
18
|
+
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
19
19
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
20
20
|
}, BasePluginAPI<{}, {}, {}, {}>>;
|
|
21
21
|
export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSetup<{
|
|
@@ -34,7 +34,7 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
|
|
|
34
34
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
35
35
|
program: import("@modern-js/utils").Command;
|
|
36
36
|
}, void>;
|
|
37
|
-
beforeExit: import("@modern-js/plugin").
|
|
37
|
+
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
38
38
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
39
39
|
}, BasePluginAPI<{}, {}, {}, {}>> | undefined, options?: import("@modern-js/plugin").PluginOptions<{
|
|
40
40
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}, {}, {}, {}>>;
|
|
@@ -52,7 +52,7 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
|
|
|
52
52
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
53
53
|
program: import("@modern-js/utils").Command;
|
|
54
54
|
}, void>;
|
|
55
|
-
beforeExit: import("@modern-js/plugin").
|
|
55
|
+
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
56
56
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
57
57
|
}, import("@modern-js/plugin").AsyncSetup<{
|
|
58
58
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}, {}, {}, {}>>;
|
|
@@ -70,7 +70,7 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
|
|
|
70
70
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
71
71
|
program: import("@modern-js/utils").Command;
|
|
72
72
|
}, void>;
|
|
73
|
-
beforeExit: import("@modern-js/plugin").
|
|
73
|
+
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
74
74
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
75
75
|
}, BasePluginAPI<{}, {}, {}, {}>>, Record<string, unknown>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
|
|
76
76
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}, {}, {}, {}>>;
|
|
@@ -88,7 +88,7 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
|
|
|
88
88
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
89
89
|
program: import("@modern-js/utils").Command;
|
|
90
90
|
}, void>;
|
|
91
|
-
beforeExit: import("@modern-js/plugin").
|
|
91
|
+
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
92
92
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
93
93
|
}, BasePluginAPI<{}, {}, {}, {}>>, registerHook: (newHooks: Partial<{
|
|
94
94
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}, {}, {}, {}>>;
|
|
@@ -106,6 +106,6 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
|
|
|
106
106
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
107
107
|
program: import("@modern-js/utils").Command;
|
|
108
108
|
}, void>;
|
|
109
|
-
beforeExit: import("@modern-js/plugin").
|
|
109
|
+
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
110
110
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
111
111
|
}>) => void;
|
package/dist/manager.js
CHANGED
|
@@ -13,7 +13,7 @@ const baseHooks = {
|
|
|
13
13
|
commands: (0, plugin_1.createAsyncWorkflow)(),
|
|
14
14
|
watchFiles: (0, plugin_1.createParallelWorkflow)(),
|
|
15
15
|
fileChange: (0, plugin_1.createAsyncWorkflow)(),
|
|
16
|
-
beforeExit: (0, plugin_1.
|
|
16
|
+
beforeExit: (0, plugin_1.createWorkflow)(),
|
|
17
17
|
addRuntimeExports: (0, plugin_1.createAsyncWaterfall)(),
|
|
18
18
|
};
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CoreOptions } from '.';
|
|
2
|
+
export declare const dev: (options?: CoreOptions, commandOptions?: string[]) => void;
|
|
3
|
+
export declare const build: (options?: CoreOptions, commandOptions?: string[]) => void;
|
|
4
|
+
export declare const deploy: (options?: CoreOptions, commandOptions?: string[]) => void;
|
package/dist/node-api.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deploy = exports.build = exports.dev = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const dev = (options, commandOptions = []) => {
|
|
6
|
+
_1.cli.runCommand('dev', commandOptions, options);
|
|
7
|
+
};
|
|
8
|
+
exports.dev = dev;
|
|
9
|
+
const build = (options, commandOptions = []) => {
|
|
10
|
+
_1.cli.runCommand('build', commandOptions, options);
|
|
11
|
+
};
|
|
12
|
+
exports.build = build;
|
|
13
|
+
const deploy = (options, commandOptions = []) => {
|
|
14
|
+
_1.cli.runCommand('deploy', commandOptions, options);
|
|
15
|
+
};
|
|
16
|
+
exports.deploy = deploy;
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParallelWorkflow, AsyncWaterfall, AsyncWorkflow, ToRunners, ToThreads } from '@modern-js/plugin';
|
|
1
|
+
import { Workflow, ParallelWorkflow, AsyncWaterfall, AsyncWorkflow, ToRunners, ToThreads } from '@modern-js/plugin';
|
|
2
2
|
import type { Command } from '@modern-js/utils';
|
|
3
3
|
import type { UserConfig, NormalizedConfig } from './config';
|
|
4
4
|
export type BaseHooks<Extends extends {
|
|
@@ -21,7 +21,7 @@ export type BaseHooks<Extends extends {
|
|
|
21
21
|
commands: AsyncWorkflow<{
|
|
22
22
|
program: Command;
|
|
23
23
|
}, void>;
|
|
24
|
-
beforeExit:
|
|
24
|
+
beforeExit: Workflow<void, void>;
|
|
25
25
|
addRuntimeExports: AsyncWaterfall<void>;
|
|
26
26
|
};
|
|
27
27
|
export type CliHooksRunner<Extends extends {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkIsDuplicationPlugin(plugins: (string | undefined)[], autoLoadPlugin?: boolean): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsDuplicationPlugin = void 0;
|
|
4
|
+
const utils_1 = require("@modern-js/utils");
|
|
5
|
+
function checkIsDuplicationPlugin(plugins, autoLoadPlugin = false) {
|
|
6
|
+
const set = new Set();
|
|
7
|
+
const duplicationPlugins = [];
|
|
8
|
+
plugins
|
|
9
|
+
.filter(plugin => typeof plugin === 'string')
|
|
10
|
+
.forEach(plugin => {
|
|
11
|
+
if (set.has(plugin)) {
|
|
12
|
+
duplicationPlugins.push(plugin);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
set.add(plugin);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
if (duplicationPlugins.length > 0) {
|
|
19
|
+
utils_1.logger.warn(`Duplicate registration plugins: ${duplicationPlugins.join(',')}.`);
|
|
20
|
+
if (autoLoadPlugin) {
|
|
21
|
+
utils_1.logger.warn('This is probably because you enabled `autoLoadPlugin` configuration and also registered these plugins manually');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.checkIsDuplicationPlugin = checkIsDuplicationPlugin;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./commander"), exports);
|
|
|
18
18
|
__exportStar(require("./createFileWatcher"), exports);
|
|
19
19
|
__exportStar(require("./mergeConfig"), exports);
|
|
20
20
|
__exportStar(require("./repeatKeyWarning"), exports);
|
|
21
|
+
__exportStar(require("./checkIsDuplicationPlugin"), exports);
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"modern",
|
|
11
11
|
"modern.js"
|
|
12
12
|
],
|
|
13
|
-
"version": "2.
|
|
13
|
+
"version": "2.11.0",
|
|
14
14
|
"jsnext:source": "./src/index.ts",
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"main": "./dist/index.js",
|
|
@@ -24,15 +24,27 @@
|
|
|
24
24
|
},
|
|
25
25
|
"default": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./node": {
|
|
28
|
+
"jsnext:source": "./src/node-api.ts",
|
|
29
|
+
"types": "./dist/node-api.d.ts",
|
|
30
|
+
"default": "./dist/node-api.js"
|
|
31
|
+
},
|
|
27
32
|
"./bin": {
|
|
28
33
|
"jsnext:source": "./src/bin.ts",
|
|
29
34
|
"default": "./dist/bin.js"
|
|
30
35
|
},
|
|
36
|
+
"./config": {
|
|
37
|
+
"jsnext:source": "./src/config.ts",
|
|
38
|
+
"types": "./dist/config/types/index.d.ts",
|
|
39
|
+
"default": "./dist/config/index.js"
|
|
40
|
+
},
|
|
31
41
|
"./runBin": {
|
|
32
42
|
"jsnext:source": "./src/runBin.ts",
|
|
43
|
+
"types": "./dist/runBin.d.ts",
|
|
33
44
|
"default": "./dist/runBin.js"
|
|
34
45
|
},
|
|
35
46
|
"./types": {
|
|
47
|
+
"types": "./dist/types/index.d.ts",
|
|
36
48
|
"default": "./dist/types/index.js"
|
|
37
49
|
}
|
|
38
50
|
},
|
|
@@ -44,37 +56,39 @@
|
|
|
44
56
|
"types": [
|
|
45
57
|
"./dist/types/index.d.ts"
|
|
46
58
|
],
|
|
59
|
+
"node": [
|
|
60
|
+
"./dist/node-api.d.ts"
|
|
61
|
+
],
|
|
47
62
|
"runBin": [
|
|
48
63
|
"./dist/runBin.d.ts"
|
|
49
64
|
]
|
|
50
65
|
}
|
|
51
66
|
},
|
|
52
67
|
"dependencies": {
|
|
53
|
-
"@modern-js/node-bundle-require": "2.
|
|
54
|
-
"@modern-js/plugin": "2.
|
|
55
|
-
"@modern-js/utils": "2.
|
|
68
|
+
"@modern-js/node-bundle-require": "2.11.0",
|
|
69
|
+
"@modern-js/plugin": "2.11.0",
|
|
70
|
+
"@modern-js/utils": "2.11.0"
|
|
56
71
|
},
|
|
57
72
|
"devDependencies": {
|
|
58
|
-
"@jest/types": "^27.0.6",
|
|
59
73
|
"@types/babel__code-frame": "^7.0.3",
|
|
60
74
|
"@types/babel__core": "^7.1.16",
|
|
61
|
-
"@types/jest": "^
|
|
75
|
+
"@types/jest": "^29",
|
|
62
76
|
"@types/less": "^3.0.3",
|
|
63
77
|
"@types/node": "^14",
|
|
64
78
|
"autoprefixer": "10.4.13",
|
|
65
79
|
"btsm": "2.2.2",
|
|
66
80
|
"html-webpack-plugin": "5.5.0",
|
|
67
|
-
"jest": "^
|
|
81
|
+
"jest": "^29",
|
|
68
82
|
"postcss": "8.4.21",
|
|
69
83
|
"sass": "^1.45.0",
|
|
70
84
|
"terser-webpack-plugin": "^5.1.4",
|
|
71
85
|
"typescript": "^4",
|
|
72
|
-
"webpack": "^5.
|
|
73
|
-
"@modern-js/builder-shared": "2.
|
|
74
|
-
"@modern-js/babel-preset-app": "2.
|
|
75
|
-
"@modern-js/types": "2.
|
|
76
|
-
"@scripts/jest-config": "2.
|
|
77
|
-
"@scripts/build": "2.
|
|
86
|
+
"webpack": "^5.76.2",
|
|
87
|
+
"@modern-js/builder-shared": "2.11.0",
|
|
88
|
+
"@modern-js/babel-preset-app": "2.11.0",
|
|
89
|
+
"@modern-js/types": "2.11.0",
|
|
90
|
+
"@scripts/jest-config": "2.11.0",
|
|
91
|
+
"@scripts/build": "2.11.0"
|
|
78
92
|
},
|
|
79
93
|
"sideEffects": false,
|
|
80
94
|
"publishConfig": {
|