@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/runBin.js CHANGED
@@ -1,22 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "run", {
7
- enumerable: true,
8
- get: function() {
9
- return run;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
16
  }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var runBin_exports = {};
21
+ __export(runBin_exports, {
22
+ run: () => run
11
23
  });
12
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
13
- const _utils = require("@modern-js/utils");
14
- const _gradientstring = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/gradient-string"));
15
- const _ = require(".");
24
+ module.exports = __toCommonJS(runBin_exports);
25
+ var import_utils = require("@modern-js/utils");
26
+ var import__ = require(".");
16
27
  const run = async (otherCoreOptions = {}, options = {}) => {
17
- var _options;
18
28
  if (otherCoreOptions.initialLog) {
19
- _utils.logger.log(` ${_gradientstring.default.cristal(otherCoreOptions.initialLog)}
29
+ import_utils.logger.greet(` ${otherCoreOptions.initialLog}
20
30
  `);
21
31
  }
22
32
  const command = process.argv[2];
@@ -35,7 +45,7 @@ const run = async (otherCoreOptions = {}, options = {}) => {
35
45
  }
36
46
  }
37
47
  const { version } = require("../package.json");
38
- const cliParams = (0, _utils.minimist)(process.argv.slice(2));
48
+ const cliParams = (0, import_utils.minimist)(process.argv.slice(2));
39
49
  const runOptions = {
40
50
  version
41
51
  };
@@ -59,10 +69,14 @@ const run = async (otherCoreOptions = {}, options = {}) => {
59
69
  runOptions.configFile = customConfigFile;
60
70
  }
61
71
  if (typeof options.override === "boolean" && options.override) {
62
- await _.cli.run(otherCoreOptions);
63
- } else if (typeof ((_options = options) === null || _options === void 0 ? void 0 : _options.override) === "function") {
64
- await _.cli.run(await options.override(runOptions));
72
+ await import__.cli.run(otherCoreOptions);
73
+ } else if (typeof (options === null || options === void 0 ? void 0 : options.override) === "function") {
74
+ await import__.cli.run(await options.override(runOptions));
65
75
  } else {
66
- await _.cli.run(_utils.lodash.merge({}, runOptions, otherCoreOptions));
76
+ await import__.cli.run(import_utils.lodash.merge({}, runOptions, otherCoreOptions));
67
77
  }
68
78
  };
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ run
82
+ });
@@ -1,16 +1,29 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "patchSchema", {
6
- enumerable: true,
7
- get: function() {
8
- return patchSchema;
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) => {
7
+ for (var name in all)
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 });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var patchSchema_exports = {};
20
+ __export(patchSchema_exports, {
21
+ patchSchema: () => patchSchema
10
22
  });
11
- const _utils = require("@modern-js/utils");
12
- const _lodash = require("@modern-js/utils/lodash");
13
- const debug = (0, _utils.createDebugger)("validate-schema");
23
+ module.exports = __toCommonJS(patchSchema_exports);
24
+ var import_utils = require("@modern-js/utils");
25
+ var import_lodash = require("@modern-js/utils/lodash");
26
+ const debug = (0, import_utils.createDebugger)("validate-schema");
14
27
  const patchSchema = (pluginSchemas) => {
15
28
  const finalSchema = {
16
29
  type: "object",
@@ -25,7 +38,7 @@ const patchSchema = (pluginSchemas) => {
25
38
  };
26
39
  }
27
40
  node = node[prop];
28
- if (!node || !(0, _utils.isObject)(node)) {
41
+ if (!node || !(0, import_utils.isObject)(node)) {
29
42
  throw new Error(`add schema ${props.join(".")} error`);
30
43
  }
31
44
  node.properties = node.hasOwnProperty("properties") ? node.properties : {};
@@ -49,9 +62,13 @@ const patchSchema = (pluginSchemas) => {
49
62
  const mountProperty = props.pop();
50
63
  const targetNode = findTargetNode(props);
51
64
  if (!targetNode.hasOwnProperty(mountProperty)) {
52
- targetNode[mountProperty] = (0, _lodash.cloneDeep)(schema);
65
+ targetNode[mountProperty] = (0, import_lodash.cloneDeep)(schema);
53
66
  }
54
67
  }
55
68
  debug(`final validate schema: %o`, finalSchema);
56
69
  return finalSchema;
57
70
  };
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ patchSchema
74
+ });
@@ -1,13 +1,26 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "traverseSchema", {
6
- enumerable: true,
7
- get: function() {
8
- return traverseSchema;
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) => {
7
+ for (var name in all)
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 });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var traverseSchema_exports = {};
20
+ __export(traverseSchema_exports, {
21
+ traverseSchema: () => traverseSchema
10
22
  });
23
+ module.exports = __toCommonJS(traverseSchema_exports);
11
24
  const traverseSchema = (schema) => {
12
25
  const keys = [];
13
26
  const traverse = ({ properties }, old = []) => {
@@ -26,3 +39,7 @@ const traverseSchema = (schema) => {
26
39
  traverse(schema);
27
40
  return keys;
28
41
  };
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ traverseSchema
45
+ });
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var config_exports = {};
16
+ module.exports = __toCommonJS(config_exports);
@@ -1,32 +1,71 @@
1
1
  import { Entrypoint, InternalPlugins, ServerRoute, HtmlTemplates, HtmlPartials } from '@modern-js/types';
2
2
  import { BuilderInstance } from '@modern-js/builder-shared';
3
- export type ToolsType = 'app-tools' | 'module-tools' | 'doc-tools' | 'monorepo-tools';
3
+ export type ToolsType = 'app-tools' | 'module-tools' | 'monorepo-tools';
4
4
  export interface IAppContext {
5
+ /** name for generating conventional constants, such as .modern-js */
5
6
  metaName: string;
7
+ /** Root directory of the current project */
6
8
  appDirectory: string;
9
+ /** Source code directory */
10
+ srcDirectory: string;
11
+ /** Directory for output files */
12
+ distDirectory: string;
13
+ /** Directory for API modules */
14
+ apiDirectory: string;
15
+ /** Directory for lambda modules */
16
+ lambdaDirectory: string;
17
+ /** Directory for shared modules */
18
+ sharedDirectory: string;
19
+ /** Directory for framework temp files */
20
+ internalDirectory: string;
21
+ /** node_modules directory */
22
+ nodeModulesDirectory: string;
23
+ /** Path to the configuration file */
7
24
  configFile: string | false;
25
+ /** Path to the server configuration file */
8
26
  serverConfigFile: string;
27
+ /** Currently registered server plugins */
9
28
  serverInternalPlugins: InternalPlugins;
29
+ /** IPv4 address of the current machine */
10
30
  ip?: string;
31
+ /** Port number of the development server */
11
32
  port?: number;
12
- distDirectory: string;
13
- toolsType?: ToolsType;
33
+ /** Name of the current project's package.json */
14
34
  packageName: string;
15
- srcDirectory: string;
16
- apiDirectory: string;
17
- lambdaDirectory: string;
18
- sharedDirectory: string;
19
- nodeModulesDirectory: string;
20
- internalDirectory: string;
35
+ /** Currently registered plugins */
21
36
  plugins: any[];
37
+ /** Information for entry points */
22
38
  entrypoints: Entrypoint[];
39
+ /** Selected entry points */
23
40
  checkedEntries: string[];
41
+ /** Information for server routes */
24
42
  serverRoutes: ServerRoute[];
25
- htmlTemplates: HtmlTemplates;
43
+ /** Whether to use api only mode */
26
44
  apiOnly: boolean;
27
- internalDirAlias: string;
28
- internalSrcAlias: string;
45
+ /** The Builder instance */
29
46
  builder?: BuilderInstance;
47
+ /** Tools type of the current project */
48
+ toolsType?: ToolsType;
49
+ /** Type of the bundler being used */
30
50
  bundlerType?: 'webpack' | 'rspack' | 'esbuild';
51
+ /**
52
+ * The alias path for internal usage
53
+ * @private
54
+ */
55
+ internalDirAlias: string;
56
+ /**
57
+ * The alias path for internal usage
58
+ * @private
59
+ */
60
+ internalSrcAlias: string;
61
+ /**
62
+ * Information for HTML templates
63
+ * @private
64
+ */
65
+ htmlTemplates: HtmlTemplates;
66
+ /**
67
+ * Information for HTML templates by entry
68
+ * @private
69
+ */
31
70
  partialsByEntrypoint?: Record<string, HtmlPartials>;
32
71
  }
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var context_exports = {};
16
+ module.exports = __toCommonJS(context_exports);
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var coreOptions_exports = {};
16
+ module.exports = __toCommonJS(coreOptions_exports);
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var hooks_exports = {};
16
+ module.exports = __toCommonJS(hooks_exports);
@@ -1,11 +1,32 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
18
+ __reExport(types_exports, require("./plugin"), module.exports);
19
+ __reExport(types_exports, require("./config"), module.exports);
20
+ __reExport(types_exports, require("./pluginAPI"), module.exports);
21
+ __reExport(types_exports, require("./hooks"), module.exports);
22
+ __reExport(types_exports, require("./context"), module.exports);
23
+ __reExport(types_exports, require("./coreOptions"), module.exports);
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ ...require("./plugin"),
27
+ ...require("./config"),
28
+ ...require("./pluginAPI"),
29
+ ...require("./hooks"),
30
+ ...require("./context"),
31
+ ...require("./coreOptions")
4
32
  });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./plugin"), exports);
7
- _export_star._(require("./config"), exports);
8
- _export_star._(require("./pluginAPI"), exports);
9
- _export_star._(require("./hooks"), exports);
10
- _export_star._(require("./context"), exports);
11
- _export_star._(require("./coreOptions"), exports);
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var plugin_exports = {};
16
+ module.exports = __toCommonJS(plugin_exports);
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var pluginAPI_exports = {};
16
+ module.exports = __toCommonJS(pluginAPI_exports);
@@ -1,14 +1,27 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "checkIsDuplicationPlugin", {
6
- enumerable: true,
7
- get: function() {
8
- return checkIsDuplicationPlugin;
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) => {
7
+ for (var name in all)
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 });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var checkIsDuplicationPlugin_exports = {};
20
+ __export(checkIsDuplicationPlugin_exports, {
21
+ checkIsDuplicationPlugin: () => checkIsDuplicationPlugin
10
22
  });
11
- const _utils = require("@modern-js/utils");
23
+ module.exports = __toCommonJS(checkIsDuplicationPlugin_exports);
24
+ var import_utils = require("@modern-js/utils");
12
25
  function checkIsDuplicationPlugin(plugins, autoLoadPlugin = false) {
13
26
  const set = /* @__PURE__ */ new Set();
14
27
  const duplicationPlugins = [];
@@ -20,9 +33,13 @@ function checkIsDuplicationPlugin(plugins, autoLoadPlugin = false) {
20
33
  }
21
34
  });
22
35
  if (duplicationPlugins.length > 0) {
23
- _utils.logger.warn(`Duplicate registration plugins: ${duplicationPlugins.join(",")}.`);
36
+ import_utils.logger.warn(`Duplicate registration plugins: ${duplicationPlugins.join(",")}.`);
24
37
  if (autoLoadPlugin) {
25
- _utils.logger.warn("This is probably because you enabled `autoLoadPlugin` configuration and also registered these plugins manually");
38
+ import_utils.logger.warn("This is probably because you enabled `autoLoadPlugin` configuration and also registered these plugins manually");
26
39
  }
27
40
  }
28
41
  }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ checkIsDuplicationPlugin
45
+ });
@@ -1,29 +1,34 @@
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
- initCommandsMap: function() {
14
- return initCommandsMap;
15
- },
16
- program: function() {
17
- return _utils.program;
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 commander_exports = {};
20
+ __export(commander_exports, {
21
+ initCommandsMap: () => initCommandsMap,
22
+ program: () => import_utils.program
19
23
  });
20
- const _utils = require("@modern-js/utils");
24
+ module.exports = __toCommonJS(commander_exports);
25
+ var import_utils = require("@modern-js/utils");
21
26
  function initCommandsMap() {
22
- if (!_utils.program.hasOwnProperty("commandsMap")) {
23
- Object.defineProperty(_utils.program, "commandsMap", {
27
+ if (!import_utils.program.hasOwnProperty("commandsMap")) {
28
+ Object.defineProperty(import_utils.program, "commandsMap", {
24
29
  get() {
25
30
  const map = /* @__PURE__ */ new Map();
26
- for (const command of _utils.program.commands) {
31
+ for (const command of import_utils.program.commands) {
27
32
  map.set(command._name, command);
28
33
  }
29
34
  return map;
@@ -32,3 +37,8 @@ function initCommandsMap() {
32
37
  });
33
38
  }
34
39
  }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ initCommandsMap,
43
+ program
44
+ });
@@ -1,24 +1,45 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "createFileWatcher", {
6
- enumerable: true,
7
- get: function() {
8
- return createFileWatcher;
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 createFileWatcher_exports = {};
30
+ __export(createFileWatcher_exports, {
31
+ createFileWatcher: () => createFileWatcher
10
32
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
- const _crypto = /* @__PURE__ */ _interop_require_default._(require("crypto"));
14
- const _path = /* @__PURE__ */ _interop_require_wildcard._(require("path"));
15
- const _fs = /* @__PURE__ */ _interop_require_wildcard._(require("fs"));
16
- const _utils = require("@modern-js/utils");
17
- const debug = (0, _utils.createDebugger)("watch-files");
33
+ module.exports = __toCommonJS(createFileWatcher_exports);
34
+ var import_crypto = __toESM(require("crypto"));
35
+ var path = __toESM(require("path"));
36
+ var fs = __toESM(require("fs"));
37
+ var import_utils = require("@modern-js/utils");
38
+ const debug = (0, import_utils.createDebugger)("watch-files");
18
39
  const hashMap = /* @__PURE__ */ new Map();
19
- const md5 = (data) => _crypto.default.createHash("md5").update(data).digest("hex");
40
+ const md5 = (data) => import_crypto.default.createHash("md5").update(data).digest("hex");
20
41
  const createFileWatcher = async (appContext, hooksRunner) => {
21
- if ((0, _utils.isDevCommand)()) {
42
+ if ((0, import_utils.isDevCommand)()) {
22
43
  const { appDirectory } = appContext;
23
44
  const extraFiles = await hooksRunner.watchFiles();
24
45
  const watched = extraFiles.filter((extra) => {
@@ -30,10 +51,10 @@ const createFileWatcher = async (appContext, hooksRunner) => {
30
51
  return extra.files;
31
52
  }).flat();
32
53
  const isPrivate = (filename) => privateWatched.some((ff) => {
33
- return _path.resolve(appDirectory, filename).startsWith(ff);
54
+ return path.resolve(appDirectory, filename).startsWith(ff);
34
55
  });
35
56
  debug(`watched: %o`, watched);
36
- const watcher = _utils.chokidar.watch([
57
+ const watcher = import_utils.chokidar.watch([
37
58
  ...watched,
38
59
  ...privateWatched
39
60
  ], {
@@ -50,7 +71,7 @@ const createFileWatcher = async (appContext, hooksRunner) => {
50
71
  });
51
72
  watcher.on("change", (changed) => {
52
73
  const lastHash = hashMap.get(changed);
53
- const currentHash = md5(_fs.readFileSync(_path.join(appDirectory, changed), "utf8"));
74
+ const currentHash = md5(fs.readFileSync(path.join(appDirectory, changed), "utf8"));
54
75
  if (currentHash !== lastHash) {
55
76
  debug(`file change: %s`, changed);
56
77
  hashMap.set(changed, currentHash);
@@ -63,7 +84,7 @@ const createFileWatcher = async (appContext, hooksRunner) => {
63
84
  });
64
85
  watcher.on("add", (changed) => {
65
86
  debug(`add file: %s`, changed);
66
- const currentHash = md5(_fs.readFileSync(_path.join(appDirectory, changed), "utf8"));
87
+ const currentHash = md5(fs.readFileSync(path.join(appDirectory, changed), "utf8"));
67
88
  hashMap.set(changed, currentHash);
68
89
  hooksRunner.fileChange({
69
90
  filename: changed,
@@ -88,3 +109,7 @@ const createFileWatcher = async (appContext, hooksRunner) => {
88
109
  return watcher;
89
110
  }
90
111
  };
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ createFileWatcher
115
+ });