@modern-js/utils 2.35.1 → 2.37.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli/alias.js +45 -46
- package/dist/cjs/cli/applyOptionsChain.js +30 -13
- package/dist/cjs/cli/babel.js +36 -26
- package/dist/cjs/cli/commands.js +29 -21
- package/dist/cjs/cli/common.js +29 -20
- package/dist/cjs/cli/config.js +24 -7
- package/dist/cjs/cli/constants/chainId.js +24 -7
- package/dist/cjs/cli/constants/index.js +84 -113
- package/dist/cjs/cli/ensure.js +37 -18
- package/dist/cjs/cli/fs.js +29 -19
- package/dist/cjs/cli/get/config.js +26 -9
- package/dist/cjs/cli/get/data.js +67 -54
- package/dist/cjs/cli/get/index.js +46 -25
- package/dist/cjs/cli/index.js +58 -23
- package/dist/cjs/cli/is/config.js +37 -31
- package/dist/cjs/cli/is/env.js +32 -29
- package/dist/cjs/cli/is/index.js +26 -8
- package/dist/cjs/cli/is/project.js +67 -53
- package/dist/cjs/cli/is/type.js +39 -36
- package/dist/cjs/cli/logger.js +25 -130
- package/dist/cjs/cli/monorepo.js +58 -58
- package/dist/cjs/cli/package.js +34 -26
- package/dist/cjs/cli/path.js +64 -54
- package/dist/cjs/cli/port.js +39 -13
- package/dist/cjs/cli/prettyInstructions.js +48 -29
- package/dist/cjs/cli/require.js +35 -29
- package/dist/cjs/cli/runtimeExports.js +42 -16
- package/dist/cjs/cli/watch.js +41 -22
- package/dist/cjs/compiled.js +127 -138
- package/dist/cjs/import.js +25 -15
- package/dist/cjs/index.js +24 -6
- package/dist/cjs/universal/constants.js +32 -21
- package/dist/cjs/universal/formatWebpack.js +25 -15
- package/dist/cjs/universal/pluginDagSort.js +25 -8
- package/dist/esm/cli/alias.js +10 -22
- package/dist/esm/cli/applyOptionsChain.js +4 -1
- package/dist/esm/cli/babel.js +6 -2
- package/dist/esm/cli/commands.js +10 -4
- package/dist/esm/cli/common.js +8 -3
- package/dist/esm/cli/config.js +4 -1
- package/dist/esm/cli/constants/chainId.js +4 -1
- package/dist/esm/cli/constants/index.js +62 -39
- package/dist/esm/cli/ensure.js +6 -2
- package/dist/esm/cli/fs.js +6 -2
- package/dist/esm/cli/get/config.js +4 -1
- package/dist/esm/cli/get/data.js +18 -8
- package/dist/esm/cli/get/index.js +6 -2
- package/dist/esm/cli/is/config.js +14 -6
- package/dist/esm/cli/is/env.js +12 -8
- package/dist/esm/cli/is/index.js +0 -1
- package/dist/esm/cli/is/project.js +17 -8
- package/dist/esm/cli/is/type.js +20 -9
- package/dist/esm/cli/logger.js +4 -128
- package/dist/esm/cli/monorepo.js +14 -16
- package/dist/esm/cli/package.js +10 -4
- package/dist/esm/cli/path.js +24 -11
- package/dist/esm/cli/port.js +5 -2
- package/dist/esm/cli/prettyInstructions.js +6 -2
- package/dist/esm/cli/require.js +14 -6
- package/dist/esm/cli/runtimeExports.js +6 -3
- package/dist/esm/cli/watch.js +10 -6
- package/dist/esm/compiled.js +65 -31
- package/dist/esm/import.js +6 -3
- package/dist/esm/universal/constants.js +12 -4
- package/dist/esm/universal/formatWebpack.js +5 -2
- package/dist/esm/universal/pluginDagSort.js +5 -2
- package/dist/esm-node/cli/alias.js +8 -19
- package/dist/esm-node/cli/applyOptionsChain.js +4 -1
- package/dist/esm-node/cli/babel.js +6 -2
- package/dist/esm-node/cli/commands.js +10 -4
- package/dist/esm-node/cli/common.js +8 -3
- package/dist/esm-node/cli/config.js +4 -1
- package/dist/esm-node/cli/constants/chainId.js +4 -1
- package/dist/esm-node/cli/constants/index.js +62 -39
- package/dist/esm-node/cli/ensure.js +6 -2
- package/dist/esm-node/cli/fs.js +6 -2
- package/dist/esm-node/cli/get/config.js +4 -1
- package/dist/esm-node/cli/get/data.js +18 -8
- package/dist/esm-node/cli/get/index.js +6 -2
- package/dist/esm-node/cli/is/config.js +14 -6
- package/dist/esm-node/cli/is/env.js +12 -6
- package/dist/esm-node/cli/is/index.js +0 -1
- package/dist/esm-node/cli/is/project.js +16 -7
- package/dist/esm-node/cli/is/type.js +20 -9
- package/dist/esm-node/cli/logger.js +4 -113
- package/dist/esm-node/cli/monorepo.js +14 -18
- package/dist/esm-node/cli/package.js +10 -4
- package/dist/esm-node/cli/path.js +24 -11
- package/dist/esm-node/cli/port.js +4 -1
- package/dist/esm-node/cli/prettyInstructions.js +6 -2
- package/dist/esm-node/cli/require.js +14 -6
- package/dist/esm-node/cli/runtimeExports.js +4 -1
- package/dist/esm-node/cli/watch.js +6 -2
- package/dist/esm-node/compiled.js +65 -31
- package/dist/esm-node/import.js +5 -2
- package/dist/esm-node/universal/constants.js +12 -4
- package/dist/esm-node/universal/formatWebpack.js +5 -2
- package/dist/esm-node/universal/pluginDagSort.js +5 -2
- package/dist/types/cli/alias.d.ts +0 -5
- package/dist/types/cli/constants/index.d.ts +0 -14
- package/dist/types/cli/is/env.d.ts +1 -2
- package/dist/types/cli/is/index.d.ts +0 -1
- package/dist/types/cli/logger.d.ts +1 -69
- package/dist/types/cli/monorepo.d.ts +0 -1
- package/dist/types/universal/constants.d.ts +4 -0
- package/package.json +6 -13
- package/dist/cjs/cli/is/platform.js +0 -21
- package/dist/compiled/gradient-string/index.d.ts +0 -1
- package/dist/compiled/gradient-string/index.js +0 -1
- package/dist/compiled/gradient-string/license +0 -21
- package/dist/compiled/gradient-string/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/index.js +0 -7
- package/dist/compiled/webpack-dev-middleware/license +0 -20
- package/dist/compiled/webpack-dev-middleware/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/types/index.d.ts +0 -262
- package/dist/esm/cli/is/platform.js +0 -6
- package/dist/esm-node/cli/is/platform.js +0 -2
- package/dist/types/cli/is/platform.d.ts +0 -2
package/dist/esm/cli/require.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
2
2
|
import { findExists } from "./fs";
|
3
|
-
|
3
|
+
var compatRequire = function(filePath) {
|
4
4
|
var interop = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
5
5
|
var mod = require(filePath);
|
6
6
|
var rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
|
7
7
|
return rtnESMDefault ? mod.default : mod;
|
8
8
|
};
|
9
|
-
|
10
|
-
|
9
|
+
var dynamicImport = new Function("modulePath", "return import(modulePath)");
|
10
|
+
var requireExistModule = function(filename, opt) {
|
11
11
|
var final = _object_spread({
|
12
12
|
extensions: [
|
13
13
|
".ts",
|
@@ -23,12 +23,12 @@ export var requireExistModule = function(filename, opt) {
|
|
23
23
|
}
|
24
24
|
return compatRequire(exist, final.interop);
|
25
25
|
};
|
26
|
-
|
26
|
+
var cleanRequireCache = function(filelist) {
|
27
27
|
filelist.forEach(function(filepath) {
|
28
28
|
delete require.cache[filepath];
|
29
29
|
});
|
30
30
|
};
|
31
|
-
|
31
|
+
function deleteRequireCache(path) {
|
32
32
|
if (require.cache[path]) {
|
33
33
|
delete require.cache[path];
|
34
34
|
}
|
@@ -38,7 +38,7 @@ export function deleteRequireCache(path) {
|
|
38
38
|
});
|
39
39
|
}
|
40
40
|
}
|
41
|
-
|
41
|
+
var tryResolve = function(name, resolvePath) {
|
42
42
|
var filePath = "";
|
43
43
|
try {
|
44
44
|
filePath = require.resolve(name, {
|
@@ -55,3 +55,11 @@ export var tryResolve = function(name, resolvePath) {
|
|
55
55
|
}
|
56
56
|
return filePath;
|
57
57
|
};
|
58
|
+
export {
|
59
|
+
cleanRequireCache,
|
60
|
+
compatRequire,
|
61
|
+
deleteRequireCache,
|
62
|
+
dynamicImport,
|
63
|
+
requireExistModule,
|
64
|
+
tryResolve
|
65
|
+
};
|
@@ -18,7 +18,7 @@ var memo = function(fn) {
|
|
18
18
|
return res;
|
19
19
|
};
|
20
20
|
};
|
21
|
-
|
21
|
+
var createRuntimeExportsUtils = memo(function() {
|
22
22
|
var pwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", namespace = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "index";
|
23
23
|
var entryExportFile = path.join(pwd, ".runtime-exports/".concat(namespace, ".js"));
|
24
24
|
var addExport = function(statement) {
|
@@ -35,7 +35,10 @@ export var createRuntimeExportsUtils = memo(function() {
|
|
35
35
|
return entryExportFile;
|
36
36
|
};
|
37
37
|
return {
|
38
|
-
addExport
|
39
|
-
getPath
|
38
|
+
addExport,
|
39
|
+
getPath
|
40
40
|
};
|
41
41
|
});
|
42
|
+
export {
|
43
|
+
createRuntimeExportsUtils
|
44
|
+
};
|
package/dist/esm/cli/watch.js
CHANGED
@@ -2,16 +2,16 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
3
|
import path from "path";
|
4
4
|
import { chokidar } from "../compiled";
|
5
|
-
|
5
|
+
var WatchChangeType = {
|
6
6
|
ADD: "add",
|
7
7
|
UNLINK: "unlink",
|
8
8
|
CHANGE: "change"
|
9
9
|
};
|
10
|
-
|
10
|
+
var watch = function(watchDir, runTask) {
|
11
11
|
var ignored = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
12
12
|
var ready = false;
|
13
13
|
var watcher = chokidar.watch(watchDir, {
|
14
|
-
ignored
|
14
|
+
ignored
|
15
15
|
});
|
16
16
|
watcher.on("ready", function() {
|
17
17
|
return ready = true;
|
@@ -26,7 +26,7 @@ export var watch = function(watchDir, runTask) {
|
|
26
26
|
return [
|
27
27
|
4,
|
28
28
|
runTask({
|
29
|
-
changedFilePath
|
29
|
+
changedFilePath,
|
30
30
|
changeType: WatchChangeType.CHANGE
|
31
31
|
})
|
32
32
|
];
|
@@ -57,7 +57,7 @@ export var watch = function(watchDir, runTask) {
|
|
57
57
|
return [
|
58
58
|
4,
|
59
59
|
runTask({
|
60
|
-
changedFilePath
|
60
|
+
changedFilePath,
|
61
61
|
changeType: WatchChangeType.ADD
|
62
62
|
})
|
63
63
|
];
|
@@ -85,7 +85,7 @@ export var watch = function(watchDir, runTask) {
|
|
85
85
|
return [
|
86
86
|
4,
|
87
87
|
runTask({
|
88
|
-
changedFilePath
|
88
|
+
changedFilePath,
|
89
89
|
changeType: WatchChangeType.UNLINK
|
90
90
|
})
|
91
91
|
];
|
@@ -106,3 +106,7 @@ export var watch = function(watchDir, runTask) {
|
|
106
106
|
});
|
107
107
|
return watcher;
|
108
108
|
};
|
109
|
+
export {
|
110
|
+
WatchChangeType,
|
111
|
+
watch
|
112
|
+
};
|
package/dist/esm/compiled.js
CHANGED
@@ -1,32 +1,66 @@
|
|
1
1
|
import { Import } from "./import";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
2
|
+
import { default as default2 } from "../compiled/fs-extra";
|
3
|
+
import { default as default3 } from "../compiled/ora";
|
4
|
+
import { default as default4 } from "../compiled/glob";
|
5
|
+
import { default as default5 } from "../compiled/js-yaml";
|
6
|
+
import { default as default6 } from "../compiled/chalk";
|
7
|
+
import { default as default7 } from "../compiled/debug";
|
8
|
+
import { default as default8 } from "../compiled/slash";
|
9
|
+
import { default as default9 } from "../compiled/execa";
|
10
|
+
import { default as default10 } from "../compiled/json5";
|
11
|
+
import { default as default11 } from "../compiled/upath";
|
12
|
+
import { default as default12 } from "../compiled/pkg-up";
|
13
|
+
import { nanoid } from "../compiled/nanoid";
|
14
|
+
import { default as default13 } from "../compiled/semver";
|
15
|
+
import { default as default14 } from "../compiled/dotenv";
|
16
|
+
import { default as default15 } from "../compiled/lodash";
|
17
|
+
import { default as default16 } from "../compiled/globby";
|
18
|
+
import { default as default17 } from "../compiled/address";
|
19
|
+
import { default as default18 } from "../compiled/signale";
|
20
|
+
import { default as default19 } from "../compiled/url-join";
|
21
|
+
import { default as default20 } from "../compiled/minimist";
|
22
|
+
import { default as default21 } from "../compiled/fast-glob";
|
23
|
+
import { default as default22 } from "../compiled/filesize";
|
24
|
+
import { default as default23 } from "../compiled/gzip-size";
|
25
|
+
import { default as default24 } from "../compiled/strip-ansi";
|
26
|
+
import { default as default25 } from "../compiled/dotenv-expand";
|
27
|
+
import { default as default26 } from "../compiled/browserslist";
|
28
|
+
import { program, Command } from "../compiled/commander";
|
29
|
+
import { Signale } from "../compiled/signale";
|
30
|
+
var mime = Import.lazy("../compiled/mime-types", require);
|
31
|
+
var chokidar = Import.lazy("../compiled/chokidar", require);
|
32
|
+
var inquirer = Import.lazy("../compiled/inquirer", require);
|
33
|
+
export {
|
34
|
+
Command,
|
35
|
+
Signale,
|
36
|
+
default17 as address,
|
37
|
+
default26 as browserslist,
|
38
|
+
default6 as chalk,
|
39
|
+
chokidar,
|
40
|
+
default7 as debug,
|
41
|
+
default14 as dotenv,
|
42
|
+
default25 as dotenvExpand,
|
43
|
+
default9 as execa,
|
44
|
+
default21 as fastGlob,
|
45
|
+
default22 as filesize,
|
46
|
+
default2 as fs,
|
47
|
+
default4 as glob,
|
48
|
+
default16 as globby,
|
49
|
+
default23 as gzipSize,
|
50
|
+
inquirer,
|
51
|
+
default10 as json5,
|
52
|
+
default15 as lodash,
|
53
|
+
mime,
|
54
|
+
default20 as minimist,
|
55
|
+
nanoid,
|
56
|
+
default3 as ora,
|
57
|
+
default12 as pkgUp,
|
58
|
+
program,
|
59
|
+
default13 as semver,
|
60
|
+
default18 as signale,
|
61
|
+
default8 as slash,
|
62
|
+
default24 as stripAnsi,
|
63
|
+
default11 as upath,
|
64
|
+
default19 as urlJoin,
|
65
|
+
default5 as yaml
|
66
|
+
};
|
package/dist/esm/import.js
CHANGED
@@ -2,7 +2,10 @@ var lazy = function(moduleName, requireFn) {
|
|
2
2
|
var importLazyLocal = require("../compiled/import-lazy")(requireFn);
|
3
3
|
return importLazyLocal(moduleName);
|
4
4
|
};
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
var Import = {
|
6
|
+
lazy
|
7
|
+
};
|
8
|
+
export {
|
9
|
+
Import,
|
10
|
+
lazy as lazyImport
|
8
11
|
};
|
@@ -1,4 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
var ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
|
2
|
+
var ROUTE_MODULES = "_routeModules";
|
3
|
+
var HMR_SOCK_PATH = "/webpack-hmr";
|
4
|
+
var HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
|
5
|
+
var LOADER_REPORTER_NAME = "server-loader";
|
6
|
+
export {
|
7
|
+
HMR_SOCK_PATH,
|
8
|
+
HTML_CHUNKSMAP_SEPARATOR,
|
9
|
+
LOADER_REPORTER_NAME,
|
10
|
+
ROUTE_MANIFEST,
|
11
|
+
ROUTE_MODULES
|
12
|
+
};
|
@@ -50,7 +50,7 @@ var defaultColor = {
|
|
50
50
|
yellow: noop,
|
51
51
|
underline: noop
|
52
52
|
};
|
53
|
-
|
53
|
+
function addErrorTips(errors) {
|
54
54
|
var color = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultColor;
|
55
55
|
var errorHelpers = [
|
56
56
|
{
|
@@ -88,4 +88,7 @@ function formatWebpackMessages(json) {
|
|
88
88
|
result.errors = addErrorTips(result.errors, color);
|
89
89
|
return result;
|
90
90
|
}
|
91
|
-
export {
|
91
|
+
export {
|
92
|
+
addErrorTips,
|
93
|
+
formatWebpackMessages
|
94
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
var pluginDagSort = function(plugins) {
|
2
2
|
var _loop = function() {
|
3
3
|
var zep = zeroEndPoints.shift();
|
4
4
|
sortedPoint.push(getPluginByAny(zep));
|
@@ -67,7 +67,10 @@ export var pluginDagSort = function(plugins) {
|
|
67
67
|
restInRingPoints[l[0]] = true;
|
68
68
|
restInRingPoints[l[1]] = true;
|
69
69
|
});
|
70
|
-
throw new Error("plugins
|
70
|
+
throw new Error("plugins dependencies has loop: ".concat(Object.keys(restInRingPoints).join(",")));
|
71
71
|
}
|
72
72
|
return sortedPoint;
|
73
73
|
};
|
74
|
+
export {
|
75
|
+
pluginDagSort
|
76
|
+
};
|
@@ -1,25 +1,9 @@
|
|
1
1
|
import fs from "fs";
|
2
2
|
import path from "path";
|
3
|
-
import { chalk } from "../compiled";
|
4
3
|
import { readTsConfigByFile } from "./get";
|
5
4
|
import { applyOptionsChain } from "./applyOptionsChain";
|
6
|
-
|
7
|
-
|
8
|
-
if (!alias) {
|
9
|
-
return null;
|
10
|
-
}
|
11
|
-
const isTsProject = fs.existsSync(tsconfigPath);
|
12
|
-
if (!isTsProject) {
|
13
|
-
return null;
|
14
|
-
}
|
15
|
-
const userAlias = getUserAlias(alias);
|
16
|
-
if (Object.keys(userAlias).length > 0) {
|
17
|
-
return chalk.red('Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript');
|
18
|
-
}
|
19
|
-
return null;
|
20
|
-
};
|
21
|
-
export const mergeAlias = (alias) => applyOptionsChain({}, alias);
|
22
|
-
export const getAliasConfig = (aliasOption, option) => {
|
5
|
+
const mergeAlias = (alias) => applyOptionsChain({}, alias);
|
6
|
+
const getAliasConfig = (aliasOption, option) => {
|
23
7
|
var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
|
24
8
|
const isTsProject = fs.existsSync(option.tsconfigPath);
|
25
9
|
const alias = mergeAlias(aliasOption);
|
@@ -43,9 +27,14 @@ export const getAliasConfig = (aliasOption, option) => {
|
|
43
27
|
isTsProject
|
44
28
|
};
|
45
29
|
};
|
46
|
-
|
30
|
+
const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
|
47
31
|
if (Array.isArray(alias[k])) {
|
48
32
|
o[k] = alias[k];
|
49
33
|
}
|
50
34
|
return o;
|
51
35
|
}, {});
|
36
|
+
export {
|
37
|
+
getAliasConfig,
|
38
|
+
getUserAlias,
|
39
|
+
mergeAlias
|
40
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { isFunction, isPlainObject } from "./is";
|
2
2
|
import { logger } from "./logger";
|
3
|
-
|
3
|
+
function applyOptionsChain(defaults, options, utils, mergeFn = Object.assign) {
|
4
4
|
if (!options) {
|
5
5
|
return defaults;
|
6
6
|
}
|
@@ -22,3 +22,6 @@ default options is: ${JSON.stringify(defaults)}`);
|
|
22
22
|
}
|
23
23
|
return defaults;
|
24
24
|
}
|
25
|
+
export {
|
26
|
+
applyOptionsChain
|
27
|
+
};
|
@@ -74,7 +74,7 @@ const modifyPresetOptions = (presetName, options, presets = []) => {
|
|
74
74
|
}
|
75
75
|
});
|
76
76
|
};
|
77
|
-
|
77
|
+
const getBabelUtils = (config) => {
|
78
78
|
const noop = () => {
|
79
79
|
};
|
80
80
|
return {
|
@@ -91,7 +91,7 @@ export const getBabelUtils = (config) => {
|
|
91
91
|
modifyPresetReactOptions: (options) => modifyPresetOptions("@babel/preset-react", options, config.presets || [])
|
92
92
|
};
|
93
93
|
};
|
94
|
-
|
94
|
+
const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) => {
|
95
95
|
if (userBabelConfig) {
|
96
96
|
const babelUtils = {
|
97
97
|
...getBabelUtils(defaultOptions),
|
@@ -101,3 +101,7 @@ export const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabel
|
|
101
101
|
}
|
102
102
|
return defaultOptions;
|
103
103
|
};
|
104
|
+
export {
|
105
|
+
applyUserBabelConfig,
|
106
|
+
getBabelUtils
|
107
|
+
};
|
@@ -1,16 +1,22 @@
|
|
1
|
-
|
1
|
+
const getFullArgv = () => {
|
2
2
|
var _process_env_MODERN_ARGV;
|
3
3
|
return ((_process_env_MODERN_ARGV = process.env.MODERN_ARGV) === null || _process_env_MODERN_ARGV === void 0 ? void 0 : _process_env_MODERN_ARGV.split(" ")) || process.argv;
|
4
4
|
};
|
5
|
-
|
5
|
+
const getArgv = () => {
|
6
6
|
return getFullArgv().slice(2);
|
7
7
|
};
|
8
|
-
|
8
|
+
const getCommand = () => {
|
9
9
|
const args = getArgv();
|
10
10
|
const command = args[0];
|
11
11
|
return command;
|
12
12
|
};
|
13
|
-
|
13
|
+
const isDevCommand = () => {
|
14
14
|
const command = getCommand();
|
15
15
|
return command === "dev" || command === "start";
|
16
16
|
};
|
17
|
+
export {
|
18
|
+
getArgv,
|
19
|
+
getCommand,
|
20
|
+
getFullArgv,
|
21
|
+
isDevCommand
|
22
|
+
};
|
@@ -1,10 +1,15 @@
|
|
1
1
|
import { debug } from "../../compiled/debug";
|
2
|
-
|
3
|
-
|
2
|
+
const createDebugger = (scope) => debug(`modern-js:${scope}`);
|
3
|
+
const clearConsole = () => {
|
4
4
|
if (process.stdout.isTTY && !process.env.DEBUG) {
|
5
5
|
process.stdout.write("\x1B[H\x1B[2J");
|
6
6
|
}
|
7
7
|
};
|
8
|
-
|
8
|
+
const wait = (time = 0) => new Promise((resolve) => {
|
9
9
|
setTimeout(resolve, time);
|
10
10
|
});
|
11
|
+
export {
|
12
|
+
clearConsole,
|
13
|
+
createDebugger,
|
14
|
+
wait
|
15
|
+
};
|
@@ -1,26 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
const ROUTE_SPEC_FILE = "route.json";
|
2
|
+
const NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
|
3
|
+
const MAIN_ENTRY_NAME = "main";
|
4
|
+
const SERVER_BUNDLE_DIRECTORY = "bundles";
|
5
|
+
const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
|
6
|
+
const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
|
7
|
+
const SERVER_RENDER_FUNCTION_NAME = "serverRender";
|
8
|
+
const LOADABLE_STATS_FILE = "loadable-stats.json";
|
9
|
+
const API_DIR = "api";
|
10
|
+
const SERVER_DIR = "server";
|
11
|
+
const SHARED_DIR = "shared";
|
12
|
+
const CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
|
13
|
+
const CONFIG_FILE_EXTENSIONS = [
|
14
14
|
".js",
|
15
15
|
".ts",
|
16
16
|
".mjs"
|
17
17
|
];
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
const OUTPUT_CONFIG_FILE = "modern.config.json";
|
19
|
+
const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
|
20
|
+
const ROUTE_MANIFEST_FILE = "routes-manifest.json";
|
21
|
+
const LOADER_ROUTES_DIR = `loader-routes`;
|
22
|
+
const DEFAULT_DEV_HOST = "0.0.0.0";
|
23
|
+
const INTERNAL_APP_TOOLS_PLUGINS = {
|
24
24
|
"@modern-js/app-tools": "@modern-js/app-tools/cli",
|
25
25
|
"@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
|
26
26
|
"@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
|
@@ -36,10 +36,10 @@ export const INTERNAL_APP_TOOLS_PLUGINS = {
|
|
36
36
|
// legacy router (inner react-router-dom v5)
|
37
37
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
38
38
|
};
|
39
|
-
|
39
|
+
const INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = {
|
40
40
|
"@modern-js/runtime": "@modern-js/runtime/cli"
|
41
41
|
};
|
42
|
-
|
42
|
+
const INTERNAL_MODULE_TOOLS_PLUGINS = {
|
43
43
|
"@modern-js/module-tools": "@modern-js/module-tools",
|
44
44
|
"@modern-js/runtime": "@modern-js/runtime/cli",
|
45
45
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
|
@@ -48,16 +48,16 @@ export const INTERNAL_MODULE_TOOLS_PLUGINS = {
|
|
48
48
|
// legacy router (inner react-router-dom v5)
|
49
49
|
"@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
|
50
50
|
};
|
51
|
-
|
51
|
+
const INTERNAL_MONOREPO_TOOLS_PLUGINS = {
|
52
52
|
"@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
|
53
53
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
|
54
54
|
};
|
55
|
-
|
55
|
+
const INTERNAL_DOC_TOOLS_PLUGINS = {
|
56
56
|
"@modern-js/doc-tools": "@modern-js/doc-tools",
|
57
57
|
"@modern-js/runtime": "@modern-js/runtime/cli",
|
58
58
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
|
59
59
|
};
|
60
|
-
|
60
|
+
const INTERNAL_CLI_PLUGINS = {
|
61
61
|
"@modern-js/app-tools": "@modern-js/app-tools/cli",
|
62
62
|
"@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
|
63
63
|
"@modern-js/module-tools": "@modern-js/module-tools",
|
@@ -78,25 +78,48 @@ export const INTERNAL_CLI_PLUGINS = {
|
|
78
78
|
// legacy router (inner react-router-dom v5)
|
79
79
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
80
80
|
};
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
const SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
|
82
|
+
const SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
|
83
|
+
const SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
|
84
|
+
const SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
|
85
|
+
const SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
|
86
|
+
const INTERNAL_SERVER_PLUGINS = {
|
87
87
|
[SERVER_PLUGIN_BFF]: "@modern-js/plugin-bff/server",
|
88
88
|
[SERVER_PLUGIN_EXPRESS]: "@modern-js/plugin-express/server",
|
89
89
|
[SERVER_PLUGIN_KOA]: "@modern-js/plugin-koa/server",
|
90
90
|
[SERVER_PLUGIN_SERVER]: "@modern-js/plugin-server/server",
|
91
91
|
[SERVER_PLUGIN_POLYFILL]: "@modern-js/plugin-polyfill/server"
|
92
92
|
};
|
93
|
-
export const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
94
|
-
allowNamespaces: true,
|
95
|
-
allExtensions: true,
|
96
|
-
allowDeclareFields: true,
|
97
|
-
// aligns Babel's behavior with TypeScript's default behavior.
|
98
|
-
// https://babeljs.io/docs/en/babel-preset-typescript#optimizeconstenums
|
99
|
-
optimizeConstEnums: true,
|
100
|
-
isTSX: true
|
101
|
-
};
|
102
93
|
export * from "./chainId";
|
94
|
+
export {
|
95
|
+
API_DIR,
|
96
|
+
CONFIG_CACHE_DIR,
|
97
|
+
CONFIG_FILE_EXTENSIONS,
|
98
|
+
DEFAULT_DEV_HOST,
|
99
|
+
DEFAULT_SERVER_CONFIG,
|
100
|
+
ENTRY_NAME_PATTERN,
|
101
|
+
INTERNAL_APP_TOOLS_PLUGINS,
|
102
|
+
INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
103
|
+
INTERNAL_CLI_PLUGINS,
|
104
|
+
INTERNAL_DOC_TOOLS_PLUGINS,
|
105
|
+
INTERNAL_MODULE_TOOLS_PLUGINS,
|
106
|
+
INTERNAL_MONOREPO_TOOLS_PLUGINS,
|
107
|
+
INTERNAL_SERVER_PLUGINS,
|
108
|
+
LOADABLE_STATS_FILE,
|
109
|
+
LOADER_ROUTES_DIR,
|
110
|
+
MAIN_ENTRY_NAME,
|
111
|
+
NESTED_ROUTE_SPEC_FILE,
|
112
|
+
OUTPUT_CONFIG_FILE,
|
113
|
+
ROUTE_MANIFEST_FILE,
|
114
|
+
ROUTE_SPEC_FILE,
|
115
|
+
SERVER_BUNDLE_DIRECTORY,
|
116
|
+
SERVER_DIR,
|
117
|
+
SERVER_PLUGIN_BFF,
|
118
|
+
SERVER_PLUGIN_EXPRESS,
|
119
|
+
SERVER_PLUGIN_KOA,
|
120
|
+
SERVER_PLUGIN_POLYFILL,
|
121
|
+
SERVER_PLUGIN_SERVER,
|
122
|
+
SERVER_RENDER_FUNCTION_NAME,
|
123
|
+
SERVER_WORKER_BUNDLE_DIRECTORY,
|
124
|
+
SHARED_DIR
|
125
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import path from "path";
|
2
|
-
|
3
|
-
|
2
|
+
const ensureAbsolutePath = (base, filePath) => path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath);
|
3
|
+
const ensureArray = (params) => {
|
4
4
|
if (Array.isArray(params)) {
|
5
5
|
return params;
|
6
6
|
}
|
@@ -8,3 +8,7 @@ export const ensureArray = (params) => {
|
|
8
8
|
params
|
9
9
|
];
|
10
10
|
};
|
11
|
+
export {
|
12
|
+
ensureAbsolutePath,
|
13
|
+
ensureArray
|
14
|
+
};
|
package/dist/esm-node/cli/fs.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { fs } from "../compiled";
|
2
|
-
|
2
|
+
const findExists = (files) => {
|
3
3
|
for (const file of files) {
|
4
4
|
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
|
5
5
|
return file;
|
@@ -7,8 +7,12 @@ export const findExists = (files) => {
|
|
7
7
|
}
|
8
8
|
return false;
|
9
9
|
};
|
10
|
-
|
10
|
+
const emptyDir = async (dir) => {
|
11
11
|
if (await fs.pathExists(dir)) {
|
12
12
|
await fs.emptyDir(dir);
|
13
13
|
}
|
14
14
|
};
|
15
|
+
export {
|
16
|
+
emptyDir,
|
17
|
+
findExists
|
18
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { isPlainObject } from "../is";
|
2
|
-
|
2
|
+
const getEntryOptions = (name, isMainEntry, baseOptions, optionsByEntries, packageName) => {
|
3
3
|
if (optionsByEntries) {
|
4
4
|
let optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
|
5
5
|
if (optionsByEntry === void 0 && isMainEntry && packageName) {
|
@@ -14,3 +14,6 @@ export const getEntryOptions = (name, isMainEntry, baseOptions, optionsByEntries
|
|
14
14
|
}
|
15
15
|
};
|
16
16
|
const getOptionsByEntryName = (name, optionsByEntries) => optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : void 0;
|
17
|
+
export {
|
18
|
+
getEntryOptions
|
19
|
+
};
|