@modern-js/utils 2.4.0 → 2.5.0-alpha.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 +16 -14
- 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 +4 -4
- 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 +2 -0
- package/dist/index.js +61 -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 +51 -51
- package/dist/logger.js +127 -95
- package/dist/monorepo.d.ts +3 -3
- package/dist/monorepo.js +117 -74
- package/dist/nestedRoutes.d.ts +9 -0
- package/dist/nestedRoutes.js +144 -0
- 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 +7 -7
- 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/remix-router.d.ts +1 -0
- package/dist/remix-router.js +17 -0
- 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/serialize.d.ts +1 -0
- package/dist/serialize.js +36 -0
- 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 +5 -5
- package/dist/watch.js +82 -55
- package/package.json +31 -9
package/dist/wait.js
CHANGED
@@ -1,7 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var wait_exports = {};
|
19
|
+
__export(wait_exports, {
|
20
|
+
wait: () => wait
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(wait_exports);
|
23
|
+
const wait = (time = 0) => new Promise((resolve) => {
|
24
|
+
setTimeout(resolve, time);
|
25
|
+
});
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
27
|
+
0 && (module.exports = {
|
28
|
+
wait
|
6
29
|
});
|
7
|
-
exports.wait = wait;
|
package/dist/watch.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
export type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
|
1
|
+
export declare type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
|
2
2
|
export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
|
3
|
-
type RunTaskType = (option: {
|
4
|
-
|
5
|
-
|
3
|
+
declare type RunTaskType = (option: {
|
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-alpha.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",
|
@@ -24,6 +23,9 @@
|
|
24
23
|
"./format": "./dist/format.js",
|
25
24
|
"./logger": "./dist/logger.js",
|
26
25
|
"./constants": "./dist/constants.js",
|
26
|
+
"./serialize": "./dist/serialize.js",
|
27
|
+
"./nestedRoutes": "./dist/nestedRoutes.js",
|
28
|
+
"./remix-router": "./dist/remix-router.js",
|
27
29
|
"./ajv": "./compiled/ajv/index.js",
|
28
30
|
"./glob": "./compiled/glob/index.js",
|
29
31
|
"./chalk": "./compiled/chalk/index.js",
|
@@ -62,6 +64,12 @@
|
|
62
64
|
"constants": [
|
63
65
|
"./dist/constants.d.ts"
|
64
66
|
],
|
67
|
+
"serialize": [
|
68
|
+
"./dist/serialize.d.ts"
|
69
|
+
],
|
70
|
+
"nestedRoutes": [
|
71
|
+
"./dist/nestedRoutes.d.ts"
|
72
|
+
],
|
65
73
|
"ajv": [
|
66
74
|
"./compiled/ajv/types/ajv.d.ts"
|
67
75
|
],
|
@@ -121,28 +129,42 @@
|
|
121
129
|
],
|
122
130
|
"chain-id": [
|
123
131
|
"./dist/chainId.d.ts"
|
132
|
+
],
|
133
|
+
"remix-router": [
|
134
|
+
"./dist/remix-router.d.ts"
|
124
135
|
]
|
125
136
|
}
|
126
137
|
},
|
127
138
|
"dependencies": {
|
128
|
-
"caniuse-lite": "^1.0.
|
129
|
-
"lodash": "^4.17.21"
|
139
|
+
"caniuse-lite": "^1.0.30001451",
|
140
|
+
"lodash": "^4.17.21",
|
141
|
+
"serialize-javascript": "^6.0.0",
|
142
|
+
"@remix-run/router": "^1.3.2"
|
143
|
+
},
|
144
|
+
"peerDependencies": {
|
145
|
+
"react": ">=17.0.0",
|
146
|
+
"react-dom": ">=17.0.0",
|
147
|
+
"react-router-dom": "^6.8.1"
|
130
148
|
},
|
131
149
|
"devDependencies": {
|
150
|
+
"react": ">=17.0.0",
|
151
|
+
"react-dom": ">=17.0.0",
|
152
|
+
"react-router-dom": "^6.8.1",
|
132
153
|
"@types/jest": "^27",
|
133
154
|
"@types/node": "^14",
|
134
155
|
"jest": "^27",
|
135
156
|
"typescript": "^4",
|
136
157
|
"webpack": "^5.75.0",
|
137
|
-
"@
|
138
|
-
"@
|
139
|
-
"@scripts/build": "2.
|
158
|
+
"@types/serialize-javascript": "^5.0.1",
|
159
|
+
"@modern-js/types": "2.5.0",
|
160
|
+
"@scripts/build": "2.5.0",
|
161
|
+
"@scripts/jest-config": "2.5.0"
|
140
162
|
},
|
141
163
|
"sideEffects": false,
|
142
164
|
"scripts": {
|
143
165
|
"new": "modern-lib new",
|
144
|
-
"dev": "
|
145
|
-
"build": "
|
166
|
+
"dev": "modern-lib build --watch",
|
167
|
+
"build": "modern-lib build",
|
146
168
|
"test": "jest --passWithNoTests"
|
147
169
|
}
|
148
170
|
}
|