@modern-js/utils 2.58.0 → 2.58.2-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/dist/cjs/cli/require.js +21 -9
- package/dist/cjs/universal/pluginDagSort.js +1 -4
- package/dist/compiled/ajv/codegen.js +1 -0
- package/dist/compiled/ajv/index.js +9 -0
- package/dist/compiled/ajv/license +22 -0
- package/dist/compiled/ajv/package.json +1 -0
- package/dist/compiled/ajv/types/ajv.d.ts +16 -0
- package/dist/compiled/ajv/types/compile/codegen/code.d.ts +40 -0
- package/dist/compiled/ajv/types/compile/codegen/index.d.ts +79 -0
- package/dist/compiled/ajv/types/compile/codegen/scope.d.ts +79 -0
- package/dist/compiled/ajv/types/compile/errors.d.ts +13 -0
- package/dist/compiled/ajv/types/compile/index.d.ts +80 -0
- package/dist/compiled/ajv/types/compile/ref_error.d.ts +6 -0
- package/dist/compiled/ajv/types/compile/resolve.d.ts +12 -0
- package/dist/compiled/ajv/types/compile/rules.d.ts +28 -0
- package/dist/compiled/ajv/types/compile/util.d.ts +40 -0
- package/dist/compiled/ajv/types/compile/validate/index.d.ts +42 -0
- package/dist/compiled/ajv/types/compile/validate/subschema.d.ts +47 -0
- package/dist/compiled/ajv/types/core.d.ts +173 -0
- package/dist/compiled/ajv/types/runtime/validation_error.d.ts +7 -0
- package/dist/compiled/ajv/types/types/index.d.ts +183 -0
- package/dist/compiled/ajv/types/types/json-schema.d.ts +124 -0
- package/dist/compiled/ajv/types/types/jtd-schema.d.ts +169 -0
- package/dist/compiled/ajv/types/vocabularies/errors.d.ts +1 -0
- package/dist/compiled/ajv/uri-js.d.ts +59 -0
- package/dist/compiled/ajv-keywords/index.d.ts +1 -0
- package/dist/compiled/ajv-keywords/index.js +1 -0
- package/dist/compiled/ajv-keywords/license +21 -0
- package/dist/compiled/ajv-keywords/package.json +1 -0
- package/dist/compiled/better-ajv-errors/index.d.ts +1 -0
- package/dist/compiled/better-ajv-errors/index.js +1 -0
- package/dist/compiled/better-ajv-errors/license +13 -0
- package/dist/compiled/better-ajv-errors/package.json +1 -0
- package/dist/compiled/schema-utils3/index.d.ts +1 -0
- package/dist/compiled/schema-utils3/index.js +3 -0
- package/dist/compiled/schema-utils3/license +20 -0
- package/dist/compiled/schema-utils3/package.json +1 -0
- package/dist/esm/cli/require.js +98 -23
- package/dist/esm/universal/pluginDagSort.js +5 -8
- package/dist/esm-node/cli/require.js +20 -8
- package/dist/esm-node/universal/pluginDagSort.js +1 -4
- package/dist/types/cli/require.d.ts +3 -3
- package/package.json +6 -6
package/dist/esm/cli/require.js
CHANGED
@@ -1,28 +1,103 @@
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
+
import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
1
3
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
4
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
2
5
|
import { findExists } from "./fs";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
function compatibleRequire(path) {
|
7
|
+
return _compatibleRequire.apply(this, arguments);
|
8
|
+
}
|
9
|
+
function _compatibleRequire() {
|
10
|
+
_compatibleRequire = _async_to_generator(function(path) {
|
11
|
+
var interop, requiredModule, err;
|
12
|
+
var _arguments = arguments;
|
13
|
+
return _ts_generator(this, function(_state) {
|
14
|
+
switch (_state.label) {
|
15
|
+
case 0:
|
16
|
+
interop = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : true;
|
17
|
+
if (path.endsWith(".json")) {
|
18
|
+
return [
|
19
|
+
2,
|
20
|
+
require(path)
|
21
|
+
];
|
22
|
+
}
|
23
|
+
_state.label = 1;
|
24
|
+
case 1:
|
25
|
+
_state.trys.push([
|
26
|
+
1,
|
27
|
+
2,
|
28
|
+
,
|
29
|
+
6
|
30
|
+
]);
|
31
|
+
requiredModule = require(path);
|
32
|
+
return [
|
33
|
+
3,
|
34
|
+
6
|
35
|
+
];
|
36
|
+
case 2:
|
37
|
+
err = _state.sent();
|
38
|
+
if (!(err.code === "ERR_REQUIRE_ESM" || _instanceof(err, SyntaxError)))
|
39
|
+
return [
|
40
|
+
3,
|
41
|
+
4
|
42
|
+
];
|
43
|
+
return [
|
44
|
+
4,
|
45
|
+
import(path)
|
46
|
+
];
|
47
|
+
case 3:
|
48
|
+
requiredModule = _state.sent();
|
49
|
+
return [
|
50
|
+
2,
|
51
|
+
interop ? requiredModule.default : requiredModule
|
52
|
+
];
|
53
|
+
case 4:
|
54
|
+
throw err;
|
55
|
+
case 5:
|
56
|
+
return [
|
57
|
+
3,
|
58
|
+
6
|
59
|
+
];
|
60
|
+
case 6:
|
61
|
+
return [
|
62
|
+
2,
|
63
|
+
interop && (requiredModule === null || requiredModule === void 0 ? void 0 : requiredModule.__esModule) ? requiredModule.default : requiredModule
|
64
|
+
];
|
65
|
+
}
|
66
|
+
});
|
67
|
+
});
|
68
|
+
return _compatibleRequire.apply(this, arguments);
|
69
|
+
}
|
9
70
|
var dynamicImport = new Function("modulePath", "return import(modulePath)");
|
10
|
-
var requireExistModule = function(
|
11
|
-
var
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
71
|
+
var requireExistModule = function() {
|
72
|
+
var _ref = _async_to_generator(function(filename, opt) {
|
73
|
+
var final, exist;
|
74
|
+
return _ts_generator(this, function(_state) {
|
75
|
+
final = _object_spread({
|
76
|
+
extensions: [
|
77
|
+
".ts",
|
78
|
+
".js"
|
79
|
+
],
|
80
|
+
interop: true
|
81
|
+
}, opt);
|
82
|
+
exist = findExists(final.extensions.map(function(ext) {
|
83
|
+
return "".concat(filename).concat(ext);
|
84
|
+
}));
|
85
|
+
if (!exist) {
|
86
|
+
return [
|
87
|
+
2,
|
88
|
+
null
|
89
|
+
];
|
90
|
+
}
|
91
|
+
return [
|
92
|
+
2,
|
93
|
+
compatibleRequire(exist, final.interop)
|
94
|
+
];
|
95
|
+
});
|
96
|
+
});
|
97
|
+
return function requireExistModule2(filename, opt) {
|
98
|
+
return _ref.apply(this, arguments);
|
99
|
+
};
|
100
|
+
}();
|
26
101
|
var cleanRequireCache = function(filelist) {
|
27
102
|
filelist.forEach(function(filepath) {
|
28
103
|
delete require.cache[filepath];
|
@@ -57,7 +132,7 @@ var tryResolve = function(name, resolvePath) {
|
|
57
132
|
};
|
58
133
|
export {
|
59
134
|
cleanRequireCache,
|
60
|
-
|
135
|
+
compatibleRequire,
|
61
136
|
deleteRequireCache,
|
62
137
|
dynamicImport,
|
63
138
|
requireExistModule,
|
@@ -10,14 +10,11 @@ var pluginDagSort = function(plugins) {
|
|
10
10
|
return sp[key] === item[key];
|
11
11
|
});
|
12
12
|
});
|
13
|
-
zeroEndPoints = restPoints.filter(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
});
|
19
|
-
}
|
20
|
-
);
|
13
|
+
zeroEndPoints = restPoints.filter(function(item) {
|
14
|
+
return !allLines.find(function(l) {
|
15
|
+
return l[1] === item[key];
|
16
|
+
});
|
17
|
+
});
|
21
18
|
};
|
22
19
|
var key = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "name", preKey = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "pre", postKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "post";
|
23
20
|
var getPluginByAny = function getPluginByAny2(q) {
|
@@ -1,11 +1,23 @@
|
|
1
1
|
import { findExists } from "./fs";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
async function compatibleRequire(path, interop = true) {
|
3
|
+
if (path.endsWith(".json")) {
|
4
|
+
return require(path);
|
5
|
+
}
|
6
|
+
let requiredModule;
|
7
|
+
try {
|
8
|
+
requiredModule = require(path);
|
9
|
+
} catch (err) {
|
10
|
+
if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
|
11
|
+
requiredModule = await import(path);
|
12
|
+
return interop ? requiredModule.default : requiredModule;
|
13
|
+
} else {
|
14
|
+
throw err;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
return interop && (requiredModule === null || requiredModule === void 0 ? void 0 : requiredModule.__esModule) ? requiredModule.default : requiredModule;
|
18
|
+
}
|
7
19
|
const dynamicImport = new Function("modulePath", "return import(modulePath)");
|
8
|
-
const requireExistModule = (filename, opt) => {
|
20
|
+
const requireExistModule = async (filename, opt) => {
|
9
21
|
const final = {
|
10
22
|
extensions: [
|
11
23
|
".ts",
|
@@ -18,7 +30,7 @@ const requireExistModule = (filename, opt) => {
|
|
18
30
|
if (!exist) {
|
19
31
|
return null;
|
20
32
|
}
|
21
|
-
return
|
33
|
+
return compatibleRequire(exist, final.interop);
|
22
34
|
};
|
23
35
|
const cleanRequireCache = (filelist) => {
|
24
36
|
filelist.forEach((filepath) => {
|
@@ -52,7 +64,7 @@ const tryResolve = (name, resolvePath) => {
|
|
52
64
|
};
|
53
65
|
export {
|
54
66
|
cleanRequireCache,
|
55
|
-
|
67
|
+
compatibleRequire,
|
56
68
|
deleteRequireCache,
|
57
69
|
dynamicImport,
|
58
70
|
requireExistModule,
|
@@ -33,10 +33,7 @@ const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post")
|
|
33
33
|
sortedPoint.push(getPluginByAny(zep));
|
34
34
|
allLines = allLines.filter((l) => l[0] !== getPluginByAny(zep)[key]);
|
35
35
|
const restPoints = plugins.filter((item) => !sortedPoint.find((sp) => sp[key] === item[key]));
|
36
|
-
zeroEndPoints = restPoints.filter(
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
38
|
-
(item) => !allLines.find((l) => l[1] === item[key])
|
39
|
-
);
|
36
|
+
zeroEndPoints = restPoints.filter((item) => !allLines.find((l) => l[1] === item[key]));
|
40
37
|
}
|
41
38
|
if (allLines.length) {
|
42
39
|
const restInRingPoints = {};
|
@@ -1,14 +1,14 @@
|
|
1
1
|
/**
|
2
2
|
* Require function compatible with esm and cjs module.
|
3
|
-
* @param
|
3
|
+
* @param path - File to required.
|
4
4
|
* @returns module export object.
|
5
5
|
*/
|
6
|
-
export declare
|
6
|
+
export declare function compatibleRequire(path: string, interop?: boolean): Promise<any>;
|
7
7
|
export declare const dynamicImport: Function;
|
8
8
|
export declare const requireExistModule: (filename: string, opt?: {
|
9
9
|
extensions?: string[];
|
10
10
|
interop?: boolean;
|
11
|
-
}) => any
|
11
|
+
}) => Promise<any>;
|
12
12
|
export declare const cleanRequireCache: (filelist: string[]) => void;
|
13
13
|
export declare function deleteRequireCache(path: string): void;
|
14
14
|
/**
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.58.0",
|
18
|
+
"version": "2.58.2-alpha.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -151,10 +151,10 @@
|
|
151
151
|
}
|
152
152
|
},
|
153
153
|
"dependencies": {
|
154
|
+
"@swc/helpers": "0.5.3",
|
154
155
|
"caniuse-lite": "^1.0.30001520",
|
155
156
|
"lodash": "^4.17.21",
|
156
|
-
"rslog": "^1.1.0"
|
157
|
-
"@swc/helpers": "0.5.3"
|
157
|
+
"rslog": "^1.1.0"
|
158
158
|
},
|
159
159
|
"devDependencies": {
|
160
160
|
"@types/jest": "^29",
|
@@ -162,9 +162,9 @@
|
|
162
162
|
"jest": "^29",
|
163
163
|
"typescript": "^5",
|
164
164
|
"webpack": "^5.93.0",
|
165
|
-
"@scripts/
|
166
|
-
"@modern-js/types": "2.58.
|
167
|
-
"@scripts/
|
165
|
+
"@scripts/build": "2.58.1",
|
166
|
+
"@modern-js/types": "2.58.1",
|
167
|
+
"@scripts/jest-config": "2.58.1"
|
168
168
|
},
|
169
169
|
"sideEffects": false,
|
170
170
|
"scripts": {
|