@modern-js/core 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @modern-js/core
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 65f1322: fix(core): merge array config correctly
8
+
9
+ fix(core): 修复合并配置中的数组时出现错误的问题
10
+
11
+ - fd5a3ed: fix: failed to exit new command
12
+
13
+ fix: 修复 new 命令执行完成后未退出进程的问题
14
+
15
+ - 7b2cdcb: feat(core): support read modern.config.local.ts
16
+
17
+ feat(core): 支持读取 modern.config.local.ts 文件
18
+
19
+ - 7736171: fix: remove disableRunBuild
20
+ fix: 移除 disableRunBuild
21
+ - Updated dependencies [fd5a3ed]
22
+ - Updated dependencies [6ca1c0b]
23
+ - Updated dependencies [89b6739]
24
+ - @modern-js/utils@2.3.0
25
+ - @modern-js/node-bundle-require@2.3.0
26
+ - @modern-js/plugin@2.3.0
27
+
28
+ ## 2.2.0
29
+
30
+ ### Minor Changes
31
+
32
+ - 12ef50f: feat: `modern-js/core` can watch files change
33
+ feat: `modern-js/core` 可以监听文件变化
34
+
35
+ ### Patch Changes
36
+
37
+ - cb12ee7: chore: remove some unused deps, bump postcss version
38
+
39
+ chore: 移除未使用的依赖, 升级 postcss 版本
40
+
41
+ - 360a259: fix: `@modern-js/core` add `afterPrepare` hook
42
+ fix: `@modern-js/core` 新增 `afterPrepare` hook
43
+ - Updated dependencies [49eff0c]
44
+ - @modern-js/utils@2.2.0
45
+ - @modern-js/node-bundle-require@2.2.0
46
+ - @modern-js/plugin@2.2.0
47
+
3
48
  ## 2.1.0
4
49
 
5
50
  ### Patch Changes
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.createLoadedConfig = exports.assignPkgConfig = void 0;
7
+ const path_1 = __importDefault(require("path"));
4
8
  const lodash_1 = require("@modern-js/utils/lodash");
5
9
  const utils_1 = require("@modern-js/utils");
6
- const load_configs_1 = require("../load-configs");
10
+ const utils_2 = require("../utils");
11
+ const loadConfig_1 = require("./loadConfig");
7
12
  /**
8
13
  * Assign the pkg config into the user config.
9
14
  */
@@ -17,15 +22,55 @@ const assignPkgConfig = (userConfig = {}, pkgConfig = {}) => (0, lodash_1.mergeW
17
22
  return undefined;
18
23
  });
19
24
  exports.assignPkgConfig = assignPkgConfig;
25
+ /**
26
+ * A modern config can export a function or an object
27
+ * If it's a function, it will be called and return a config object
28
+ */
29
+ async function getConfigObject(config) {
30
+ if (typeof config === 'function') {
31
+ return (await config(0)) || {};
32
+ }
33
+ return config || {};
34
+ }
35
+ async function loadLocalConfig(appDirectory, configFile) {
36
+ let localConfigFile = false;
37
+ if (typeof configFile === 'string') {
38
+ for (const ext of utils_1.CONFIG_FILE_EXTENSIONS) {
39
+ if (configFile.endsWith(ext)) {
40
+ const replacedPath = configFile.replace(ext, `.local${ext}`);
41
+ if (utils_1.fs.existsSync(replacedPath)) {
42
+ localConfigFile = replacedPath;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ else {
48
+ localConfigFile = (0, utils_1.findExists)(utils_1.CONFIG_FILE_EXTENSIONS.map(extension => path_1.default.resolve(appDirectory, `${loadConfig_1.LOCAL_CONFIG_FILE_NAME}${extension}`)));
49
+ }
50
+ if (localConfigFile) {
51
+ const loaded = await (0, loadConfig_1.loadConfig)(appDirectory, localConfigFile);
52
+ return getConfigObject(loaded.config);
53
+ }
54
+ return null;
55
+ }
20
56
  async function createLoadedConfig(appDirectory, filePath, packageJsonConfig) {
21
- const loaded = await (0, load_configs_1.loadConfig)(appDirectory, filePath, packageJsonConfig);
22
- const config = !loaded
23
- ? {}
24
- : await (typeof loaded.config === 'function'
25
- ? loaded.config(0)
26
- : loaded.config);
57
+ const configFile = (0, loadConfig_1.getConfigFilePath)(appDirectory, filePath);
58
+ const loaded = await (0, loadConfig_1.loadConfig)(appDirectory, configFile, packageJsonConfig);
59
+ const config = await getConfigObject(loaded.config);
60
+ let mergedConfig = config;
61
+ if (loaded.pkgConfig) {
62
+ mergedConfig = (0, exports.assignPkgConfig)(config, loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig);
63
+ }
64
+ // Only load local config when running dev command
65
+ if ((0, utils_1.isDevCommand)()) {
66
+ const localConfig = await loadLocalConfig(appDirectory, configFile);
67
+ // The priority of local config is higher than the user config and pkg config
68
+ if (localConfig) {
69
+ mergedConfig = (0, utils_2.mergeConfig)([mergedConfig, localConfig]);
70
+ }
71
+ }
27
72
  return {
28
- config: (0, exports.assignPkgConfig)(config, loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig),
73
+ config: mergedConfig,
29
74
  filePath: loaded.path,
30
75
  dependencies: loaded.dependencies || [],
31
76
  pkgConfig: loaded.pkgConfig || {},
@@ -1,5 +1,6 @@
1
1
  import path from 'path';
2
2
  export declare const CONFIG_FILE_NAME = "modern.config";
3
+ export declare const LOCAL_CONFIG_FILE_NAME = "modern.config.local";
3
4
  export declare const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
4
5
  /**
5
6
  * Get user config from package.json.
@@ -23,10 +24,10 @@ export declare const getConfigFilePath: (appDirectory: string, filePath?: string
23
24
  /**
24
25
  * Parse and load user config file, support extensions like .ts, mjs, js, ejs.
25
26
  * @param appDirectory - App root directory, from which start search user config file.
26
- * @param filePath - Specific absolute config file path.
27
+ * @param configFile - Specific absolute config file path.
27
28
  * @returns Object contain config file path, user config object and dependency files used by config file.
28
29
  */
29
- export declare const loadConfig: <T>(appDirectory: string, filePath?: string, packageJsonConfig?: string) => Promise<{
30
+ export declare const loadConfig: <T>(appDirectory: string, configFile: string | false, packageJsonConfig?: string) => Promise<{
30
31
  path: string | false;
31
32
  config?: T | undefined;
32
33
  dependencies?: string[] | undefined;
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadConfig = exports.getConfigFilePath = exports.clearFilesOverTime = exports.getDependencies = exports.getPackageConfig = exports.PACKAGE_JSON_CONFIG_NAME = exports.CONFIG_FILE_NAME = void 0;
6
+ exports.loadConfig = exports.getConfigFilePath = exports.clearFilesOverTime = exports.getDependencies = exports.getPackageConfig = exports.PACKAGE_JSON_CONFIG_NAME = exports.LOCAL_CONFIG_FILE_NAME = exports.CONFIG_FILE_NAME = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const utils_1 = require("@modern-js/utils");
9
9
  const node_bundle_require_1 = require("@modern-js/node-bundle-require");
10
10
  const debug = (0, utils_1.createDebugger)('load-config');
11
11
  exports.CONFIG_FILE_NAME = 'modern.config';
12
+ exports.LOCAL_CONFIG_FILE_NAME = 'modern.config.local';
12
13
  exports.PACKAGE_JSON_CONFIG_NAME = 'modernConfig';
13
14
  /**
14
15
  * Get user config from package.json.
@@ -97,11 +98,10 @@ exports.getConfigFilePath = getConfigFilePath;
97
98
  /**
98
99
  * Parse and load user config file, support extensions like .ts, mjs, js, ejs.
99
100
  * @param appDirectory - App root directory, from which start search user config file.
100
- * @param filePath - Specific absolute config file path.
101
+ * @param configFile - Specific absolute config file path.
101
102
  * @returns Object contain config file path, user config object and dependency files used by config file.
102
103
  */
103
- const loadConfig = async (appDirectory, filePath, packageJsonConfig) => {
104
- const configFile = (0, exports.getConfigFilePath)(appDirectory, filePath);
104
+ const loadConfig = async (appDirectory, configFile, packageJsonConfig) => {
105
105
  const pkgConfig = (0, exports.getPackageConfig)(appDirectory, packageJsonConfig);
106
106
  let config;
107
107
  const dependencies = pkgConfig
@@ -111,8 +111,6 @@ const loadConfig = async (appDirectory, filePath, packageJsonConfig) => {
111
111
  delete require.cache[configFile];
112
112
  const mod = await bundleRequireWithCatch(configFile, { appDirectory });
113
113
  config = mod.default || mod;
114
- // TODO: get deps.
115
- // dependencies = dependencies.concat(getDependencies(configFile));
116
114
  }
117
115
  return {
118
116
  path: configFile,
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  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.mountHook = exports.manager = void 0;
21
21
  const path_1 = __importDefault(require("path"));
22
22
  const utils_1 = require("@modern-js/utils");
23
- const commander_1 = require("./utils/commander");
23
+ const utils_2 = require("./utils");
24
24
  const loadPlugins_1 = require("./loadPlugins");
25
25
  const context_1 = require("./context");
26
26
  Object.defineProperty(exports, "initAppContext", { enumerable: true, get: function () { return context_1.initAppContext; } });
@@ -76,7 +76,7 @@ const createCli = () => {
76
76
  const mergedOptions = (0, exports.mergeOptions)(options);
77
77
  initOptions = mergedOptions;
78
78
  const appDirectory = await initAppDir(options === null || options === void 0 ? void 0 : options.cwd);
79
- (0, commander_1.initCommandsMap)();
79
+ (0, utils_2.initCommandsMap)();
80
80
  setProgramVersion(options === null || options === void 0 ? void 0 : options.version);
81
81
  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';
82
82
  (0, loadEnv_1.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
@@ -123,14 +123,16 @@ const createCli = () => {
123
123
  context_1.ResolvedConfigContext.set(resolved);
124
124
  await hooksRunner.addRuntimeExports();
125
125
  await hooksRunner.prepare();
126
+ await hooksRunner.afterPrepare();
126
127
  return {
127
128
  resolved,
128
129
  appContext: (0, context_1.useAppContext)(),
129
130
  };
130
131
  };
131
132
  async function run(options) {
132
- await init(options);
133
+ const { appContext } = await init(options);
133
134
  await hooksRunner.commands({ program: utils_1.program });
135
+ await (0, utils_2.createFileWatcher)(appContext, hooksRunner);
134
136
  utils_1.program.parse(process.argv);
135
137
  }
136
138
  async function test(argv, options) {
package/dist/manager.d.ts CHANGED
@@ -6,6 +6,12 @@ export declare const manager: import("@modern-js/plugin").AsyncManager<{
6
6
  }>;
7
7
  validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
8
8
  prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
9
+ afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
10
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
11
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
12
+ filename: string;
13
+ eventType: "add" | "unlink" | "change";
14
+ }, void>;
9
15
  commands: import("@modern-js/plugin").AsyncWorkflow<{
10
16
  program: import("@modern-js/utils").Command;
11
17
  }, void>;
@@ -19,6 +25,12 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
19
25
  }>;
20
26
  validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
21
27
  prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
28
+ afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
29
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
30
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
31
+ filename: string;
32
+ eventType: "add" | "unlink" | "change";
33
+ }, void>;
22
34
  commands: import("@modern-js/plugin").AsyncWorkflow<{
23
35
  program: import("@modern-js/utils").Command;
24
36
  }, void>;
@@ -31,6 +43,12 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
31
43
  }>;
32
44
  validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
33
45
  prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
46
+ afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
47
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
48
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
49
+ filename: string;
50
+ eventType: "add" | "unlink" | "change";
51
+ }, void>;
34
52
  commands: import("@modern-js/plugin").AsyncWorkflow<{
35
53
  program: import("@modern-js/utils").Command;
36
54
  }, void>;
@@ -43,6 +61,12 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
43
61
  }>;
44
62
  validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
45
63
  prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
64
+ afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
65
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
66
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
67
+ filename: string;
68
+ eventType: "add" | "unlink" | "change";
69
+ }, void>;
46
70
  commands: import("@modern-js/plugin").AsyncWorkflow<{
47
71
  program: import("@modern-js/utils").Command;
48
72
  }, void>;
@@ -55,6 +79,12 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
55
79
  }>;
56
80
  validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
57
81
  prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
82
+ afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
83
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
84
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
85
+ filename: string;
86
+ eventType: "add" | "unlink" | "change";
87
+ }, void>;
58
88
  commands: import("@modern-js/plugin").AsyncWorkflow<{
59
89
  program: import("@modern-js/utils").Command;
60
90
  }, void>;
@@ -67,6 +97,12 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
67
97
  }>;
68
98
  validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
69
99
  prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
100
+ afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
101
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
102
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
103
+ filename: string;
104
+ eventType: "add" | "unlink" | "change";
105
+ }, void>;
70
106
  commands: import("@modern-js/plugin").AsyncWorkflow<{
71
107
  program: import("@modern-js/utils").Command;
72
108
  }, void>;
@@ -79,6 +115,12 @@ export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSet
79
115
  }>;
80
116
  validateSchema: import("@modern-js/plugin").ParallelWorkflow<void, any>;
81
117
  prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
118
+ afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
119
+ watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, any>;
120
+ fileChange: import("@modern-js/plugin").AsyncWorkflow<{
121
+ filename: string;
122
+ eventType: "add" | "unlink" | "change";
123
+ }, void>;
82
124
  commands: import("@modern-js/plugin").AsyncWorkflow<{
83
125
  program: import("@modern-js/utils").Command;
84
126
  }, void>;
package/dist/manager.js CHANGED
@@ -9,7 +9,10 @@ const baseHooks = {
9
9
  resolvedConfig: (0, plugin_1.createAsyncWaterfall)(),
10
10
  validateSchema: (0, plugin_1.createParallelWorkflow)(),
11
11
  prepare: (0, plugin_1.createAsyncWorkflow)(),
12
+ afterPrepare: (0, plugin_1.createAsyncWorkflow)(),
12
13
  commands: (0, plugin_1.createAsyncWorkflow)(),
14
+ watchFiles: (0, plugin_1.createParallelWorkflow)(),
15
+ fileChange: (0, plugin_1.createAsyncWorkflow)(),
13
16
  beforeExit: (0, plugin_1.createAsyncWorkflow)(),
14
17
  addRuntimeExports: (0, plugin_1.createAsyncWaterfall)(),
15
18
  };
@@ -12,6 +12,12 @@ export type BaseHooks<Extends extends {
12
12
  }>;
13
13
  validateSchema: ParallelWorkflow<void>;
14
14
  prepare: AsyncWorkflow<void, void>;
15
+ afterPrepare: AsyncWorkflow<void, void>;
16
+ watchFiles: ParallelWorkflow<void>;
17
+ fileChange: AsyncWorkflow<{
18
+ filename: string;
19
+ eventType: 'add' | 'change' | 'unlink';
20
+ }, void>;
15
21
  commands: AsyncWorkflow<{
16
22
  program: Command;
17
23
  }, void>;
@@ -31,7 +37,6 @@ export interface DevToolData<DevOptions = any> {
31
37
  name: string;
32
38
  value: string;
33
39
  };
34
- disableRunBuild?: boolean;
35
40
  action: (options: DevOptions, context: {
36
41
  isTsProject?: boolean;
37
42
  }) => void | Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { CliHooksRunner, IAppContext } from '../types';
2
+ export declare const createFileWatcher: (appContext: IAppContext, hooksRunner: CliHooksRunner) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.createFileWatcher = void 0;
30
+ const crypto_1 = __importDefault(require("crypto"));
31
+ const path = __importStar(require("path"));
32
+ const fs = __importStar(require("fs"));
33
+ const utils_1 = require("@modern-js/utils");
34
+ const debug = (0, utils_1.createDebugger)('watch-files');
35
+ const hashMap = new Map();
36
+ const md5 = (data) => crypto_1.default.createHash('md5').update(data).digest('hex');
37
+ const createFileWatcher = async (appContext, hooksRunner) => {
38
+ // only add fs watcher on dev mode.
39
+ if ((0, utils_1.isDevCommand)()) {
40
+ const { appDirectory } = appContext;
41
+ const extraFiles = await hooksRunner.watchFiles();
42
+ const watched = extraFiles.filter(Boolean);
43
+ debug(`watched: %o`, watched);
44
+ const watcher = utils_1.chokidar.watch(watched, {
45
+ cwd: appDirectory,
46
+ ignoreInitial: true,
47
+ ignorePermissionErrors: true,
48
+ ignored: [
49
+ /node_modules/,
50
+ '**/__test__/**',
51
+ '**/*.test.(js|jsx|ts|tsx)',
52
+ '**/*.spec.(js|jsx|ts|tsx)',
53
+ '**/*.stories.(js|jsx|ts|tsx)',
54
+ ],
55
+ });
56
+ watcher.on('change', changed => {
57
+ const lastHash = hashMap.get(changed);
58
+ const currentHash = md5(fs.readFileSync(path.join(appDirectory, changed), 'utf8'));
59
+ if (currentHash !== lastHash) {
60
+ debug(`file change: %s`, changed);
61
+ hashMap.set(changed, currentHash);
62
+ hooksRunner.fileChange({ filename: changed, eventType: 'change' });
63
+ }
64
+ });
65
+ watcher.on('add', name => {
66
+ debug(`add file: %s`, name);
67
+ const currentHash = md5(fs.readFileSync(path.join(appDirectory, name), 'utf8'));
68
+ hashMap.set(name, currentHash);
69
+ hooksRunner.fileChange({ filename: name, eventType: 'add' });
70
+ });
71
+ watcher.on('unlink', name => {
72
+ debug(`remove file: %s`, name);
73
+ if (hashMap.has(name)) {
74
+ hashMap.delete(name);
75
+ }
76
+ hooksRunner.fileChange({ filename: name, eventType: 'unlink' });
77
+ });
78
+ watcher.on('error', err => {
79
+ throw err;
80
+ });
81
+ return watcher;
82
+ }
83
+ };
84
+ exports.createFileWatcher = createFileWatcher;
@@ -0,0 +1,4 @@
1
+ export * from './commander';
2
+ export * from './createFileWatcher';
3
+ export * from './mergeConfig';
4
+ export * from './repeatKeyWarning';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./commander"), exports);
18
+ __exportStar(require("./createFileWatcher"), exports);
19
+ __exportStar(require("./mergeConfig"), exports);
20
+ __exportStar(require("./repeatKeyWarning"), exports);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeConfig = void 0;
4
+ const utils_1 = require("@modern-js/utils");
4
5
  const lodash_1 = require("@modern-js/utils/lodash");
5
6
  const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target, source, key) => {
6
7
  // Do not use the following merge logic for source.designSystem and tools.tailwind(css)
@@ -10,15 +11,16 @@ const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target
10
11
  key === 'devServer') {
11
12
  return (0, lodash_1.mergeWith)({}, target !== null && target !== void 0 ? target : {}, source !== null && source !== void 0 ? source : {});
12
13
  }
13
- if (Array.isArray(target)) {
14
- if (Array.isArray(source)) {
15
- return [...target, ...source];
14
+ if (Array.isArray(target) || Array.isArray(source)) {
15
+ if (target === undefined) {
16
+ return source;
16
17
  }
17
- else {
18
- return source !== undefined ? [...target, source] : target;
18
+ if (source === undefined) {
19
+ return target;
19
20
  }
21
+ return [...(0, utils_1.ensureArray)(target), ...(0, utils_1.ensureArray)(source)];
20
22
  }
21
- else if ((0, lodash_1.isFunction)(target) || (0, lodash_1.isFunction)(source)) {
23
+ if ((0, lodash_1.isFunction)(target) || (0, lodash_1.isFunction)(source)) {
22
24
  if (source === undefined) {
23
25
  return target;
24
26
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "modern",
11
11
  "modern.js"
12
12
  ],
13
- "version": "2.1.0",
13
+ "version": "2.3.0",
14
14
  "jsnext:source": "./src/index.ts",
15
15
  "types": "./dist/index.d.ts",
16
16
  "main": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@modern-js/node-bundle-require": "2.1.0",
55
- "@modern-js/plugin": "2.1.0",
56
- "@modern-js/utils": "2.1.0"
54
+ "@modern-js/node-bundle-require": "2.3.0",
55
+ "@modern-js/plugin": "2.3.0",
56
+ "@modern-js/utils": "2.3.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@jest/types": "^27.0.6",
@@ -64,19 +64,18 @@
64
64
  "@types/node": "^14",
65
65
  "autoprefixer": "^10.3.1",
66
66
  "btsm": "2.2.2",
67
- "electron-builder": "22.7.0",
68
67
  "html-webpack-plugin": "5.5.0",
69
68
  "jest": "^27",
70
- "postcss": "^8.4.14",
69
+ "postcss": "8.4.21",
71
70
  "sass": "^1.45.0",
72
71
  "terser-webpack-plugin": "^5.1.4",
73
72
  "typescript": "^4",
74
73
  "webpack": "^5.75.0",
75
- "@modern-js/builder-shared": "2.1.0",
76
- "@modern-js/babel-preset-app": "2.1.0",
77
- "@modern-js/types": "2.1.0",
78
- "@scripts/jest-config": "2.1.0",
79
- "@scripts/build": "2.1.0"
74
+ "@modern-js/builder-shared": "2.3.0",
75
+ "@modern-js/babel-preset-app": "2.3.0",
76
+ "@modern-js/types": "2.3.0",
77
+ "@scripts/jest-config": "2.3.0",
78
+ "@scripts/build": "2.3.0"
80
79
  },
81
80
  "sideEffects": false,
82
81
  "publishConfig": {