@modern-js/utils 2.18.0 → 2.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/cjs/{alias.js → cli/alias.js} +3 -3
  3. package/dist/cjs/{applyOptionsChain.js → cli/applyOptionsChain.js} +6 -5
  4. package/dist/cjs/{babel.js → cli/babel.js} +3 -3
  5. package/dist/cjs/cli/common.js +26 -0
  6. package/dist/cjs/{constants.js → cli/constants/index.js} +14 -2
  7. package/dist/cjs/{readTsConfig.js → cli/ensure.js} +10 -9
  8. package/dist/cjs/cli/fs.js +29 -0
  9. package/dist/cjs/{getEntryOptions.js → cli/get/config.js} +2 -2
  10. package/dist/cjs/cli/get/data.js +112 -0
  11. package/dist/cjs/cli/get/index.js +46 -0
  12. package/dist/cjs/cli/index.js +41 -0
  13. package/dist/cjs/{is/index.js → cli/is/config.js} +2 -43
  14. package/dist/cjs/{is/nodeEnv.js → cli/is/env.js} +3 -1
  15. package/dist/cjs/cli/is/index.js +22 -0
  16. package/dist/cjs/cli/is/project.js +92 -0
  17. package/dist/cjs/{is → cli/is}/type.js +3 -1
  18. package/dist/cjs/{logger.js → cli/logger.js} +1 -1
  19. package/dist/cjs/{monorepo.js → cli/monorepo.js} +1 -1
  20. package/dist/cjs/{nodeEnv.js → cli/package.js} +8 -1
  21. package/dist/cjs/{path.js → cli/path.js} +8 -2
  22. package/dist/cjs/{pathSerializer.js → cli/pathSerializer.js} +1 -1
  23. package/dist/cjs/{getPort.js → cli/port.js} +1 -1
  24. package/dist/cjs/{prettyInstructions.js → cli/prettyInstructions.js} +1 -2
  25. package/dist/cjs/{printBuildError.js → cli/print.js} +1 -1
  26. package/dist/cjs/{compatRequire.js → cli/require.js} +21 -3
  27. package/dist/cjs/{routes.js → cli/routes.js} +4 -11
  28. package/dist/cjs/{runtimeExports.js → cli/runtimeExports.js} +1 -1
  29. package/dist/cjs/cli/watch.js +61 -0
  30. package/dist/cjs/index.js +1 -42
  31. package/dist/cjs/runtime/router.js +19 -0
  32. package/dist/cjs/{ssr.js → runtime-node/index.js} +3 -1
  33. package/dist/esm/{alias.js → cli/alias.js} +2 -2
  34. package/dist/esm/{applyOptionsChain.js → cli/applyOptionsChain.js} +2 -1
  35. package/dist/esm/{babel.js → cli/babel.js} +1 -1
  36. package/dist/esm/cli/common.js +10 -0
  37. package/dist/esm/{constants.js → cli/constants/index.js} +1 -1
  38. package/dist/esm/{ensureAbsolutePath.js → cli/ensure.js} +8 -0
  39. package/dist/esm/{findExists.js → cli/fs.js} +6 -1
  40. package/dist/esm/{getEntryOptions.js → cli/get/config.js} +2 -2
  41. package/dist/esm/cli/get/data.js +86 -0
  42. package/dist/esm/cli/get/index.js +13 -0
  43. package/dist/esm/cli/index.js +24 -0
  44. package/dist/esm/{is/index.js → cli/is/config.js} +1 -21
  45. package/dist/esm/{is/nodeEnv.js → cli/is/env.js} +1 -0
  46. package/dist/esm/cli/is/index.js +5 -0
  47. package/dist/esm/cli/is/project.js +67 -0
  48. package/dist/esm/{is → cli/is}/type.js +1 -0
  49. package/dist/esm/{logger.js → cli/logger.js} +1 -1
  50. package/dist/esm/{monorepo.js → cli/monorepo.js} +1 -1
  51. package/dist/esm/{nodeEnv.js → cli/package.js} +7 -1
  52. package/dist/esm/{path.js → cli/path.js} +4 -1
  53. package/dist/esm/{pathSerializer.js → cli/pathSerializer.js} +1 -1
  54. package/dist/esm/{getPort.js → cli/port.js} +1 -1
  55. package/dist/esm/{prettyInstructions.js → cli/prettyInstructions.js} +2 -2
  56. package/dist/esm/{printBuildError.js → cli/print.js} +1 -1
  57. package/dist/esm/{compatRequire.js → cli/require.js} +18 -1
  58. package/dist/esm/{routes.js → cli/routes.js} +2 -2
  59. package/dist/esm/{runtimeExports.js → cli/runtimeExports.js} +1 -1
  60. package/dist/esm/{watch.js → cli/watch.js} +2 -2
  61. package/dist/esm/index.js +1 -42
  62. package/dist/esm/runtime/router.js +2 -0
  63. package/dist/esm/{ssr.js → runtime-node/index.js} +1 -0
  64. package/dist/types/{applyOptionsChain.d.ts → cli/applyOptionsChain.d.ts} +1 -1
  65. package/dist/types/{debug.d.ts → cli/common.d.ts} +3 -1
  66. package/dist/types/{constants.d.ts → cli/constants/index.d.ts} +2 -6
  67. package/dist/types/{ensureAbsolutePath.d.ts → cli/ensure.d.ts} +2 -1
  68. package/dist/types/{findExists.d.ts → cli/fs.d.ts} +2 -1
  69. package/dist/types/cli/get/data.d.ts +9 -0
  70. package/dist/types/cli/get/index.d.ts +4 -0
  71. package/dist/types/cli/index.d.ts +24 -0
  72. package/dist/types/cli/is/config.d.ts +30 -0
  73. package/dist/types/{is/nodeEnv.d.ts → cli/is/env.d.ts} +2 -1
  74. package/dist/types/cli/is/index.d.ts +5 -0
  75. package/dist/types/cli/is/project.d.ts +25 -0
  76. package/dist/types/{is → cli/is}/type.d.ts +9 -1
  77. package/dist/types/{logger.d.ts → cli/logger.d.ts} +1 -1
  78. package/dist/types/cli/package.d.ts +4 -0
  79. package/dist/types/{path.d.ts → cli/path.d.ts} +5 -2
  80. package/dist/types/{prettyInstructions.d.ts → cli/prettyInstructions.d.ts} +0 -3
  81. package/dist/types/{compatRequire.d.ts → cli/require.d.ts} +9 -1
  82. package/dist/types/cli/routes.d.ts +1 -0
  83. package/dist/types/{watch.d.ts → cli/watch.d.ts} +1 -1
  84. package/dist/types/index.d.ts +2 -43
  85. package/dist/types/runtime/router.d.ts +2 -0
  86. package/dist/types/{ssr.d.ts → runtime-node/index.d.ts} +2 -1
  87. package/package.json +55 -92
  88. package/dist/cjs/FileSizeReporter.js +0 -139
  89. package/dist/cjs/analyzeProject.js +0 -68
  90. package/dist/cjs/clearConsole.js +0 -13
  91. package/dist/cjs/debug.js +0 -10
  92. package/dist/cjs/emptyDir.js +0 -14
  93. package/dist/cjs/ensureAbsolutePath.js +0 -15
  94. package/dist/cjs/ensureArray.js +0 -16
  95. package/dist/cjs/findExists.js +0 -22
  96. package/dist/cjs/getBrowserslist.js +0 -24
  97. package/dist/cjs/getCoreJsVersion.js +0 -58
  98. package/dist/cjs/getPackageManager.js +0 -42
  99. package/dist/cjs/getServerConfig.js +0 -55
  100. package/dist/cjs/getTargetDir.js +0 -53
  101. package/dist/cjs/plugin.js +0 -28
  102. package/dist/cjs/react.js +0 -30
  103. package/dist/cjs/removeSlash.js +0 -19
  104. package/dist/cjs/resolve.js +0 -57
  105. package/dist/cjs/types.js +0 -4
  106. package/dist/cjs/version.js +0 -43
  107. package/dist/cjs/wait.js +0 -11
  108. package/dist/cjs/watch.js +0 -96
  109. package/dist/esm/FileSizeReporter.js +0 -121
  110. package/dist/esm/analyzeProject.js +0 -13
  111. package/dist/esm/clearConsole.js +0 -5
  112. package/dist/esm/debug.js +0 -2
  113. package/dist/esm/emptyDir.js +0 -6
  114. package/dist/esm/ensureArray.js +0 -8
  115. package/dist/esm/getBrowserslist.js +0 -9
  116. package/dist/esm/getCoreJsVersion.js +0 -10
  117. package/dist/esm/getPackageManager.js +0 -29
  118. package/dist/esm/getServerConfig.js +0 -7
  119. package/dist/esm/getTargetDir.js +0 -5
  120. package/dist/esm/plugin.js +0 -20
  121. package/dist/esm/react.js +0 -17
  122. package/dist/esm/readTsConfig.js +0 -9
  123. package/dist/esm/removeSlash.js +0 -3
  124. package/dist/esm/resolve.js +0 -41
  125. package/dist/esm/types.js +0 -1
  126. package/dist/esm/version.js +0 -23
  127. package/dist/esm/wait.js +0 -4
  128. package/dist/types/FileSizeReporter.d.ts +0 -16
  129. package/dist/types/analyzeProject.d.ts +0 -2
  130. package/dist/types/clearConsole.d.ts +0 -1
  131. package/dist/types/emptyDir.d.ts +0 -1
  132. package/dist/types/ensureArray.d.ts +0 -1
  133. package/dist/types/getBrowserslist.d.ts +0 -2
  134. package/dist/types/getCoreJsVersion.d.ts +0 -1
  135. package/dist/types/getPackageManager.d.ts +0 -1
  136. package/dist/types/getServerConfig.d.ts +0 -1
  137. package/dist/types/getTargetDir.d.ts +0 -1
  138. package/dist/types/is/index.d.ts +0 -58
  139. package/dist/types/nodeEnv.d.ts +0 -3
  140. package/dist/types/plugin.d.ts +0 -2
  141. package/dist/types/react.d.ts +0 -1
  142. package/dist/types/readTsConfig.d.ts +0 -2
  143. package/dist/types/removeSlash.d.ts +0 -3
  144. package/dist/types/resolve.d.ts +0 -13
  145. package/dist/types/routes.d.ts +0 -2
  146. package/dist/types/types.d.ts +0 -1
  147. package/dist/types/version.d.ts +0 -2
  148. package/dist/types/wait.d.ts +0 -2
  149. /package/dist/cjs/{commands.js → cli/commands.js} +0 -0
  150. /package/dist/cjs/{chainId.js → cli/constants/chainId.js} +0 -0
  151. /package/dist/cjs/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
  152. /package/dist/cjs/{is → cli/is}/platform.js +0 -0
  153. /package/dist/cjs/{testUtils.js → cli/test.js} +0 -0
  154. /package/dist/cjs/{universal → runtime}/nestedRoutes.js +0 -0
  155. /package/dist/cjs/{universal → runtime}/remixRouter.js +0 -0
  156. /package/dist/cjs/{runtime → runtime-browser}/index.js +0 -0
  157. /package/dist/cjs/{runtime → runtime-browser}/parsed.js +0 -0
  158. /package/dist/cjs/{universal → runtime-node}/serialize.js +0 -0
  159. /package/dist/cjs/{storage.js → runtime-node/storage.js} +0 -0
  160. /package/dist/esm/{commands.js → cli/commands.js} +0 -0
  161. /package/dist/esm/{chainId.js → cli/constants/chainId.js} +0 -0
  162. /package/dist/esm/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
  163. /package/dist/esm/{is → cli/is}/platform.js +0 -0
  164. /package/dist/esm/{testUtils.js → cli/test.js} +0 -0
  165. /package/dist/esm/{universal → runtime}/nestedRoutes.js +0 -0
  166. /package/dist/esm/{universal → runtime}/remixRouter.js +0 -0
  167. /package/dist/esm/{runtime → runtime-browser}/index.js +0 -0
  168. /package/dist/esm/{runtime → runtime-browser}/parsed.js +0 -0
  169. /package/dist/esm/{universal → runtime-node}/serialize.js +0 -0
  170. /package/dist/esm/{storage.js → runtime-node/storage.js} +0 -0
  171. /package/dist/types/{alias.d.ts → cli/alias.d.ts} +0 -0
  172. /package/dist/types/{babel.d.ts → cli/babel.d.ts} +0 -0
  173. /package/dist/types/{commands.d.ts → cli/commands.d.ts} +0 -0
  174. /package/dist/types/{chainId.d.ts → cli/constants/chainId.d.ts} +0 -0
  175. /package/dist/types/{generateMetaTags.d.ts → cli/generateMetaTags.d.ts} +0 -0
  176. /package/dist/types/{getEntryOptions.d.ts → cli/get/config.d.ts} +0 -0
  177. /package/dist/types/{is → cli/is}/platform.d.ts +0 -0
  178. /package/dist/types/{monorepo.d.ts → cli/monorepo.d.ts} +0 -0
  179. /package/dist/types/{pathSerializer.d.ts → cli/pathSerializer.d.ts} +0 -0
  180. /package/dist/types/{getPort.d.ts → cli/port.d.ts} +0 -0
  181. /package/dist/types/{printBuildError.d.ts → cli/print.d.ts} +0 -0
  182. /package/dist/types/{runtimeExports.d.ts → cli/runtimeExports.d.ts} +0 -0
  183. /package/dist/types/{testUtils.d.ts → cli/test.d.ts} +0 -0
  184. /package/dist/types/{universal → runtime}/nestedRoutes.d.ts +0 -0
  185. /package/dist/types/{universal → runtime}/remixRouter.d.ts +0 -0
  186. /package/dist/types/{runtime → runtime-browser}/index.d.ts +0 -0
  187. /package/dist/types/{runtime → runtime-browser}/parsed.d.ts +0 -0
  188. /package/dist/types/{universal → runtime-node}/serialize.d.ts +0 -0
  189. /package/dist/types/{storage.d.ts → runtime-node/storage.d.ts} +0 -0
@@ -1,4 +1,10 @@
1
- import { execa } from "./compiled";
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 "./compiled";
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 "../compiled/lodash";
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,5 +1,5 @@
1
1
  import net from "net";
2
- import { chalk } from "./compiled";
2
+ import { chalk } from "../compiled";
3
3
  import { logger } from "./logger";
4
4
  export const getPort = async (port, { tryLimits = 20, strictPort = false } = {}) => {
5
5
  if (typeof port === "string") {
@@ -1,9 +1,9 @@
1
1
  import os from "os";
2
- import { chalk } from "./compiled";
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
- export const getIpv4Interfaces = () => {
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 { chalk } from "./compiled";
1
+ import { chalk } from "../compiled";
2
2
  import { logger } from "./logger";
3
3
  export function printBuildError(err) {
4
4
  const message = err != null && err.message;
@@ -1,4 +1,4 @@
1
- import { findExists } from "./findExists";
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
- export const getPathWithoutExt = (filename) => {
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
  };
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { fs } from "./compiled";
2
+ import { fs } from "../compiled";
3
3
  import { normalizeOutputPath } from "./path";
4
4
  const memo = (fn) => {
5
5
  const cache = /* @__PURE__ */ new Map();
@@ -1,5 +1,5 @@
1
- import * as path from "path";
2
- import { chokidar } from "./compiled";
1
+ import path from "path";
2
+ import { chokidar } from "../compiled";
3
3
  export const WatchChangeType = {
4
4
  ADD: "add",
5
5
  UNLINK: "unlink",
package/dist/esm/index.js CHANGED
@@ -1,44 +1,3 @@
1
1
  export * from "./compiled";
2
- export * from "./commands";
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";
@@ -0,0 +1,2 @@
1
+ export * from "./nestedRoutes";
2
+ export * from "./remixRouter";
@@ -1,3 +1,4 @@
1
1
  import { createStorage } from "./storage";
2
2
  const { run, useContext: useHeaders } = createStorage();
3
3
  export { run, useHeaders };
4
+ export { serializeJson } from "./serialize";
@@ -1,3 +1,3 @@
1
- import type { Falsy } from './types';
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("../compiled/debug").Debugger;
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,4 @@
1
+ export declare const getServerConfig: (appDirectory: string, configFile: string) => Promise<string | false>;
2
+ export declare const getTargetDir: (from: string, baseDir: string, targetBaseDir: string) => string;
3
+ export * from './data';
4
+ export * from './config';
@@ -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,5 @@
1
+ export * from './env';
2
+ export * from './platform';
3
+ export * from './type';
4
+ export * from './config';
5
+ export * from './project';
@@ -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 { Color } from '../compiled/chalk';
1
+ import { Color } from '../../compiled/chalk';
2
2
  type LogLevel = 'debug' | 'info' | 'warn' | 'error';
3
3
  type LogMsg = number | string | Error | null;
4
4
  interface LoggerConfiguration {
@@ -0,0 +1,4 @@
1
+ export declare function getPnpmVersion(): Promise<string>;
2
+ export declare function canUseNpm(): Promise<boolean>;
3
+ export declare function canUseYarn(): Promise<boolean>;
4
+ export declare function canUsePnpm(): Promise<boolean>;
@@ -1,4 +1,4 @@
1
- import { lodash as _ } from './compiled';
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;
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- import os from 'os';
3
- export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
4
1
  export type AddressUrl = {
5
2
  label: string;
6
3
  url: 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("./compiled").FSWatcher;
7
+ export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("../compiled").FSWatcher;
8
8
  export {};
@@ -1,44 +1,3 @@
1
1
  export * from './compiled';
2
- export * from './commands';
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';
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';
@@ -0,0 +1,2 @@
1
+ export * from './nestedRoutes';
2
+ export * from './remixRouter';
@@ -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';