@modern-js/utils 2.4.0 → 2.5.0
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 +14 -0
- package/dist/FileSizeReporter.d.ts +5 -5
- package/dist/FileSizeReporter.js +143 -136
- package/dist/alias.d.ts +14 -12
- package/dist/alias.js +94 -54
- package/dist/analyzeProject.d.ts +1 -1
- package/dist/analyzeProject.js +58 -33
- package/dist/applyOptionsChain.d.ts +1 -1
- package/dist/applyOptionsChain.js +55 -27
- package/dist/chainId.d.ts +256 -184
- package/dist/chainId.js +132 -187
- package/dist/clearConsole.d.ts +1 -1
- package/dist/clearConsole.js +29 -7
- package/dist/commands.d.ts +1 -1
- package/dist/commands.js +33 -10
- package/dist/compatRequire.d.ts +3 -3
- package/dist/compatRequire.js +74 -38
- package/dist/compiled.d.ts +2 -1
- package/dist/compiled.js +137 -72
- package/dist/constants.d.ts +131 -105
- package/dist/constants.js +298 -277
- package/dist/debug.d.ts +1 -1
- package/dist/debug.js +28 -11
- package/dist/emptyDir.d.ts +1 -1
- package/dist/emptyDir.js +51 -9
- package/dist/ensureAbsolutePath.d.ts +1 -1
- package/dist/ensureAbsolutePath.js +33 -14
- package/dist/ensureArray.d.ts +1 -1
- package/dist/ensureArray.js +30 -8
- package/dist/findExists.d.ts +1 -1
- package/dist/findExists.js +37 -17
- package/dist/format.d.ts +3 -3
- package/dist/format.js +93 -81
- package/dist/generateMetaTags.d.ts +3 -3
- package/dist/generateMetaTags.js +56 -43
- package/dist/getBrowserslist.d.ts +1 -1
- package/dist/getBrowserslist.js +31 -7
- package/dist/getCoreJsVersion.d.ts +1 -1
- package/dist/getCoreJsVersion.js +39 -35
- package/dist/getEntryOptions.d.ts +1 -1
- package/dist/getEntryOptions.js +51 -24
- package/dist/getPackageManager.d.ts +1 -1
- package/dist/getPackageManager.js +75 -28
- package/dist/getPort.d.ts +7 -4
- package/dist/getPort.js +104 -58
- package/dist/getServerConfig.d.ts +1 -1
- package/dist/getServerConfig.js +61 -32
- package/dist/import.d.ts +2 -2
- package/dist/import.js +31 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +59 -59
- package/dist/is/index.d.ts +12 -1
- package/dist/is/index.js +83 -82
- package/dist/is/node-env.d.ts +1 -1
- package/dist/is/node-env.js +39 -17
- package/dist/is/platform.d.ts +1 -1
- package/dist/is/platform.js +30 -10
- package/dist/is/type.d.ts +1 -1
- package/dist/is/type.js +48 -22
- package/dist/logger.d.ts +48 -48
- package/dist/logger.js +127 -95
- package/dist/monorepo.d.ts +3 -3
- package/dist/monorepo.js +117 -74
- package/dist/nodeEnv.d.ts +1 -1
- package/dist/nodeEnv.js +72 -25
- package/dist/path.d.ts +3 -1
- package/dist/path.js +76 -59
- package/dist/pathSerializer.d.ts +6 -6
- package/dist/pathSerializer.js +65 -43
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +45 -26
- package/dist/prettyInstructions.d.ts +4 -4
- package/dist/prettyInstructions.js +107 -65
- package/dist/printBuildError.d.ts +1 -1
- package/dist/printBuildError.js +54 -40
- package/dist/react.d.ts +1 -1
- package/dist/react.js +57 -21
- package/dist/readTsConfig.d.ts +1 -1
- package/dist/readTsConfig.js +38 -12
- package/dist/removeSlash.d.ts +1 -1
- package/dist/removeSlash.js +33 -9
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +49 -22
- package/dist/runtimeExports.d.ts +3 -3
- package/dist/runtimeExports.js +59 -39
- package/dist/ssr.d.ts +2 -1
- package/dist/ssr.js +30 -7
- package/dist/storage.d.ts +3 -3
- package/dist/storage.js +65 -59
- package/dist/test-utils.d.ts +1 -1
- package/dist/test-utils.js +30 -24
- package/dist/tryResolve.d.ts +2 -1
- package/dist/tryResolve.js +45 -33
- package/dist/types.d.ts +1 -1
- package/dist/types.js +15 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +83 -24
- package/dist/wait.d.ts +1 -1
- package/dist/wait.js +28 -6
- package/dist/watch.d.ts +3 -3
- package/dist/watch.js +82 -55
- package/package.json +7 -8
package/dist/watch.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
export type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
|
2
2
|
export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
|
3
3
|
type RunTaskType = (option: {
|
4
|
-
|
5
|
-
|
4
|
+
changedFilePath: string;
|
5
|
+
changeType: WatchChangeTypeValueT;
|
6
6
|
}) => void | Promise<void>;
|
7
7
|
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("./compiled").FSWatcher;
|
8
|
-
export {};
|
8
|
+
export {};
|
package/dist/watch.js
CHANGED
@@ -1,59 +1,86 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
24
10
|
};
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
25
|
+
return new Promise((resolve, reject) => {
|
26
|
+
var fulfilled = (value) => {
|
27
|
+
try {
|
28
|
+
step(generator.next(value));
|
29
|
+
} catch (e) {
|
30
|
+
reject(e);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
var rejected = (value) => {
|
34
|
+
try {
|
35
|
+
step(generator.throw(value));
|
36
|
+
} catch (e) {
|
37
|
+
reject(e);
|
38
|
+
}
|
39
|
+
};
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
42
|
+
});
|
43
|
+
};
|
44
|
+
var watch_exports = {};
|
45
|
+
__export(watch_exports, {
|
46
|
+
WatchChangeType: () => WatchChangeType,
|
47
|
+
watch: () => watch
|
48
|
+
});
|
49
|
+
module.exports = __toCommonJS(watch_exports);
|
50
|
+
var path = __toESM(require("path"));
|
51
|
+
var import_compiled = require("./compiled");
|
52
|
+
const WatchChangeType = {
|
53
|
+
ADD: "add",
|
54
|
+
UNLINK: "unlink",
|
55
|
+
CHANGE: "change"
|
33
56
|
};
|
34
57
|
const watch = (watchDir, runTask, ignored = []) => {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
let ready = false;
|
59
|
+
const watcher = import_compiled.chokidar.watch(watchDir, {
|
60
|
+
ignored
|
61
|
+
});
|
62
|
+
watcher.on("ready", () => ready = true);
|
63
|
+
watcher.on("change", (filePath) => __async(void 0, null, function* () {
|
64
|
+
const changedFilePath = path.resolve(filePath);
|
65
|
+
yield runTask({ changedFilePath, changeType: WatchChangeType.CHANGE });
|
66
|
+
}));
|
67
|
+
watcher.on("add", (filePath) => __async(void 0, null, function* () {
|
68
|
+
const changedFilePath = path.resolve(filePath);
|
69
|
+
if (ready) {
|
70
|
+
yield runTask({ changedFilePath, changeType: WatchChangeType.ADD });
|
71
|
+
}
|
72
|
+
}));
|
73
|
+
watcher.on("unlink", (filePath) => __async(void 0, null, function* () {
|
74
|
+
const changedFilePath = path.resolve(filePath);
|
75
|
+
yield runTask({ changedFilePath, changeType: WatchChangeType.UNLINK });
|
76
|
+
}));
|
77
|
+
watcher.on("error", (err) => {
|
78
|
+
throw err;
|
79
|
+
});
|
80
|
+
return watcher;
|
58
81
|
};
|
59
|
-
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
83
|
+
0 && (module.exports = {
|
84
|
+
WatchChangeType,
|
85
|
+
watch
|
86
|
+
});
|
package/package.json
CHANGED
@@ -11,12 +11,11 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
14
|
+
"version": "2.5.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
18
18
|
"module": "./dist/index.js",
|
19
|
-
"jsnext:modern": "./dist/index.js",
|
20
19
|
"_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
|
21
20
|
"exports": {
|
22
21
|
".": "./dist/index.js",
|
@@ -125,7 +124,7 @@
|
|
125
124
|
}
|
126
125
|
},
|
127
126
|
"dependencies": {
|
128
|
-
"caniuse-lite": "^1.0.
|
127
|
+
"caniuse-lite": "^1.0.30001451",
|
129
128
|
"lodash": "^4.17.21"
|
130
129
|
},
|
131
130
|
"devDependencies": {
|
@@ -134,15 +133,15 @@
|
|
134
133
|
"jest": "^27",
|
135
134
|
"typescript": "^4",
|
136
135
|
"webpack": "^5.75.0",
|
137
|
-
"@modern-js/types": "2.
|
138
|
-
"@scripts/jest-config": "2.
|
139
|
-
"@scripts/build": "2.
|
136
|
+
"@modern-js/types": "2.5.0",
|
137
|
+
"@scripts/jest-config": "2.5.0",
|
138
|
+
"@scripts/build": "2.5.0"
|
140
139
|
},
|
141
140
|
"sideEffects": false,
|
142
141
|
"scripts": {
|
143
142
|
"new": "modern-lib new",
|
144
|
-
"dev": "
|
145
|
-
"build": "
|
143
|
+
"dev": "modern-lib build --watch",
|
144
|
+
"build": "modern-lib build",
|
146
145
|
"test": "jest --passWithNoTests"
|
147
146
|
}
|
148
147
|
}
|