@modern-js/utils 1.3.8-canary.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +3 -4
  3. package/dist/js/modern/monorepo.js +0 -83
  4. package/dist/js/node/monorepo.js +0 -116
  5. package/dist/js/treeshaking/monorepo.js +0 -96
  6. package/dist/pkgUp.d.ts +0 -2
  7. package/dist/pkgUp.js +0 -8
  8. package/dist/types/FileSizeReporter.d.ts +0 -16
  9. package/dist/types/alias.d.ts +0 -21
  10. package/dist/types/applyOptionsChain.d.ts +0 -6
  11. package/dist/types/clearConsole.d.ts +0 -1
  12. package/dist/types/compatRequire.d.ts +0 -8
  13. package/dist/types/compiled.d.ts +0 -17
  14. package/dist/types/constants.d.ts +0 -222
  15. package/dist/types/debug.d.ts +0 -6
  16. package/dist/types/emptyDir.d.ts +0 -1
  17. package/dist/types/ensureAbsolutePath.d.ts +0 -7
  18. package/dist/types/findExists.d.ts +0 -6
  19. package/dist/types/format.d.ts +0 -16
  20. package/dist/types/generateMetaTags.d.ts +0 -16
  21. package/dist/types/getBrowserslist.d.ts +0 -2
  22. package/dist/types/getCacheIdentifier.d.ts +0 -7
  23. package/dist/types/getEntryOptions.d.ts +0 -1
  24. package/dist/types/getPackageManager.d.ts +0 -1
  25. package/dist/types/getPort.d.ts +0 -7
  26. package/dist/types/getServerConfig.d.ts +0 -1
  27. package/dist/types/import.d.ts +0 -5
  28. package/dist/types/index.d.ts +0 -32
  29. package/dist/types/is/index.d.ts +0 -34
  30. package/dist/types/is/node-env.d.ts +0 -4
  31. package/dist/types/is/platform.d.ts +0 -2
  32. package/dist/types/is/type.d.ts +0 -8
  33. package/dist/types/logger.d.ts +0 -63
  34. package/dist/types/monorepo.d.ts +0 -11
  35. package/dist/types/nodeEnv.d.ts +0 -3
  36. package/dist/types/path.d.ts +0 -3
  37. package/dist/types/prettyInstructions.d.ts +0 -6
  38. package/dist/types/printBuildError.d.ts +0 -8
  39. package/dist/types/readTsConfig.d.ts +0 -2
  40. package/dist/types/removeSlash.d.ts +0 -3
  41. package/dist/types/runtimeExports.d.ts +0 -4
  42. package/dist/types/wait.d.ts +0 -2
  43. package/dist/types/watch.d.ts +0 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6800be3b: feat: move storage from plugin-ssr to utils
8
+
9
+ ## 1.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 77ff9754: feat: prebundle some deps (chalk, filesize, import-lazy, strip-ansi)
14
+ - d2d1d6b2: feat: support server config
15
+
16
+ ### Patch Changes
17
+
18
+ - 07a4887e: feat: prebundle commander and signale to @modern-js/utils
19
+ - ea2ae711: feat: prebundle dependencies, reduce install size
20
+ - 17d0cc46: feat: prebundle lodash to @modern-js/utils/lodash
21
+ - d2d1d6b2: feat: add prepare hook
22
+
3
23
  ## 1.3.7
4
24
 
5
25
  ### Patch Changes
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.8-canary.0",
14
+ "version": "1.4.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -60,7 +60,7 @@
60
60
  "typescript": "^4"
61
61
  },
62
62
  "devDependencies": {
63
- "@modern-js/types": "^1.3.6",
63
+ "@modern-js/types": "^1.4.0",
64
64
  "@scripts/build": "0.0.0",
65
65
  "@scripts/jest-config": "0.0.0",
66
66
  "@types/debug": "4.1.7",
@@ -96,8 +96,7 @@
96
96
  "sideEffects": false,
97
97
  "publishConfig": {
98
98
  "registry": "https://registry.npmjs.org/",
99
- "access": "public",
100
- "types": "./dist/index.d.ts"
99
+ "access": "public"
101
100
  },
102
101
  "scripts": {
103
102
  "new": "modern new",
@@ -1,83 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
- import fs from 'fs';
8
- import path from 'path';
9
- import { glob, yaml } from "./compiled";
10
- const PACKAGE_MAX_DEPTH = 5;
11
- const WOKRSPACES_FILES = {
12
- YARN: 'package.json',
13
- PNPM: 'pnpm-workspaces.yaml',
14
- LERNA: 'lerna.json'
15
- };
16
- export const isLerna = root => fs.existsSync(path.join(root, WOKRSPACES_FILES.LERNA));
17
- export const isYarnWorkspaces = root => {
18
- var _json$workspaces;
19
-
20
- const pkg = path.join(root, WOKRSPACES_FILES.YARN);
21
-
22
- if (!fs.existsSync(pkg)) {
23
- return false;
24
- }
25
-
26
- const json = JSON.parse(fs.readFileSync(pkg, 'utf8'));
27
- return Boolean((_json$workspaces = json.workspaces) === null || _json$workspaces === void 0 ? void 0 : _json$workspaces.packages);
28
- };
29
- export const isPnpmWorkspaces = root => fs.existsSync(path.join(root, WOKRSPACES_FILES.PNPM));
30
- export const isMonorepo = root => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
31
- export const isModernjsMonorepo = root => {
32
- const json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
33
-
34
- const deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
35
-
36
- return Boolean(deps['@modern-js/monorepo-tools']);
37
- };
38
- export const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
39
- let inMonorepo = false;
40
-
41
- for (let depth = 0; depth < maxDepth; depth++) {
42
- if (isMonorepo(appDirectory)) {
43
- inMonorepo = true;
44
- break;
45
- } // eslint-d isable-next-line no-param-reassign
46
-
47
-
48
- appDirectory = path.dirname(appDirectory);
49
- }
50
-
51
- return inMonorepo ? appDirectory : undefined;
52
- };
53
- export const getMonorepoPackages = root => {
54
- let packages = [];
55
-
56
- if (isYarnWorkspaces(root)) {
57
- const json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
58
- ({
59
- packages
60
- } = json.workspaces);
61
- } else if (isLerna(root)) {
62
- const json = JSON.parse(fs.readFileSync(path.resolve(root, 'lerna.json'), 'utf8'));
63
- ({
64
- packages
65
- } = json);
66
- } else {
67
- ({
68
- packages
69
- } = yaml.load(fs.readFileSync(path.join(root, WOKRSPACES_FILES.PNPM), 'utf8')));
70
- }
71
-
72
- if (packages) {
73
- return packages.map(name => // The trailing / ensures only dirs are picked up
74
- glob.sync(path.join(root, `${name}/`), {
75
- ignore: ['**/node_modules/**']
76
- })).reduce((acc, val) => acc.concat(val), []).filter(filepath => fs.existsSync(path.resolve(filepath, 'package.json'))).map(filepath => ({
77
- path: filepath,
78
- name: JSON.parse(fs.readFileSync(path.resolve(filepath, 'package.json'), 'utf8')).name
79
- }));
80
- }
81
-
82
- return [];
83
- };
@@ -1,116 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isYarnWorkspaces = exports.isPnpmWorkspaces = exports.isMonorepo = exports.isModernjsMonorepo = exports.isLerna = exports.getMonorepoPackages = exports.findMonorepoRoot = void 0;
7
-
8
- var _fs = _interopRequireDefault(require("fs"));
9
-
10
- var _path = _interopRequireDefault(require("path"));
11
-
12
- var _compiled = require("./compiled");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
-
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
- const PACKAGE_MAX_DEPTH = 5;
23
- const WOKRSPACES_FILES = {
24
- YARN: 'package.json',
25
- PNPM: 'pnpm-workspaces.yaml',
26
- LERNA: 'lerna.json'
27
- };
28
-
29
- const isLerna = root => _fs.default.existsSync(_path.default.join(root, WOKRSPACES_FILES.LERNA));
30
-
31
- exports.isLerna = isLerna;
32
-
33
- const isYarnWorkspaces = root => {
34
- var _json$workspaces;
35
-
36
- const pkg = _path.default.join(root, WOKRSPACES_FILES.YARN);
37
-
38
- if (!_fs.default.existsSync(pkg)) {
39
- return false;
40
- }
41
-
42
- const json = JSON.parse(_fs.default.readFileSync(pkg, 'utf8'));
43
- return Boolean((_json$workspaces = json.workspaces) === null || _json$workspaces === void 0 ? void 0 : _json$workspaces.packages);
44
- };
45
-
46
- exports.isYarnWorkspaces = isYarnWorkspaces;
47
-
48
- const isPnpmWorkspaces = root => _fs.default.existsSync(_path.default.join(root, WOKRSPACES_FILES.PNPM));
49
-
50
- exports.isPnpmWorkspaces = isPnpmWorkspaces;
51
-
52
- const isMonorepo = root => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
53
-
54
- exports.isMonorepo = isMonorepo;
55
-
56
- const isModernjsMonorepo = root => {
57
- const json = JSON.parse(_fs.default.readFileSync(_path.default.join(root, 'package.json'), 'utf8'));
58
-
59
- const deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
60
-
61
- return Boolean(deps['@modern-js/monorepo-tools']);
62
- };
63
-
64
- exports.isModernjsMonorepo = isModernjsMonorepo;
65
-
66
- const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
67
- let inMonorepo = false;
68
-
69
- for (let depth = 0; depth < maxDepth; depth++) {
70
- if (isMonorepo(appDirectory)) {
71
- inMonorepo = true;
72
- break;
73
- } // eslint-d isable-next-line no-param-reassign
74
-
75
-
76
- appDirectory = _path.default.dirname(appDirectory);
77
- }
78
-
79
- return inMonorepo ? appDirectory : undefined;
80
- };
81
-
82
- exports.findMonorepoRoot = findMonorepoRoot;
83
-
84
- const getMonorepoPackages = root => {
85
- let packages = [];
86
-
87
- if (isYarnWorkspaces(root)) {
88
- const json = JSON.parse(_fs.default.readFileSync(_path.default.join(root, 'package.json'), 'utf8'));
89
- ({
90
- packages
91
- } = json.workspaces);
92
- } else if (isLerna(root)) {
93
- const json = JSON.parse(_fs.default.readFileSync(_path.default.resolve(root, 'lerna.json'), 'utf8'));
94
- ({
95
- packages
96
- } = json);
97
- } else {
98
- ({
99
- packages
100
- } = _compiled.yaml.load(_fs.default.readFileSync(_path.default.join(root, WOKRSPACES_FILES.PNPM), 'utf8')));
101
- }
102
-
103
- if (packages) {
104
- return packages.map(name => // The trailing / ensures only dirs are picked up
105
- _compiled.glob.sync(_path.default.join(root, `${name}/`), {
106
- ignore: ['**/node_modules/**']
107
- })).reduce((acc, val) => acc.concat(val), []).filter(filepath => _fs.default.existsSync(_path.default.resolve(filepath, 'package.json'))).map(filepath => ({
108
- path: filepath,
109
- name: JSON.parse(_fs.default.readFileSync(_path.default.resolve(filepath, 'package.json'), 'utf8')).name
110
- }));
111
- }
112
-
113
- return [];
114
- };
115
-
116
- exports.getMonorepoPackages = getMonorepoPackages;
@@ -1,96 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
- import fs from 'fs';
8
- import path from 'path';
9
- import { glob, yaml } from "./compiled";
10
- var PACKAGE_MAX_DEPTH = 5;
11
- var WOKRSPACES_FILES = {
12
- YARN: 'package.json',
13
- PNPM: 'pnpm-workspaces.yaml',
14
- LERNA: 'lerna.json'
15
- };
16
- export var isLerna = function isLerna(root) {
17
- return fs.existsSync(path.join(root, WOKRSPACES_FILES.LERNA));
18
- };
19
- export var isYarnWorkspaces = function isYarnWorkspaces(root) {
20
- var _json$workspaces;
21
-
22
- var pkg = path.join(root, WOKRSPACES_FILES.YARN);
23
-
24
- if (!fs.existsSync(pkg)) {
25
- return false;
26
- }
27
-
28
- var json = JSON.parse(fs.readFileSync(pkg, 'utf8'));
29
- return Boolean((_json$workspaces = json.workspaces) === null || _json$workspaces === void 0 ? void 0 : _json$workspaces.packages);
30
- };
31
- export var isPnpmWorkspaces = function isPnpmWorkspaces(root) {
32
- return fs.existsSync(path.join(root, WOKRSPACES_FILES.PNPM));
33
- };
34
- export var isMonorepo = function isMonorepo(root) {
35
- return isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
36
- };
37
- export var isModernjsMonorepo = function isModernjsMonorepo(root) {
38
- var json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
39
-
40
- var deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
41
-
42
- return Boolean(deps['@modern-js/monorepo-tools']);
43
- };
44
- export var findMonorepoRoot = function findMonorepoRoot(appDirectory) {
45
- var maxDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PACKAGE_MAX_DEPTH;
46
- var inMonorepo = false;
47
-
48
- for (var depth = 0; depth < maxDepth; depth++) {
49
- if (isMonorepo(appDirectory)) {
50
- inMonorepo = true;
51
- break;
52
- } // eslint-d isable-next-line no-param-reassign
53
-
54
-
55
- appDirectory = path.dirname(appDirectory);
56
- }
57
-
58
- return inMonorepo ? appDirectory : undefined;
59
- };
60
- export var getMonorepoPackages = function getMonorepoPackages(root) {
61
- var packages = [];
62
-
63
- if (isYarnWorkspaces(root)) {
64
- var json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
65
- packages = json.workspaces.packages;
66
- } else if (isLerna(root)) {
67
- var _json = JSON.parse(fs.readFileSync(path.resolve(root, 'lerna.json'), 'utf8'));
68
-
69
- packages = _json.packages;
70
- } else {
71
- var _ref = yaml.load(fs.readFileSync(path.join(root, WOKRSPACES_FILES.PNPM), 'utf8'));
72
-
73
- packages = _ref.packages;
74
- }
75
-
76
- if (packages) {
77
- return packages.map(function (name) {
78
- return (// The trailing / ensures only dirs are picked up
79
- glob.sync(path.join(root, "".concat(name, "/")), {
80
- ignore: ['**/node_modules/**']
81
- })
82
- );
83
- }).reduce(function (acc, val) {
84
- return acc.concat(val);
85
- }, []).filter(function (filepath) {
86
- return fs.existsSync(path.resolve(filepath, 'package.json'));
87
- }).map(function (filepath) {
88
- return {
89
- path: filepath,
90
- name: JSON.parse(fs.readFileSync(path.resolve(filepath, 'package.json'), 'utf8')).name
91
- };
92
- });
93
- }
94
-
95
- return [];
96
- };
package/dist/pkgUp.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import pkgUp from 'pkg-up';
2
- export { pkgUp };
package/dist/pkgUp.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.pkgUp = void 0;
7
- const pkg_up_1 = __importDefault(require("pkg-up"));
8
- exports.pkgUp = pkg_up_1.default;
@@ -1,16 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file at
6
- * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
- */
8
- declare function printFileSizesAfterBuild(webpackStats: any, previousSizeMap: {
9
- root: string;
10
- sizes: Record<string, number[]>;
11
- }, buildFolder: string, maxBundleGzipSize: number, maxChunkGzipSize: number): void;
12
- declare function measureFileSizesBeforeBuild(buildFolder: string): Promise<{
13
- root: string;
14
- sizes: Record<string, number[]>;
15
- }>;
16
- export { measureFileSizesBeforeBuild, printFileSizesAfterBuild };
@@ -1,21 +0,0 @@
1
- declare type AliasOption = Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>) | Record<string, string> | undefined;
2
- interface NormalizedConfig {
3
- source: {
4
- alias?: AliasOption | Array<AliasOption>;
5
- };
6
- }
7
- interface IAliasConfig {
8
- absoluteBaseUrl: string;
9
- paths?: Record<string, string | string[]>;
10
- isTsPath?: boolean;
11
- isTsProject?: boolean;
12
- }
13
- export declare const validAlias: <T extends NormalizedConfig>(modernConfig: T, { tsconfigPath }: {
14
- tsconfigPath: string;
15
- }) => string | null;
16
- export declare const getAlias: (aliasOption: AliasOption | Array<AliasOption>, option: {
17
- appDirectory: string;
18
- tsconfigPath: string;
19
- }) => IAliasConfig;
20
- export declare const getUserAlias: (alias?: Record<string, string | string[]>) => Record<string, string | string[]>;
21
- export {};
@@ -1,6 +0,0 @@
1
- export declare const applyOptionsChain: <T, U>(defaults: T, options?: T | (T | ((config: T, utils?: U | undefined) => void | T))[] | ((config: T, utils?: U | undefined) => void | T) | undefined, utils?: U | undefined, mergeFn?: {
2
- <T_1, U_1>(target: T_1, source: U_1): T_1 & U_1;
3
- <T_2, U_2, V>(target: T_2, source1: U_2, source2: V): T_2 & U_2 & V;
4
- <T_3, U_3, V_1, W>(target: T_3, source1: U_3, source2: V_1, source3: W): T_3 & U_3 & V_1 & W;
5
- (target: object, ...sources: any[]): any;
6
- }) => T;
@@ -1 +0,0 @@
1
- export declare const clearConsole: () => void;
@@ -1,8 +0,0 @@
1
- /**
2
- * Require function compatible with esm and cjs module.
3
- * @param filePath - File to required.
4
- * @returns module export object.
5
- */
6
- export declare const compatRequire: (filePath: string) => any;
7
- export declare const requireExistModule: (filename: string, extensions?: string[]) => any;
8
- export declare const cleanRequireCache: (filelist: string[]) => void;
@@ -1,17 +0,0 @@
1
- import fs from '../compiled/fs-extra';
2
- import chalk from '../compiled/chalk';
3
- export { fs, chalk };
4
- export type { IOptions as GlobOptions } from '../compiled/glob';
5
- export type { FSWatcher, WatchOptions } from '../compiled/chokidar';
6
- export declare const glob: typeof import('../compiled/glob');
7
- export declare const yaml: typeof import('../compiled/js-yaml');
8
- export declare const execa: typeof import('../compiled/execa');
9
- export declare const pkgUp: typeof import('../compiled/pkg-up');
10
- export declare const upath: typeof import('../compiled/upath');
11
- export declare const debug: typeof import('../compiled/debug');
12
- export declare const chokidar: typeof import('../compiled/chokidar');
13
- export declare const gzipSize: typeof import('../compiled/gzip-size');
14
- export declare const filesize: typeof import('../compiled/filesize');
15
- export declare const stripAnsi: typeof import('../compiled/strip-ansi');
16
- export declare const browserslist: typeof import('../compiled/browserslist');
17
- export declare const recursiveReaddir: typeof import('../compiled/recursive-readdir');
@@ -1,222 +0,0 @@
1
- /**
2
- * hmr socket connect path
3
- */
4
- export declare const HMR_SOCK_PATH = "/_modern_js_hmr_ws";
5
- /**
6
- * route specification file
7
- */
8
- export declare const ROUTE_SPEC_FILE = "route.json";
9
- /**
10
- * main entry name
11
- */
12
- export declare const MAIN_ENTRY_NAME = "main";
13
- /**
14
- * open editor request path
15
- */
16
- export declare const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
17
- /**
18
- * server side bundles directory, which relative to dist.
19
- */
20
- export declare const SERVER_BUNDLE_DIRECTORY = "bundles";
21
- /**
22
- * entry name pattern used for ajv pattern properties.
23
- */
24
- export declare const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
25
- /**
26
- * SSR server render function name
27
- */
28
- export declare const SERVER_RENDER_FUNCTION_NAME = "serverRender";
29
- /**
30
- * loadbale manifest json file
31
- */
32
- export declare const LOADABLE_STATS_FILE = "loadable-stats.json";
33
- /**
34
- * internal specified folder
35
- */
36
- export declare const API_DIR = "api";
37
- export declare const SERVER_DIR = "server";
38
- export declare const SHARED_DIR = "shared";
39
- /**
40
- * Modern.config.ts cached dir
41
- */
42
- export declare const CONFIG_CACHE_DIR = "./node_modules/.node-bundle-require";
43
- export declare const CONFIG_FILE_EXTENSIONS: string[];
44
- /**
45
- * Serialized config path
46
- */
47
- export declare const OUTPUT_CONFIG_FILE = "modern.config.json";
48
- /**
49
- * Default server config basename
50
- */
51
- export declare const DEFAULT_SERVER_CONFIG = "modern.server.config";
52
- /**
53
- * Internal plugins that work as soon as they are installed.
54
- */
55
- export declare const INTERNAL_PLUGINS: {
56
- [name: string]: {
57
- cli?: string;
58
- server?: string;
59
- };
60
- };
61
- /**
62
- * The schema registered in the plugin.
63
- */
64
- export declare const PLUGIN_SCHEMAS: {
65
- '@modern-js/runtime': ({
66
- target: string;
67
- schema: {
68
- type: string;
69
- additionalProperties: boolean;
70
- patternProperties?: undefined;
71
- };
72
- } | {
73
- target: string;
74
- schema: {
75
- type: string;
76
- patternProperties: {
77
- "^[a-zA-Z0-9_-]+$": {
78
- type: string;
79
- };
80
- };
81
- additionalProperties: boolean;
82
- };
83
- })[];
84
- '@modern-js/plugin-bff': {
85
- target: string;
86
- schema: {
87
- type: string;
88
- properties: {
89
- prefix: {
90
- type: string[];
91
- items: {
92
- type: string;
93
- };
94
- };
95
- fetcher: {
96
- type: string;
97
- };
98
- proxy: {
99
- type: string;
100
- };
101
- requestCreator: {
102
- type: string;
103
- };
104
- };
105
- };
106
- }[];
107
- '@modern-js/plugin-esbuild': {
108
- target: string;
109
- schema: {
110
- typeof: string[];
111
- };
112
- }[];
113
- '@modern-js/plugin-less': {
114
- target: string;
115
- schema: {
116
- typeof: string[];
117
- };
118
- }[];
119
- '@modern-js/plugin-sass': {
120
- target: string;
121
- schema: {
122
- typeof: string[];
123
- };
124
- }[];
125
- '@modern-js/plugin-tailwindcss': {
126
- target: string;
127
- schema: {
128
- typeof: string[];
129
- };
130
- }[];
131
- '@modern-js/plugin-proxy': {
132
- target: string;
133
- schema: {
134
- typeof: string[];
135
- };
136
- }[];
137
- '@modern-js/plugin-unbundle': ({
138
- target: string;
139
- schema: {
140
- type: string;
141
- properties?: undefined;
142
- };
143
- } | {
144
- target: string;
145
- schema: {
146
- type: string;
147
- properties: {
148
- ignore: {
149
- type: string[];
150
- items: {
151
- type: string;
152
- };
153
- };
154
- ignoreModuleCache: {
155
- type: string;
156
- };
157
- clearPdnCache: {
158
- type: string;
159
- };
160
- pdnHost: {
161
- type: string;
162
- };
163
- };
164
- };
165
- })[];
166
- '@modern-js/plugin-ssg': {
167
- target: string;
168
- schema: {
169
- oneOf: ({
170
- type: string;
171
- instanceof?: undefined;
172
- } | {
173
- instanceof: string;
174
- type?: undefined;
175
- })[];
176
- };
177
- }[];
178
- '@modern-js/plugin-ssr': {
179
- target: string;
180
- schema: {
181
- type: string[];
182
- };
183
- }[];
184
- '@modern-js/plugin-state': {
185
- target: string;
186
- schema: {
187
- type: string[];
188
- };
189
- }[];
190
- '@modern-js/plugin-design-token': ({
191
- target: string;
192
- schema: {
193
- typeof: string[];
194
- type?: undefined;
195
- };
196
- } | {
197
- target: string;
198
- schema: {
199
- type: string[];
200
- typeof?: undefined;
201
- };
202
- })[];
203
- '@modern-js/plugin-router': {
204
- target: string;
205
- schema: {
206
- type: string[];
207
- };
208
- }[];
209
- '@modern-js/plugin-testing': {
210
- target: string;
211
- schema: {
212
- typeof: string[];
213
- };
214
- }[];
215
- '@modern-js/plugin-garfish': {
216
- target: string;
217
- schema: {
218
- type: string[];
219
- };
220
- }[];
221
- '@modern-js/plugin-nocode': never[];
222
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * Create debug function with unified namespace prefix.
3
- * @param scope - Custom module name of your debug function.
4
- * @returns Debug function which namespace start with modern-js:.
5
- */
6
- export declare const createDebugger: (scope: string) => import("../compiled/debug").Debugger;
@@ -1 +0,0 @@
1
- export declare const emptyDir: (dir: string) => Promise<void>;
@@ -1,7 +0,0 @@
1
- /**
2
- * ensure absolute file path.
3
- * @param base - Base path to resolve relative from.
4
- * @param filePath - Aboluste or relative file path.
5
- * @returns Resolved absolute file path.
6
- */
7
- export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
@@ -1,6 +0,0 @@
1
- /**
2
- * Find first already exists file.
3
- * @param files - Asbolute file paths with extension.
4
- * @returns The file path if exists, or false if no file exists.
5
- */
6
- export declare const findExists: (files: string[]) => string | false;
@@ -1,16 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file at
6
- * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
- */
8
- import { StatsCompilation } from 'webpack';
9
- import type { ProxyDetail, BffProxyOptions } from '@modern-js/types';
10
- declare function formatWebpackMessages(json: StatsCompilation): {
11
- errors: string[];
12
- warnings: string[];
13
- };
14
- export { formatWebpackMessages };
15
- declare function formatProxyOptions(proxyOptions: BffProxyOptions): ProxyDetail[];
16
- export { formatProxyOptions };
@@ -1,16 +0,0 @@
1
- /**
2
- * Copyright JS Foundation and other contributors.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file at
6
- * https://github.com/jantimon/html-webpack-plugin/blob/main/LICENSE
7
- *
8
- * Modified from https://github.com/jantimon/html-webpack-plugin/blob/2f5de7ab9e8bca60e9e200f2e4b4cfab90db28d4/index.js#L800
9
- */
10
- export declare type MetaAttributes = {
11
- [attributeName: string]: string | boolean;
12
- };
13
- export interface MetaOptions {
14
- [name: string]: string | false | MetaAttributes;
15
- }
16
- export declare const generateMetaTags: (metaOptions?: MetaOptions | undefined) => string;
@@ -1,2 +0,0 @@
1
- export declare const defaults: string[];
2
- export declare const getBrowserslist: (appDirectory: string) => string[];
@@ -1,7 +0,0 @@
1
- /**
2
- * Generate cache identifier from some packages and config files.
3
- */
4
- export declare function getCacheIdentifier(packages: {
5
- name: string;
6
- version: string;
7
- }[], _files?: string[]): string;
@@ -1 +0,0 @@
1
- export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string | undefined) => T | undefined;
@@ -1 +0,0 @@
1
- export declare function getPackageManager(cwd?: string): Promise<"npm" | "yarn" | "pnpm">;
@@ -1,7 +0,0 @@
1
- /**
2
- * Get available free port.
3
- * @param port - Current port want to use.
4
- * @param tryLimits - Maximum number of retries.
5
- * @returns Available port number.
6
- */
7
- export declare const getPort: (port: string | number, tryLimits?: number) => Promise<number>;
@@ -1 +0,0 @@
1
- export declare const getServerConfig: (appDirectory: string, configFile: string) => Promise<string | false>;
@@ -1,5 +0,0 @@
1
- declare const lazy: (moduleName: string, requireFn: (id: string) => unknown) => any;
2
- export { lazy as lazyImport };
3
- export declare const Import: {
4
- lazy: (moduleName: string, requireFn: (id: string) => unknown) => any;
5
- };
@@ -1,32 +0,0 @@
1
- export * from './compiled';
2
- export * from './format';
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 './ensureAbsolutePath';
12
- export * from './getCacheIdentifier';
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 './generateMetaTags';
25
- export * from './prettyInstructions';
26
- export * from './alias';
27
- export * from './import';
28
- export * from './watch';
29
- export * from './nodeEnv';
30
- export * from './wait';
31
- export * from './emptyDir';
32
- export * from './getServerConfig';
@@ -1,34 +0,0 @@
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
- * Is typescript project.
11
- *
12
- * @param root - App directory.
13
- * @returns Whether to use typescript.
14
- */
15
- export declare const isTypescript: (root: string) => boolean;
16
- /**
17
- * Is Empty object
18
- *
19
- * @param o - Any object.
20
- * @returns Whether it is empty object.
21
- */
22
- export declare const isEmpty: (o: Record<string, unknown>) => boolean;
23
- /**
24
- * Is SSR project
25
- *
26
- * @param config - User config.
27
- * @returns Whether to use server side render.
28
- */
29
- export declare const isSSR: (config: any) => boolean;
30
- export declare const isUseSSRBundle: (config: any) => boolean;
31
- export declare const isFastRefresh: () => boolean;
32
- export * from './node-env';
33
- export * from './platform';
34
- export * from './type';
@@ -1,4 +0,0 @@
1
- export declare const isDev: () => boolean;
2
- export declare const isProd: () => boolean;
3
- export declare const isTest: () => boolean;
4
- export declare const isProdProfile: () => boolean;
@@ -1,2 +0,0 @@
1
- export declare const isNodeJS: () => boolean;
2
- export declare const isBrowser: () => boolean;
@@ -1,8 +0,0 @@
1
- export declare function isString(str: any): str is string;
2
- export declare function isUndefined(obj: any): obj is undefined;
3
- export declare function isArray(obj: unknown): obj is any[];
4
- export declare function isFunction(func: any): func is Function;
5
- export declare function isObject(obj: unknown): obj is Record<string, any>;
6
- export declare function isPlainObject(obj: unknown): obj is Record<string, any>;
7
- export declare function isPromise(obj: any): obj is Promise<any>;
8
- export declare function isRegExp(obj: any): obj is RegExp;
@@ -1,63 +0,0 @@
1
- import { Color } from '../compiled/chalk';
2
- declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
3
- interface LoggerConfiguration {
4
- color?: typeof Color;
5
- label?: string;
6
- level?: LogLevel;
7
- }
8
- interface InstanceConfiguration {
9
- displayLabel?: boolean;
10
- underlineLabel?: boolean;
11
- uppercaseLabel?: boolean;
12
- }
13
- interface ConstructorOptions {
14
- config?: InstanceConfiguration;
15
- types?: Record<string, LoggerConfiguration>;
16
- }
17
- declare type LoggerFunction = (message?: number | string | Error, ...args: any[]) => void;
18
- declare const LOG_TYPES: {
19
- error: {
20
- color: string;
21
- label: string;
22
- level: string;
23
- };
24
- info: {
25
- color: string;
26
- label: string;
27
- level: string;
28
- };
29
- warn: {
30
- color: string;
31
- label: string;
32
- level: string;
33
- };
34
- debug: {
35
- color: string;
36
- label: string;
37
- level: string;
38
- };
39
- log: {
40
- level: string;
41
- };
42
- };
43
- declare class Logger {
44
- private readonly logCount;
45
- private history;
46
- private readonly config;
47
- private readonly types;
48
- private readonly longestLabel;
49
- [key: string]: any;
50
- constructor(options?: ConstructorOptions);
51
- private retainLog;
52
- private _log;
53
- private getLongestLabel;
54
- private get longestUnderlinedLabel();
55
- getRetainedLogs(type: string): string[];
56
- clearRetainedLogs(type: string): void;
57
- }
58
- declare type LoggerInterface = {
59
- [key in keyof typeof LOG_TYPES]: LoggerFunction;
60
- };
61
- declare const logger: Logger & LoggerInterface;
62
- export { logger };
63
- export type { LoggerInterface };
@@ -1,11 +0,0 @@
1
- import path from 'path';
2
- export declare const isLerna: (root: string) => boolean;
3
- export declare const isYarnWorkspaces: (root: string) => boolean;
4
- export declare const isPnpmWorkspaces: (root: string) => boolean;
5
- export declare const isMonorepo: (root: string) => boolean;
6
- export declare const isModernjsMonorepo: (root: string) => boolean;
7
- export declare const findMonorepoRoot: (appDirectory: string, maxDepth?: number) => string | undefined;
8
- export declare const getMonorepoPackages: (root: string) => {
9
- name: string;
10
- path: string;
11
- }[];
@@ -1,3 +0,0 @@
1
- export declare function canUseNpm(): Promise<boolean>;
2
- export declare function canUseYarn(): Promise<boolean>;
3
- export declare function canUsePnpm(): Promise<boolean>;
@@ -1,3 +0,0 @@
1
- export declare const isRelativePath: (test: string) => boolean;
2
- export declare const normalizeOutputPath: (s: string) => string;
3
- export declare const normalizeToPosixPath: (p: string) => string;
@@ -1,6 +0,0 @@
1
- interface EntryPoint {
2
- entryName: string;
3
- }
4
- export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
5
- export declare const prettyInstructions: (appContext: any, config: any) => string;
6
- export {};
@@ -1,8 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file at
6
- * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
- */
8
- export declare function printBuildError(err: Error): void;
@@ -1,2 +0,0 @@
1
- export declare const readTsConfig: (root: string) => any;
2
- export declare const readTsConfigByFile: (filename: string) => any;
@@ -1,3 +0,0 @@
1
- export declare const removeLeadingSlash: (s: string) => string;
2
- export declare const removeTailSlash: (s: string) => string;
3
- export declare const removeSlash: (s: string) => string;
@@ -1,4 +0,0 @@
1
- export declare const createRuntimeExportsUtils: (pwd: any, namespace: string, ts?: any) => {
2
- addExport: (statement: string) => void;
3
- getPath: () => string;
4
- };
@@ -1,2 +0,0 @@
1
- declare const wait: (time?: number) => Promise<unknown>;
2
- export { wait };
@@ -1,8 +0,0 @@
1
- export declare type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
2
- export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
3
- declare type RunTaskType = (option: {
4
- changedFilePath: string;
5
- changeType: WatchChangeTypeValueT;
6
- }) => void | Promise<void>;
7
- export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("./compiled").FSWatcher;
8
- export {};