@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
@@ -1,11 +1,11 @@
|
|
1
1
|
import { execa } from "../compiled";
|
2
|
-
|
2
|
+
async function getPnpmVersion() {
|
3
3
|
const { stdout } = await execa("pnpm", [
|
4
4
|
"--version"
|
5
5
|
]);
|
6
6
|
return stdout;
|
7
7
|
}
|
8
|
-
|
8
|
+
async function canUseNpm() {
|
9
9
|
try {
|
10
10
|
await execa("npm", [
|
11
11
|
"--version"
|
@@ -17,7 +17,7 @@ export async function canUseNpm() {
|
|
17
17
|
return false;
|
18
18
|
}
|
19
19
|
}
|
20
|
-
|
20
|
+
async function canUseYarn() {
|
21
21
|
try {
|
22
22
|
await execa("yarn", [
|
23
23
|
"--version"
|
@@ -29,7 +29,7 @@ export async function canUseYarn() {
|
|
29
29
|
return false;
|
30
30
|
}
|
31
31
|
}
|
32
|
-
|
32
|
+
async function canUsePnpm() {
|
33
33
|
try {
|
34
34
|
await execa("pnpm", [
|
35
35
|
"--version"
|
@@ -41,3 +41,9 @@ export async function canUsePnpm() {
|
|
41
41
|
return false;
|
42
42
|
}
|
43
43
|
}
|
44
|
+
export {
|
45
|
+
canUseNpm,
|
46
|
+
canUsePnpm,
|
47
|
+
canUseYarn,
|
48
|
+
getPnpmVersion
|
49
|
+
};
|
@@ -2,11 +2,11 @@ import path from "path";
|
|
2
2
|
import os from "os";
|
3
3
|
import fs from "fs";
|
4
4
|
import { nanoid, upath } from "../compiled";
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
const isPathString = (test) => path.posix.basename(test) !== test || path.win32.basename(test) !== test;
|
6
|
+
const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
7
|
+
const normalizeOutputPath = (s) => s.replace(/\\/g, "\\\\");
|
8
|
+
const normalizeToPosixPath = (p) => upath.normalizeSafe(path.normalize(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
|
9
|
+
const getTemplatePath = (prefix) => {
|
10
10
|
const tmpRoot = fs.realpathSync(os.tmpdir());
|
11
11
|
const parts = [
|
12
12
|
tmpRoot
|
@@ -15,7 +15,7 @@ export const getTemplatePath = (prefix) => {
|
|
15
15
|
parts.push(nanoid());
|
16
16
|
return path.resolve(...parts);
|
17
17
|
};
|
18
|
-
|
18
|
+
function getRealTemporaryDirectory() {
|
19
19
|
let ret = null;
|
20
20
|
try {
|
21
21
|
ret = os.tmpdir();
|
@@ -24,12 +24,25 @@ export function getRealTemporaryDirectory() {
|
|
24
24
|
}
|
25
25
|
return ret;
|
26
26
|
}
|
27
|
-
|
27
|
+
function splitPathString(str) {
|
28
28
|
return str.split(/[\\/]/);
|
29
29
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
const removeLeadingSlash = (s) => s.replace(/^\/+/, "");
|
31
|
+
const removeTailSlash = (s) => s.replace(/\/+$/, "");
|
32
|
+
const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
|
33
|
+
const cutNameByHyphen = (s) => {
|
34
34
|
return s.split(/[-_]/)[0];
|
35
35
|
};
|
36
|
+
export {
|
37
|
+
cutNameByHyphen,
|
38
|
+
getRealTemporaryDirectory,
|
39
|
+
getTemplatePath,
|
40
|
+
isPathString,
|
41
|
+
isRelativePath,
|
42
|
+
normalizeOutputPath,
|
43
|
+
normalizeToPosixPath,
|
44
|
+
removeLeadingSlash,
|
45
|
+
removeSlash,
|
46
|
+
removeTailSlash,
|
47
|
+
splitPathString
|
48
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import net from "net";
|
2
2
|
import { chalk } from "../compiled";
|
3
3
|
import { logger } from "./logger";
|
4
|
-
|
4
|
+
const getPort = async (port, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
|
5
5
|
if (typeof port === "string") {
|
6
6
|
port = parseInt(port, 10);
|
7
7
|
}
|
@@ -37,8 +37,11 @@ export const getPort = async (port, { tryLimits = 20, strictPort = false, slient
|
|
37
37
|
if (strictPort) {
|
38
38
|
throw new Error(`Port "${original}" is occupied, please choose another one.`);
|
39
39
|
} else if (!slient) {
|
40
|
-
logger.info(`
|
40
|
+
logger.info(`Port ${original} is in use. ${chalk.yellow(`using port ${port}.`)}`);
|
41
41
|
}
|
42
42
|
}
|
43
43
|
return port;
|
44
44
|
};
|
45
|
+
export {
|
46
|
+
getPort
|
47
|
+
};
|
@@ -16,13 +16,10 @@ const getIpv4Interfaces = () => {
|
|
16
16
|
});
|
17
17
|
return ipv4Interfaces;
|
18
18
|
};
|
19
|
-
|
19
|
+
const getAddressUrls = (protocol = "http", port, host) => {
|
20
20
|
const LOCAL_LABEL = "Local: ";
|
21
21
|
const NETWORK_LABEL = "Network: ";
|
22
|
-
const isLocalhost = (url) =>
|
23
|
-
var _url;
|
24
|
-
return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
|
25
|
-
};
|
22
|
+
const isLocalhost = (url) => url === null || url === void 0 ? void 0 : url.includes("localhost");
|
26
23
|
if (host && host !== DEFAULT_DEV_HOST) {
|
27
24
|
return [
|
28
25
|
{
|
@@ -47,13 +44,13 @@ export const getAddressUrls = (protocol = "http", port, host) => {
|
|
47
44
|
return memo;
|
48
45
|
}, []);
|
49
46
|
};
|
50
|
-
|
47
|
+
const prettyInstructions = (appContext, config) => {
|
51
48
|
var _appContext_builder_context_devServer, _appContext_builder, _config_dev, _config_source;
|
52
49
|
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
53
50
|
const 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);
|
54
51
|
const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
|
55
52
|
const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
|
56
|
-
let message = "
|
53
|
+
let message = "\n";
|
57
54
|
if (isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
|
58
55
|
message += urls.map(({ label, url }) => ` ${chalk.bold(`> ${label.padEnd(10)}`)}${chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
|
59
56
|
`).join("");
|
@@ -76,3 +73,7 @@ export const prettyInstructions = (appContext, config) => {
|
|
76
73
|
}
|
77
74
|
return message;
|
78
75
|
};
|
76
|
+
export {
|
77
|
+
getAddressUrls,
|
78
|
+
prettyInstructions
|
79
|
+
};
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import { findExists } from "./fs";
|
2
|
-
|
3
|
-
var _mod;
|
2
|
+
const compatRequire = (filePath, interop = true) => {
|
4
3
|
const mod = require(filePath);
|
5
|
-
const rtnESMDefault = interop && (
|
4
|
+
const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
|
6
5
|
return rtnESMDefault ? mod.default : mod;
|
7
6
|
};
|
8
|
-
|
9
|
-
|
7
|
+
const dynamicImport = new Function("modulePath", "return import(modulePath)");
|
8
|
+
const requireExistModule = (filename, opt) => {
|
10
9
|
const final = {
|
11
10
|
extensions: [
|
12
11
|
".ts",
|
@@ -21,12 +20,12 @@ export const requireExistModule = (filename, opt) => {
|
|
21
20
|
}
|
22
21
|
return compatRequire(exist, final.interop);
|
23
22
|
};
|
24
|
-
|
23
|
+
const cleanRequireCache = (filelist) => {
|
25
24
|
filelist.forEach((filepath) => {
|
26
25
|
delete require.cache[filepath];
|
27
26
|
});
|
28
27
|
};
|
29
|
-
|
28
|
+
function deleteRequireCache(path) {
|
30
29
|
if (require.cache[path]) {
|
31
30
|
delete require.cache[path];
|
32
31
|
}
|
@@ -34,7 +33,7 @@ export function deleteRequireCache(path) {
|
|
34
33
|
module.children = module.children.filter((item) => item.filename !== path);
|
35
34
|
}
|
36
35
|
}
|
37
|
-
|
36
|
+
const tryResolve = (name, resolvePath) => {
|
38
37
|
let filePath = "";
|
39
38
|
try {
|
40
39
|
filePath = require.resolve(name, {
|
@@ -51,3 +50,11 @@ export const tryResolve = (name, resolvePath) => {
|
|
51
50
|
}
|
52
51
|
return filePath;
|
53
52
|
};
|
53
|
+
export {
|
54
|
+
cleanRequireCache,
|
55
|
+
compatRequire,
|
56
|
+
deleteRequireCache,
|
57
|
+
dynamicImport,
|
58
|
+
requireExistModule,
|
59
|
+
tryResolve
|
60
|
+
};
|
@@ -14,7 +14,7 @@ const memo = (fn) => {
|
|
14
14
|
return res;
|
15
15
|
};
|
16
16
|
};
|
17
|
-
|
17
|
+
const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
|
18
18
|
const entryExportFile = path.join(pwd, `.runtime-exports/${namespace}.js`);
|
19
19
|
const addExport = (statement) => {
|
20
20
|
statement = normalizeOutputPath(statement);
|
@@ -33,3 +33,6 @@ export const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") =>
|
|
33
33
|
getPath
|
34
34
|
};
|
35
35
|
});
|
36
|
+
export {
|
37
|
+
createRuntimeExportsUtils
|
38
|
+
};
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import { chokidar } from "../compiled";
|
3
|
-
|
3
|
+
const WatchChangeType = {
|
4
4
|
ADD: "add",
|
5
5
|
UNLINK: "unlink",
|
6
6
|
CHANGE: "change"
|
7
7
|
};
|
8
|
-
|
8
|
+
const watch = (watchDir, runTask, ignored = []) => {
|
9
9
|
let ready = false;
|
10
10
|
const watcher = chokidar.watch(watchDir, {
|
11
11
|
ignored
|
@@ -39,3 +39,7 @@ export const watch = (watchDir, runTask, ignored = []) => {
|
|
39
39
|
});
|
40
40
|
return watcher;
|
41
41
|
};
|
42
|
+
export {
|
43
|
+
WatchChangeType,
|
44
|
+
watch
|
45
|
+
};
|
@@ -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
|
+
const mime = Import.lazy("../compiled/mime-types", require);
|
31
|
+
const chokidar = Import.lazy("../compiled/chokidar", require);
|
32
|
+
const 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-node/import.js
CHANGED
@@ -2,7 +2,10 @@ const lazy = (moduleName, requireFn) => {
|
|
2
2
|
const importLazyLocal = require("../compiled/import-lazy")(requireFn);
|
3
3
|
return importLazyLocal(moduleName);
|
4
4
|
};
|
5
|
-
|
6
|
-
export const Import = {
|
5
|
+
const Import = {
|
7
6
|
lazy
|
8
7
|
};
|
8
|
+
export {
|
9
|
+
Import,
|
10
|
+
lazy as lazyImport
|
11
|
+
};
|
@@ -1,4 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
2
|
+
const HMR_SOCK_PATH = "/webpack-hmr";
|
3
|
+
const HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
|
4
|
+
const 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 @@ const defaultColor = {
|
|
50
50
|
yellow: noop,
|
51
51
|
underline: noop
|
52
52
|
};
|
53
|
-
|
53
|
+
function addErrorTips(errors, color = defaultColor) {
|
54
54
|
const errorHelpers = [
|
55
55
|
{
|
56
56
|
validator(message) {
|
@@ -79,9 +79,9 @@ export default {
|
|
79
79
|
});
|
80
80
|
}
|
81
81
|
function formatWebpackMessages(json, color = defaultColor) {
|
82
|
-
var _json_errors,
|
83
|
-
const formattedErrors =
|
84
|
-
const formattedWarnings =
|
82
|
+
var _json_errors, _json_warnings, _result_errors;
|
83
|
+
const formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
|
84
|
+
const formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
|
85
85
|
const result = {
|
86
86
|
errors: formattedErrors || [],
|
87
87
|
warnings: formattedWarnings || [],
|
@@ -96,4 +96,7 @@ function formatWebpackMessages(json, color = defaultColor) {
|
|
96
96
|
result.errors = addErrorTips(result.errors, color);
|
97
97
|
return result;
|
98
98
|
}
|
99
|
-
export {
|
99
|
+
export {
|
100
|
+
addErrorTips,
|
101
|
+
formatWebpackMessages
|
102
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post") => {
|
2
2
|
let allLines = [];
|
3
3
|
function getPluginByAny(q) {
|
4
4
|
const target = plugins.find((item) => typeof q === "string" ? item[key] === q : item[key] === q[key]);
|
@@ -44,7 +44,10 @@ export const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "
|
|
44
44
|
restInRingPoints[l[0]] = true;
|
45
45
|
restInRingPoints[l[1]] = true;
|
46
46
|
});
|
47
|
-
throw new Error(`plugins
|
47
|
+
throw new Error(`plugins dependencies has loop: ${Object.keys(restInRingPoints).join(",")}`);
|
48
48
|
}
|
49
49
|
return sortedPoint;
|
50
50
|
};
|
51
|
+
export {
|
52
|
+
pluginDagSort
|
53
|
+
};
|
@@ -11,11 +11,6 @@ interface IAliasConfig {
|
|
11
11
|
isTsPath?: boolean;
|
12
12
|
isTsProject?: boolean;
|
13
13
|
}
|
14
|
-
export declare const validAlias: <T extends NormalizedConfig>(modernConfig: T, {
|
15
|
-
tsconfigPath
|
16
|
-
}: {
|
17
|
-
tsconfigPath: string;
|
18
|
-
}) => string | null;
|
19
14
|
export declare const mergeAlias: (alias: NormalizedConfig['source']['alias']) => Alias;
|
20
15
|
export declare const getAliasConfig: (aliasOption: NormalizedConfig['source']['alias'], option: {
|
21
16
|
appDirectory: string;
|
@@ -89,8 +89,6 @@ export declare const CHAIN_ID: {
|
|
89
89
|
readonly STYLE: "style-loader";
|
90
90
|
/** postcss-loader */
|
91
91
|
readonly POSTCSS: "postcss";
|
92
|
-
/** markdown-loader */
|
93
|
-
readonly MARKDOWN: "markdown";
|
94
92
|
/** ignore-css-loader */
|
95
93
|
readonly IGNORE_CSS: "ignore-css";
|
96
94
|
/** css-modules-typescript-loader */
|
@@ -172,6 +170,8 @@ export declare const CHAIN_ID: {
|
|
172
170
|
readonly HTML_ASYNC_CHUNK: "html-async-chunk";
|
173
171
|
/** SWC_POLYFILL_CHECKER */
|
174
172
|
readonly SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin";
|
173
|
+
/** RouterPlugin */
|
174
|
+
readonly ROUTER_MANIFEST: "route-plugin";
|
175
175
|
};
|
176
176
|
/** Predefined minimizers */
|
177
177
|
readonly MINIMIZER: {
|
@@ -5,5 +5,4 @@ export declare const getNodeEnv: () => string;
|
|
5
5
|
export declare const isDev: () => boolean;
|
6
6
|
export declare const isProd: () => boolean;
|
7
7
|
export declare const isTest: () => boolean;
|
8
|
-
export declare const
|
9
|
-
export declare const isFastRefresh: () => boolean;
|
8
|
+
export declare const isBrowser: () => boolean;
|
@@ -1,64 +1 @@
|
|
1
|
-
|
2
|
-
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
3
|
-
type LogMsg = number | string | Error | null;
|
4
|
-
interface LoggerConfiguration {
|
5
|
-
color?: typeof Color;
|
6
|
-
label?: string;
|
7
|
-
level?: LogLevel;
|
8
|
-
}
|
9
|
-
interface InstanceConfiguration {
|
10
|
-
displayLabel?: boolean;
|
11
|
-
uppercaseLabel?: boolean;
|
12
|
-
}
|
13
|
-
interface ConstructorOptions {
|
14
|
-
config?: InstanceConfiguration;
|
15
|
-
level?: string;
|
16
|
-
types?: Record<string, LoggerConfiguration>;
|
17
|
-
}
|
18
|
-
type LoggerFunction = (message?: LogMsg, ...args: any[]) => void;
|
19
|
-
declare const LOG_TYPES: {
|
20
|
-
error: {
|
21
|
-
color: string;
|
22
|
-
label: string;
|
23
|
-
level: string;
|
24
|
-
};
|
25
|
-
info: {
|
26
|
-
color: string;
|
27
|
-
label: string;
|
28
|
-
level: string;
|
29
|
-
};
|
30
|
-
success: {
|
31
|
-
color: string;
|
32
|
-
label: string;
|
33
|
-
level: string;
|
34
|
-
};
|
35
|
-
warn: {
|
36
|
-
color: string;
|
37
|
-
label: string;
|
38
|
-
level: string;
|
39
|
-
};
|
40
|
-
debug: {
|
41
|
-
color: string;
|
42
|
-
label: string;
|
43
|
-
level: string;
|
44
|
-
};
|
45
|
-
log: {
|
46
|
-
level: string;
|
47
|
-
};
|
48
|
-
};
|
49
|
-
export declare const isErrorStackMessage: (message: string) => boolean;
|
50
|
-
declare class Logger {
|
51
|
-
private readonly level;
|
52
|
-
private readonly config;
|
53
|
-
private readonly types;
|
54
|
-
private readonly longestLabel;
|
55
|
-
[key: string]: any;
|
56
|
-
constructor(options?: ConstructorOptions);
|
57
|
-
private _log;
|
58
|
-
private getLongestLabel;
|
59
|
-
}
|
60
|
-
type LoggerInterface = { [key in keyof typeof LOG_TYPES]: LoggerFunction };
|
61
|
-
declare const logger: Logger & LoggerInterface;
|
62
|
-
export { Logger };
|
63
|
-
export { logger };
|
64
|
-
export type { LoggerInterface };
|
1
|
+
export { logger, createLogger, type Logger } from 'rslog';
|
@@ -3,7 +3,6 @@ export declare const isLerna: (root: string) => boolean;
|
|
3
3
|
export declare const isYarnWorkspaces: (root: string) => boolean;
|
4
4
|
export declare const isPnpmWorkspaces: (root: string) => boolean;
|
5
5
|
export declare const isMonorepo: (root: string) => boolean;
|
6
|
-
export declare const isModernjsMonorepo: (root: string) => boolean;
|
7
6
|
export declare const findMonorepoRoot: (appDirectory: string, maxDepth?: number) => string | undefined;
|
8
7
|
export declare const getMonorepoPackages: (root: string) => {
|
9
8
|
name: string;
|