@modern-js/core 2.35.0 → 2.36.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/dist/bin.js +2 -5
- package/dist/config/createDefaultConfig.js +24 -7
- package/dist/config/createLoadedConfig.js +55 -37
- package/dist/config/createResolvedConfig.js +50 -25
- package/dist/config/index.js +24 -6
- package/dist/config/loadConfig.js +62 -49
- package/dist/context.js +61 -48
- package/dist/createCli.js +72 -60
- package/dist/index.js +57 -56
- package/dist/loadEnv.js +40 -14
- package/dist/loadPlugins.js +40 -31
- package/dist/manager.js +45 -36
- package/dist/nodeApi.js +31 -22
- package/dist/runBin.js +32 -18
- package/dist/schema/patchSchema.js +29 -12
- package/dist/schema/traverseSchema.js +24 -7
- package/dist/types/config/index.js +15 -3
- package/dist/types/context.d.ts +51 -12
- package/dist/types/context.js +15 -3
- package/dist/types/coreOptions.js +15 -3
- package/dist/types/hooks.js +15 -3
- package/dist/types/index.js +30 -9
- package/dist/types/plugin.js +15 -3
- package/dist/types/pluginAPI.js +15 -3
- package/dist/utils/checkIsDuplicationPlugin.js +27 -10
- package/dist/utils/commander.js +29 -19
- package/dist/utils/createFileWatcher.js +45 -20
- package/dist/utils/index.js +30 -9
- package/dist/utils/initAppDir.js +38 -12
- package/dist/utils/mergeConfig.js +32 -15
- package/dist/utils/repeatKeyWarning.js +27 -17
- package/package.json +8 -8
package/dist/createCli.js
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return mergeOptions;
|
|
15
|
-
},
|
|
16
|
-
createCli: function() {
|
|
17
|
-
return createCli;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var createCli_exports = {};
|
|
20
|
+
__export(createCli_exports, {
|
|
21
|
+
createCli: () => createCli,
|
|
22
|
+
mergeOptions: () => mergeOptions
|
|
19
23
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
module.exports = __toCommonJS(createCli_exports);
|
|
25
|
+
var import_utils = require("@modern-js/utils");
|
|
26
|
+
var import_utils2 = require("./utils");
|
|
27
|
+
var import_loadPlugins = require("./loadPlugins");
|
|
28
|
+
var import_context = require("./context");
|
|
29
|
+
var import_loadEnv = require("./loadEnv");
|
|
30
|
+
var import_manager = require("./manager");
|
|
31
|
+
var import_config = require("./config");
|
|
32
|
+
var import_checkIsDuplicationPlugin = require("./utils/checkIsDuplicationPlugin");
|
|
28
33
|
const setProgramVersion = (version = "unknown") => {
|
|
29
|
-
|
|
34
|
+
import_utils.program.name("modern").usage("<command> [options]").version(version);
|
|
30
35
|
};
|
|
31
36
|
const mergeOptions = (options) => {
|
|
32
37
|
const defaultOptions = {
|
|
33
|
-
serverConfigFile:
|
|
38
|
+
serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG
|
|
34
39
|
};
|
|
35
40
|
return {
|
|
36
41
|
...defaultOptions,
|
|
@@ -41,35 +46,35 @@ const createCli = () => {
|
|
|
41
46
|
let hooksRunner;
|
|
42
47
|
let initOptions;
|
|
43
48
|
const init = async (options) => {
|
|
44
|
-
var
|
|
45
|
-
|
|
49
|
+
var _mergedOptions_options, _mergedOptions_internalPlugins, _mergedOptions_internalPlugins1, _mergedOptions_internalPlugins2;
|
|
50
|
+
import_manager.manager.clear();
|
|
46
51
|
const mergedOptions = mergeOptions(options);
|
|
47
52
|
initOptions = mergedOptions;
|
|
48
|
-
const appDirectory = await (0,
|
|
49
|
-
(0,
|
|
50
|
-
setProgramVersion(
|
|
53
|
+
const appDirectory = await (0, import_utils2.initAppDir)(options === null || options === void 0 ? void 0 : options.cwd);
|
|
54
|
+
(0, import_utils2.initCommandsMap)();
|
|
55
|
+
setProgramVersion(options === null || options === void 0 ? void 0 : options.version);
|
|
51
56
|
var _mergedOptions_options_metaName;
|
|
52
|
-
const metaName = (_mergedOptions_options_metaName =
|
|
53
|
-
(0,
|
|
54
|
-
const loaded = await (0,
|
|
55
|
-
const plugins = await (0,
|
|
56
|
-
internalPlugins:
|
|
57
|
-
autoLoad:
|
|
58
|
-
forceAutoLoadPlugins:
|
|
57
|
+
const metaName = (_mergedOptions_options_metaName = mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions_options = mergedOptions.options) === null || _mergedOptions_options === void 0 ? void 0 : _mergedOptions_options.metaName) !== null && _mergedOptions_options_metaName !== void 0 ? _mergedOptions_options_metaName : "MODERN";
|
|
58
|
+
(0, import_loadEnv.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
|
|
59
|
+
const loaded = await (0, import_config.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);
|
|
60
|
+
const plugins = await (0, import_loadPlugins.loadPlugins)(appDirectory, loaded.config, {
|
|
61
|
+
internalPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions_internalPlugins = mergedOptions.internalPlugins) === null || _mergedOptions_internalPlugins === void 0 ? void 0 : _mergedOptions_internalPlugins.cli,
|
|
62
|
+
autoLoad: mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions_internalPlugins1 = mergedOptions.internalPlugins) === null || _mergedOptions_internalPlugins1 === void 0 ? void 0 : _mergedOptions_internalPlugins1.autoLoad,
|
|
63
|
+
forceAutoLoadPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.forceAutoLoadPlugins
|
|
59
64
|
});
|
|
60
|
-
(0,
|
|
61
|
-
plugins.forEach((plugin) => plugin &&
|
|
62
|
-
const appContext = (0,
|
|
65
|
+
(0, import_checkIsDuplicationPlugin.checkIsDuplicationPlugin)(plugins.map((plugin) => plugin.name), loaded.config.autoLoadPlugins);
|
|
66
|
+
plugins.forEach((plugin) => plugin && import_manager.manager.usePlugin(plugin));
|
|
67
|
+
const appContext = (0, import_context.initAppContext)({
|
|
63
68
|
appDirectory,
|
|
64
69
|
plugins,
|
|
65
70
|
configFile: loaded.filePath,
|
|
66
|
-
options:
|
|
67
|
-
serverConfigFile:
|
|
68
|
-
serverInternalPlugins: (
|
|
71
|
+
options: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options,
|
|
72
|
+
serverConfigFile: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.serverConfigFile,
|
|
73
|
+
serverInternalPlugins: (mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions_internalPlugins2 = mergedOptions.internalPlugins) === null || _mergedOptions_internalPlugins2 === void 0 ? void 0 : _mergedOptions_internalPlugins2.server) || import_utils.INTERNAL_SERVER_PLUGINS
|
|
69
74
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
hooksRunner = await
|
|
75
|
+
import_context.ConfigContext.set(loaded.config);
|
|
76
|
+
import_context.AppContext.set(appContext);
|
|
77
|
+
hooksRunner = await import_manager.manager.init();
|
|
73
78
|
[
|
|
74
79
|
"SIGINT",
|
|
75
80
|
"SIGTERM",
|
|
@@ -79,7 +84,9 @@ const createCli = () => {
|
|
|
79
84
|
process.on(event, async (err) => {
|
|
80
85
|
hooksRunner.beforeExit();
|
|
81
86
|
if (err instanceof Error) {
|
|
82
|
-
|
|
87
|
+
import_utils.logger.error(err.stack);
|
|
88
|
+
} else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
|
|
89
|
+
console.trace("Unknown Error", err);
|
|
83
90
|
}
|
|
84
91
|
process.nextTick(() => {
|
|
85
92
|
process.exit(1);
|
|
@@ -89,29 +96,29 @@ const createCli = () => {
|
|
|
89
96
|
await hooksRunner.beforeConfig();
|
|
90
97
|
const extraConfigs = await hooksRunner.config();
|
|
91
98
|
const extraSchemas = await hooksRunner.validateSchema();
|
|
92
|
-
const normalizedConfig = await (0,
|
|
99
|
+
const normalizedConfig = await (0, import_config.createResolveConfig)(loaded, extraConfigs, extraSchemas, options === null || options === void 0 ? void 0 : options.onSchemaError);
|
|
93
100
|
const { resolved } = await hooksRunner.resolvedConfig({
|
|
94
101
|
resolved: normalizedConfig
|
|
95
102
|
});
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
import_context.ConfigContext.set(loaded.config);
|
|
104
|
+
import_context.ResolvedConfigContext.set(resolved);
|
|
98
105
|
await hooksRunner.prepare();
|
|
99
106
|
await hooksRunner.afterPrepare();
|
|
100
107
|
return {
|
|
101
108
|
resolved,
|
|
102
|
-
appContext: (0,
|
|
109
|
+
appContext: (0, import_context.useAppContext)()
|
|
103
110
|
};
|
|
104
111
|
};
|
|
105
112
|
async function run(options) {
|
|
106
113
|
var _program_commands;
|
|
107
114
|
const { appContext } = await init(options);
|
|
108
115
|
await hooksRunner.commands({
|
|
109
|
-
program:
|
|
116
|
+
program: import_utils.program
|
|
110
117
|
});
|
|
111
|
-
await (0,
|
|
112
|
-
|
|
113
|
-
if (!((_program_commands =
|
|
114
|
-
|
|
118
|
+
await (0, import_utils2.createFileWatcher)(appContext, hooksRunner);
|
|
119
|
+
import_utils.program.parse(process.argv);
|
|
120
|
+
if (!((_program_commands = import_utils.program.commands) === null || _program_commands === void 0 ? void 0 : _program_commands.length)) {
|
|
121
|
+
import_utils.logger.warn("No command found, please make sure you have registered plugins correctly.");
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
async function runCommand(command, commandOptions = [], options) {
|
|
@@ -119,13 +126,13 @@ const createCli = () => {
|
|
|
119
126
|
process.env.MODERN_ARGV = argv.join(" ");
|
|
120
127
|
const { appContext } = await init(options);
|
|
121
128
|
await hooksRunner.commands({
|
|
122
|
-
program:
|
|
129
|
+
program: import_utils.program
|
|
123
130
|
});
|
|
124
|
-
await (0,
|
|
125
|
-
|
|
131
|
+
await (0, import_utils2.createFileWatcher)(appContext, hooksRunner);
|
|
132
|
+
import_utils.program.parse(argv);
|
|
126
133
|
}
|
|
127
134
|
async function test(argv, options) {
|
|
128
|
-
const newProgram = new
|
|
135
|
+
const newProgram = new import_utils.Command();
|
|
129
136
|
const { coreOptions } = options !== null && options !== void 0 ? options : {};
|
|
130
137
|
await init(coreOptions);
|
|
131
138
|
await hooksRunner.commands({
|
|
@@ -141,3 +148,8 @@ const createCli = () => {
|
|
|
141
148
|
getPrevInitOptions: () => initOptions
|
|
142
149
|
};
|
|
143
150
|
};
|
|
151
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
152
|
+
0 && (module.exports = {
|
|
153
|
+
createCli,
|
|
154
|
+
mergeOptions
|
|
155
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return _utils.mergeConfig;
|
|
15
|
-
},
|
|
16
|
-
initAppDir: function() {
|
|
17
|
-
return _utils.initAppDir;
|
|
18
|
-
},
|
|
19
|
-
manager: function() {
|
|
20
|
-
return _manager.manager;
|
|
21
|
-
},
|
|
22
|
-
createPlugin: function() {
|
|
23
|
-
return _manager.createPlugin;
|
|
24
|
-
},
|
|
25
|
-
registerHook: function() {
|
|
26
|
-
return _manager.registerHook;
|
|
27
|
-
},
|
|
28
|
-
AppContext: function() {
|
|
29
|
-
return _context.AppContext;
|
|
30
|
-
},
|
|
31
|
-
ConfigContext: function() {
|
|
32
|
-
return _context.ConfigContext;
|
|
33
|
-
},
|
|
34
|
-
ResolvedConfigContext: function() {
|
|
35
|
-
return _context.ResolvedConfigContext;
|
|
36
|
-
},
|
|
37
|
-
useAppContext: function() {
|
|
38
|
-
return _context.useAppContext;
|
|
39
|
-
},
|
|
40
|
-
useConfigContext: function() {
|
|
41
|
-
return _context.useConfigContext;
|
|
42
|
-
},
|
|
43
|
-
useResolvedConfigContext: function() {
|
|
44
|
-
return _context.useResolvedConfigContext;
|
|
45
|
-
},
|
|
46
|
-
initAppContext: function() {
|
|
47
|
-
return _context.initAppContext;
|
|
48
|
-
},
|
|
49
|
-
cli: function() {
|
|
50
|
-
return cli;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
51
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var src_exports = {};
|
|
21
|
+
__export(src_exports, {
|
|
22
|
+
AppContext: () => import_context.AppContext,
|
|
23
|
+
ConfigContext: () => import_context.ConfigContext,
|
|
24
|
+
ResolvedConfigContext: () => import_context.ResolvedConfigContext,
|
|
25
|
+
cli: () => cli,
|
|
26
|
+
createPlugin: () => import_manager.createPlugin,
|
|
27
|
+
initAppContext: () => import_context.initAppContext,
|
|
28
|
+
initAppDir: () => import_utils.initAppDir,
|
|
29
|
+
manager: () => import_manager.manager,
|
|
30
|
+
mergeConfig: () => import_utils.mergeConfig,
|
|
31
|
+
registerHook: () => import_manager.registerHook,
|
|
32
|
+
useAppContext: () => import_context.useAppContext,
|
|
33
|
+
useConfigContext: () => import_context.useConfigContext,
|
|
34
|
+
useResolvedConfigContext: () => import_context.useResolvedConfigContext
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
var import_createCli = require("./createCli");
|
|
38
|
+
__reExport(src_exports, require("./types"), module.exports);
|
|
39
|
+
__reExport(src_exports, require("@modern-js/plugin"), module.exports);
|
|
40
|
+
var import_utils = require("./utils");
|
|
41
|
+
var import_manager = require("./manager");
|
|
42
|
+
var import_context = require("./context");
|
|
43
|
+
const cli = (0, import_createCli.createCli)();
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
AppContext,
|
|
47
|
+
ConfigContext,
|
|
48
|
+
ResolvedConfigContext,
|
|
49
|
+
cli,
|
|
50
|
+
createPlugin,
|
|
51
|
+
initAppContext,
|
|
52
|
+
initAppDir,
|
|
53
|
+
manager,
|
|
54
|
+
mergeConfig,
|
|
55
|
+
registerHook,
|
|
56
|
+
useAppContext,
|
|
57
|
+
useConfigContext,
|
|
58
|
+
useResolvedConfigContext,
|
|
59
|
+
...require("./types"),
|
|
60
|
+
...require("@modern-js/plugin")
|
|
52
61
|
});
|
|
53
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
|
54
|
-
const _createCli = require("./createCli");
|
|
55
|
-
_export_star._(require("./types"), exports);
|
|
56
|
-
_export_star._(require("@modern-js/plugin"), exports);
|
|
57
|
-
const _utils = require("./utils");
|
|
58
|
-
const _manager = require("./manager");
|
|
59
|
-
const _context = require("./context");
|
|
60
|
-
const cli = (0, _createCli.createCli)();
|
package/dist/loadEnv.js
CHANGED
|
@@ -1,27 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var loadEnv_exports = {};
|
|
30
|
+
__export(loadEnv_exports, {
|
|
31
|
+
loadEnv: () => loadEnv
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
module.exports = __toCommonJS(loadEnv_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
15
37
|
const loadEnv = (appDirectory, mode = process.env.NODE_ENV) => {
|
|
16
38
|
[
|
|
17
39
|
`.env.${mode}.local`,
|
|
18
40
|
".env.local",
|
|
19
41
|
`.env.${mode}`,
|
|
20
42
|
".env"
|
|
21
|
-
].map((name) =>
|
|
22
|
-
const envConfig =
|
|
43
|
+
].map((name) => import_path.default.resolve(appDirectory, name)).filter((filePath) => import_fs.default.existsSync(filePath) && !import_fs.default.statSync(filePath).isDirectory()).forEach((filePath) => {
|
|
44
|
+
const envConfig = import_utils.dotenv.config({
|
|
23
45
|
path: filePath
|
|
24
46
|
});
|
|
25
|
-
(0,
|
|
47
|
+
(0, import_utils.dotenvExpand)(envConfig);
|
|
26
48
|
});
|
|
27
49
|
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
loadEnv
|
|
53
|
+
});
|
package/dist/loadPlugins.js
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return isOldPluginConfig;
|
|
15
|
-
},
|
|
16
|
-
loadPlugins: function() {
|
|
17
|
-
return loadPlugins;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var loadPlugins_exports = {};
|
|
20
|
+
__export(loadPlugins_exports, {
|
|
21
|
+
isOldPluginConfig: () => isOldPluginConfig,
|
|
22
|
+
loadPlugins: () => loadPlugins
|
|
19
23
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
module.exports = __toCommonJS(loadPlugins_exports);
|
|
25
|
+
var import_utils = require("@modern-js/utils");
|
|
26
|
+
var import_manager = require("./manager");
|
|
27
|
+
const debug = (0, import_utils.createDebugger)("load-plugins");
|
|
23
28
|
const resolveCliPlugin = async (p, appDirectory) => {
|
|
24
29
|
const pkg = typeof p === "string" ? p : p[0];
|
|
25
30
|
const pluginOptions = typeof p === "string" ? void 0 : p[1];
|
|
26
|
-
const path = (0,
|
|
27
|
-
let
|
|
31
|
+
const path = (0, import_utils.tryResolve)(pkg, appDirectory);
|
|
32
|
+
let module2;
|
|
28
33
|
try {
|
|
29
|
-
|
|
34
|
+
module2 = (0, import_utils.compatRequire)(path);
|
|
30
35
|
} catch (e) {
|
|
31
|
-
({ default:
|
|
36
|
+
({ default: module2 } = await (0, import_utils.dynamicImport)(path));
|
|
32
37
|
}
|
|
33
|
-
if (typeof
|
|
34
|
-
const result =
|
|
35
|
-
return (0,
|
|
38
|
+
if (typeof module2 === "function") {
|
|
39
|
+
const result = module2(pluginOptions);
|
|
40
|
+
return (0, import_manager.createPlugin)(result.setup, result);
|
|
36
41
|
}
|
|
37
|
-
return
|
|
42
|
+
return module2;
|
|
38
43
|
};
|
|
39
44
|
const isOldPluginConfig = (config) => Array.isArray(config) && config.some((item) => {
|
|
40
45
|
return typeof item === "string" || Array.isArray(item);
|
|
@@ -42,9 +47,9 @@ const isOldPluginConfig = (config) => Array.isArray(config) && config.some((item
|
|
|
42
47
|
const loadPlugins = async (appDirectory, userConfig, options = {}) => {
|
|
43
48
|
const pluginConfig = userConfig.plugins;
|
|
44
49
|
const plugins = [
|
|
45
|
-
...options.forceAutoLoadPlugins || userConfig.autoLoadPlugins ? (0,
|
|
50
|
+
...options.forceAutoLoadPlugins || userConfig.autoLoadPlugins ? (0, import_utils.getInternalPlugins)(appDirectory, options.internalPlugins) : [],
|
|
46
51
|
...isOldPluginConfig(pluginConfig) ? pluginConfig : [],
|
|
47
|
-
...options.autoLoad ? (0,
|
|
52
|
+
...options.autoLoad ? (0, import_utils.getInternalPlugins)(appDirectory, options.autoLoad) : []
|
|
48
53
|
];
|
|
49
54
|
const loadedPlugins = await Promise.all(plugins.map((plugin) => {
|
|
50
55
|
const loadedPlugin = resolveCliPlugin(plugin, appDirectory);
|
|
@@ -52,10 +57,14 @@ const loadPlugins = async (appDirectory, userConfig, options = {}) => {
|
|
|
52
57
|
return loadedPlugin;
|
|
53
58
|
}));
|
|
54
59
|
if (!isOldPluginConfig(pluginConfig)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
loadedPlugins.push(...pluginConfig.map((item) => (0, _manager.createPlugin)(item.setup, item)));
|
|
60
|
+
if (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.length) {
|
|
61
|
+
loadedPlugins.push(...pluginConfig.map((item) => (0, import_manager.createPlugin)(item.setup, item)));
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
return loadedPlugins;
|
|
61
65
|
};
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
isOldPluginConfig,
|
|
69
|
+
loadPlugins
|
|
70
|
+
});
|
package/dist/manager.js
CHANGED
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return manager;
|
|
15
|
-
},
|
|
16
|
-
createPlugin: function() {
|
|
17
|
-
return createPlugin;
|
|
18
|
-
},
|
|
19
|
-
registerHook: function() {
|
|
20
|
-
return registerHook;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var manager_exports = {};
|
|
20
|
+
__export(manager_exports, {
|
|
21
|
+
createPlugin: () => createPlugin,
|
|
22
|
+
manager: () => manager,
|
|
23
|
+
registerHook: () => registerHook
|
|
22
24
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
module.exports = __toCommonJS(manager_exports);
|
|
26
|
+
var import_plugin = require("@modern-js/plugin");
|
|
27
|
+
var import_context = require("./context");
|
|
25
28
|
const baseHooks = {
|
|
26
|
-
beforeConfig: (0,
|
|
27
|
-
config: (0,
|
|
28
|
-
resolvedConfig: (0,
|
|
29
|
-
validateSchema: (0,
|
|
30
|
-
prepare: (0,
|
|
31
|
-
afterPrepare: (0,
|
|
32
|
-
commands: (0,
|
|
33
|
-
watchFiles: (0,
|
|
34
|
-
fileChange: (0,
|
|
35
|
-
beforeExit: (0,
|
|
36
|
-
addRuntimeExports: (0,
|
|
29
|
+
beforeConfig: (0, import_plugin.createAsyncWorkflow)(),
|
|
30
|
+
config: (0, import_plugin.createParallelWorkflow)(),
|
|
31
|
+
resolvedConfig: (0, import_plugin.createAsyncWaterfall)(),
|
|
32
|
+
validateSchema: (0, import_plugin.createParallelWorkflow)(),
|
|
33
|
+
prepare: (0, import_plugin.createAsyncWorkflow)(),
|
|
34
|
+
afterPrepare: (0, import_plugin.createAsyncWorkflow)(),
|
|
35
|
+
commands: (0, import_plugin.createAsyncWorkflow)(),
|
|
36
|
+
watchFiles: (0, import_plugin.createParallelWorkflow)(),
|
|
37
|
+
fileChange: (0, import_plugin.createAsyncWorkflow)(),
|
|
38
|
+
beforeExit: (0, import_plugin.createWorkflow)(),
|
|
39
|
+
addRuntimeExports: (0, import_plugin.createAsyncWaterfall)()
|
|
37
40
|
};
|
|
38
41
|
const pluginAPI = {
|
|
39
|
-
setAppContext:
|
|
40
|
-
useAppContext:
|
|
41
|
-
useConfigContext:
|
|
42
|
-
useResolvedConfigContext:
|
|
42
|
+
setAppContext: import_context.setAppContext,
|
|
43
|
+
useAppContext: import_context.useAppContext,
|
|
44
|
+
useConfigContext: import_context.useConfigContext,
|
|
45
|
+
useResolvedConfigContext: import_context.useResolvedConfigContext
|
|
43
46
|
};
|
|
44
|
-
const manager = (0,
|
|
47
|
+
const manager = (0, import_plugin.createAsyncManager)(baseHooks, pluginAPI);
|
|
45
48
|
const { createPlugin, registerHook } = manager;
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
createPlugin,
|
|
52
|
+
manager,
|
|
53
|
+
registerHook
|
|
54
|
+
});
|
package/dist/nodeApi.js
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return dev;
|
|
15
|
-
},
|
|
16
|
-
build: function() {
|
|
17
|
-
return build;
|
|
18
|
-
},
|
|
19
|
-
deploy: function() {
|
|
20
|
-
return deploy;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var nodeApi_exports = {};
|
|
20
|
+
__export(nodeApi_exports, {
|
|
21
|
+
build: () => build,
|
|
22
|
+
deploy: () => deploy,
|
|
23
|
+
dev: () => dev
|
|
22
24
|
});
|
|
23
|
-
|
|
25
|
+
module.exports = __toCommonJS(nodeApi_exports);
|
|
26
|
+
var import__ = require(".");
|
|
24
27
|
const dev = (options, commandOptions = []) => {
|
|
25
|
-
|
|
28
|
+
import__.cli.runCommand("dev", commandOptions, options);
|
|
26
29
|
};
|
|
27
30
|
const build = (options, commandOptions = []) => {
|
|
28
|
-
|
|
31
|
+
import__.cli.runCommand("build", commandOptions, options);
|
|
29
32
|
};
|
|
30
33
|
const deploy = (options, commandOptions = []) => {
|
|
31
|
-
|
|
34
|
+
import__.cli.runCommand("deploy", commandOptions, options);
|
|
32
35
|
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
build,
|
|
39
|
+
deploy,
|
|
40
|
+
dev
|
|
41
|
+
});
|