@modern-js/utils 2.18.0 → 2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/{alias.js → cli/alias.js} +3 -3
- package/dist/cjs/{applyOptionsChain.js → cli/applyOptionsChain.js} +6 -5
- package/dist/cjs/{babel.js → cli/babel.js} +3 -3
- package/dist/cjs/cli/common.js +26 -0
- package/dist/cjs/{constants.js → cli/constants/index.js} +14 -2
- package/dist/cjs/{readTsConfig.js → cli/ensure.js} +10 -9
- package/dist/cjs/cli/fs.js +29 -0
- package/dist/cjs/{getEntryOptions.js → cli/get/config.js} +2 -2
- package/dist/cjs/cli/get/data.js +112 -0
- package/dist/cjs/cli/get/index.js +46 -0
- package/dist/cjs/cli/index.js +41 -0
- package/dist/cjs/{is/index.js → cli/is/config.js} +2 -43
- package/dist/cjs/{is/nodeEnv.js → cli/is/env.js} +3 -1
- package/dist/cjs/cli/is/index.js +22 -0
- package/dist/cjs/cli/is/project.js +92 -0
- package/dist/cjs/{is → cli/is}/type.js +3 -1
- package/dist/cjs/{logger.js → cli/logger.js} +1 -1
- package/dist/cjs/{monorepo.js → cli/monorepo.js} +1 -1
- package/dist/cjs/{nodeEnv.js → cli/package.js} +8 -1
- package/dist/cjs/{path.js → cli/path.js} +8 -2
- package/dist/cjs/{pathSerializer.js → cli/pathSerializer.js} +1 -1
- package/dist/cjs/{getPort.js → cli/port.js} +1 -1
- package/dist/cjs/{prettyInstructions.js → cli/prettyInstructions.js} +1 -2
- package/dist/cjs/{printBuildError.js → cli/print.js} +1 -1
- package/dist/cjs/{compatRequire.js → cli/require.js} +21 -3
- package/dist/cjs/{routes.js → cli/routes.js} +4 -11
- package/dist/cjs/{runtimeExports.js → cli/runtimeExports.js} +1 -1
- package/dist/cjs/cli/watch.js +61 -0
- package/dist/cjs/index.js +1 -42
- package/dist/cjs/runtime/router.js +19 -0
- package/dist/cjs/{ssr.js → runtime-node/index.js} +3 -1
- package/dist/esm/{alias.js → cli/alias.js} +2 -2
- package/dist/esm/{applyOptionsChain.js → cli/applyOptionsChain.js} +2 -1
- package/dist/esm/{babel.js → cli/babel.js} +1 -1
- package/dist/esm/cli/common.js +10 -0
- package/dist/esm/{constants.js → cli/constants/index.js} +1 -1
- package/dist/esm/{ensureAbsolutePath.js → cli/ensure.js} +8 -0
- package/dist/esm/{findExists.js → cli/fs.js} +6 -1
- package/dist/esm/{getEntryOptions.js → cli/get/config.js} +2 -2
- package/dist/esm/cli/get/data.js +86 -0
- package/dist/esm/cli/get/index.js +13 -0
- package/dist/esm/cli/index.js +24 -0
- package/dist/esm/{is/index.js → cli/is/config.js} +1 -21
- package/dist/esm/{is/nodeEnv.js → cli/is/env.js} +1 -0
- package/dist/esm/cli/is/index.js +5 -0
- package/dist/esm/cli/is/project.js +67 -0
- package/dist/esm/{is → cli/is}/type.js +1 -0
- package/dist/esm/{logger.js → cli/logger.js} +1 -1
- package/dist/esm/{monorepo.js → cli/monorepo.js} +1 -1
- package/dist/esm/{nodeEnv.js → cli/package.js} +7 -1
- package/dist/esm/{path.js → cli/path.js} +4 -1
- package/dist/esm/{pathSerializer.js → cli/pathSerializer.js} +1 -1
- package/dist/esm/{getPort.js → cli/port.js} +1 -1
- package/dist/esm/{prettyInstructions.js → cli/prettyInstructions.js} +2 -2
- package/dist/esm/{printBuildError.js → cli/print.js} +1 -1
- package/dist/esm/{compatRequire.js → cli/require.js} +18 -1
- package/dist/esm/{routes.js → cli/routes.js} +2 -2
- package/dist/esm/{runtimeExports.js → cli/runtimeExports.js} +1 -1
- package/dist/esm/{watch.js → cli/watch.js} +2 -2
- package/dist/esm/index.js +1 -42
- package/dist/esm/runtime/router.js +2 -0
- package/dist/esm/{ssr.js → runtime-node/index.js} +1 -0
- package/dist/types/{applyOptionsChain.d.ts → cli/applyOptionsChain.d.ts} +1 -1
- package/dist/types/{debug.d.ts → cli/common.d.ts} +3 -1
- package/dist/types/{constants.d.ts → cli/constants/index.d.ts} +2 -6
- package/dist/types/{ensureAbsolutePath.d.ts → cli/ensure.d.ts} +2 -1
- package/dist/types/{findExists.d.ts → cli/fs.d.ts} +2 -1
- package/dist/types/cli/get/data.d.ts +9 -0
- package/dist/types/cli/get/index.d.ts +4 -0
- package/dist/types/cli/index.d.ts +24 -0
- package/dist/types/cli/is/config.d.ts +30 -0
- package/dist/types/{is/nodeEnv.d.ts → cli/is/env.d.ts} +2 -1
- package/dist/types/cli/is/index.d.ts +5 -0
- package/dist/types/cli/is/project.d.ts +25 -0
- package/dist/types/{is → cli/is}/type.d.ts +9 -1
- package/dist/types/{logger.d.ts → cli/logger.d.ts} +1 -1
- package/dist/types/cli/package.d.ts +4 -0
- package/dist/types/{path.d.ts → cli/path.d.ts} +5 -2
- package/dist/types/{prettyInstructions.d.ts → cli/prettyInstructions.d.ts} +0 -3
- package/dist/types/{compatRequire.d.ts → cli/require.d.ts} +9 -1
- package/dist/types/cli/routes.d.ts +1 -0
- package/dist/types/{watch.d.ts → cli/watch.d.ts} +1 -1
- package/dist/types/index.d.ts +2 -43
- package/dist/types/runtime/router.d.ts +2 -0
- package/dist/types/{ssr.d.ts → runtime-node/index.d.ts} +2 -1
- package/package.json +56 -93
- package/dist/cjs/FileSizeReporter.js +0 -139
- package/dist/cjs/analyzeProject.js +0 -68
- package/dist/cjs/clearConsole.js +0 -13
- package/dist/cjs/debug.js +0 -10
- package/dist/cjs/emptyDir.js +0 -14
- package/dist/cjs/ensureAbsolutePath.js +0 -15
- package/dist/cjs/ensureArray.js +0 -16
- package/dist/cjs/findExists.js +0 -22
- package/dist/cjs/getBrowserslist.js +0 -24
- package/dist/cjs/getCoreJsVersion.js +0 -58
- package/dist/cjs/getPackageManager.js +0 -42
- package/dist/cjs/getServerConfig.js +0 -55
- package/dist/cjs/getTargetDir.js +0 -53
- package/dist/cjs/plugin.js +0 -28
- package/dist/cjs/react.js +0 -30
- package/dist/cjs/removeSlash.js +0 -19
- package/dist/cjs/resolve.js +0 -57
- package/dist/cjs/types.js +0 -4
- package/dist/cjs/version.js +0 -43
- package/dist/cjs/wait.js +0 -11
- package/dist/cjs/watch.js +0 -96
- package/dist/esm/FileSizeReporter.js +0 -121
- package/dist/esm/analyzeProject.js +0 -13
- package/dist/esm/clearConsole.js +0 -5
- package/dist/esm/debug.js +0 -2
- package/dist/esm/emptyDir.js +0 -6
- package/dist/esm/ensureArray.js +0 -8
- package/dist/esm/getBrowserslist.js +0 -9
- package/dist/esm/getCoreJsVersion.js +0 -10
- package/dist/esm/getPackageManager.js +0 -29
- package/dist/esm/getServerConfig.js +0 -7
- package/dist/esm/getTargetDir.js +0 -5
- package/dist/esm/plugin.js +0 -20
- package/dist/esm/react.js +0 -17
- package/dist/esm/readTsConfig.js +0 -9
- package/dist/esm/removeSlash.js +0 -3
- package/dist/esm/resolve.js +0 -41
- package/dist/esm/types.js +0 -1
- package/dist/esm/version.js +0 -23
- package/dist/esm/wait.js +0 -4
- package/dist/types/FileSizeReporter.d.ts +0 -16
- package/dist/types/analyzeProject.d.ts +0 -2
- package/dist/types/clearConsole.d.ts +0 -1
- package/dist/types/emptyDir.d.ts +0 -1
- package/dist/types/ensureArray.d.ts +0 -1
- package/dist/types/getBrowserslist.d.ts +0 -2
- package/dist/types/getCoreJsVersion.d.ts +0 -1
- package/dist/types/getPackageManager.d.ts +0 -1
- package/dist/types/getServerConfig.d.ts +0 -1
- package/dist/types/getTargetDir.d.ts +0 -1
- package/dist/types/is/index.d.ts +0 -58
- package/dist/types/nodeEnv.d.ts +0 -3
- package/dist/types/plugin.d.ts +0 -2
- package/dist/types/react.d.ts +0 -1
- package/dist/types/readTsConfig.d.ts +0 -2
- package/dist/types/removeSlash.d.ts +0 -3
- package/dist/types/resolve.d.ts +0 -13
- package/dist/types/routes.d.ts +0 -2
- package/dist/types/types.d.ts +0 -1
- package/dist/types/version.d.ts +0 -2
- package/dist/types/wait.d.ts +0 -2
- /package/dist/cjs/{commands.js → cli/commands.js} +0 -0
- /package/dist/cjs/{chainId.js → cli/constants/chainId.js} +0 -0
- /package/dist/cjs/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
- /package/dist/cjs/{is → cli/is}/platform.js +0 -0
- /package/dist/cjs/{testUtils.js → cli/test.js} +0 -0
- /package/dist/cjs/{universal → runtime}/nestedRoutes.js +0 -0
- /package/dist/cjs/{universal → runtime}/remixRouter.js +0 -0
- /package/dist/cjs/{runtime → runtime-browser}/index.js +0 -0
- /package/dist/cjs/{runtime → runtime-browser}/parsed.js +0 -0
- /package/dist/cjs/{universal → runtime-node}/serialize.js +0 -0
- /package/dist/cjs/{storage.js → runtime-node/storage.js} +0 -0
- /package/dist/esm/{commands.js → cli/commands.js} +0 -0
- /package/dist/esm/{chainId.js → cli/constants/chainId.js} +0 -0
- /package/dist/esm/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
- /package/dist/esm/{is → cli/is}/platform.js +0 -0
- /package/dist/esm/{testUtils.js → cli/test.js} +0 -0
- /package/dist/esm/{universal → runtime}/nestedRoutes.js +0 -0
- /package/dist/esm/{universal → runtime}/remixRouter.js +0 -0
- /package/dist/esm/{runtime → runtime-browser}/index.js +0 -0
- /package/dist/esm/{runtime → runtime-browser}/parsed.js +0 -0
- /package/dist/esm/{universal → runtime-node}/serialize.js +0 -0
- /package/dist/esm/{storage.js → runtime-node/storage.js} +0 -0
- /package/dist/types/{alias.d.ts → cli/alias.d.ts} +0 -0
- /package/dist/types/{babel.d.ts → cli/babel.d.ts} +0 -0
- /package/dist/types/{commands.d.ts → cli/commands.d.ts} +0 -0
- /package/dist/types/{chainId.d.ts → cli/constants/chainId.d.ts} +0 -0
- /package/dist/types/{generateMetaTags.d.ts → cli/generateMetaTags.d.ts} +0 -0
- /package/dist/types/{getEntryOptions.d.ts → cli/get/config.d.ts} +0 -0
- /package/dist/types/{is → cli/is}/platform.d.ts +0 -0
- /package/dist/types/{monorepo.d.ts → cli/monorepo.d.ts} +0 -0
- /package/dist/types/{pathSerializer.d.ts → cli/pathSerializer.d.ts} +0 -0
- /package/dist/types/{getPort.d.ts → cli/port.d.ts} +0 -0
- /package/dist/types/{printBuildError.d.ts → cli/print.d.ts} +0 -0
- /package/dist/types/{runtimeExports.d.ts → cli/runtimeExports.d.ts} +0 -0
- /package/dist/types/{testUtils.d.ts → cli/test.d.ts} +0 -0
- /package/dist/types/{universal → runtime}/nestedRoutes.d.ts +0 -0
- /package/dist/types/{universal → runtime}/remixRouter.d.ts +0 -0
- /package/dist/types/{runtime → runtime-browser}/index.d.ts +0 -0
- /package/dist/types/{runtime → runtime-browser}/parsed.d.ts +0 -0
- /package/dist/types/{universal → runtime-node}/serialize.d.ts +0 -0
- /package/dist/types/{storage.d.ts → runtime-node/storage.d.ts} +0 -0
@@ -1,4 +1,10 @@
|
|
1
|
-
import { execa } from "
|
1
|
+
import { execa } from "../compiled";
|
2
|
+
export async function getPnpmVersion() {
|
3
|
+
const { stdout } = await execa("pnpm", [
|
4
|
+
"--version"
|
5
|
+
]);
|
6
|
+
return stdout;
|
7
|
+
}
|
2
8
|
export async function canUseNpm() {
|
3
9
|
try {
|
4
10
|
await execa("npm", [
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import os from "os";
|
3
3
|
import fs from "fs";
|
4
|
-
import { nanoid, upath, lodash as _ } from "
|
4
|
+
import { nanoid, upath, lodash as _ } from "../compiled";
|
5
5
|
export const isPathString = (test) => path.posix.basename(test) !== test || path.win32.basename(test) !== test;
|
6
6
|
export const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
7
7
|
export const normalizeOutputPath = (s) => s.replace(/\\/g, "\\\\");
|
@@ -41,3 +41,6 @@ export function getRealTemporaryDirectory() {
|
|
41
41
|
export function splitPathString(str) {
|
42
42
|
return str.split(/[\\/]/);
|
43
43
|
}
|
44
|
+
export const removeLeadingSlash = (s) => s.replace(/^\/+/, "");
|
45
|
+
export const removeTailSlash = (s) => s.replace(/\/+$/, "");
|
46
|
+
export const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import os from "os";
|
2
|
-
import _ from "
|
2
|
+
import _ from "../../compiled/lodash";
|
3
3
|
import { compilePathMatcherRegExp, normalizeToPosixPath, getRealTemporaryDirectory, splitPathString, upwardPaths } from "./path";
|
4
4
|
export const matchUpwardPathsAsUnknown = (p) => _(upwardPaths(normalizeToPosixPath(p))).map((match) => ({
|
5
5
|
match,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import os from "os";
|
2
|
-
import { chalk } from "
|
2
|
+
import { chalk } from "../compiled";
|
3
3
|
import { isDev, isSingleEntry } from "./is";
|
4
4
|
import { DEFAULT_DEV_HOST } from "./constants";
|
5
5
|
const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
6
|
-
|
6
|
+
const getIpv4Interfaces = () => {
|
7
7
|
const interfaces = os.networkInterfaces();
|
8
8
|
const ipv4Interfaces = [];
|
9
9
|
Object.keys(interfaces).forEach((key) => {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { findExists } from "./
|
1
|
+
import { findExists } from "./fs";
|
2
2
|
export const compatRequire = (filePath, interop = true) => {
|
3
3
|
const mod = require(filePath);
|
4
4
|
const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
|
@@ -33,3 +33,20 @@ export function deleteRequireCache(path) {
|
|
33
33
|
module.children = module.children.filter((item) => item.filename !== path);
|
34
34
|
}
|
35
35
|
}
|
36
|
+
export const tryResolve = (name, resolvePath) => {
|
37
|
+
let filePath = "";
|
38
|
+
try {
|
39
|
+
filePath = require.resolve(name, {
|
40
|
+
paths: [
|
41
|
+
resolvePath
|
42
|
+
]
|
43
|
+
});
|
44
|
+
delete require.cache[filePath];
|
45
|
+
} catch (err) {
|
46
|
+
if (err.code === "MODULE_NOT_FOUND") {
|
47
|
+
throw new Error(`Can not find module ${name}.`);
|
48
|
+
}
|
49
|
+
throw err;
|
50
|
+
}
|
51
|
+
return filePath;
|
52
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import path from "path";
|
2
|
-
import { normalizeToPosixPath } from "./path";
|
3
2
|
import { MAIN_ENTRY_NAME } from "./constants";
|
4
|
-
|
3
|
+
import { normalizeToPosixPath } from "./path";
|
4
|
+
const getPathWithoutExt = (filename) => {
|
5
5
|
const extname = path.extname(filename);
|
6
6
|
return filename.slice(0, -extname.length);
|
7
7
|
};
|
package/dist/esm/index.js
CHANGED
@@ -1,44 +1,3 @@
|
|
1
1
|
export * from "./compiled";
|
2
|
-
export * from "./
|
3
|
-
export * from "./FileSizeReporter";
|
4
|
-
export * from "./printBuildError";
|
5
|
-
export * from "./debug";
|
6
|
-
export * from "./findExists";
|
7
|
-
export * from "./is";
|
8
|
-
export * from "./compatRequire";
|
9
|
-
export * from "./logger";
|
10
|
-
export * from "./constants";
|
11
|
-
export * from "./ensureArray";
|
12
|
-
export * from "./ensureAbsolutePath";
|
13
|
-
export * from "./clearConsole";
|
14
|
-
export * from "./applyOptionsChain";
|
15
|
-
export * from "./getBrowserslist";
|
16
|
-
export * from "./removeSlash";
|
17
|
-
export * from "./getEntryOptions";
|
18
|
-
export * from "./getPort";
|
19
|
-
export * from "./monorepo";
|
20
|
-
export * from "./getPackageManager";
|
21
|
-
export * from "./runtimeExports";
|
22
|
-
export * from "./readTsConfig";
|
23
|
-
export * from "./path";
|
24
|
-
export * from "./pathSerializer";
|
25
|
-
export * from "./generateMetaTags";
|
26
|
-
export * from "./prettyInstructions";
|
27
|
-
export * from "./alias";
|
2
|
+
export * from "./cli";
|
28
3
|
export * from "./import";
|
29
|
-
export * from "./watch";
|
30
|
-
export * from "./nodeEnv";
|
31
|
-
export * from "./wait";
|
32
|
-
export * from "./emptyDir";
|
33
|
-
export * from "./getServerConfig";
|
34
|
-
export * from "./resolve";
|
35
|
-
export * from "./analyzeProject";
|
36
|
-
export * from "./chainId";
|
37
|
-
export * from "./version";
|
38
|
-
export * from "./plugin";
|
39
|
-
export * from "./routes";
|
40
|
-
export * from "./testUtils";
|
41
|
-
export * from "./getCoreJsVersion";
|
42
|
-
export * from "./react";
|
43
|
-
export * from "./getTargetDir";
|
44
|
-
export * from "./babel";
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
1
|
+
export type Falsy = false | null | undefined | 0 | '';
|
2
2
|
export declare function applyOptionsChain<T, U>(defaults: T, options?: T | ((config: T, utils?: U) => T | void) | Array<T | ((config: T, utils?: U) => T | void)> | Falsy, utils?: U, mergeFn?: typeof Object.assign): T;
|
3
3
|
export declare function applyOptionsChain<T, U>(defaults: T, options: T | ((config: T, utils: U) => T | void) | Array<T | ((config: T, utils: U) => T | void)> | Falsy, utils: U, mergeFn?: typeof Object.assign): T;
|
@@ -3,4 +3,6 @@
|
|
3
3
|
* @param scope - Custom module name of your debug function.
|
4
4
|
* @returns Debug function which namespace start with modern-js:.
|
5
5
|
*/
|
6
|
-
export declare const createDebugger: (scope: string) => import("
|
6
|
+
export declare const createDebugger: (scope: string) => import("../../compiled/debug").Debugger;
|
7
|
+
export declare const clearConsole: () => void;
|
8
|
+
export declare const wait: (time?: number) => Promise<unknown>;
|
@@ -9,11 +9,6 @@ export declare const ROUTE_SPEC_FILE = "route.json";
|
|
9
9
|
*/
|
10
10
|
|
11
11
|
export declare const MAIN_ENTRY_NAME = "main";
|
12
|
-
/**
|
13
|
-
* open editor request path
|
14
|
-
*/
|
15
|
-
|
16
|
-
export declare const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
|
17
12
|
/**
|
18
13
|
* server side bundles directory, which relative to dist.
|
19
14
|
*/
|
@@ -245,4 +240,5 @@ export declare const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: {
|
|
245
240
|
allowDeclareFields: boolean;
|
246
241
|
optimizeConstEnums: boolean;
|
247
242
|
isTSX: boolean;
|
248
|
-
};
|
243
|
+
};
|
244
|
+
export * from './chainId';
|
@@ -4,4 +4,5 @@
|
|
4
4
|
* @param filePath - Absolute or relative file path.
|
5
5
|
* @returns Resolved absolute file path.
|
6
6
|
*/
|
7
|
-
export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
|
7
|
+
export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
|
8
|
+
export declare const ensureArray: <T>(params: T | T[]) => T[];
|
@@ -3,4 +3,5 @@
|
|
3
3
|
* @param files - Absolute file paths with extension.
|
4
4
|
* @returns The file path if exists, or false if no file exists.
|
5
5
|
*/
|
6
|
-
export declare const findExists: (files: string[]) => string | false;
|
6
|
+
export declare const findExists: (files: string[]) => string | false;
|
7
|
+
export declare const emptyDir: (dir: string) => Promise<void>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { InternalPlugins } from '@modern-js/types';
|
2
|
+
export declare function getPackageManager(cwd?: string): Promise<"pnpm" | "npm" | "yarn">;
|
3
|
+
export declare const getCoreJsVersion: (corejsPkgPath: string) => string;
|
4
|
+
export declare const getAntdMajorVersion: (appDirectory: string) => number | null;
|
5
|
+
export declare const defaults: string[];
|
6
|
+
export declare const getBrowserslist: (appDirectory: string) => string[];
|
7
|
+
export declare function getInternalPlugins(appDirectory: string, internalPlugins?: InternalPlugins): string[];
|
8
|
+
export declare const readTsConfig: (root: string) => any;
|
9
|
+
export declare const readTsConfigByFile: (filename: string) => any;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export * from './constants';
|
2
|
+
export * from './get';
|
3
|
+
export * from './is';
|
4
|
+
export * from './alias';
|
5
|
+
export * from './applyOptionsChain';
|
6
|
+
export * from './babel';
|
7
|
+
export * from './commands';
|
8
|
+
export * from './common';
|
9
|
+
export * from './ensure';
|
10
|
+
export * from './fs';
|
11
|
+
export * from './generateMetaTags';
|
12
|
+
export * from './logger';
|
13
|
+
export * from './monorepo';
|
14
|
+
export * from './package';
|
15
|
+
export * from './path';
|
16
|
+
export * from './pathSerializer';
|
17
|
+
export * from './port';
|
18
|
+
export * from './prettyInstructions';
|
19
|
+
export * from './print';
|
20
|
+
export * from './require';
|
21
|
+
export * from './routes';
|
22
|
+
export * from './runtimeExports';
|
23
|
+
export * from './test';
|
24
|
+
export * from './watch';
|
@@ -0,0 +1,30 @@
|
|
1
|
+
interface EntryPoint {
|
2
|
+
entryName: string;
|
3
|
+
}
|
4
|
+
/**
|
5
|
+
* Is SSR project
|
6
|
+
*
|
7
|
+
* @param config - User config.
|
8
|
+
* @returns Whether to use server side render.
|
9
|
+
*/
|
10
|
+
|
11
|
+
export declare const isSSR: (config: any) => boolean;
|
12
|
+
export declare const isUseSSRBundle: (config: any) => boolean;
|
13
|
+
/**
|
14
|
+
* Is Worker project
|
15
|
+
*
|
16
|
+
* @param config - User config.
|
17
|
+
* @returns Whether to use worker deploy.
|
18
|
+
*/
|
19
|
+
|
20
|
+
export declare const isServiceWorker: (config: any) => boolean;
|
21
|
+
export declare const isRouterV5: (config: {
|
22
|
+
runtime?: {
|
23
|
+
router?: {
|
24
|
+
mode?: string;
|
25
|
+
} | boolean;
|
26
|
+
};
|
27
|
+
}) => boolean;
|
28
|
+
export declare const isSSGEntry: (config: any, entryName: string, entrypoints: EntryPoint[]) => boolean;
|
29
|
+
export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
|
30
|
+
export {};
|
@@ -5,4 +5,5 @@ 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 isProdProfile: () => boolean;
|
8
|
+
export declare const isProdProfile: () => boolean;
|
9
|
+
export declare const isFastRefresh: () => boolean;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/**
|
2
|
+
* Check if the package name is in dependencies or devDependencies.
|
3
|
+
*
|
4
|
+
* @param appDirectory - Project root directory.
|
5
|
+
* @param name - Package name.
|
6
|
+
* @returns True if the name is in dependencies or devDependencies, false otherwise.
|
7
|
+
*/
|
8
|
+
export declare const isDepExists: (appDirectory: string, name: string) => boolean;
|
9
|
+
/**
|
10
|
+
* Try to resolve npm package, return true if package is installed.
|
11
|
+
*/
|
12
|
+
|
13
|
+
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
14
|
+
export declare const isApiOnly: (appDirectory: string, entryDir?: string) => Promise<boolean>;
|
15
|
+
export declare const isWebOnly: () => Promise<boolean>;
|
16
|
+
export declare const isBeyondReact17: (cwd: string) => boolean;
|
17
|
+
export declare const isReact18: (cwd: string) => boolean;
|
18
|
+
/**
|
19
|
+
* Is typescript project.
|
20
|
+
*
|
21
|
+
* @param root - App directory.
|
22
|
+
* @returns Whether to use typescript.
|
23
|
+
*/
|
24
|
+
|
25
|
+
export declare const isTypescript: (root: string) => boolean;
|
@@ -5,4 +5,12 @@ export declare function isFunction(func: any): func is Function;
|
|
5
5
|
export declare function isObject(obj: unknown): obj is Record<string, any>;
|
6
6
|
export declare function isPlainObject(obj: unknown): obj is Record<string, any>;
|
7
7
|
export declare function isPromise(obj: any): obj is Promise<any>;
|
8
|
-
export declare function isRegExp(obj: any): obj is RegExp;
|
8
|
+
export declare function isRegExp(obj: any): obj is RegExp;
|
9
|
+
/**
|
10
|
+
* Is Empty object
|
11
|
+
*
|
12
|
+
* @param o - Any object.
|
13
|
+
* @returns Whether it is empty object.
|
14
|
+
*/
|
15
|
+
|
16
|
+
export declare const isEmpty: (o: Record<string, unknown>) => boolean;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { lodash as _ } from '
|
1
|
+
import { lodash as _ } from '../compiled';
|
2
2
|
export declare const isPathString: (test: string) => boolean;
|
3
3
|
export declare const isRelativePath: (test: string) => boolean;
|
4
4
|
export declare const normalizeOutputPath: (s: string) => string;
|
@@ -15,4 +15,7 @@ export declare function compilePathMatcherRegExp(match: string | RegExp): RegExp
|
|
15
15
|
export declare const _joinPathParts: (_part: unknown, i: number, parts: _.List<string>) => string;
|
16
16
|
export declare function upwardPaths(start: string): string[];
|
17
17
|
export declare function getRealTemporaryDirectory(): string | null;
|
18
|
-
export declare function splitPathString(str: string): string[];
|
18
|
+
export declare function splitPathString(str: string): string[];
|
19
|
+
export declare const removeLeadingSlash: (s: string) => string;
|
20
|
+
export declare const removeTailSlash: (s: string) => string;
|
21
|
+
export declare const removeSlash: (s: string) => string;
|
@@ -10,4 +10,12 @@ export declare const requireExistModule: (filename: string, opt?: {
|
|
10
10
|
interop?: boolean;
|
11
11
|
}) => any;
|
12
12
|
export declare const cleanRequireCache: (filelist: string[]) => void;
|
13
|
-
export declare function deleteRequireCache(path: string): void;
|
13
|
+
export declare function deleteRequireCache(path: string): void;
|
14
|
+
/**
|
15
|
+
* Try to resolve npm package entry file path.
|
16
|
+
* @param name - Package name.
|
17
|
+
* @param resolvePath - Path to resolve dependencies.
|
18
|
+
* @returns Resolved file path.
|
19
|
+
*/
|
20
|
+
|
21
|
+
export declare const tryResolve: (name: string, resolvePath: string) => string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getRouteId: (componentPath: string, routesDir: string, entryName: string) => string;
|
@@ -4,5 +4,5 @@ type RunTaskType = (option: {
|
|
4
4
|
changedFilePath: string;
|
5
5
|
changeType: WatchChangeTypeValueT;
|
6
6
|
}) => void | Promise<void>;
|
7
|
-
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("
|
7
|
+
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("../compiled").FSWatcher;
|
8
8
|
export {};
|
package/dist/types/index.d.ts
CHANGED
@@ -1,44 +1,3 @@
|
|
1
1
|
export * from './compiled';
|
2
|
-
export * from './
|
3
|
-
export * from './
|
4
|
-
export * from './printBuildError';
|
5
|
-
export * from './debug';
|
6
|
-
export * from './findExists';
|
7
|
-
export * from './is';
|
8
|
-
export * from './compatRequire';
|
9
|
-
export * from './logger';
|
10
|
-
export * from './constants';
|
11
|
-
export * from './ensureArray';
|
12
|
-
export * from './ensureAbsolutePath';
|
13
|
-
export * from './clearConsole';
|
14
|
-
export * from './applyOptionsChain';
|
15
|
-
export * from './getBrowserslist';
|
16
|
-
export * from './removeSlash';
|
17
|
-
export * from './getEntryOptions';
|
18
|
-
export * from './getPort';
|
19
|
-
export * from './monorepo';
|
20
|
-
export * from './getPackageManager';
|
21
|
-
export * from './runtimeExports';
|
22
|
-
export * from './readTsConfig';
|
23
|
-
export * from './path';
|
24
|
-
export * from './pathSerializer';
|
25
|
-
export * from './generateMetaTags';
|
26
|
-
export * from './prettyInstructions';
|
27
|
-
export * from './alias';
|
28
|
-
export * from './import';
|
29
|
-
export * from './watch';
|
30
|
-
export * from './nodeEnv';
|
31
|
-
export * from './wait';
|
32
|
-
export * from './emptyDir';
|
33
|
-
export * from './getServerConfig';
|
34
|
-
export * from './resolve';
|
35
|
-
export * from './analyzeProject';
|
36
|
-
export * from './chainId';
|
37
|
-
export * from './version';
|
38
|
-
export * from './plugin';
|
39
|
-
export * from './routes';
|
40
|
-
export * from './testUtils';
|
41
|
-
export * from './getCoreJsVersion';
|
42
|
-
export * from './react';
|
43
|
-
export * from './getTargetDir';
|
44
|
-
export * from './babel';
|
2
|
+
export * from './cli';
|
3
|
+
export * from './import';
|
@@ -5,4 +5,5 @@
|
|
5
5
|
*/
|
6
6
|
import type { IncomingHttpHeaders } from 'http';
|
7
7
|
declare const run: <O>(context: IncomingHttpHeaders, cb: () => O | Promise<O>) => Promise<O>, useHeaders: () => IncomingHttpHeaders;
|
8
|
-
export { run, useHeaders };
|
8
|
+
export { run, useHeaders };
|
9
|
+
export { serializeJson } from './serialize';
|