@modern-js/core 1.7.1-beta.peer.1 → 1.9.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.
Files changed (196) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +47 -0
  3. package/bin/modern-js.js +1 -1
  4. package/compiled/ajv/codegen.js +1 -0
  5. package/compiled/ajv/dist/ajv.d.ts +16 -0
  6. package/compiled/ajv/dist/compile/codegen/code.d.ts +40 -0
  7. package/compiled/ajv/dist/compile/codegen/index.d.ts +79 -0
  8. package/compiled/ajv/dist/compile/codegen/scope.d.ts +79 -0
  9. package/compiled/ajv/dist/compile/errors.d.ts +13 -0
  10. package/compiled/ajv/dist/compile/index.d.ts +80 -0
  11. package/compiled/ajv/dist/compile/ref_error.d.ts +6 -0
  12. package/compiled/ajv/dist/compile/resolve.d.ts +12 -0
  13. package/compiled/ajv/dist/compile/rules.d.ts +28 -0
  14. package/compiled/ajv/dist/compile/util.d.ts +40 -0
  15. package/compiled/ajv/dist/compile/validate/index.d.ts +42 -0
  16. package/compiled/ajv/dist/compile/validate/subschema.d.ts +47 -0
  17. package/compiled/ajv/dist/core.d.ts +173 -0
  18. package/compiled/ajv/dist/runtime/validation_error.d.ts +7 -0
  19. package/compiled/ajv/dist/types/index.d.ts +183 -0
  20. package/compiled/ajv/dist/types/json-schema.d.ts +124 -0
  21. package/compiled/ajv/dist/types/jtd-schema.d.ts +169 -0
  22. package/compiled/ajv/index.js +9 -0
  23. package/compiled/ajv/license +22 -0
  24. package/compiled/ajv/package.json +1 -0
  25. package/compiled/ajv/uri-js/dist/es5/uri.all.d.ts +59 -0
  26. package/compiled/ajv-keywords/ajv/dist/ajv.d.ts +16 -0
  27. package/compiled/ajv-keywords/ajv/dist/compile/codegen/code.d.ts +40 -0
  28. package/compiled/ajv-keywords/ajv/dist/compile/codegen/index.d.ts +79 -0
  29. package/compiled/ajv-keywords/ajv/dist/compile/codegen/scope.d.ts +79 -0
  30. package/compiled/ajv-keywords/ajv/dist/compile/errors.d.ts +13 -0
  31. package/compiled/ajv-keywords/ajv/dist/compile/index.d.ts +80 -0
  32. package/compiled/ajv-keywords/ajv/dist/compile/ref_error.d.ts +6 -0
  33. package/compiled/ajv-keywords/ajv/dist/compile/resolve.d.ts +12 -0
  34. package/compiled/ajv-keywords/ajv/dist/compile/rules.d.ts +28 -0
  35. package/compiled/ajv-keywords/ajv/dist/compile/util.d.ts +40 -0
  36. package/compiled/ajv-keywords/ajv/dist/compile/validate/index.d.ts +42 -0
  37. package/compiled/ajv-keywords/ajv/dist/compile/validate/subschema.d.ts +47 -0
  38. package/compiled/ajv-keywords/ajv/dist/core.d.ts +173 -0
  39. package/compiled/ajv-keywords/ajv/dist/runtime/validation_error.d.ts +7 -0
  40. package/compiled/ajv-keywords/ajv/dist/types/index.d.ts +183 -0
  41. package/compiled/ajv-keywords/ajv/dist/types/json-schema.d.ts +124 -0
  42. package/compiled/ajv-keywords/ajv/dist/types/jtd-schema.d.ts +169 -0
  43. package/compiled/ajv-keywords/dist/index.d.ts +4 -0
  44. package/compiled/ajv-keywords/index.js +1 -0
  45. package/compiled/ajv-keywords/license +21 -0
  46. package/compiled/ajv-keywords/package.json +1 -0
  47. package/compiled/ajv-keywords/uri-js/dist/es5/uri.all.d.ts +59 -0
  48. package/compiled/better-ajv-errors/ajv/dist/ajv.d.ts +16 -0
  49. package/compiled/better-ajv-errors/ajv/dist/compile/codegen/code.d.ts +40 -0
  50. package/compiled/better-ajv-errors/ajv/dist/compile/codegen/index.d.ts +79 -0
  51. package/compiled/better-ajv-errors/ajv/dist/compile/codegen/scope.d.ts +79 -0
  52. package/compiled/better-ajv-errors/ajv/dist/compile/errors.d.ts +13 -0
  53. package/compiled/better-ajv-errors/ajv/dist/compile/index.d.ts +80 -0
  54. package/compiled/better-ajv-errors/ajv/dist/compile/ref_error.d.ts +6 -0
  55. package/compiled/better-ajv-errors/ajv/dist/compile/resolve.d.ts +12 -0
  56. package/compiled/better-ajv-errors/ajv/dist/compile/rules.d.ts +28 -0
  57. package/compiled/better-ajv-errors/ajv/dist/compile/util.d.ts +40 -0
  58. package/compiled/better-ajv-errors/ajv/dist/compile/validate/index.d.ts +42 -0
  59. package/compiled/better-ajv-errors/ajv/dist/compile/validate/subschema.d.ts +47 -0
  60. package/compiled/better-ajv-errors/ajv/dist/core.d.ts +173 -0
  61. package/compiled/better-ajv-errors/ajv/dist/runtime/validation_error.d.ts +7 -0
  62. package/compiled/better-ajv-errors/ajv/dist/types/index.d.ts +183 -0
  63. package/compiled/better-ajv-errors/ajv/dist/types/json-schema.d.ts +124 -0
  64. package/compiled/better-ajv-errors/ajv/dist/types/jtd-schema.d.ts +169 -0
  65. package/compiled/better-ajv-errors/index.js +1 -0
  66. package/compiled/better-ajv-errors/license +13 -0
  67. package/compiled/better-ajv-errors/package.json +1 -0
  68. package/compiled/better-ajv-errors/typings.d.ts +24 -0
  69. package/compiled/better-ajv-errors/uri-js/dist/es5/uri.all.d.ts +59 -0
  70. package/compiled/v8-compile-cache/index.js +1 -0
  71. package/compiled/v8-compile-cache/license +21 -0
  72. package/compiled/v8-compile-cache/package.json +1 -0
  73. package/dist/cli.d.ts +1 -0
  74. package/dist/cli.js +33 -0
  75. package/dist/config/defaults.d.ts +28 -0
  76. package/dist/config/defaults.js +98 -0
  77. package/dist/{types/config → config}/index.d.ts +2 -2
  78. package/dist/config/index.js +120 -0
  79. package/dist/config/mergeConfig.d.ts +30 -0
  80. package/dist/config/mergeConfig.js +26 -0
  81. package/dist/config/schema/deploy.d.ts +16 -0
  82. package/dist/config/schema/deploy.js +16 -0
  83. package/dist/config/schema/index.d.ts +466 -0
  84. package/dist/config/schema/index.js +95 -0
  85. package/dist/config/schema/output.d.ts +146 -0
  86. package/dist/config/schema/output.js +68 -0
  87. package/dist/config/schema/server.d.ts +182 -0
  88. package/dist/config/schema/server.js +107 -0
  89. package/dist/config/schema/source.d.ts +58 -0
  90. package/dist/config/schema/source.js +36 -0
  91. package/dist/config/schema/tools.d.ts +36 -0
  92. package/dist/config/schema/tools.js +19 -0
  93. package/dist/config/types/electron.d.ts +13 -0
  94. package/dist/config/types/electron.js +2 -0
  95. package/dist/config/types/index.d.ts +240 -0
  96. package/dist/config/types/index.js +2 -0
  97. package/dist/config/types/less.d.ts +10 -0
  98. package/dist/config/types/less.js +2 -0
  99. package/dist/config/types/sass.d.ts +8 -0
  100. package/dist/config/types/sass.js +2 -0
  101. package/dist/{types/config → config}/types/ssg.d.ts +8 -8
  102. package/dist/config/types/ssg.js +2 -0
  103. package/dist/config/types/test.d.ts +14 -0
  104. package/dist/config/types/test.js +2 -0
  105. package/dist/config/types/unbundle.d.ts +25 -0
  106. package/dist/config/types/unbundle.js +2 -0
  107. package/dist/{types/context.d.ts → context.d.ts} +12 -22
  108. package/dist/context.js +59 -0
  109. package/dist/index.d.ts +64 -0
  110. package/dist/index.js +177 -0
  111. package/dist/{types/initWatcher.d.ts → initWatcher.d.ts} +1 -1
  112. package/dist/initWatcher.js +75 -0
  113. package/dist/{types/loadEnv.d.ts → loadEnv.d.ts} +1 -1
  114. package/dist/loadEnv.js +21 -0
  115. package/dist/{types/loadPlugins.d.ts → loadPlugins.d.ts} +13 -16
  116. package/dist/loadPlugins.js +109 -0
  117. package/dist/manager.d.ts +72 -0
  118. package/dist/manager.js +24 -0
  119. package/dist/{types/pluginAPI.d.ts → pluginAPI.d.ts} +5 -6
  120. package/dist/pluginAPI.js +16 -0
  121. package/dist/{types/utils → utils}/commander.d.ts +1 -1
  122. package/dist/utils/commander.js +20 -0
  123. package/dist/{types/utils → utils}/repeatKeyWarning.d.ts +1 -1
  124. package/dist/utils/repeatKeyWarning.js +22 -0
  125. package/package.json +14 -28
  126. package/tsconfig.json +3 -4
  127. package/dist/js/modern/cli.js +0 -29
  128. package/dist/js/modern/config/defaults.js +0 -103
  129. package/dist/js/modern/config/index.js +0 -115
  130. package/dist/js/modern/config/mergeConfig.js +0 -22
  131. package/dist/js/modern/config/schema/deploy.js +0 -17
  132. package/dist/js/modern/config/schema/index.js +0 -107
  133. package/dist/js/modern/config/schema/output.js +0 -147
  134. package/dist/js/modern/config/schema/server.js +0 -170
  135. package/dist/js/modern/config/schema/source.js +0 -59
  136. package/dist/js/modern/config/schema/tools.js +0 -36
  137. package/dist/js/modern/config/types/electron.js +0 -1
  138. package/dist/js/modern/config/types/index.js +0 -1
  139. package/dist/js/modern/config/types/less.js +0 -0
  140. package/dist/js/modern/config/types/sass.js +0 -0
  141. package/dist/js/modern/config/types/ssg.js +0 -0
  142. package/dist/js/modern/config/types/test.js +0 -0
  143. package/dist/js/modern/config/types/unbundle.js +0 -0
  144. package/dist/js/modern/context.js +0 -63
  145. package/dist/js/modern/index.js +0 -169
  146. package/dist/js/modern/initWatcher.js +0 -62
  147. package/dist/js/modern/loadEnv.js +0 -14
  148. package/dist/js/modern/loadPlugins.js +0 -122
  149. package/dist/js/modern/manager.js +0 -28
  150. package/dist/js/modern/pluginAPI.js +0 -11
  151. package/dist/js/modern/utils/commander.js +0 -19
  152. package/dist/js/modern/utils/repeatKeyWarning.js +0 -18
  153. package/dist/js/node/cli.js +0 -35
  154. package/dist/js/node/config/defaults.js +0 -110
  155. package/dist/js/node/config/index.js +0 -182
  156. package/dist/js/node/config/mergeConfig.js +0 -32
  157. package/dist/js/node/config/schema/deploy.js +0 -26
  158. package/dist/js/node/config/schema/index.js +0 -127
  159. package/dist/js/node/config/schema/output.js +0 -156
  160. package/dist/js/node/config/schema/server.js +0 -179
  161. package/dist/js/node/config/schema/source.js +0 -68
  162. package/dist/js/node/config/schema/tools.js +0 -43
  163. package/dist/js/node/config/types/electron.js +0 -5
  164. package/dist/js/node/config/types/index.js +0 -5
  165. package/dist/js/node/config/types/less.js +0 -0
  166. package/dist/js/node/config/types/sass.js +0 -0
  167. package/dist/js/node/config/types/ssg.js +0 -0
  168. package/dist/js/node/config/types/test.js +0 -0
  169. package/dist/js/node/config/types/unbundle.js +0 -0
  170. package/dist/js/node/context.js +0 -93
  171. package/dist/js/node/index.js +0 -329
  172. package/dist/js/node/initWatcher.js +0 -82
  173. package/dist/js/node/loadEnv.js +0 -30
  174. package/dist/js/node/loadPlugins.js +0 -134
  175. package/dist/js/node/manager.js +0 -45
  176. package/dist/js/node/pluginAPI.js +0 -54
  177. package/dist/js/node/utils/commander.js +0 -32
  178. package/dist/js/node/utils/repeatKeyWarning.js +0 -31
  179. package/dist/types/cli.d.ts +0 -1
  180. package/dist/types/config/defaults.d.ts +0 -28
  181. package/dist/types/config/mergeConfig.d.ts +0 -31
  182. package/dist/types/config/schema/deploy.d.ts +0 -16
  183. package/dist/types/config/schema/index.d.ts +0 -466
  184. package/dist/types/config/schema/output.d.ts +0 -146
  185. package/dist/types/config/schema/server.d.ts +0 -182
  186. package/dist/types/config/schema/source.d.ts +0 -58
  187. package/dist/types/config/schema/tools.d.ts +0 -36
  188. package/dist/types/config/types/electron.d.ts +0 -13
  189. package/dist/types/config/types/index.d.ts +0 -252
  190. package/dist/types/config/types/less.d.ts +0 -10
  191. package/dist/types/config/types/sass.d.ts +0 -8
  192. package/dist/types/config/types/test.d.ts +0 -15
  193. package/dist/types/config/types/unbundle.d.ts +0 -28
  194. package/dist/types/index.d.ts +0 -64
  195. package/dist/types/manager.d.ts +0 -75
  196. package/modern.config.js +0 -6
package/dist/index.js ADDED
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.initAppContext = exports.initAppDir = exports.cli = exports.mergeOptions = exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = exports.registerHook = exports.createPlugin = exports.usePlugins = exports.mountHook = exports.manager = void 0;
26
+ const path_1 = __importDefault(require("path"));
27
+ const utils_1 = require("@modern-js/utils");
28
+ const node_1 = require("@modern-js/plugin/node");
29
+ const commander_1 = require("./utils/commander");
30
+ const config_1 = require("./config");
31
+ const loadPlugins_1 = require("./loadPlugins");
32
+ const context_1 = require("./context");
33
+ Object.defineProperty(exports, "initAppContext", { enumerable: true, get: function () { return context_1.initAppContext; } });
34
+ const initWatcher_1 = require("./initWatcher");
35
+ const loadEnv_1 = require("./loadEnv");
36
+ const manager_1 = require("./manager");
37
+ __exportStar(require("./config"), exports);
38
+ __exportStar(require("@modern-js/plugin"), exports);
39
+ __exportStar(require("@modern-js/plugin/node"), exports);
40
+ // TODO: remove export after refactor all plugins
41
+ var manager_2 = require("./manager");
42
+ Object.defineProperty(exports, "manager", { enumerable: true, get: function () { return manager_2.manager; } });
43
+ Object.defineProperty(exports, "mountHook", { enumerable: true, get: function () { return manager_2.mountHook; } });
44
+ Object.defineProperty(exports, "usePlugins", { enumerable: true, get: function () { return manager_2.usePlugins; } });
45
+ Object.defineProperty(exports, "createPlugin", { enumerable: true, get: function () { return manager_2.createPlugin; } });
46
+ Object.defineProperty(exports, "registerHook", { enumerable: true, get: function () { return manager_2.registerHook; } });
47
+ // TODO: remove export after refactor all plugins
48
+ var pluginAPI_1 = require("./pluginAPI");
49
+ Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return pluginAPI_1.AppContext; } });
50
+ Object.defineProperty(exports, "ConfigContext", { enumerable: true, get: function () { return pluginAPI_1.ConfigContext; } });
51
+ Object.defineProperty(exports, "ResolvedConfigContext", { enumerable: true, get: function () { return pluginAPI_1.ResolvedConfigContext; } });
52
+ Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return pluginAPI_1.useAppContext; } });
53
+ Object.defineProperty(exports, "useConfigContext", { enumerable: true, get: function () { return pluginAPI_1.useConfigContext; } });
54
+ Object.defineProperty(exports, "useResolvedConfigContext", { enumerable: true, get: function () { return pluginAPI_1.useResolvedConfigContext; } });
55
+ utils_1.program
56
+ .name('modern')
57
+ .usage('<command> [options]')
58
+ .version(process.env.MODERN_JS_VERSION || '0.1.0');
59
+ const initAppDir = (cwd) => __awaiter(void 0, void 0, void 0, function* () {
60
+ if (!cwd) {
61
+ // eslint-disable-next-line no-param-reassign
62
+ cwd = process.cwd();
63
+ }
64
+ const pkg = yield (0, utils_1.pkgUp)({ cwd });
65
+ if (!pkg) {
66
+ throw new Error(`no package.json found in current work dir: ${cwd}`);
67
+ }
68
+ return path_1.default.dirname(pkg);
69
+ });
70
+ exports.initAppDir = initAppDir;
71
+ const mergeOptions = (options) => {
72
+ const defaultOptions = {
73
+ serverConfigFile: utils_1.DEFAULT_SERVER_CONFIG,
74
+ };
75
+ return Object.assign(Object.assign({}, defaultOptions), options);
76
+ };
77
+ exports.mergeOptions = mergeOptions;
78
+ const createCli = () => {
79
+ let hooksRunner;
80
+ let isRestart = false;
81
+ let restartWithExistingPort = 0;
82
+ let restartOptions;
83
+ const init = (argv = [], options) => __awaiter(void 0, void 0, void 0, function* () {
84
+ var _a, _b;
85
+ (0, node_1.enable)();
86
+ manager_1.manager.clear();
87
+ const mergedOptions = (0, exports.mergeOptions)(options);
88
+ restartOptions = mergedOptions;
89
+ const appDirectory = yield initAppDir();
90
+ (0, commander_1.initCommandsMap)();
91
+ 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';
92
+ (0, loadEnv_1.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
93
+ const loaded = yield (0, config_1.loadUserConfig)(appDirectory, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.configFile, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.packageJsonConfig);
94
+ const plugins = (0, loadPlugins_1.loadPlugins)(appDirectory, loaded.config, {
95
+ internalPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.plugins,
96
+ transformPlugin: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.transformPlugin,
97
+ });
98
+ plugins.forEach(plugin => plugin.cli && manager_1.manager.usePlugin(plugin.cli));
99
+ const appContext = (0, context_1.initAppContext)({
100
+ appDirectory,
101
+ plugins,
102
+ configFile: loaded.filePath,
103
+ options: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options,
104
+ serverConfigFile: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.serverConfigFile,
105
+ });
106
+ // 将 server.config 加入到 loaded.dependencies,以便对文件监听做热更新
107
+ (0, config_1.addServerConfigToDeps)(loaded.dependencies, appDirectory, mergedOptions.serverConfigFile);
108
+ manager_1.manager.run(() => {
109
+ context_1.ConfigContext.set(loaded.config);
110
+ context_1.AppContext.set(appContext);
111
+ });
112
+ hooksRunner = yield manager_1.manager.init();
113
+ ['SIGINT', 'SIGTERM', 'unhandledRejection', 'uncaughtException'].forEach(event => {
114
+ process.on(event, (err) => __awaiter(void 0, void 0, void 0, function* () {
115
+ yield hooksRunner.beforeExit();
116
+ if (err instanceof Error) {
117
+ utils_1.logger.error(err.stack);
118
+ }
119
+ process.nextTick(() => {
120
+ // eslint-disable-next-line no-process-exit
121
+ process.exit(1);
122
+ });
123
+ }));
124
+ });
125
+ const extraConfigs = yield hooksRunner.config();
126
+ const extraSchemas = yield hooksRunner.validateSchema();
127
+ const config = yield (0, config_1.resolveConfig)(loaded, extraConfigs, extraSchemas, restartWithExistingPort, argv, options === null || options === void 0 ? void 0 : options.onSchemaError);
128
+ const { resolved } = yield hooksRunner.resolvedConfig({
129
+ resolved: config,
130
+ });
131
+ // update context value
132
+ manager_1.manager.run(() => {
133
+ context_1.ConfigContext.set(loaded.config);
134
+ context_1.ResolvedConfigContext.set(resolved);
135
+ context_1.AppContext.set(Object.assign(Object.assign({}, appContext), { port: resolved.server.port, distDirectory: (0, utils_1.ensureAbsolutePath)(appDirectory, resolved.output.path) }));
136
+ });
137
+ yield hooksRunner.prepare();
138
+ return { loadedConfig: loaded, appContext, resolved };
139
+ });
140
+ function run(argv, options) {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ const { loadedConfig, appContext, resolved } = yield init(argv, options);
143
+ yield hooksRunner.commands({ program: utils_1.program });
144
+ (0, initWatcher_1.initWatcher)(loadedConfig, appContext.appDirectory, resolved.source.configDir, hooksRunner, argv);
145
+ manager_1.manager.run(() => utils_1.program.parse(process.argv));
146
+ });
147
+ }
148
+ function restart() {
149
+ var _a, _b;
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ isRestart = true;
152
+ restartWithExistingPort = isRestart ? (_b = (_a = context_1.AppContext.use().value) === null || _a === void 0 ? void 0 : _a.port) !== null && _b !== void 0 ? _b : 0 : 0;
153
+ utils_1.logger.info('Restart...\n');
154
+ let hasGetError = false;
155
+ const runner = manager_1.manager.useRunner();
156
+ yield runner.beforeRestart();
157
+ try {
158
+ yield init(process.argv.slice(2), restartOptions);
159
+ }
160
+ catch (err) {
161
+ console.error(err);
162
+ hasGetError = true;
163
+ }
164
+ finally {
165
+ if (!hasGetError) {
166
+ manager_1.manager.run(() => utils_1.program.parse(process.argv));
167
+ }
168
+ }
169
+ });
170
+ }
171
+ return {
172
+ init,
173
+ run,
174
+ restart,
175
+ };
176
+ };
177
+ exports.cli = createCli();
@@ -1,3 +1,3 @@
1
1
  import { LoadedConfig } from './config';
2
2
  import { HooksRunner } from './manager';
3
- export declare const initWatcher: (loaded: LoadedConfig, appDirectory: string, configDir: string | undefined, hooksRunner: HooksRunner, argv: string[]) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
3
+ export declare const initWatcher: (loaded: LoadedConfig, appDirectory: string, configDir: string | undefined, hooksRunner: HooksRunner, argv: string[]) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.initWatcher = void 0;
16
+ const crypto_1 = __importDefault(require("crypto"));
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const path_1 = __importDefault(require("path"));
19
+ const utils_1 = require("@modern-js/utils");
20
+ const debug = (0, utils_1.createDebugger)('watch-files');
21
+ const md5 = (data) => crypto_1.default.createHash('md5').update(data).digest('hex');
22
+ const hashMap = new Map();
23
+ const initWatcher = (loaded, appDirectory, configDir, hooksRunner, argv) => __awaiter(void 0, void 0, void 0, function* () {
24
+ // only add fs watcher on dev mode.
25
+ if (((0, utils_1.isDev)() || (0, utils_1.isTest)()) && argv[0] === 'dev') {
26
+ const extraFiles = yield hooksRunner.watchFiles();
27
+ const configPath = path_1.default.join(appDirectory, configDir);
28
+ const watched = [
29
+ `${configPath}/html`,
30
+ ...extraFiles,
31
+ loaded === null || loaded === void 0 ? void 0 : loaded.filePath,
32
+ ...loaded.dependencies,
33
+ ].filter(Boolean);
34
+ debug(`watched: %o`, watched);
35
+ const watcher = utils_1.chokidar.watch(watched, {
36
+ cwd: appDirectory,
37
+ ignoreInitial: true,
38
+ ignorePermissionErrors: true,
39
+ ignored: [
40
+ /node_modules/,
41
+ '**/__test__/**',
42
+ '**/*.test.(js|jsx|ts|tsx)',
43
+ '**/*.spec.(js|jsx|ts|tsx)',
44
+ '**/*.stories.(js|jsx|ts|tsx)',
45
+ ],
46
+ });
47
+ watcher.on('change', changed => {
48
+ const lastHash = hashMap.get(changed);
49
+ const currentHash = md5(fs_1.default.readFileSync(path_1.default.join(appDirectory, changed), 'utf8'));
50
+ if (currentHash !== lastHash) {
51
+ debug(`file change: %s`, changed);
52
+ hashMap.set(changed, currentHash);
53
+ hooksRunner.fileChange({ filename: changed, eventType: 'change' });
54
+ }
55
+ });
56
+ watcher.on('add', name => {
57
+ debug(`add file: %s`, name);
58
+ const currentHash = md5(fs_1.default.readFileSync(path_1.default.join(appDirectory, name), 'utf8'));
59
+ hashMap.set(name, currentHash);
60
+ hooksRunner.fileChange({ filename: name, eventType: 'add' });
61
+ });
62
+ watcher.on('unlink', name => {
63
+ debug(`remove file: %s`, name);
64
+ if (hashMap.has(name)) {
65
+ hashMap.delete(name);
66
+ }
67
+ hooksRunner.fileChange({ filename: name, eventType: 'unlink' });
68
+ });
69
+ watcher.on('error', err => {
70
+ throw err;
71
+ });
72
+ return watcher;
73
+ }
74
+ });
75
+ exports.initWatcher = initWatcher;
@@ -1 +1 @@
1
- export declare const loadEnv: (appDirectory: string, mode?: string) => void;
1
+ export declare const loadEnv: (appDirectory: string, mode?: string) => void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadEnv = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const utils_1 = require("@modern-js/utils");
10
+ const loadEnv = (appDirectory, mode = process.env.NODE_ENV) => {
11
+ // Don't change the order of the filenames, since they are ordered by the priority.
12
+ // Files on the left have more priority than files on the right.
13
+ [`.env.${mode}.local`, '.env.local', `.env.${mode}`, '.env']
14
+ .map(name => path_1.default.resolve(appDirectory, name))
15
+ .filter(filePath => fs_1.default.existsSync(filePath) && !fs_1.default.statSync(filePath).isDirectory())
16
+ .forEach(filePath => {
17
+ const envConfig = utils_1.dotenv.config({ path: filePath });
18
+ (0, utils_1.dotenvExpand)(envConfig);
19
+ });
20
+ };
21
+ exports.loadEnv = loadEnv;
@@ -3,30 +3,28 @@ import type { UserConfig } from './config';
3
3
  import { CliPlugin } from './manager';
4
4
  declare type PluginItem = string | [string, any];
5
5
  export declare type LoadedPlugin = {
6
- cli?: CliPlugin;
7
- server?: string;
8
- serverPkg?: string;
6
+ cli?: CliPlugin;
7
+ server?: string;
8
+ serverPkg?: string;
9
9
  };
10
10
  export declare type TransformPlugin = (plugin: PluginConfig, resolvedConfig: UserConfig, pluginOptions?: any) => PluginConfig;
11
11
  /**
12
12
  * @deprecated
13
13
  * Using NewPluginConfig insteand.
14
14
  */
15
-
16
15
  declare type OldPluginConfig = Array<PluginItem | {
17
- cli?: PluginItem;
18
- server?: PluginItem;
16
+ cli?: PluginItem;
17
+ server?: PluginItem;
19
18
  }>;
20
19
  declare type NewPluginConfig = CliPlugin[] | {
21
- cli?: CliPlugin[];
22
- /** Custom server plugin is not supported yet. */
23
-
24
- server?: never;
20
+ cli?: CliPlugin[];
21
+ /** Custom server plugin is not supported yet. */
22
+ server?: never;
25
23
  };
26
24
  export declare type PluginConfig = OldPluginConfig | NewPluginConfig;
27
25
  export declare function getAppPlugins(appDirectory: string, oldPluginConfig: OldPluginConfig, internalPlugins?: typeof INTERNAL_PLUGINS): (PluginItem | {
28
- cli?: PluginItem | undefined;
29
- server?: PluginItem | undefined;
26
+ cli?: PluginItem | undefined;
27
+ server?: PluginItem | undefined;
30
28
  })[];
31
29
  /**
32
30
  * Load internal plugins which in @modern-js scope and user's custom plugins.
@@ -36,9 +34,8 @@ export declare function getAppPlugins(appDirectory: string, oldPluginConfig: Old
36
34
  * @param options.transformPlugin - transform plugin before using it. Used for compatible with legacy jupiter plugins.
37
35
  * @returns Plugin Objects has been required.
38
36
  */
39
-
40
37
  export declare const loadPlugins: (appDirectory: string, userConfig: UserConfig, options?: {
41
- internalPlugins?: typeof INTERNAL_PLUGINS;
42
- transformPlugin?: TransformPlugin;
38
+ internalPlugins?: typeof INTERNAL_PLUGINS;
39
+ transformPlugin?: TransformPlugin;
43
40
  }) => LoadedPlugin[];
44
- export {};
41
+ export {};
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadPlugins = exports.getAppPlugins = void 0;
4
+ const utils_1 = require("@modern-js/utils");
5
+ const manager_1 = require("./manager");
6
+ const debug = (0, utils_1.createDebugger)('load-plugins');
7
+ /**
8
+ * Try to resolve plugin entry file path.
9
+ * @param name - Plugin name.
10
+ * @param appDirectory - Application root directory.
11
+ * @returns Resolved file path.
12
+ */
13
+ const tryResolve = (name, appDirectory) => {
14
+ let filePath = '';
15
+ try {
16
+ filePath = require.resolve(name, { paths: [appDirectory] });
17
+ delete require.cache[filePath];
18
+ }
19
+ catch (err) {
20
+ if (err.code === 'MODULE_NOT_FOUND') {
21
+ throw new Error(`Can not find plugin ${name}.`);
22
+ }
23
+ throw err;
24
+ }
25
+ return filePath;
26
+ };
27
+ function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
28
+ const allPlugins = internalPlugins || utils_1.INTERNAL_PLUGINS;
29
+ const appPlugins = [
30
+ ...Object.keys(allPlugins)
31
+ .filter(name => {
32
+ const config = allPlugins[name];
33
+ if (config.forced === true) {
34
+ // 参考 packages/cli/core/src/cli.ts 文件
35
+ return true;
36
+ }
37
+ return (0, utils_1.isDepExists)(appDirectory, name);
38
+ })
39
+ .map(name => allPlugins[name]),
40
+ ...oldPluginConfig,
41
+ ];
42
+ return appPlugins;
43
+ }
44
+ exports.getAppPlugins = getAppPlugins;
45
+ const resolveCliPlugin = (p, userConfig, appDirectory, transformPlugin) => {
46
+ const pkg = typeof p === 'string' ? p : p[0];
47
+ const pluginOptions = typeof p === 'string' ? undefined : p[1];
48
+ const path = tryResolve(pkg, appDirectory);
49
+ let module = (0, utils_1.compatRequire)(path);
50
+ if (transformPlugin) {
51
+ module = transformPlugin(module, userConfig, pluginOptions);
52
+ }
53
+ if (typeof module === 'function') {
54
+ const result = module(pluginOptions);
55
+ return (0, manager_1.createPlugin)(result.setup, result);
56
+ }
57
+ return module;
58
+ };
59
+ const isOldPluginConfig = (config) => Array.isArray(config) &&
60
+ config.some(item => {
61
+ if (typeof item === 'string' || Array.isArray(item)) {
62
+ return true;
63
+ }
64
+ return 'cli' in item || 'server' in item;
65
+ });
66
+ /**
67
+ * Load internal plugins which in @modern-js scope and user's custom plugins.
68
+ * @param appDirectory - Application root directory.
69
+ * @param userConfig - Resolved user config.
70
+ * @param options.internalPlugins - Internal plugins.
71
+ * @param options.transformPlugin - transform plugin before using it. Used for compatible with legacy jupiter plugins.
72
+ * @returns Plugin Objects has been required.
73
+ */
74
+ const loadPlugins = (appDirectory, userConfig, options = {}) => {
75
+ const pluginConfig = userConfig.plugins;
76
+ const plugins = getAppPlugins(appDirectory, isOldPluginConfig(pluginConfig) ? pluginConfig : [], options.internalPlugins);
77
+ const loadedPlugins = plugins.map(plugin => {
78
+ const _plugin = typeof plugin === 'string' || Array.isArray(plugin)
79
+ ? { cli: plugin }
80
+ : plugin;
81
+ const { cli, server } = _plugin;
82
+ const loadedPlugin = {};
83
+ if (cli) {
84
+ loadedPlugin.cli = resolveCliPlugin(cli, userConfig, appDirectory, options.transformPlugin);
85
+ }
86
+ // server plugins don't support to accept params
87
+ if (server && typeof server === 'string') {
88
+ loadedPlugin.server = server;
89
+ loadedPlugin.serverPkg = server;
90
+ }
91
+ debug(`resolve plugin %s: %s`, plugin, {
92
+ cli: loadedPlugin.cli,
93
+ server: loadedPlugin.server,
94
+ });
95
+ return loadedPlugin;
96
+ });
97
+ if (!isOldPluginConfig(pluginConfig)) {
98
+ const cliPlugins = Array.isArray(pluginConfig)
99
+ ? pluginConfig
100
+ : pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.cli;
101
+ if (cliPlugins === null || cliPlugins === void 0 ? void 0 : cliPlugins.length) {
102
+ loadedPlugins.push(...cliPlugins.map(item => ({
103
+ cli: (0, manager_1.createPlugin)(item.setup, item),
104
+ })));
105
+ }
106
+ }
107
+ return loadedPlugins;
108
+ };
109
+ exports.loadPlugins = loadPlugins;
@@ -0,0 +1,72 @@
1
+ import { ToThreads, ToRunners, AsyncSetup, PluginOptions, AsyncWorkflow, AsyncWaterfall, ParallelWorkflow } from '@modern-js/plugin';
2
+ import type { Hooks } from '@modern-js/types';
3
+ import type { Command } from './utils/commander';
4
+ import type { NormalizedConfig } from './config/mergeConfig';
5
+ import type { UserConfig } from './config';
6
+ import { pluginAPI } from './pluginAPI';
7
+ export declare type HooksRunner = ToRunners<{
8
+ config: ParallelWorkflow<void, UserConfig>;
9
+ resolvedConfig: AsyncWaterfall<{
10
+ resolved: NormalizedConfig;
11
+ }>;
12
+ validateSchema: ParallelWorkflow<void>;
13
+ prepare: AsyncWorkflow<void, void>;
14
+ commands: AsyncWorkflow<{
15
+ program: Command;
16
+ }, void>;
17
+ watchFiles: ParallelWorkflow<void>;
18
+ fileChange: AsyncWorkflow<{
19
+ filename: string;
20
+ eventType: 'add' | 'change' | 'unlink';
21
+ }, void>;
22
+ beforeExit: AsyncWorkflow<void, void>;
23
+ beforeRestart: AsyncWorkflow<void, void>;
24
+ }>;
25
+ declare const baseHooks: {
26
+ config: ParallelWorkflow<void, UserConfig>;
27
+ resolvedConfig: AsyncWaterfall<{
28
+ resolved: NormalizedConfig;
29
+ }>;
30
+ validateSchema: ParallelWorkflow<void, unknown>;
31
+ prepare: AsyncWorkflow<void, void>;
32
+ commands: AsyncWorkflow<{
33
+ program: Command;
34
+ }, void>;
35
+ watchFiles: ParallelWorkflow<void, unknown>;
36
+ fileChange: AsyncWorkflow<{
37
+ filename: string;
38
+ eventType: 'add' | 'change' | 'unlink';
39
+ }, void>;
40
+ beforeExit: AsyncWorkflow<void, void>;
41
+ beforeRestart: AsyncWorkflow<void, void>;
42
+ };
43
+ /** All hooks of cli plugin. */
44
+ export declare type CliHooks = typeof baseHooks & Hooks;
45
+ /** All hook callbacks of cli plugin. */
46
+ export declare type CliHookCallbacks = ToThreads<CliHooks>;
47
+ export declare const manager: import("@modern-js/plugin").AsyncManager<CliHooks, {
48
+ setAppContext: (value: import("@modern-js/types").IAppContext) => void;
49
+ useAppContext: () => import("@modern-js/types").IAppContext;
50
+ useConfigContext: () => UserConfig;
51
+ useResolvedConfigContext: () => NormalizedConfig;
52
+ }>;
53
+ /** Plugin options of a cli plugin. */
54
+ export declare type CliPlugin = PluginOptions<CliHooks, AsyncSetup<CliHooks, typeof pluginAPI>>;
55
+ export declare const createPlugin: (setup?: AsyncSetup<CliHooks, {
56
+ setAppContext: (value: import("@modern-js/types").IAppContext) => void;
57
+ useAppContext: () => import("@modern-js/types").IAppContext;
58
+ useConfigContext: () => UserConfig;
59
+ useResolvedConfigContext: () => NormalizedConfig;
60
+ }> | undefined, options?: PluginOptions<CliHooks, AsyncSetup<CliHooks, {
61
+ setAppContext: (value: import("@modern-js/types").IAppContext) => void;
62
+ useAppContext: () => import("@modern-js/types").IAppContext;
63
+ useConfigContext: () => UserConfig;
64
+ useResolvedConfigContext: () => NormalizedConfig;
65
+ }>> | undefined) => import("@modern-js/plugin").AsyncPlugin<CliHooks, {
66
+ setAppContext: (value: import("@modern-js/types").IAppContext) => void;
67
+ useAppContext: () => import("@modern-js/types").IAppContext;
68
+ useConfigContext: () => UserConfig;
69
+ useResolvedConfigContext: () => NormalizedConfig;
70
+ }>, registerHook: (newHooks: Partial<CliHooks>) => void, mountHook: () => ToRunners<CliHooks>;
71
+ export declare const usePlugins: (plugins: string[]) => void;
72
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePlugins = exports.mountHook = exports.registerHook = exports.createPlugin = exports.manager = void 0;
4
+ const plugin_1 = require("@modern-js/plugin");
5
+ const utils_1 = require("@modern-js/utils");
6
+ const pluginAPI_1 = require("./pluginAPI");
7
+ const baseHooks = {
8
+ config: (0, plugin_1.createParallelWorkflow)(),
9
+ resolvedConfig: (0, plugin_1.createAsyncWaterfall)(),
10
+ validateSchema: (0, plugin_1.createParallelWorkflow)(),
11
+ prepare: (0, plugin_1.createAsyncWorkflow)(),
12
+ commands: (0, plugin_1.createAsyncWorkflow)(),
13
+ watchFiles: (0, plugin_1.createParallelWorkflow)(),
14
+ fileChange: (0, plugin_1.createAsyncWorkflow)(),
15
+ beforeExit: (0, plugin_1.createAsyncWorkflow)(),
16
+ beforeRestart: (0, plugin_1.createAsyncWorkflow)(),
17
+ };
18
+ exports.manager = (0, plugin_1.createAsyncManager)(baseHooks, pluginAPI_1.pluginAPI);
19
+ exports.createPlugin = exports.manager.createPlugin, exports.registerHook = exports.manager.registerHook, exports.mountHook = exports.manager.useRunner;
20
+ const usePlugins = (plugins) => plugins.forEach(pluginPath => {
21
+ const module = (0, utils_1.compatRequire)(require.resolve(pluginPath));
22
+ exports.manager.usePlugin(module);
23
+ });
24
+ exports.usePlugins = usePlugins;
@@ -2,12 +2,11 @@ import type { CommonAPI } from '@modern-js/plugin';
2
2
  import type { CliHooks } from './manager';
3
3
  import { AppContext, ConfigContext, useAppContext, useConfigContext, ResolvedConfigContext, useResolvedConfigContext } from './context';
4
4
  export declare const pluginAPI: {
5
- setAppContext: (value: import("@modern-js/types/cli").IAppContext) => void;
6
- useAppContext: () => import("@modern-js/types/cli").IAppContext;
7
- useConfigContext: () => import("./config").UserConfig;
8
- useResolvedConfigContext: () => import(".").NormalizedConfig;
5
+ setAppContext: (value: import("@modern-js/types/cli").IAppContext) => void;
6
+ useAppContext: () => import("@modern-js/types/cli").IAppContext;
7
+ useConfigContext: () => import("./config").UserConfig;
8
+ useResolvedConfigContext: () => import(".").NormalizedConfig;
9
9
  };
10
10
  /** all apis for cli plugin */
11
-
12
11
  export declare type PluginAPI = typeof pluginAPI & CommonAPI<CliHooks>;
13
- export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext };
12
+ export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = exports.pluginAPI = void 0;
4
+ const context_1 = require("./context");
5
+ Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return context_1.AppContext; } });
6
+ Object.defineProperty(exports, "ConfigContext", { enumerable: true, get: function () { return context_1.ConfigContext; } });
7
+ Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return context_1.useAppContext; } });
8
+ Object.defineProperty(exports, "useConfigContext", { enumerable: true, get: function () { return context_1.useConfigContext; } });
9
+ Object.defineProperty(exports, "ResolvedConfigContext", { enumerable: true, get: function () { return context_1.ResolvedConfigContext; } });
10
+ Object.defineProperty(exports, "useResolvedConfigContext", { enumerable: true, get: function () { return context_1.useResolvedConfigContext; } });
11
+ exports.pluginAPI = {
12
+ setAppContext: context_1.setAppContext,
13
+ useAppContext: context_1.useAppContext,
14
+ useConfigContext: context_1.useConfigContext,
15
+ useResolvedConfigContext: context_1.useResolvedConfigContext,
16
+ };
@@ -1,4 +1,4 @@
1
1
  import { program, Command } from '@modern-js/utils';
2
2
  export declare function initCommandsMap(): void;
3
3
  export type { Command };
4
- export { program };
4
+ export { program };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.program = exports.initCommandsMap = void 0;
4
+ const utils_1 = require("@modern-js/utils");
5
+ Object.defineProperty(exports, "program", { enumerable: true, get: function () { return utils_1.program; } });
6
+ function initCommandsMap() {
7
+ if (!utils_1.program.hasOwnProperty('commandsMap')) {
8
+ Object.defineProperty(utils_1.program, 'commandsMap', {
9
+ get() {
10
+ const map = new Map();
11
+ for (const command of utils_1.program.commands) {
12
+ map.set(command._name, command);
13
+ }
14
+ return map;
15
+ },
16
+ configurable: false,
17
+ });
18
+ }
19
+ }
20
+ exports.initCommandsMap = initCommandsMap;
@@ -1,3 +1,3 @@
1
1
  import { UserConfig } from '../config';
2
2
  export declare const deepGet: (obj: any, key: string) => any;
3
- export declare const repeatKeyWarning: (schema: any, jsConfig: UserConfig, pkgConfig: UserConfig) => void;
3
+ export declare const repeatKeyWarning: (schema: any, jsConfig: UserConfig, pkgConfig: UserConfig) => void;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.repeatKeyWarning = exports.deepGet = void 0;
4
+ const schema_1 = require("../config/schema");
5
+ const deepGet = (obj, key) => {
6
+ for (const p of key.split('.')) {
7
+ // eslint-disable-next-line no-param-reassign
8
+ obj = obj ? obj[p] : undefined;
9
+ }
10
+ return obj;
11
+ };
12
+ exports.deepGet = deepGet;
13
+ const repeatKeyWarning = (schema, jsConfig, pkgConfig) => {
14
+ const keys = (0, schema_1.traverseSchema)(schema);
15
+ for (const key of keys) {
16
+ if ((0, exports.deepGet)(jsConfig, key) !== undefined &&
17
+ (0, exports.deepGet)(pkgConfig, key) !== undefined) {
18
+ throw new Error(`The same configuration ${key} exists in modern.config.js and package.json.\n Please remove it from package.json.`);
19
+ }
20
+ }
21
+ };
22
+ exports.repeatKeyWarning = repeatKeyWarning;