@modern-js/utils 2.35.0 → 2.36.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli/alias.js +48 -49
- 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 +27 -10
- package/dist/cjs/cli/constants/index.js +86 -104
- 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 +45 -41
- 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 -125
- 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 +50 -34
- package/dist/cjs/cli/require.js +36 -31
- 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 +29 -21
- package/dist/cjs/universal/formatWebpack.js +28 -18
- package/dist/cjs/universal/pluginDagSort.js +25 -8
- package/dist/esm/cli/alias.js +13 -25
- 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 +7 -4
- package/dist/esm/cli/constants/index.js +64 -31
- 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 +23 -17
- 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 -123
- 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 +6 -3
- package/dist/esm/cli/prettyInstructions.js +8 -5
- package/dist/esm/cli/require.js +15 -8
- 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 +10 -4
- package/dist/esm/universal/formatWebpack.js +8 -5
- package/dist/esm/universal/pluginDagSort.js +5 -2
- package/dist/esm-node/cli/alias.js +11 -22
- 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 +7 -4
- package/dist/esm-node/cli/constants/index.js +64 -31
- 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 +23 -17
- 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 -108
- 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 +5 -2
- package/dist/esm-node/cli/prettyInstructions.js +8 -7
- package/dist/esm-node/cli/require.js +15 -8
- 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 +10 -4
- package/dist/esm-node/universal/formatWebpack.js +8 -5
- package/dist/esm-node/universal/pluginDagSort.js +5 -2
- package/dist/types/cli/alias.d.ts +0 -5
- package/dist/types/cli/constants/chainId.d.ts +2 -2
- 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 -64
- package/dist/types/cli/monorepo.d.ts +0 -1
- package/package.json +6 -84
- package/dist/cjs/cli/is/platform.js +0 -21
- package/dist/cjs/runtime/nestedRoutes.js +0 -149
- package/dist/cjs/runtime/remixRouter.js +0 -6
- package/dist/cjs/runtime/router.js +0 -6
- package/dist/cjs/runtime-browser/index.js +0 -6
- package/dist/cjs/runtime-browser/parsed.js +0 -28
- package/dist/cjs/runtime-node/index.js +0 -28
- package/dist/cjs/runtime-node/loaderContext/createLoaderCtx.js +0 -34
- package/dist/cjs/runtime-node/loaderContext/createRequestCtx.js +0 -38
- package/dist/cjs/runtime-node/loaderContext/index.js +0 -22
- package/dist/cjs/runtime-node/nestedRoutes.js +0 -28
- package/dist/cjs/runtime-node/router.js +0 -6
- package/dist/cjs/runtime-node/serialize.js +0 -17
- package/dist/cjs/runtime-node/storage.js +0 -48
- package/dist/cjs/universal/time.js +0 -38
- 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/runtime/nestedRoutes.js +0 -163
- package/dist/esm/runtime/remixRouter.js +0 -1
- package/dist/esm/runtime/router.js +0 -1
- package/dist/esm/runtime-browser/index.js +0 -1
- package/dist/esm/runtime-browser/parsed.js +0 -18
- package/dist/esm/runtime-node/index.js +0 -6
- package/dist/esm/runtime-node/loaderContext/createLoaderCtx.js +0 -20
- package/dist/esm/runtime-node/loaderContext/createRequestCtx.js +0 -24
- package/dist/esm/runtime-node/loaderContext/index.js +0 -3
- package/dist/esm/runtime-node/nestedRoutes.js +0 -20
- package/dist/esm/runtime-node/router.js +0 -1
- package/dist/esm/runtime-node/serialize.js +0 -6
- package/dist/esm/runtime-node/storage.js +0 -36
- package/dist/esm/universal/time.js +0 -29
- package/dist/esm-node/cli/is/platform.js +0 -2
- package/dist/esm-node/runtime/nestedRoutes.js +0 -129
- package/dist/esm-node/runtime/remixRouter.js +0 -1
- package/dist/esm-node/runtime/router.js +0 -1
- package/dist/esm-node/runtime-browser/index.js +0 -1
- package/dist/esm-node/runtime-browser/parsed.js +0 -18
- package/dist/esm-node/runtime-node/index.js +0 -6
- package/dist/esm-node/runtime-node/loaderContext/createLoaderCtx.js +0 -15
- package/dist/esm-node/runtime-node/loaderContext/createRequestCtx.js +0 -19
- package/dist/esm-node/runtime-node/loaderContext/index.js +0 -3
- package/dist/esm-node/runtime-node/nestedRoutes.js +0 -18
- package/dist/esm-node/runtime-node/router.js +0 -1
- package/dist/esm-node/runtime-node/serialize.js +0 -6
- package/dist/esm-node/runtime-node/storage.js +0 -38
- package/dist/esm-node/universal/time.js +0 -28
- package/dist/types/cli/is/platform.d.ts +0 -2
- package/dist/types/runtime/nestedRoutes.d.ts +0 -13
- package/dist/types/runtime/remixRouter.d.ts +0 -1
- package/dist/types/runtime/router.d.ts +0 -1
- package/dist/types/runtime-browser/index.d.ts +0 -1
- package/dist/types/runtime-browser/parsed.d.ts +0 -1
- package/dist/types/runtime-node/index.d.ts +0 -10
- package/dist/types/runtime-node/loaderContext/createLoaderCtx.d.ts +0 -7
- package/dist/types/runtime-node/loaderContext/createRequestCtx.d.ts +0 -7
- package/dist/types/runtime-node/loaderContext/index.d.ts +0 -4
- package/dist/types/runtime-node/nestedRoutes.d.ts +0 -3
- package/dist/types/runtime-node/router.d.ts +0 -1
- package/dist/types/runtime-node/serialize.d.ts +0 -1
- package/dist/types/runtime-node/storage.d.ts +0 -5
- package/dist/types/universal/time.d.ts +0 -1
@@ -19,13 +19,12 @@ var getIpv4Interfaces = function() {
|
|
19
19
|
});
|
20
20
|
return ipv4Interfaces;
|
21
21
|
};
|
22
|
-
|
22
|
+
var getAddressUrls = function() {
|
23
23
|
var protocol = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "http", port = arguments.length > 1 ? arguments[1] : void 0, host = arguments.length > 2 ? arguments[2] : void 0;
|
24
24
|
var LOCAL_LABEL = "Local: ";
|
25
25
|
var NETWORK_LABEL = "Network: ";
|
26
26
|
var isLocalhost = function(url) {
|
27
|
-
|
28
|
-
return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
|
27
|
+
return url === null || url === void 0 ? void 0 : url.includes("localhost");
|
29
28
|
};
|
30
29
|
if (host && host !== DEFAULT_DEV_HOST) {
|
31
30
|
return [
|
@@ -51,7 +50,7 @@ export var getAddressUrls = function() {
|
|
51
50
|
return memo;
|
52
51
|
}, []);
|
53
52
|
};
|
54
|
-
|
53
|
+
var prettyInstructions = function(appContext, config) {
|
55
54
|
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
|
56
55
|
var entrypoints = appContext.entrypoints, serverRoutes = appContext.serverRoutes, port = appContext.port, apiOnly = appContext.apiOnly, checkedEntries = appContext.checkedEntries;
|
57
56
|
var isHttps = isDev() && ((_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : (_appContext_builder_context_devServer = _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
|
@@ -59,7 +58,7 @@ export var prettyInstructions = function(appContext, config) {
|
|
59
58
|
var routes = !apiOnly ? serverRoutes.filter(function(route) {
|
60
59
|
return route.entryName;
|
61
60
|
}) : serverRoutes;
|
62
|
-
var message = "
|
61
|
+
var message = "\n";
|
63
62
|
if (isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
|
64
63
|
message += urls.map(function(param) {
|
65
64
|
var label = param.label, url = param.url;
|
@@ -87,3 +86,7 @@ export var prettyInstructions = function(appContext, config) {
|
|
87
86
|
}
|
88
87
|
return message;
|
89
88
|
};
|
89
|
+
export {
|
90
|
+
getAddressUrls,
|
91
|
+
prettyInstructions
|
92
|
+
};
|
package/dist/esm/cli/require.js
CHANGED
@@ -1,14 +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
|
-
var _mod;
|
6
5
|
var mod = require(filePath);
|
7
|
-
var rtnESMDefault = interop && (
|
6
|
+
var rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
|
8
7
|
return rtnESMDefault ? mod.default : mod;
|
9
8
|
};
|
10
|
-
|
11
|
-
|
9
|
+
var dynamicImport = new Function("modulePath", "return import(modulePath)");
|
10
|
+
var requireExistModule = function(filename, opt) {
|
12
11
|
var final = _object_spread({
|
13
12
|
extensions: [
|
14
13
|
".ts",
|
@@ -24,12 +23,12 @@ export var requireExistModule = function(filename, opt) {
|
|
24
23
|
}
|
25
24
|
return compatRequire(exist, final.interop);
|
26
25
|
};
|
27
|
-
|
26
|
+
var cleanRequireCache = function(filelist) {
|
28
27
|
filelist.forEach(function(filepath) {
|
29
28
|
delete require.cache[filepath];
|
30
29
|
});
|
31
30
|
};
|
32
|
-
|
31
|
+
function deleteRequireCache(path) {
|
33
32
|
if (require.cache[path]) {
|
34
33
|
delete require.cache[path];
|
35
34
|
}
|
@@ -39,7 +38,7 @@ export function deleteRequireCache(path) {
|
|
39
38
|
});
|
40
39
|
}
|
41
40
|
}
|
42
|
-
|
41
|
+
var tryResolve = function(name, resolvePath) {
|
43
42
|
var filePath = "";
|
44
43
|
try {
|
45
44
|
filePath = require.resolve(name, {
|
@@ -56,3 +55,11 @@ export var tryResolve = function(name, resolvePath) {
|
|
56
55
|
}
|
57
56
|
return filePath;
|
58
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,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
var ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
|
2
|
+
var HMR_SOCK_PATH = "/webpack-hmr";
|
3
|
+
var HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
|
4
|
+
var LOADER_REPORTER_NAME = "server-loader";
|
5
|
+
export {
|
6
|
+
HMR_SOCK_PATH,
|
7
|
+
HTML_CHUNKSMAP_SEPARATOR,
|
8
|
+
LOADER_REPORTER_NAME,
|
9
|
+
ROUTE_MANIFEST
|
10
|
+
};
|
@@ -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
|
{
|
@@ -71,9 +71,9 @@ export function addErrorTips(errors) {
|
|
71
71
|
}
|
72
72
|
function formatWebpackMessages(json) {
|
73
73
|
var color = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultColor;
|
74
|
-
var _json_errors,
|
75
|
-
var formattedErrors =
|
76
|
-
var formattedWarnings =
|
74
|
+
var _json_errors, _json_warnings, _result_errors;
|
75
|
+
var formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
|
76
|
+
var formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
|
77
77
|
var result = {
|
78
78
|
errors: formattedErrors || [],
|
79
79
|
warnings: formattedWarnings || [],
|
@@ -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,26 +1,10 @@
|
|
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
|
-
|
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) => {
|
23
|
-
var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
|
5
|
+
const mergeAlias = (alias) => applyOptionsChain({}, alias);
|
6
|
+
const getAliasConfig = (aliasOption, option) => {
|
7
|
+
var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
|
24
8
|
const isTsProject = fs.existsSync(option.tsconfigPath);
|
25
9
|
const alias = mergeAlias(aliasOption);
|
26
10
|
if (!isTsProject) {
|
@@ -32,20 +16,25 @@ export const getAliasConfig = (aliasOption, option) => {
|
|
32
16
|
};
|
33
17
|
}
|
34
18
|
const tsconfig = readTsConfigByFile(option.tsconfigPath);
|
35
|
-
const baseUrl =
|
19
|
+
const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
|
36
20
|
return {
|
37
21
|
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
38
22
|
paths: {
|
39
23
|
...alias,
|
40
|
-
...
|
24
|
+
...tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
|
41
25
|
},
|
42
26
|
isTsPath: true,
|
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,4 +1,4 @@
|
|
1
|
-
|
1
|
+
const CHAIN_ID = {
|
2
2
|
/** Predefined rules */
|
3
3
|
RULE: {
|
4
4
|
/** Rule for .mjs */
|
@@ -89,8 +89,6 @@ export const CHAIN_ID = {
|
|
89
89
|
STYLE: "style-loader",
|
90
90
|
/** postcss-loader */
|
91
91
|
POSTCSS: "postcss",
|
92
|
-
/** markdown-loader */
|
93
|
-
MARKDOWN: "markdown",
|
94
92
|
/** ignore-css-loader */
|
95
93
|
IGNORE_CSS: "ignore-css",
|
96
94
|
/** css-modules-typescript-loader */
|
@@ -171,7 +169,9 @@ export const CHAIN_ID = {
|
|
171
169
|
/** HtmlAsyncChunkPlugin */
|
172
170
|
HTML_ASYNC_CHUNK: "html-async-chunk",
|
173
171
|
/** SWC_POLYFILL_CHECKER */
|
174
|
-
SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
|
172
|
+
SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin",
|
173
|
+
/** RouterPlugin */
|
174
|
+
ROUTER_MANIFEST: "route-plugin"
|
175
175
|
},
|
176
176
|
/** Predefined minimizers */
|
177
177
|
MINIMIZER: {
|
@@ -192,3 +192,6 @@ export const CHAIN_ID = {
|
|
192
192
|
TS_CONFIG_PATHS: "ts-config-paths"
|
193
193
|
}
|
194
194
|
};
|
195
|
+
export {
|
196
|
+
CHAIN_ID
|
197
|
+
};
|