@modern-js/utils 2.69.5 → 3.0.0-alpha.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/cjs/cli/alias.js +76 -70
- package/dist/cjs/cli/applyOptionsChain.js +44 -45
- package/dist/cjs/cli/babel.js +100 -119
- package/dist/cjs/cli/commands.js +61 -59
- package/dist/cjs/cli/common.js +45 -37
- package/dist/cjs/cli/config.js +36 -30
- package/dist/cjs/cli/constants.js +124 -161
- package/dist/cjs/cli/ensure.js +52 -45
- package/dist/cjs/cli/fs.js +41 -38
- package/dist/cjs/cli/get/config.js +43 -38
- package/dist/cjs/cli/get/data.js +108 -125
- package/dist/cjs/cli/get/index.js +109 -58
- package/dist/cjs/cli/index.js +202 -63
- package/dist/cjs/cli/is/config.js +75 -71
- package/dist/cjs/cli/is/env.js +49 -37
- package/dist/cjs/cli/is/index.js +76 -25
- package/dist/cjs/cli/is/project.js +139 -135
- package/dist/cjs/cli/is/type.js +65 -49
- package/dist/cjs/cli/logger.js +36 -27
- package/dist/cjs/cli/monorepo.js +100 -96
- package/dist/cjs/cli/package.js +85 -82
- package/dist/cjs/cli/path.js +101 -82
- package/dist/cjs/cli/port.js +71 -74
- package/dist/cjs/cli/prettyInstructions.js +106 -116
- package/dist/cjs/cli/require.js +116 -136
- package/dist/cjs/cli/route.js +67 -77
- package/dist/cjs/cli/runtimeExports.js +16 -70
- package/dist/cjs/cli/version.js +53 -42
- package/dist/cjs/cli/watch.js +79 -72
- package/dist/cjs/compiled.js +199 -128
- package/dist/cjs/import.js +58 -33
- package/dist/cjs/index.js +69 -23
- package/dist/cjs/universal/constants.js +77 -67
- package/dist/cjs/universal/index.js +33 -25
- package/dist/cjs/universal/path.js +33 -27
- package/dist/cjs/universal/pluginDagSort.js +69 -68
- package/dist/compiled/address/index.js +171 -1
- package/dist/compiled/browserslist/index.js +1329 -1
- package/dist/compiled/chalk/index.js +2368 -1
- package/dist/compiled/chokidar/index.js +4138 -16
- package/dist/compiled/chokidar/index.js.LICENSE.txt +41 -0
- package/dist/compiled/commander/index.js +1540 -1
- package/dist/compiled/debug/index.js +621 -1
- package/dist/compiled/dotenv/index.js +101 -1
- package/dist/compiled/dotenv-expand/index.js +54 -1
- package/dist/compiled/execa/index.js +1738 -1
- package/dist/compiled/fast-glob/index.js +4645 -17
- package/dist/compiled/fast-glob/index.js.LICENSE.txt +38 -0
- package/dist/compiled/filesize/index.js +193 -4
- package/dist/compiled/filesize/index.js.LICENSE.txt +7 -0
- package/dist/compiled/fs-extra/index.js +2222 -1
- package/dist/compiled/glob/index.js +2011 -1
- package/dist/compiled/globby/index.js +690 -1
- package/dist/compiled/gzip-size/index.js +157 -1
- package/dist/compiled/import-lazy/index.js +45 -1
- package/dist/compiled/inquirer/index.js +20162 -4
- package/dist/compiled/inquirer/index.js.LICENSE.txt +7 -0
- package/dist/compiled/js-yaml/index.js +2188 -1
- package/dist/compiled/json5/index.js +983 -1
- package/dist/compiled/lodash/index.js +0 -4
- package/dist/compiled/mime-types/index.js +108 -6
- package/dist/compiled/mime-types/index.js.LICENSE.txt +13 -0
- package/dist/compiled/minimist/index.js +202 -1
- package/dist/compiled/nanoid/index.js +83 -1
- package/dist/compiled/ora/index.js +3936 -3
- package/dist/compiled/ora/index.js.LICENSE.txt +1 -0
- package/dist/compiled/pkg-up/index.js +177 -1
- package/dist/compiled/semver/index.js +1779 -1
- package/dist/compiled/signale/index.js +1704 -1
- package/dist/compiled/slash/index.js +32 -1
- package/dist/compiled/strip-ansi/index.js +34 -1
- package/dist/compiled/tsconfig-paths/index.js +629 -1
- package/dist/compiled/upath/index.js +135 -1
- package/dist/compiled/url-join/index.js +61 -1
- package/dist/compiled/webpack-chain/index.js +1475 -1
- package/dist/esm/cli/alias.mjs +31 -0
- package/dist/esm/cli/applyOptionsChain.mjs +16 -0
- package/dist/esm/cli/babel.mjs +76 -0
- package/dist/esm/cli/commands.mjs +23 -0
- package/dist/esm/cli/common.mjs +11 -0
- package/dist/esm/cli/config.mjs +5 -0
- package/dist/esm/cli/constants.mjs +29 -0
- package/dist/esm/cli/ensure.mjs +9 -0
- package/dist/esm/cli/fs.mjs +9 -0
- package/dist/esm/cli/get/config.mjs +14 -0
- package/dist/esm/cli/get/data.mjs +57 -0
- package/dist/esm/cli/get/index.mjs +18 -0
- package/dist/{esm-node/cli/index.js → esm/cli/index.mjs} +0 -1
- package/dist/esm/cli/is/config.mjs +34 -0
- package/dist/esm/cli/is/env.mjs +6 -0
- package/dist/esm/cli/is/project.mjs +104 -0
- package/dist/esm/cli/is/type.mjs +26 -0
- package/dist/esm/cli/logger.mjs +2 -0
- package/dist/esm/cli/monorepo.mjs +50 -0
- package/dist/esm/cli/package.mjs +51 -0
- package/dist/esm/cli/path.mjs +35 -0
- package/dist/esm/cli/port.mjs +35 -0
- package/dist/esm/cli/prettyInstructions.mjs +68 -0
- package/dist/esm/cli/require.mjs +79 -0
- package/dist/esm/cli/route.mjs +36 -0
- package/dist/esm/cli/runtimeExports.mjs +0 -0
- package/dist/esm/cli/version.mjs +21 -0
- package/dist/esm/cli/watch.mjs +40 -0
- package/dist/esm/compiled.mjs +115 -0
- package/dist/esm/import.mjs +25 -0
- package/dist/esm/universal/constants.mjs +13 -0
- package/dist/{esm-node/universal/index.js → esm/universal/index.mjs} +1 -3
- package/dist/esm/universal/path.mjs +2 -0
- package/dist/esm/universal/pluginDagSort.mjs +41 -0
- package/dist/esm-node/cli/alias.mjs +31 -0
- package/dist/esm-node/cli/applyOptionsChain.mjs +16 -0
- package/dist/esm-node/cli/babel.mjs +76 -0
- package/dist/esm-node/cli/commands.mjs +23 -0
- package/dist/esm-node/cli/common.mjs +11 -0
- package/dist/esm-node/cli/config.mjs +5 -0
- package/dist/esm-node/cli/constants.mjs +29 -0
- package/dist/esm-node/cli/ensure.mjs +9 -0
- package/dist/esm-node/cli/fs.mjs +9 -0
- package/dist/esm-node/cli/get/config.mjs +14 -0
- package/dist/esm-node/cli/get/data.mjs +57 -0
- package/dist/esm-node/cli/get/index.mjs +18 -0
- package/dist/esm-node/cli/index.mjs +22 -0
- package/dist/esm-node/cli/is/config.mjs +34 -0
- package/dist/esm-node/cli/is/env.mjs +6 -0
- package/dist/esm-node/cli/is/index.mjs +4 -0
- package/dist/esm-node/cli/is/project.mjs +104 -0
- package/dist/esm-node/cli/is/type.mjs +26 -0
- package/dist/esm-node/cli/logger.mjs +2 -0
- package/dist/esm-node/cli/monorepo.mjs +50 -0
- package/dist/esm-node/cli/package.mjs +51 -0
- package/dist/esm-node/cli/path.mjs +35 -0
- package/dist/esm-node/cli/port.mjs +35 -0
- package/dist/esm-node/cli/prettyInstructions.mjs +68 -0
- package/dist/esm-node/cli/require.mjs +79 -0
- package/dist/esm-node/cli/route.mjs +36 -0
- package/dist/esm-node/cli/runtimeExports.mjs +0 -0
- package/dist/esm-node/cli/version.mjs +21 -0
- package/dist/esm-node/cli/watch.mjs +40 -0
- package/dist/esm-node/compiled.mjs +115 -0
- package/dist/esm-node/import.mjs +25 -0
- package/dist/esm-node/index.mjs +3 -0
- package/dist/esm-node/universal/constants.mjs +13 -0
- package/dist/esm-node/universal/index.mjs +2 -0
- package/dist/esm-node/universal/path.mjs +2 -0
- package/dist/esm-node/universal/pluginDagSort.mjs +41 -0
- package/dist/types/cli/constants.d.ts +2 -26
- package/dist/types/cli/get/data.d.ts +0 -1
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/is/config.d.ts +1 -1
- package/dist/types/cli/runtimeExports.d.ts +1 -4
- package/dist/types/cli/watch.d.ts +1 -1
- package/dist/types/compiled.d.ts +0 -5
- package/dist/types/universal/constants.d.ts +4 -7
- package/package.json +27 -27
- package/rslib.config.mts +140 -0
- package/dist/cjs/cli/action.js +0 -55
- package/dist/cjs/universal/formatWebpack.js +0 -127
- package/dist/esm/cli/action.js +0 -68
- package/dist/esm/cli/alias.js +0 -43
- package/dist/esm/cli/applyOptionsChain.js +0 -29
- package/dist/esm/cli/babel.js +0 -122
- package/dist/esm/cli/commands.js +0 -39
- package/dist/esm/cli/common.js +0 -20
- package/dist/esm/cli/config.js +0 -11
- package/dist/esm/cli/constants.js +0 -114
- package/dist/esm/cli/ensure.js +0 -16
- package/dist/esm/cli/fs.js +0 -65
- package/dist/esm/cli/get/config.js +0 -19
- package/dist/esm/cli/get/data.js +0 -143
- package/dist/esm/cli/get/index.js +0 -38
- package/dist/esm/cli/index.js +0 -23
- package/dist/esm/cli/is/config.js +0 -70
- package/dist/esm/cli/is/env.js +0 -22
- package/dist/esm/cli/is/index.js +0 -4
- package/dist/esm/cli/is/project.js +0 -146
- package/dist/esm/cli/is/type.js +0 -39
- package/dist/esm/cli/logger.js +0 -5
- package/dist/esm/cli/monorepo.js +0 -82
- package/dist/esm/cli/package.js +0 -203
- package/dist/esm/cli/path.js +0 -66
- package/dist/esm/cli/port.js +0 -97
- package/dist/esm/cli/prettyInstructions.js +0 -102
- package/dist/esm/cli/require.js +0 -235
- package/dist/esm/cli/route.js +0 -64
- package/dist/esm/cli/runtimeExports.js +0 -44
- package/dist/esm/cli/version.js +0 -26
- package/dist/esm/cli/watch.js +0 -112
- package/dist/esm/compiled.js +0 -66
- package/dist/esm/import.js +0 -11
- package/dist/esm/index.js +0 -3
- package/dist/esm/universal/constants.js +0 -32
- package/dist/esm/universal/formatWebpack.js +0 -95
- package/dist/esm/universal/index.js +0 -4
- package/dist/esm/universal/path.js +0 -6
- package/dist/esm/universal/pluginDagSort.js +0 -73
- package/dist/esm-node/cli/action.js +0 -30
- package/dist/esm-node/cli/alias.js +0 -40
- package/dist/esm-node/cli/applyOptionsChain.js +0 -27
- package/dist/esm-node/cli/babel.js +0 -107
- package/dist/esm-node/cli/commands.js +0 -39
- package/dist/esm-node/cli/common.js +0 -15
- package/dist/esm-node/cli/config.js +0 -9
- package/dist/esm-node/cli/constants.js +0 -114
- package/dist/esm-node/cli/ensure.js +0 -14
- package/dist/esm-node/cli/fs.js +0 -18
- package/dist/esm-node/cli/get/config.js +0 -19
- package/dist/esm-node/cli/get/data.js +0 -96
- package/dist/esm-node/cli/get/index.js +0 -22
- package/dist/esm-node/cli/is/config.js +0 -50
- package/dist/esm-node/cli/is/env.js +0 -12
- package/dist/esm-node/cli/is/project.js +0 -105
- package/dist/esm-node/cli/is/type.js +0 -36
- package/dist/esm-node/cli/logger.js +0 -5
- package/dist/esm-node/cli/monorepo.js +0 -67
- package/dist/esm-node/cli/package.js +0 -66
- package/dist/esm-node/cli/path.js +0 -48
- package/dist/esm-node/cli/port.js +0 -48
- package/dist/esm-node/cli/prettyInstructions.js +0 -90
- package/dist/esm-node/cli/require.js +0 -111
- package/dist/esm-node/cli/route.js +0 -60
- package/dist/esm-node/cli/runtimeExports.js +0 -38
- package/dist/esm-node/cli/version.js +0 -26
- package/dist/esm-node/cli/watch.js +0 -45
- package/dist/esm-node/compiled.js +0 -66
- package/dist/esm-node/import.js +0 -11
- package/dist/esm-node/universal/constants.js +0 -32
- package/dist/esm-node/universal/formatWebpack.js +0 -102
- package/dist/esm-node/universal/path.js +0 -6
- package/dist/esm-node/universal/pluginDagSort.js +0 -50
- package/dist/types/cli/action.d.ts +0 -2
- package/dist/types/universal/formatWebpack.d.ts +0 -26
- /package/dist/{esm-node/cli/is/index.js → esm/cli/is/index.mjs} +0 -0
- /package/dist/{esm-node/index.js → esm/index.mjs} +0 -0
package/dist/cjs/cli/alias.js
CHANGED
|
@@ -1,76 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
getUserAlias: ()=>getUserAlias,
|
|
37
|
+
getAliasConfig: ()=>getAliasConfig,
|
|
38
|
+
mergeAlias: ()=>mergeAlias
|
|
34
39
|
});
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const external_fs_namespaceObject = require("fs");
|
|
41
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
42
|
+
const external_path_namespaceObject = require("path");
|
|
43
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
44
|
+
const external_applyOptionsChain_js_namespaceObject = require("./applyOptionsChain.js");
|
|
45
|
+
const index_js_namespaceObject = require("./get/index.js");
|
|
46
|
+
const mergeAlias = (alias)=>(0, external_applyOptionsChain_js_namespaceObject.applyOptionsChain)({}, alias);
|
|
47
|
+
const getAliasConfig = (aliasOption, option)=>{
|
|
48
|
+
const isTsProject = external_fs_default().existsSync(option.tsconfigPath);
|
|
49
|
+
const alias = mergeAlias(aliasOption);
|
|
50
|
+
if (!isTsProject) return {
|
|
51
|
+
absoluteBaseUrl: option.appDirectory,
|
|
52
|
+
paths: alias,
|
|
53
|
+
isTsPath: false,
|
|
54
|
+
isTsProject
|
|
55
|
+
};
|
|
56
|
+
const tsconfig = (0, index_js_namespaceObject.readTsConfigByFile)(option.tsconfigPath);
|
|
57
|
+
const baseUrl = tsconfig?.compilerOptions?.baseUrl;
|
|
46
58
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
absoluteBaseUrl: baseUrl ? external_path_default().join(option.appDirectory, baseUrl) : option.appDirectory,
|
|
60
|
+
paths: {
|
|
61
|
+
...alias,
|
|
62
|
+
...tsconfig?.compilerOptions?.paths
|
|
63
|
+
},
|
|
64
|
+
isTsPath: true,
|
|
65
|
+
isTsProject
|
|
51
66
|
};
|
|
52
|
-
}
|
|
53
|
-
const tsconfig = (0, import_get.readTsConfigByFile)(option.tsconfigPath);
|
|
54
|
-
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
|
|
55
|
-
return {
|
|
56
|
-
absoluteBaseUrl: baseUrl ? import_path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
|
|
57
|
-
paths: {
|
|
58
|
-
...alias,
|
|
59
|
-
...tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
|
|
60
|
-
},
|
|
61
|
-
isTsPath: true,
|
|
62
|
-
isTsProject
|
|
63
|
-
};
|
|
64
67
|
};
|
|
65
|
-
const getUserAlias = (alias = {})
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
const getUserAlias = (alias = {})=>Object.keys(alias).reduce((o, k)=>{
|
|
69
|
+
if (Array.isArray(alias[k])) o[k] = alias[k];
|
|
70
|
+
return o;
|
|
71
|
+
}, {});
|
|
72
|
+
exports.getAliasConfig = __webpack_exports__.getAliasConfig;
|
|
73
|
+
exports.getUserAlias = __webpack_exports__.getUserAlias;
|
|
74
|
+
exports.mergeAlias = __webpack_exports__.mergeAlias;
|
|
75
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
76
|
+
"getAliasConfig",
|
|
77
|
+
"getUserAlias",
|
|
78
|
+
"mergeAlias"
|
|
79
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
80
|
+
Object.defineProperty(exports, '__esModule', {
|
|
81
|
+
value: true
|
|
76
82
|
});
|
|
@@ -1,51 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
applyOptionsChain: ()=>applyOptionsChain
|
|
22
28
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var import_logger = require("./logger");
|
|
29
|
+
const index_js_namespaceObject = require("./is/index.js");
|
|
30
|
+
const external_logger_js_namespaceObject = require("./logger.js");
|
|
26
31
|
function applyOptionsChain(defaults, options, utils, mergeFn = Object.assign) {
|
|
27
|
-
|
|
32
|
+
if (!options) return defaults;
|
|
33
|
+
if ((0, index_js_namespaceObject.isPlainObject)(options)) return mergeFn(defaults, options);
|
|
34
|
+
if ((0, index_js_namespaceObject.isFunction)(options)) {
|
|
35
|
+
const ret = options(defaults, utils);
|
|
36
|
+
if (ret) {
|
|
37
|
+
if (!(0, index_js_namespaceObject.isPlainObject)(ret)) external_logger_js_namespaceObject.logger.warn(`${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`);
|
|
38
|
+
return ret;
|
|
39
|
+
}
|
|
40
|
+
} else if (Array.isArray(options)) return options.reduce((memo, cur)=>applyOptionsChain(memo, cur, utils, mergeFn), defaults);
|
|
41
|
+
else throw new Error(`applyOptionsChain error:\ndefault options is: ${JSON.stringify(defaults)}`);
|
|
28
42
|
return defaults;
|
|
29
|
-
}
|
|
30
|
-
if ((0, import_is.isPlainObject)(options)) {
|
|
31
|
-
return mergeFn(defaults, options);
|
|
32
|
-
} else if ((0, import_is.isFunction)(options)) {
|
|
33
|
-
const ret = options(defaults, utils);
|
|
34
|
-
if (ret) {
|
|
35
|
-
if (!(0, import_is.isPlainObject)(ret)) {
|
|
36
|
-
import_logger.logger.warn(`${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`);
|
|
37
|
-
}
|
|
38
|
-
return ret;
|
|
39
|
-
}
|
|
40
|
-
} else if (Array.isArray(options)) {
|
|
41
|
-
return options.reduce((memo, cur) => applyOptionsChain(memo, cur, utils, mergeFn), defaults);
|
|
42
|
-
} else {
|
|
43
|
-
throw new Error(`applyOptionsChain error:
|
|
44
|
-
default options is: ${JSON.stringify(defaults)}`);
|
|
45
|
-
}
|
|
46
|
-
return defaults;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
exports.applyOptionsChain = __webpack_exports__.applyOptionsChain;
|
|
45
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
46
|
+
"applyOptionsChain"
|
|
47
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
48
|
+
Object.defineProperty(exports, '__esModule', {
|
|
49
|
+
value: true
|
|
51
50
|
});
|
package/dist/cjs/cli/babel.js
CHANGED
|
@@ -1,132 +1,113 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
applyUserBabelConfig: ()=>applyUserBabelConfig,
|
|
28
|
+
getBabelUtils: ()=>getBabelUtils
|
|
29
|
+
});
|
|
30
|
+
const external_path_namespaceObject = require("path");
|
|
31
|
+
const external_applyOptionsChain_js_namespaceObject = require("./applyOptionsChain.js");
|
|
32
|
+
const external_ensure_js_namespaceObject = require("./ensure.js");
|
|
33
|
+
const external_path_js_namespaceObject = require("./path.js");
|
|
34
|
+
const formatPath = (originPath)=>{
|
|
35
|
+
if ((0, external_path_namespaceObject.isAbsolute)(originPath)) return originPath.split(external_path_namespaceObject.sep).join('/');
|
|
36
|
+
return originPath;
|
|
9
37
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
38
|
+
const getPluginItemName = (item)=>{
|
|
39
|
+
if ('string' == typeof item) return formatPath(item);
|
|
40
|
+
if (Array.isArray(item) && 'string' == typeof item[0]) return formatPath(item[0]);
|
|
41
|
+
return null;
|
|
17
42
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
applyUserBabelConfig: () => applyUserBabelConfig,
|
|
22
|
-
getBabelUtils: () => getBabelUtils
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(babel_exports);
|
|
25
|
-
var import_path = require("path");
|
|
26
|
-
var import_applyOptionsChain = require("./applyOptionsChain");
|
|
27
|
-
var import_ensure = require("./ensure");
|
|
28
|
-
var import_path2 = require("./path");
|
|
29
|
-
const formatPath = (originPath) => {
|
|
30
|
-
if ((0, import_path.isAbsolute)(originPath)) {
|
|
31
|
-
return originPath.split(import_path.sep).join("/");
|
|
32
|
-
}
|
|
33
|
-
return originPath;
|
|
43
|
+
const addPlugins = (plugins, config)=>{
|
|
44
|
+
if (config.plugins) config.plugins.push(...plugins);
|
|
45
|
+
else config.plugins = plugins;
|
|
34
46
|
};
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (Array.isArray(item) && typeof item[0] === "string") {
|
|
40
|
-
return formatPath(item[0]);
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
47
|
+
const addPresets = (presets, config)=>{
|
|
48
|
+
if (config.presets) config.presets.push(...presets);
|
|
49
|
+
else config.presets = presets;
|
|
43
50
|
};
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
const removePlugins = (plugins, config)=>{
|
|
52
|
+
if (!config.plugins) return;
|
|
53
|
+
const removeList = (0, external_ensure_js_namespaceObject.ensureArray)(plugins);
|
|
54
|
+
config.plugins = config.plugins.filter((item)=>{
|
|
55
|
+
const name = getPluginItemName(item);
|
|
56
|
+
if (name) return !removeList.find((removeItem)=>name.includes(removeItem));
|
|
57
|
+
return true;
|
|
58
|
+
});
|
|
50
59
|
};
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
const removePresets = (presets, config)=>{
|
|
61
|
+
if (!config.presets) return;
|
|
62
|
+
const removeList = (0, external_ensure_js_namespaceObject.ensureArray)(presets);
|
|
63
|
+
config.presets = config.presets.filter((item)=>{
|
|
64
|
+
const name = getPluginItemName(item);
|
|
65
|
+
if (name) return !removeList.find((removeItem)=>name.includes(removeItem));
|
|
66
|
+
return true;
|
|
67
|
+
});
|
|
57
68
|
};
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const modifyPresetOptions = (presetName, options, presets = [])=>{
|
|
70
|
+
presets.forEach((preset, index)=>{
|
|
71
|
+
if (Array.isArray(preset)) {
|
|
72
|
+
if ('string' == typeof preset[0] && (0, external_path_js_namespaceObject.normalizeToPosixPath)(preset[0]).includes(presetName)) preset[1] = {
|
|
73
|
+
...preset[1] || {},
|
|
74
|
+
...options
|
|
75
|
+
};
|
|
76
|
+
} else if ('string' == typeof preset && (0, external_path_js_namespaceObject.normalizeToPosixPath)(preset).includes(presetName)) presets[index] = [
|
|
77
|
+
preset,
|
|
78
|
+
options
|
|
79
|
+
];
|
|
80
|
+
});
|
|
70
81
|
};
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
const getBabelUtils = (config)=>{
|
|
83
|
+
const noop = ()=>{};
|
|
84
|
+
return {
|
|
85
|
+
addPlugins: (plugins)=>addPlugins(plugins, config),
|
|
86
|
+
addPresets: (presets)=>addPresets(presets, config),
|
|
87
|
+
removePlugins: (plugins)=>removePlugins(plugins, config),
|
|
88
|
+
removePresets: (presets)=>removePresets(presets, config),
|
|
89
|
+
addIncludes: noop,
|
|
90
|
+
addExcludes: noop,
|
|
91
|
+
modifyPresetEnvOptions: (options)=>modifyPresetOptions('@babel/preset-env', options, config.presets || []),
|
|
92
|
+
modifyPresetReactOptions: (options)=>modifyPresetOptions('@babel/preset-react', options, config.presets || [])
|
|
93
|
+
};
|
|
83
94
|
};
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
...preset[1] || {},
|
|
90
|
-
...options
|
|
95
|
+
const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)=>{
|
|
96
|
+
if (userBabelConfig) {
|
|
97
|
+
const babelUtils = {
|
|
98
|
+
...getBabelUtils(defaultOptions),
|
|
99
|
+
...extraBabelUtils
|
|
91
100
|
};
|
|
92
|
-
|
|
93
|
-
} else if (typeof preset === "string" && (0, import_path2.normalizeToPosixPath)(preset).includes(presetName)) {
|
|
94
|
-
presets[index] = [
|
|
95
|
-
preset,
|
|
96
|
-
options
|
|
97
|
-
];
|
|
101
|
+
return (0, external_applyOptionsChain_js_namespaceObject.applyOptionsChain)(defaultOptions, userBabelConfig || {}, babelUtils);
|
|
98
102
|
}
|
|
99
|
-
|
|
100
|
-
};
|
|
101
|
-
const getBabelUtils = (config) => {
|
|
102
|
-
const noop = () => {
|
|
103
|
-
};
|
|
104
|
-
return {
|
|
105
|
-
addPlugins: (plugins) => addPlugins(plugins, config),
|
|
106
|
-
addPresets: (presets) => addPresets(presets, config),
|
|
107
|
-
removePlugins: (plugins) => removePlugins(plugins, config),
|
|
108
|
-
removePresets: (presets) => removePresets(presets, config),
|
|
109
|
-
// `addIncludes` and `addExcludes` are noop functions by default,
|
|
110
|
-
// It can be overridden by `extraBabelUtils`.
|
|
111
|
-
addIncludes: noop,
|
|
112
|
-
addExcludes: noop,
|
|
113
|
-
// Compat `presetEnvOptions` and `presetReactOptions` in Eden.
|
|
114
|
-
modifyPresetEnvOptions: (options) => modifyPresetOptions("@babel/preset-env", options, config.presets || []),
|
|
115
|
-
modifyPresetReactOptions: (options) => modifyPresetOptions("@babel/preset-react", options, config.presets || [])
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) => {
|
|
119
|
-
if (userBabelConfig) {
|
|
120
|
-
const babelUtils = {
|
|
121
|
-
...getBabelUtils(defaultOptions),
|
|
122
|
-
...extraBabelUtils
|
|
123
|
-
};
|
|
124
|
-
return (0, import_applyOptionsChain.applyOptionsChain)(defaultOptions, userBabelConfig || {}, babelUtils);
|
|
125
|
-
}
|
|
126
|
-
return defaultOptions;
|
|
103
|
+
return defaultOptions;
|
|
127
104
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
105
|
+
exports.applyUserBabelConfig = __webpack_exports__.applyUserBabelConfig;
|
|
106
|
+
exports.getBabelUtils = __webpack_exports__.getBabelUtils;
|
|
107
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
108
|
+
"applyUserBabelConfig",
|
|
109
|
+
"getBabelUtils"
|
|
110
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
111
|
+
Object.defineProperty(exports, '__esModule', {
|
|
112
|
+
value: true
|
|
132
113
|
});
|
package/dist/cjs/cli/commands.js
CHANGED
|
@@ -1,67 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
getCommand: ()=>getCommand,
|
|
28
|
+
getArgv: ()=>getArgv,
|
|
29
|
+
getFullArgv: ()=>getFullArgv,
|
|
30
|
+
deprecatedCommands: ()=>deprecatedCommands,
|
|
31
|
+
isDevCommand: ()=>isDevCommand
|
|
26
32
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return getFullArgv().slice(2);
|
|
35
|
-
};
|
|
36
|
-
const getCommand = () => {
|
|
37
|
-
const args = getArgv();
|
|
38
|
-
const command = args[0];
|
|
39
|
-
return command;
|
|
33
|
+
const external_logger_js_namespaceObject = require("./logger.js");
|
|
34
|
+
const getFullArgv = ()=>process.env.MODERN_ARGV?.split(' ') || process.argv;
|
|
35
|
+
const getArgv = ()=>getFullArgv().slice(2);
|
|
36
|
+
const getCommand = ()=>{
|
|
37
|
+
const args = getArgv();
|
|
38
|
+
const command = args[0];
|
|
39
|
+
return command;
|
|
40
40
|
};
|
|
41
|
-
const isDevCommand = ()
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const isDevCommand = ()=>{
|
|
42
|
+
const command = getCommand();
|
|
43
|
+
return 'dev' === command || 'start' === command;
|
|
44
44
|
};
|
|
45
|
-
const deprecatedCommands = (program)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
program.command("lint [...files]").allowUnknownOption().description("Deprecated").action(() => {
|
|
50
|
-
import_logger.logger.warn('The "modern lint" command is deprecated, please use "eslint" or "biome" instead.');
|
|
45
|
+
const deprecatedCommands = (program)=>{
|
|
46
|
+
const lintCommand = program.commandsMap?.get('lint');
|
|
47
|
+
if (!lintCommand) program.command('lint [...files]').allowUnknownOption().description('Deprecated').action(()=>{
|
|
48
|
+
external_logger_js_namespaceObject.logger.warn('The "modern lint" command is deprecated, please use "eslint" or "biome" instead.');
|
|
51
49
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
program.command("pre-commit").description("Deprecated").action(() => {
|
|
56
|
-
import_logger.logger.warn('The "modern pre-commit" command is deprecated, please use "lint-staged" instead.');
|
|
50
|
+
const preCommitCommand = program.commandsMap?.get('pre-commit');
|
|
51
|
+
if (!preCommitCommand) program.command('pre-commit').description('Deprecated').action(()=>{
|
|
52
|
+
external_logger_js_namespaceObject.logger.warn('The "modern pre-commit" command is deprecated, please use "lint-staged" instead.');
|
|
57
53
|
});
|
|
58
|
-
}
|
|
59
54
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
exports.deprecatedCommands = __webpack_exports__.deprecatedCommands;
|
|
56
|
+
exports.getArgv = __webpack_exports__.getArgv;
|
|
57
|
+
exports.getCommand = __webpack_exports__.getCommand;
|
|
58
|
+
exports.getFullArgv = __webpack_exports__.getFullArgv;
|
|
59
|
+
exports.isDevCommand = __webpack_exports__.isDevCommand;
|
|
60
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
61
|
+
"deprecatedCommands",
|
|
62
|
+
"getArgv",
|
|
63
|
+
"getCommand",
|
|
64
|
+
"getFullArgv",
|
|
65
|
+
"isDevCommand"
|
|
66
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
67
|
+
Object.defineProperty(exports, '__esModule', {
|
|
68
|
+
value: true
|
|
67
69
|
});
|