@modern-js/core 2.35.1 → 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/createCli.js CHANGED
@@ -1,36 +1,41 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- mergeOptions: function() {
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
- const _utils = require("@modern-js/utils");
21
- const _utils1 = require("./utils");
22
- const _loadPlugins = require("./loadPlugins");
23
- const _context = require("./context");
24
- const _loadEnv = require("./loadEnv");
25
- const _manager = require("./manager");
26
- const _config = require("./config");
27
- const _checkIsDuplicationPlugin = require("./utils/checkIsDuplicationPlugin");
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
- _utils.program.name("modern").usage("<command> [options]").version(version);
34
+ import_utils.program.name("modern").usage("<command> [options]").version(version);
30
35
  };
31
36
  const mergeOptions = (options) => {
32
37
  const defaultOptions = {
33
- serverConfigFile: _utils.DEFAULT_SERVER_CONFIG
38
+ serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG
34
39
  };
35
40
  return {
36
41
  ...defaultOptions,
@@ -42,34 +47,34 @@ const createCli = () => {
42
47
  let initOptions;
43
48
  const init = async (options) => {
44
49
  var _mergedOptions_options, _mergedOptions_internalPlugins, _mergedOptions_internalPlugins1, _mergedOptions_internalPlugins2;
45
- _manager.manager.clear();
50
+ import_manager.manager.clear();
46
51
  const mergedOptions = mergeOptions(options);
47
52
  initOptions = mergedOptions;
48
- const appDirectory = await (0, _utils1.initAppDir)(options === null || options === void 0 ? void 0 : options.cwd);
49
- (0, _utils1.initCommandsMap)();
53
+ const appDirectory = await (0, import_utils2.initAppDir)(options === null || options === void 0 ? void 0 : options.cwd);
54
+ (0, import_utils2.initCommandsMap)();
50
55
  setProgramVersion(options === null || options === void 0 ? void 0 : options.version);
51
56
  var _mergedOptions_options_metaName;
52
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";
53
- (0, _loadEnv.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
54
- const loaded = await (0, _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);
55
- const plugins = await (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config, {
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, {
56
61
  internalPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions_internalPlugins = mergedOptions.internalPlugins) === null || _mergedOptions_internalPlugins === void 0 ? void 0 : _mergedOptions_internalPlugins.cli,
57
62
  autoLoad: mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions_internalPlugins1 = mergedOptions.internalPlugins) === null || _mergedOptions_internalPlugins1 === void 0 ? void 0 : _mergedOptions_internalPlugins1.autoLoad,
58
63
  forceAutoLoadPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.forceAutoLoadPlugins
59
64
  });
60
- (0, _checkIsDuplicationPlugin.checkIsDuplicationPlugin)(plugins.map((plugin) => plugin.name), loaded.config.autoLoadPlugins);
61
- plugins.forEach((plugin) => plugin && _manager.manager.usePlugin(plugin));
62
- const appContext = (0, _context.initAppContext)({
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
71
  options: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options,
67
72
  serverConfigFile: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.serverConfigFile,
68
- serverInternalPlugins: (mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions_internalPlugins2 = mergedOptions.internalPlugins) === null || _mergedOptions_internalPlugins2 === void 0 ? void 0 : _mergedOptions_internalPlugins2.server) || _utils.INTERNAL_SERVER_PLUGINS
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
- _context.ConfigContext.set(loaded.config);
71
- _context.AppContext.set(appContext);
72
- hooksRunner = await _manager.manager.init();
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,7 @@ const createCli = () => {
79
84
  process.on(event, async (err) => {
80
85
  hooksRunner.beforeExit();
81
86
  if (err instanceof Error) {
82
- _utils.logger.error(err.stack);
87
+ import_utils.logger.error(err.stack);
83
88
  } else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
84
89
  console.trace("Unknown Error", err);
85
90
  }
@@ -91,29 +96,29 @@ const createCli = () => {
91
96
  await hooksRunner.beforeConfig();
92
97
  const extraConfigs = await hooksRunner.config();
93
98
  const extraSchemas = await hooksRunner.validateSchema();
94
- const normalizedConfig = await (0, _config.createResolveConfig)(loaded, extraConfigs, extraSchemas, options === null || options === void 0 ? void 0 : options.onSchemaError);
99
+ const normalizedConfig = await (0, import_config.createResolveConfig)(loaded, extraConfigs, extraSchemas, options === null || options === void 0 ? void 0 : options.onSchemaError);
95
100
  const { resolved } = await hooksRunner.resolvedConfig({
96
101
  resolved: normalizedConfig
97
102
  });
98
- _context.ConfigContext.set(loaded.config);
99
- _context.ResolvedConfigContext.set(resolved);
103
+ import_context.ConfigContext.set(loaded.config);
104
+ import_context.ResolvedConfigContext.set(resolved);
100
105
  await hooksRunner.prepare();
101
106
  await hooksRunner.afterPrepare();
102
107
  return {
103
108
  resolved,
104
- appContext: (0, _context.useAppContext)()
109
+ appContext: (0, import_context.useAppContext)()
105
110
  };
106
111
  };
107
112
  async function run(options) {
108
113
  var _program_commands;
109
114
  const { appContext } = await init(options);
110
115
  await hooksRunner.commands({
111
- program: _utils.program
116
+ program: import_utils.program
112
117
  });
113
- await (0, _utils1.createFileWatcher)(appContext, hooksRunner);
114
- _utils.program.parse(process.argv);
115
- if (!((_program_commands = _utils.program.commands) === null || _program_commands === void 0 ? void 0 : _program_commands.length)) {
116
- _utils.logger.warn("No command found, please make sure you have registered plugins correctly.");
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.");
117
122
  }
118
123
  }
119
124
  async function runCommand(command, commandOptions = [], options) {
@@ -121,13 +126,13 @@ const createCli = () => {
121
126
  process.env.MODERN_ARGV = argv.join(" ");
122
127
  const { appContext } = await init(options);
123
128
  await hooksRunner.commands({
124
- program: _utils.program
129
+ program: import_utils.program
125
130
  });
126
- await (0, _utils1.createFileWatcher)(appContext, hooksRunner);
127
- _utils.program.parse(argv);
131
+ await (0, import_utils2.createFileWatcher)(appContext, hooksRunner);
132
+ import_utils.program.parse(argv);
128
133
  }
129
134
  async function test(argv, options) {
130
- const newProgram = new _utils.Command();
135
+ const newProgram = new import_utils.Command();
131
136
  const { coreOptions } = options !== null && options !== void 0 ? options : {};
132
137
  await init(coreOptions);
133
138
  await hooksRunner.commands({
@@ -143,3 +148,8 @@ const createCli = () => {
143
148
  getPrevInitOptions: () => initOptions
144
149
  };
145
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(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- mergeConfig: function() {
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.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "loadEnv", {
6
- enumerable: true,
7
- get: function() {
8
- return loadEnv;
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
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _fs = /* @__PURE__ */ _interop_require_default._(require("fs"));
13
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
14
- const _utils = require("@modern-js/utils");
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) => _path.default.resolve(appDirectory, name)).filter((filePath) => _fs.default.existsSync(filePath) && !_fs.default.statSync(filePath).isDirectory()).forEach((filePath) => {
22
- const envConfig = _utils.dotenv.config({
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, _utils.dotenvExpand)(envConfig);
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
+ });
@@ -1,40 +1,45 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- isOldPluginConfig: function() {
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
- const _utils = require("@modern-js/utils");
21
- const _manager = require("./manager");
22
- const debug = (0, _utils.createDebugger)("load-plugins");
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, _utils.tryResolve)(pkg, appDirectory);
27
- let module;
31
+ const path = (0, import_utils.tryResolve)(pkg, appDirectory);
32
+ let module2;
28
33
  try {
29
- module = (0, _utils.compatRequire)(path);
34
+ module2 = (0, import_utils.compatRequire)(path);
30
35
  } catch (e) {
31
- ({ default: module } = await (0, _utils.dynamicImport)(path));
36
+ ({ default: module2 } = await (0, import_utils.dynamicImport)(path));
32
37
  }
33
- if (typeof module === "function") {
34
- const result = module(pluginOptions);
35
- return (0, _manager.createPlugin)(result.setup, result);
38
+ if (typeof module2 === "function") {
39
+ const result = module2(pluginOptions);
40
+ return (0, import_manager.createPlugin)(result.setup, result);
36
41
  }
37
- return module;
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, _utils.getInternalPlugins)(appDirectory, options.internalPlugins) : [],
50
+ ...options.forceAutoLoadPlugins || userConfig.autoLoadPlugins ? (0, import_utils.getInternalPlugins)(appDirectory, options.internalPlugins) : [],
46
51
  ...isOldPluginConfig(pluginConfig) ? pluginConfig : [],
47
- ...options.autoLoad ? (0, _utils.getInternalPlugins)(appDirectory, options.autoLoad) : []
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);
@@ -53,8 +58,13 @@ const loadPlugins = async (appDirectory, userConfig, options = {}) => {
53
58
  }));
54
59
  if (!isOldPluginConfig(pluginConfig)) {
55
60
  if (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.length) {
56
- loadedPlugins.push(...pluginConfig.map((item) => (0, _manager.createPlugin)(item.setup, item)));
61
+ loadedPlugins.push(...pluginConfig.map((item) => (0, import_manager.createPlugin)(item.setup, item)));
57
62
  }
58
63
  }
59
64
  return loadedPlugins;
60
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(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- manager: function() {
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
- const _plugin = require("@modern-js/plugin");
24
- const _context = require("./context");
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, _plugin.createAsyncWorkflow)(),
27
- config: (0, _plugin.createParallelWorkflow)(),
28
- resolvedConfig: (0, _plugin.createAsyncWaterfall)(),
29
- validateSchema: (0, _plugin.createParallelWorkflow)(),
30
- prepare: (0, _plugin.createAsyncWorkflow)(),
31
- afterPrepare: (0, _plugin.createAsyncWorkflow)(),
32
- commands: (0, _plugin.createAsyncWorkflow)(),
33
- watchFiles: (0, _plugin.createParallelWorkflow)(),
34
- fileChange: (0, _plugin.createAsyncWorkflow)(),
35
- beforeExit: (0, _plugin.createWorkflow)(),
36
- addRuntimeExports: (0, _plugin.createAsyncWaterfall)()
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: _context.setAppContext,
40
- useAppContext: _context.useAppContext,
41
- useConfigContext: _context.useConfigContext,
42
- useResolvedConfigContext: _context.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, _plugin.createAsyncManager)(baseHooks, pluginAPI);
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(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- dev: function() {
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
- const _ = require(".");
25
+ module.exports = __toCommonJS(nodeApi_exports);
26
+ var import__ = require(".");
24
27
  const dev = (options, commandOptions = []) => {
25
- _.cli.runCommand("dev", commandOptions, options);
28
+ import__.cli.runCommand("dev", commandOptions, options);
26
29
  };
27
30
  const build = (options, commandOptions = []) => {
28
- _.cli.runCommand("build", commandOptions, options);
31
+ import__.cli.runCommand("build", commandOptions, options);
29
32
  };
30
33
  const deploy = (options, commandOptions = []) => {
31
- _.cli.runCommand("deploy", commandOptions, options);
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
+ });