@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.
- package/CHANGELOG.md +2 -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 +55 -92
- 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,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getServerConfig", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: () => getServerConfig
|
|
8
|
-
});
|
|
9
|
-
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
10
|
-
const _constants = require("./constants");
|
|
11
|
-
const _findExists = require("./findExists");
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
13
|
-
if (typeof WeakMap !== "function")
|
|
14
|
-
return null;
|
|
15
|
-
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
16
|
-
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
17
|
-
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
18
|
-
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
19
|
-
})(nodeInterop);
|
|
20
|
-
}
|
|
21
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
26
|
-
return {
|
|
27
|
-
default: obj
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
|
-
if (cache && cache.has(obj)) {
|
|
32
|
-
return cache.get(obj);
|
|
33
|
-
}
|
|
34
|
-
var newObj = {};
|
|
35
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
|
-
for (var key in obj) {
|
|
37
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
38
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
39
|
-
if (desc && (desc.get || desc.set)) {
|
|
40
|
-
Object.defineProperty(newObj, key, desc);
|
|
41
|
-
} else {
|
|
42
|
-
newObj[key] = obj[key];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
newObj.default = obj;
|
|
47
|
-
if (cache) {
|
|
48
|
-
cache.set(obj, newObj);
|
|
49
|
-
}
|
|
50
|
-
return newObj;
|
|
51
|
-
}
|
|
52
|
-
const getServerConfig = async (appDirectory, configFile) => {
|
|
53
|
-
const configFilePath = (0, _findExists.findExists)(_constants.CONFIG_FILE_EXTENSIONS.map((extension) => _path.resolve(appDirectory, `${configFile}${extension}`)));
|
|
54
|
-
return configFilePath;
|
|
55
|
-
};
|
package/dist/cjs/getTargetDir.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getTargetDir", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: () => getTargetDir
|
|
8
|
-
});
|
|
9
|
-
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
11
|
-
if (typeof WeakMap !== "function")
|
|
12
|
-
return null;
|
|
13
|
-
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
14
|
-
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
15
|
-
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
16
|
-
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
17
|
-
})(nodeInterop);
|
|
18
|
-
}
|
|
19
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
20
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
21
|
-
return obj;
|
|
22
|
-
}
|
|
23
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
24
|
-
return {
|
|
25
|
-
default: obj
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
29
|
-
if (cache && cache.has(obj)) {
|
|
30
|
-
return cache.get(obj);
|
|
31
|
-
}
|
|
32
|
-
var newObj = {};
|
|
33
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
|
-
for (var key in obj) {
|
|
35
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
36
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
37
|
-
if (desc && (desc.get || desc.set)) {
|
|
38
|
-
Object.defineProperty(newObj, key, desc);
|
|
39
|
-
} else {
|
|
40
|
-
newObj[key] = obj[key];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
newObj.default = obj;
|
|
45
|
-
if (cache) {
|
|
46
|
-
cache.set(obj, newObj);
|
|
47
|
-
}
|
|
48
|
-
return newObj;
|
|
49
|
-
}
|
|
50
|
-
const getTargetDir = (from, baseDir, targetBaseDir) => {
|
|
51
|
-
const relativePath = _path.relative(baseDir, from);
|
|
52
|
-
return _path.resolve(targetBaseDir, relativePath);
|
|
53
|
-
};
|
package/dist/cjs/plugin.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getInternalPlugins", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: () => getInternalPlugins
|
|
8
|
-
});
|
|
9
|
-
const _constants = require("./constants");
|
|
10
|
-
const _is = require("./is");
|
|
11
|
-
function getInternalPlugins(appDirectory, internalPlugins = _constants.INTERNAL_CLI_PLUGINS) {
|
|
12
|
-
return [
|
|
13
|
-
...Object.keys(internalPlugins).filter((name) => {
|
|
14
|
-
const config = internalPlugins[name];
|
|
15
|
-
if (typeof config !== "string" && config.forced === true) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
return (0, _is.isDepExists)(appDirectory, name);
|
|
19
|
-
}).map((name) => {
|
|
20
|
-
const config = internalPlugins[name];
|
|
21
|
-
if (typeof config !== "string") {
|
|
22
|
-
return config.path;
|
|
23
|
-
} else {
|
|
24
|
-
return config;
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
];
|
|
28
|
-
}
|
package/dist/cjs/react.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "isBeyondReact17", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: () => isBeyondReact17
|
|
8
|
-
});
|
|
9
|
-
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
-
const _ = require(".");
|
|
11
|
-
function _interop_require_default(obj) {
|
|
12
|
-
return obj && obj.__esModule ? obj : {
|
|
13
|
-
default: obj
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const isBeyondReact17 = (cwd) => {
|
|
17
|
-
const pkgPath = _path.default.join(cwd, "package.json");
|
|
18
|
-
if (!_.fs.existsSync(pkgPath)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const pkgInfo = JSON.parse(_.fs.readFileSync(pkgPath, "utf8"));
|
|
22
|
-
const deps = {
|
|
23
|
-
...pkgInfo.devDependencies,
|
|
24
|
-
...pkgInfo.dependencies
|
|
25
|
-
};
|
|
26
|
-
if (typeof deps.react !== "string") {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return _.semver.satisfies(_.semver.minVersion(deps.react), ">=17.0.0");
|
|
30
|
-
};
|
package/dist/cjs/removeSlash.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
Object.defineProperty(target, name, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
removeLeadingSlash: () => removeLeadingSlash,
|
|
14
|
-
removeTailSlash: () => removeTailSlash,
|
|
15
|
-
removeSlash: () => removeSlash
|
|
16
|
-
});
|
|
17
|
-
const removeLeadingSlash = (s) => s.replace(/^\/+/, "");
|
|
18
|
-
const removeTailSlash = (s) => s.replace(/\/+$/, "");
|
|
19
|
-
const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
|
package/dist/cjs/resolve.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
Object.defineProperty(target, name, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
tryResolve: () => tryResolve,
|
|
14
|
-
isPackageInstalled: () => isPackageInstalled,
|
|
15
|
-
getAntdMajorVersion: () => getAntdMajorVersion
|
|
16
|
-
});
|
|
17
|
-
const _ensureArray = require("./ensureArray");
|
|
18
|
-
const tryResolve = (name, resolvePath) => {
|
|
19
|
-
let filePath = "";
|
|
20
|
-
try {
|
|
21
|
-
filePath = require.resolve(name, {
|
|
22
|
-
paths: [
|
|
23
|
-
resolvePath
|
|
24
|
-
]
|
|
25
|
-
});
|
|
26
|
-
delete require.cache[filePath];
|
|
27
|
-
} catch (err) {
|
|
28
|
-
if (err.code === "MODULE_NOT_FOUND") {
|
|
29
|
-
throw new Error(`Can not find module ${name}.`);
|
|
30
|
-
}
|
|
31
|
-
throw err;
|
|
32
|
-
}
|
|
33
|
-
return filePath;
|
|
34
|
-
};
|
|
35
|
-
const isPackageInstalled = (name, resolvePaths) => {
|
|
36
|
-
try {
|
|
37
|
-
require.resolve(name, {
|
|
38
|
-
paths: (0, _ensureArray.ensureArray)(resolvePaths)
|
|
39
|
-
});
|
|
40
|
-
return true;
|
|
41
|
-
} catch (err) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const getAntdMajorVersion = (appDirectory) => {
|
|
46
|
-
try {
|
|
47
|
-
const pkgJsonPath = require.resolve("antd/package.json", {
|
|
48
|
-
paths: [
|
|
49
|
-
appDirectory
|
|
50
|
-
]
|
|
51
|
-
});
|
|
52
|
-
const { version } = require(pkgJsonPath);
|
|
53
|
-
return Number(version.split(".")[0]);
|
|
54
|
-
} catch (err) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
};
|
package/dist/cjs/types.js
DELETED
package/dist/cjs/version.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
Object.defineProperty(target, name, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
getPnpmVersion: () => getPnpmVersion,
|
|
14
|
-
isReact18: () => isReact18
|
|
15
|
-
});
|
|
16
|
-
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
17
|
-
const _compiled = require("./compiled");
|
|
18
|
-
function _interop_require_default(obj) {
|
|
19
|
-
return obj && obj.__esModule ? obj : {
|
|
20
|
-
default: obj
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
async function getPnpmVersion() {
|
|
24
|
-
const { stdout } = await (0, _compiled.execa)("pnpm", [
|
|
25
|
-
"--version"
|
|
26
|
-
]);
|
|
27
|
-
return stdout;
|
|
28
|
-
}
|
|
29
|
-
const isReact18 = (cwd) => {
|
|
30
|
-
const pkgPath = _path.default.join(cwd, "package.json");
|
|
31
|
-
if (!_compiled.fs.existsSync(pkgPath)) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const pkgInfo = JSON.parse(_compiled.fs.readFileSync(pkgPath, "utf8"));
|
|
35
|
-
const deps = {
|
|
36
|
-
...pkgInfo.devDependencies,
|
|
37
|
-
...pkgInfo.dependencies
|
|
38
|
-
};
|
|
39
|
-
if (typeof deps.react !== "string") {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return _compiled.semver.satisfies(_compiled.semver.minVersion(deps.react), ">=18.0.0");
|
|
43
|
-
};
|
package/dist/cjs/wait.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "wait", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: () => wait
|
|
8
|
-
});
|
|
9
|
-
const wait = (time = 0) => new Promise((resolve) => {
|
|
10
|
-
setTimeout(resolve, time);
|
|
11
|
-
});
|
package/dist/cjs/watch.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
Object.defineProperty(target, name, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
WatchChangeType: () => WatchChangeType,
|
|
14
|
-
watch: () => watch
|
|
15
|
-
});
|
|
16
|
-
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
17
|
-
const _compiled = require("./compiled");
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
19
|
-
if (typeof WeakMap !== "function")
|
|
20
|
-
return null;
|
|
21
|
-
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
22
|
-
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
23
|
-
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
24
|
-
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
25
|
-
})(nodeInterop);
|
|
26
|
-
}
|
|
27
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
28
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
29
|
-
return obj;
|
|
30
|
-
}
|
|
31
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
32
|
-
return {
|
|
33
|
-
default: obj
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
37
|
-
if (cache && cache.has(obj)) {
|
|
38
|
-
return cache.get(obj);
|
|
39
|
-
}
|
|
40
|
-
var newObj = {};
|
|
41
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
|
-
for (var key in obj) {
|
|
43
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
45
|
-
if (desc && (desc.get || desc.set)) {
|
|
46
|
-
Object.defineProperty(newObj, key, desc);
|
|
47
|
-
} else {
|
|
48
|
-
newObj[key] = obj[key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
newObj.default = obj;
|
|
53
|
-
if (cache) {
|
|
54
|
-
cache.set(obj, newObj);
|
|
55
|
-
}
|
|
56
|
-
return newObj;
|
|
57
|
-
}
|
|
58
|
-
const WatchChangeType = {
|
|
59
|
-
ADD: "add",
|
|
60
|
-
UNLINK: "unlink",
|
|
61
|
-
CHANGE: "change"
|
|
62
|
-
};
|
|
63
|
-
const watch = (watchDir, runTask, ignored = []) => {
|
|
64
|
-
let ready = false;
|
|
65
|
-
const watcher = _compiled.chokidar.watch(watchDir, {
|
|
66
|
-
ignored
|
|
67
|
-
});
|
|
68
|
-
watcher.on("ready", () => ready = true);
|
|
69
|
-
watcher.on("change", async (filePath) => {
|
|
70
|
-
const changedFilePath = _path.resolve(filePath);
|
|
71
|
-
await runTask({
|
|
72
|
-
changedFilePath,
|
|
73
|
-
changeType: WatchChangeType.CHANGE
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
watcher.on("add", async (filePath) => {
|
|
77
|
-
const changedFilePath = _path.resolve(filePath);
|
|
78
|
-
if (ready) {
|
|
79
|
-
await runTask({
|
|
80
|
-
changedFilePath,
|
|
81
|
-
changeType: WatchChangeType.ADD
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
watcher.on("unlink", async (filePath) => {
|
|
86
|
-
const changedFilePath = _path.resolve(filePath);
|
|
87
|
-
await runTask({
|
|
88
|
-
changedFilePath,
|
|
89
|
-
changeType: WatchChangeType.UNLINK
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
watcher.on("error", (err) => {
|
|
93
|
-
throw err;
|
|
94
|
-
});
|
|
95
|
-
return watcher;
|
|
96
|
-
};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { chalk, filesize, stripAnsi, gzipSize, recursiveReaddir } from "./compiled";
|
|
5
|
-
import { logger } from "./logger";
|
|
6
|
-
function canReadAsset(asset) {
|
|
7
|
-
return /\.(js|css)$/.test(asset) && !/service-worker\.js/.test(asset) && !/precache-manifest\.[0-9a-f]+\.js/.test(asset);
|
|
8
|
-
}
|
|
9
|
-
function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, maxBundleGzipSize, maxChunkGzipSize) {
|
|
10
|
-
var root = previousSizeMap.root;
|
|
11
|
-
var sizes = previousSizeMap.sizes;
|
|
12
|
-
var assets = (webpackStats.stats || [
|
|
13
|
-
webpackStats
|
|
14
|
-
]).map((stats) => stats.toJson({
|
|
15
|
-
all: false,
|
|
16
|
-
assets: true
|
|
17
|
-
}).assets.filter((asset) => canReadAsset(asset.name)).map((asset) => {
|
|
18
|
-
var fileContents = fs.readFileSync(path.join(root, asset.name));
|
|
19
|
-
var size = fileContents.length;
|
|
20
|
-
var gzippedSize = gzipSize.sync(fileContents);
|
|
21
|
-
var [previousSize, previousGzipSize] = sizes[removeFileNameHash(root, asset.name)] || [];
|
|
22
|
-
var sizeDifference = getDifferenceLabel(size, previousSize);
|
|
23
|
-
var gzipSizeDifference = getDifferenceLabel(gzippedSize, previousGzipSize);
|
|
24
|
-
return {
|
|
25
|
-
folder: path.join(path.basename(buildFolder), path.dirname(asset.name)),
|
|
26
|
-
name: path.basename(asset.name),
|
|
27
|
-
gzippedSize,
|
|
28
|
-
sizeLabel: filesize(size) + (sizeDifference ? " (" + sizeDifference + ")" : ""),
|
|
29
|
-
gzipSizeLabel: filesize(gzippedSize) + (gzipSizeDifference ? " (" + gzipSizeDifference + ")" : "")
|
|
30
|
-
};
|
|
31
|
-
})).reduce((single, all) => all.concat(single), []);
|
|
32
|
-
assets.sort((a, b) => b.size - a.size);
|
|
33
|
-
var longestSizeLabelLength = Math.max.apply(null, assets.map((a) => stripAnsi(a.sizeLabel).length));
|
|
34
|
-
var longestFileNameLength = Math.max.apply(null, assets.map((a) => stripAnsi(a.folder + path.sep + a.name).length));
|
|
35
|
-
printFileSizesHeader(longestFileNameLength, longestSizeLabelLength);
|
|
36
|
-
var suggestBundleSplitting = false;
|
|
37
|
-
assets.forEach((asset) => {
|
|
38
|
-
var { folder, name, sizeLabel, gzipSizeLabel, gzippedSize } = asset;
|
|
39
|
-
var fileNameLength = stripAnsi(folder + path.sep + name).length;
|
|
40
|
-
var sizeLength = stripAnsi(sizeLabel).length;
|
|
41
|
-
if (sizeLength < longestSizeLabelLength) {
|
|
42
|
-
var rightPadding = " ".repeat(longestSizeLabelLength - sizeLength);
|
|
43
|
-
sizeLabel += rightPadding;
|
|
44
|
-
}
|
|
45
|
-
var fileNameLabel = chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name);
|
|
46
|
-
if (fileNameLength < longestFileNameLength) {
|
|
47
|
-
var rightPadding = " ".repeat(longestFileNameLength - fileNameLength);
|
|
48
|
-
fileNameLabel += rightPadding;
|
|
49
|
-
}
|
|
50
|
-
var isMainBundle = asset.name.indexOf("main.") === 0;
|
|
51
|
-
var maxRecommendedSize = isMainBundle ? maxBundleGzipSize : maxChunkGzipSize;
|
|
52
|
-
var isLarge = maxRecommendedSize && gzippedSize > maxRecommendedSize;
|
|
53
|
-
if (isLarge && path.extname(asset.name) === ".js") {
|
|
54
|
-
suggestBundleSplitting = true;
|
|
55
|
-
}
|
|
56
|
-
logger.log(" " + fileNameLabel + " " + sizeLabel + " " + (isLarge ? chalk.yellow(gzipSizeLabel) : gzipSizeLabel));
|
|
57
|
-
});
|
|
58
|
-
if (suggestBundleSplitting) {
|
|
59
|
-
logger.log();
|
|
60
|
-
logger.warn("The bundle size is significantly larger than recommended.");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function printFileSizesHeader(longestFileNameLength, longestSizeLabelLength) {
|
|
64
|
-
const longestLengths = [
|
|
65
|
-
longestFileNameLength,
|
|
66
|
-
longestSizeLabelLength
|
|
67
|
-
];
|
|
68
|
-
const headerRow = [
|
|
69
|
-
"File",
|
|
70
|
-
"Size",
|
|
71
|
-
"Gzipped"
|
|
72
|
-
].reduce((prev, cur, index) => {
|
|
73
|
-
const length = longestLengths[index];
|
|
74
|
-
let curLabel = cur;
|
|
75
|
-
if (length) {
|
|
76
|
-
curLabel = cur.length < length ? cur + " ".repeat(length - cur.length) : cur;
|
|
77
|
-
}
|
|
78
|
-
return prev + curLabel + " ";
|
|
79
|
-
}, " ");
|
|
80
|
-
logger.log(chalk.bold(chalk.blue(headerRow)));
|
|
81
|
-
}
|
|
82
|
-
function removeFileNameHash(buildFolder, fileName) {
|
|
83
|
-
return fileName.replace(buildFolder, "").replace(/\\/g, "/").replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
|
|
84
|
-
}
|
|
85
|
-
function getDifferenceLabel(currentSize, previousSize) {
|
|
86
|
-
var FIFTY_KILOBYTES = 1024 * 50;
|
|
87
|
-
var difference = currentSize - previousSize;
|
|
88
|
-
var fileSize = !Number.isNaN(difference) ? filesize(difference) : 0;
|
|
89
|
-
if (difference >= FIFTY_KILOBYTES) {
|
|
90
|
-
return chalk.red("+" + fileSize);
|
|
91
|
-
} else if (difference < FIFTY_KILOBYTES && difference > 0) {
|
|
92
|
-
return chalk.yellow("+" + fileSize);
|
|
93
|
-
} else if (difference < 0) {
|
|
94
|
-
return chalk.green(fileSize);
|
|
95
|
-
} else {
|
|
96
|
-
return "";
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function measureFileSizesBeforeBuild(buildFolder) {
|
|
100
|
-
return new Promise((resolve) => {
|
|
101
|
-
recursiveReaddir(buildFolder, (err, fileNames) => {
|
|
102
|
-
var sizes;
|
|
103
|
-
if (!err && fileNames) {
|
|
104
|
-
sizes = fileNames.filter(canReadAsset).reduce((memo, fileName) => {
|
|
105
|
-
var contents = fs.readFileSync(fileName);
|
|
106
|
-
var key = removeFileNameHash(buildFolder, fileName);
|
|
107
|
-
memo[key] = [
|
|
108
|
-
contents.length,
|
|
109
|
-
gzipSize.sync(contents)
|
|
110
|
-
];
|
|
111
|
-
return memo;
|
|
112
|
-
}, {});
|
|
113
|
-
}
|
|
114
|
-
resolve({
|
|
115
|
-
root: buildFolder,
|
|
116
|
-
sizes: sizes || {}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
export { measureFileSizesBeforeBuild, printFileSizesAfterBuild };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import { getArgv } from "./commands";
|
|
3
|
-
import { fs, minimist } from "./compiled";
|
|
4
|
-
export const isApiOnly = async (appDirectory, entryDir) => {
|
|
5
|
-
const srcDir = path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src");
|
|
6
|
-
const existSrc = await fs.pathExists(srcDir);
|
|
7
|
-
const options = minimist(getArgv());
|
|
8
|
-
return !existSrc || Boolean(options["api-only"]);
|
|
9
|
-
};
|
|
10
|
-
export const isWebOnly = async () => {
|
|
11
|
-
const options = minimist(getArgv());
|
|
12
|
-
return Boolean(options["web-only"]);
|
|
13
|
-
};
|
package/dist/esm/clearConsole.js
DELETED
package/dist/esm/debug.js
DELETED
package/dist/esm/emptyDir.js
DELETED
package/dist/esm/ensureArray.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as fs from "../compiled/fs-extra";
|
|
2
|
-
export const getCoreJsVersion = (corejsPkgPath) => {
|
|
3
|
-
try {
|
|
4
|
-
const { version } = fs.readJSONSync(corejsPkgPath);
|
|
5
|
-
const [major, minor] = version.split(".");
|
|
6
|
-
return `${major}.${minor}`;
|
|
7
|
-
} catch (err) {
|
|
8
|
-
return "3";
|
|
9
|
-
}
|
|
10
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import os from "os";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fs } from "./compiled";
|
|
4
|
-
import { canUsePnpm, canUseYarn } from "./nodeEnv";
|
|
5
|
-
const MAX_TIMES = 5;
|
|
6
|
-
export async function getPackageManager(cwd = process.cwd()) {
|
|
7
|
-
let appDirectory = cwd;
|
|
8
|
-
let times = 0;
|
|
9
|
-
while (os.homedir() !== appDirectory && times < MAX_TIMES) {
|
|
10
|
-
times++;
|
|
11
|
-
if (fs.existsSync(path.resolve(appDirectory, "pnpm-lock.yaml"))) {
|
|
12
|
-
return "pnpm";
|
|
13
|
-
}
|
|
14
|
-
if (fs.existsSync(path.resolve(appDirectory, "yarn.lock"))) {
|
|
15
|
-
return "yarn";
|
|
16
|
-
}
|
|
17
|
-
if (fs.existsSync(path.resolve(appDirectory, "package-lock.json"))) {
|
|
18
|
-
return "npm";
|
|
19
|
-
}
|
|
20
|
-
appDirectory = path.join(appDirectory, "..");
|
|
21
|
-
}
|
|
22
|
-
if (await canUsePnpm()) {
|
|
23
|
-
return "pnpm";
|
|
24
|
-
}
|
|
25
|
-
if (await canUseYarn()) {
|
|
26
|
-
return "yarn";
|
|
27
|
-
}
|
|
28
|
-
return "npm";
|
|
29
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import { CONFIG_FILE_EXTENSIONS } from "./constants";
|
|
3
|
-
import { findExists } from "./findExists";
|
|
4
|
-
export const getServerConfig = async (appDirectory, configFile) => {
|
|
5
|
-
const configFilePath = findExists(CONFIG_FILE_EXTENSIONS.map((extension) => path.resolve(appDirectory, `${configFile}${extension}`)));
|
|
6
|
-
return configFilePath;
|
|
7
|
-
};
|
package/dist/esm/getTargetDir.js
DELETED
package/dist/esm/plugin.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { INTERNAL_CLI_PLUGINS } from "./constants";
|
|
2
|
-
import { isDepExists } from "./is";
|
|
3
|
-
export function getInternalPlugins(appDirectory, internalPlugins = INTERNAL_CLI_PLUGINS) {
|
|
4
|
-
return [
|
|
5
|
-
...Object.keys(internalPlugins).filter((name) => {
|
|
6
|
-
const config = internalPlugins[name];
|
|
7
|
-
if (typeof config !== "string" && config.forced === true) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
return isDepExists(appDirectory, name);
|
|
11
|
-
}).map((name) => {
|
|
12
|
-
const config = internalPlugins[name];
|
|
13
|
-
if (typeof config !== "string") {
|
|
14
|
-
return config.path;
|
|
15
|
-
} else {
|
|
16
|
-
return config;
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
];
|
|
20
|
-
}
|
package/dist/esm/react.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fs, semver } from ".";
|
|
3
|
-
export const isBeyondReact17 = (cwd) => {
|
|
4
|
-
const pkgPath = path.join(cwd, "package.json");
|
|
5
|
-
if (!fs.existsSync(pkgPath)) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
9
|
-
const deps = {
|
|
10
|
-
...pkgInfo.devDependencies,
|
|
11
|
-
...pkgInfo.dependencies
|
|
12
|
-
};
|
|
13
|
-
if (typeof deps.react !== "string") {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
|
|
17
|
-
};
|