@bleedingdev/modern-js-bff-core 3.9.0-ultramodern.16 → 3.9.0-ultramodern.18
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/index.js +2 -16
- package/dist/cjs/utils/index.js +11 -21
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils/index.mjs +0 -1
- package/dist/esm-node/index.mjs +1 -1
- package/dist/esm-node/utils/index.mjs +0 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts +0 -1
- package/package.json +6 -8
- package/dist/cjs/utils/alias.js +0 -112
- package/dist/esm/utils/alias.mjs +0 -57
- package/dist/esm-node/utils/alias.mjs +0 -58
- package/dist/types/utils/alias.d.ts +0 -7
package/dist/cjs/index.js
CHANGED
|
@@ -74,13 +74,11 @@ var __webpack_exports__ = {};
|
|
|
74
74
|
var __rspack_reexport = {};
|
|
75
75
|
for(const __rspack_import_key in _client__rspack_import_1)if ([
|
|
76
76
|
"HttpError",
|
|
77
|
-
"registerPaths",
|
|
78
77
|
"createStorage",
|
|
79
78
|
"isWithMetaHandler",
|
|
80
79
|
"default",
|
|
81
80
|
"HANDLER_WITH_META",
|
|
82
81
|
"ValidationError",
|
|
83
|
-
"getRelativeRuntimePath",
|
|
84
82
|
"INPUT_PARAMS_DECIDER",
|
|
85
83
|
"isInputParamsDeciderHandler",
|
|
86
84
|
"Api"
|
|
@@ -91,13 +89,11 @@ var __webpack_exports__ = {};
|
|
|
91
89
|
var __rspack_reexport = {};
|
|
92
90
|
for(const __rspack_import_key in _operators_http__rspack_import_3)if ([
|
|
93
91
|
"HttpError",
|
|
94
|
-
"registerPaths",
|
|
95
92
|
"createStorage",
|
|
96
93
|
"isWithMetaHandler",
|
|
97
94
|
"default",
|
|
98
95
|
"HANDLER_WITH_META",
|
|
99
96
|
"ValidationError",
|
|
100
|
-
"getRelativeRuntimePath",
|
|
101
97
|
"INPUT_PARAMS_DECIDER",
|
|
102
98
|
"isInputParamsDeciderHandler",
|
|
103
99
|
"Api"
|
|
@@ -107,13 +103,11 @@ var __webpack_exports__ = {};
|
|
|
107
103
|
var __rspack_reexport = {};
|
|
108
104
|
for(const __rspack_import_key in _router__rspack_import_4)if ([
|
|
109
105
|
"HttpError",
|
|
110
|
-
"registerPaths",
|
|
111
106
|
"createStorage",
|
|
112
107
|
"isWithMetaHandler",
|
|
113
108
|
"default",
|
|
114
109
|
"HANDLER_WITH_META",
|
|
115
110
|
"ValidationError",
|
|
116
|
-
"getRelativeRuntimePath",
|
|
117
111
|
"INPUT_PARAMS_DECIDER",
|
|
118
112
|
"isInputParamsDeciderHandler",
|
|
119
113
|
"Api"
|
|
@@ -123,13 +117,11 @@ var __webpack_exports__ = {};
|
|
|
123
117
|
var __rspack_reexport = {};
|
|
124
118
|
for(const __rspack_import_key in _types__rspack_import_5)if ([
|
|
125
119
|
"HttpError",
|
|
126
|
-
"registerPaths",
|
|
127
120
|
"createStorage",
|
|
128
121
|
"isWithMetaHandler",
|
|
129
122
|
"default",
|
|
130
123
|
"HANDLER_WITH_META",
|
|
131
124
|
"ValidationError",
|
|
132
|
-
"getRelativeRuntimePath",
|
|
133
125
|
"INPUT_PARAMS_DECIDER",
|
|
134
126
|
"isInputParamsDeciderHandler",
|
|
135
127
|
"Api"
|
|
@@ -143,10 +135,8 @@ var __webpack_exports__ = {};
|
|
|
143
135
|
INPUT_PARAMS_DECIDER: ()=>_utils__rspack_import_6.INPUT_PARAMS_DECIDER,
|
|
144
136
|
ValidationError: ()=>_errors_http__rspack_import_2.ValidationError,
|
|
145
137
|
createStorage: ()=>_utils__rspack_import_6.createStorage,
|
|
146
|
-
getRelativeRuntimePath: ()=>_utils__rspack_import_6.getRelativeRuntimePath,
|
|
147
138
|
isInputParamsDeciderHandler: ()=>_utils__rspack_import_6.isInputParamsDeciderHandler,
|
|
148
|
-
isWithMetaHandler: ()=>_utils__rspack_import_6.isWithMetaHandler
|
|
149
|
-
registerPaths: ()=>_utils__rspack_import_6.registerPaths
|
|
139
|
+
isWithMetaHandler: ()=>_utils__rspack_import_6.isWithMetaHandler
|
|
150
140
|
});
|
|
151
141
|
})();
|
|
152
142
|
exports.Api = __webpack_exports__.Api;
|
|
@@ -155,10 +145,8 @@ exports.HttpError = __webpack_exports__.HttpError;
|
|
|
155
145
|
exports.INPUT_PARAMS_DECIDER = __webpack_exports__.INPUT_PARAMS_DECIDER;
|
|
156
146
|
exports.ValidationError = __webpack_exports__.ValidationError;
|
|
157
147
|
exports.createStorage = __webpack_exports__.createStorage;
|
|
158
|
-
exports.getRelativeRuntimePath = __webpack_exports__.getRelativeRuntimePath;
|
|
159
148
|
exports.isInputParamsDeciderHandler = __webpack_exports__.isInputParamsDeciderHandler;
|
|
160
149
|
exports.isWithMetaHandler = __webpack_exports__.isWithMetaHandler;
|
|
161
|
-
exports.registerPaths = __webpack_exports__.registerPaths;
|
|
162
150
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
163
151
|
"Api",
|
|
164
152
|
"HANDLER_WITH_META",
|
|
@@ -166,10 +154,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
166
154
|
"INPUT_PARAMS_DECIDER",
|
|
167
155
|
"ValidationError",
|
|
168
156
|
"createStorage",
|
|
169
|
-
"getRelativeRuntimePath",
|
|
170
157
|
"isInputParamsDeciderHandler",
|
|
171
|
-
"isWithMetaHandler"
|
|
172
|
-
"registerPaths"
|
|
158
|
+
"isWithMetaHandler"
|
|
173
159
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
174
160
|
Object.defineProperty(exports, '__esModule', {
|
|
175
161
|
value: true
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"./alias" (module) {
|
|
4
|
-
module.exports = require("./alias.js");
|
|
5
|
-
},
|
|
6
3
|
"./debug" (module) {
|
|
7
4
|
module.exports = require("./debug.js");
|
|
8
5
|
},
|
|
@@ -63,37 +60,30 @@ function __webpack_require__(moduleId) {
|
|
|
63
60
|
var __webpack_exports__ = {};
|
|
64
61
|
(()=>{
|
|
65
62
|
__webpack_require__.r(__webpack_exports__);
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
for(const __rspack_import_key in _alias__rspack_import_0)if ([
|
|
69
|
-
"debug",
|
|
70
|
-
"default"
|
|
71
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_alias__rspack_import_0[__rspack_import_key];
|
|
72
|
-
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
73
|
-
var _debug__rspack_import_1 = __webpack_require__("./debug");
|
|
74
|
-
var _meta__rspack_import_2 = __webpack_require__("./meta");
|
|
63
|
+
var _debug__rspack_import_0 = __webpack_require__("./debug");
|
|
64
|
+
var _meta__rspack_import_1 = __webpack_require__("./meta");
|
|
75
65
|
var __rspack_reexport = {};
|
|
76
|
-
for(const __rspack_import_key in
|
|
66
|
+
for(const __rspack_import_key in _meta__rspack_import_1)if ([
|
|
77
67
|
"debug",
|
|
78
68
|
"default"
|
|
79
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
69
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_meta__rspack_import_1[__rspack_import_key];
|
|
80
70
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
81
|
-
var
|
|
71
|
+
var _storage__rspack_import_2 = __webpack_require__("./storage");
|
|
82
72
|
var __rspack_reexport = {};
|
|
83
|
-
for(const __rspack_import_key in
|
|
73
|
+
for(const __rspack_import_key in _storage__rspack_import_2)if ([
|
|
84
74
|
"debug",
|
|
85
75
|
"default"
|
|
86
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
76
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_storage__rspack_import_2[__rspack_import_key];
|
|
87
77
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
88
|
-
var
|
|
78
|
+
var _validate__rspack_import_3 = __webpack_require__("./validate");
|
|
89
79
|
var __rspack_reexport = {};
|
|
90
|
-
for(const __rspack_import_key in
|
|
80
|
+
for(const __rspack_import_key in _validate__rspack_import_3)if ([
|
|
91
81
|
"debug",
|
|
92
82
|
"default"
|
|
93
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
83
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_validate__rspack_import_3[__rspack_import_key];
|
|
94
84
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
95
85
|
__webpack_require__.d(__webpack_exports__, {
|
|
96
|
-
debug: ()=>
|
|
86
|
+
debug: ()=>_debug__rspack_import_0.debug
|
|
97
87
|
});
|
|
98
88
|
})();
|
|
99
89
|
exports.debug = __webpack_exports__.debug;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -4,4 +4,4 @@ export * from "./router/index.mjs";
|
|
|
4
4
|
export * from "./types.mjs";
|
|
5
5
|
export { Api } from "./api.mjs";
|
|
6
6
|
export { HttpError, ValidationError } from "./errors/http.mjs";
|
|
7
|
-
export { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage,
|
|
7
|
+
export { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage, isInputParamsDeciderHandler, isWithMetaHandler } from "./utils/index.mjs";
|
package/dist/esm/utils/index.mjs
CHANGED
package/dist/esm-node/index.mjs
CHANGED
|
@@ -5,4 +5,4 @@ export * from "./router/index.mjs";
|
|
|
5
5
|
export * from "./types.mjs";
|
|
6
6
|
export { Api } from "./api.mjs";
|
|
7
7
|
export { HttpError, ValidationError } from "./errors/http.mjs";
|
|
8
|
-
export { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage,
|
|
8
|
+
export { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage, isInputParamsDeciderHandler, isWithMetaHandler } from "./utils/index.mjs";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { HttpError, ValidationError } from './errors/http.js';
|
|
|
5
5
|
export * from './operators/http.js';
|
|
6
6
|
export * from './router/index.js';
|
|
7
7
|
export * from './types.js';
|
|
8
|
-
export { createStorage,
|
|
8
|
+
export { createStorage, HANDLER_WITH_META, INPUT_PARAMS_DECIDER, isInputParamsDeciderHandler, isWithMetaHandler, } from './utils/index.js';
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.9.0-ultramodern.
|
|
20
|
+
"version": "3.9.0-ultramodern.18",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -31,27 +31,25 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
34
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.18",
|
|
35
35
|
"@swc/helpers": "^0.5.23",
|
|
36
36
|
"koa-compose": "^4.1.0",
|
|
37
37
|
"reflect-metadata": "^0.2.2",
|
|
38
38
|
"type-fest": "5.10.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.9.0-ultramodern.
|
|
42
|
-
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.
|
|
43
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
41
|
+
"@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.9.0-ultramodern.18",
|
|
42
|
+
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.18",
|
|
43
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.18",
|
|
44
44
|
"@rslib/core": "1.0.2",
|
|
45
45
|
"@scripts/rstest-config": "2.66.0",
|
|
46
46
|
"@types/koa-compose": "^3.2.9",
|
|
47
47
|
"@types/node": "^26.6.2",
|
|
48
48
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
49
49
|
"esbuild": "^0.28.2",
|
|
50
|
-
"tsconfig-paths": "^4.2.0",
|
|
51
50
|
"zod": "^4.6.5"
|
|
52
51
|
},
|
|
53
52
|
"peerDependencies": {
|
|
54
|
-
"tsconfig-paths": "^4.2.0",
|
|
55
53
|
"zod": "^4.5.4"
|
|
56
54
|
},
|
|
57
55
|
"peerDependenciesMeta": {
|
|
@@ -65,6 +63,6 @@
|
|
|
65
63
|
"scripts": {
|
|
66
64
|
"dev": "rslib build --watch",
|
|
67
65
|
"build": "rslib build",
|
|
68
|
-
"test": "rstest
|
|
66
|
+
"test": "rstest"
|
|
69
67
|
}
|
|
70
68
|
}
|
package/dist/cjs/utils/alias.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
-
var define = (defs, kind)=>{
|
|
15
|
-
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
[kind]: defs[key]
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
define(getters, "get");
|
|
21
|
-
define(values, "value");
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
(()=>{
|
|
25
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
-
})();
|
|
27
|
-
(()=>{
|
|
28
|
-
__webpack_require__.r = (exports1)=>{
|
|
29
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
-
value: 'Module'
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
-
value: true
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
var __webpack_exports__ = {};
|
|
38
|
-
__webpack_require__.r(__webpack_exports__);
|
|
39
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
-
createMatchPath: ()=>createMatchPath,
|
|
41
|
-
getRelativeRuntimePath: ()=>getRelativeRuntimePath,
|
|
42
|
-
registerPaths: ()=>registerPaths
|
|
43
|
-
});
|
|
44
|
-
const external_fs_namespaceObject = require("fs");
|
|
45
|
-
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
46
|
-
const external_module_namespaceObject = require("module");
|
|
47
|
-
var external_module_default = /*#__PURE__*/ __webpack_require__.n(external_module_namespaceObject);
|
|
48
|
-
const external_os_namespaceObject = require("os");
|
|
49
|
-
const external_path_namespaceObject = require("path");
|
|
50
|
-
const getRelativeRuntimePath = (appDirectory, serverRuntimePath)=>{
|
|
51
|
-
let relativeRuntimePath = '';
|
|
52
|
-
relativeRuntimePath = 'win32' === external_os_namespaceObject.platform() ? `../${external_path_namespaceObject.relative(appDirectory, serverRuntimePath)}` : external_path_namespaceObject.join('../', external_path_namespaceObject.relative(appDirectory, serverRuntimePath));
|
|
53
|
-
if ('development' === process.env.NODE_ENV || 'test' === process.env.NODE_ENV) relativeRuntimePath = `./${external_path_namespaceObject.relative(appDirectory, serverRuntimePath)}`;
|
|
54
|
-
return relativeRuntimePath;
|
|
55
|
-
};
|
|
56
|
-
const sortByLongestPrefix = (arr)=>arr.concat().sort((a, b)=>b.length - a.length);
|
|
57
|
-
const createMatchPath = (paths)=>{
|
|
58
|
-
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
59
|
-
const sortedPaths = {};
|
|
60
|
-
sortedKeys.forEach((key)=>{
|
|
61
|
-
sortedPaths[key] = paths[key];
|
|
62
|
-
});
|
|
63
|
-
return (request)=>{
|
|
64
|
-
const found = Object.keys(sortedPaths).find((key)=>request.startsWith(key));
|
|
65
|
-
if (found) {
|
|
66
|
-
let foundPaths = sortedPaths[found];
|
|
67
|
-
if (!Array.isArray(foundPaths)) foundPaths = [
|
|
68
|
-
foundPaths
|
|
69
|
-
];
|
|
70
|
-
foundPaths = foundPaths.filter((foundPath)=>external_path_namespaceObject.isAbsolute(foundPath));
|
|
71
|
-
for (const p of foundPaths){
|
|
72
|
-
const foundPath = request.replace(found, p);
|
|
73
|
-
if (external_fs_default().existsSync(foundPath)) return foundPath;
|
|
74
|
-
}
|
|
75
|
-
return request.replace(found, foundPaths[0]);
|
|
76
|
-
}
|
|
77
|
-
return null;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
const registerPaths = (paths)=>{
|
|
81
|
-
const originalResolveFilename = external_module_default()._resolveFilename;
|
|
82
|
-
const { builtinModules } = external_module_default();
|
|
83
|
-
const matchPath = createMatchPath(paths);
|
|
84
|
-
external_module_default()._resolveFilename = function(request, _parent) {
|
|
85
|
-
const isCoreModule = builtinModules.includes(request);
|
|
86
|
-
if (!isCoreModule) {
|
|
87
|
-
const matched = matchPath(request);
|
|
88
|
-
if (matched) {
|
|
89
|
-
const modifiedArguments = [
|
|
90
|
-
matched,
|
|
91
|
-
...[].slice.call(arguments, 1)
|
|
92
|
-
];
|
|
93
|
-
return originalResolveFilename.apply(this, modifiedArguments);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return originalResolveFilename.apply(this, arguments);
|
|
97
|
-
};
|
|
98
|
-
return ()=>{
|
|
99
|
-
external_module_default()._resolveFilename = originalResolveFilename;
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
exports.createMatchPath = __webpack_exports__.createMatchPath;
|
|
103
|
-
exports.getRelativeRuntimePath = __webpack_exports__.getRelativeRuntimePath;
|
|
104
|
-
exports.registerPaths = __webpack_exports__.registerPaths;
|
|
105
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
106
|
-
"createMatchPath",
|
|
107
|
-
"getRelativeRuntimePath",
|
|
108
|
-
"registerPaths"
|
|
109
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
110
|
-
Object.defineProperty(exports, '__esModule', {
|
|
111
|
-
value: true
|
|
112
|
-
});
|
package/dist/esm/utils/alias.mjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import module_0 from "module";
|
|
3
|
-
import * as __rspack_external_os from "os";
|
|
4
|
-
import * as __rspack_external_path from "path";
|
|
5
|
-
const getRelativeRuntimePath = (appDirectory, serverRuntimePath)=>{
|
|
6
|
-
let relativeRuntimePath = '';
|
|
7
|
-
relativeRuntimePath = 'win32' === __rspack_external_os.platform() ? `../${__rspack_external_path.relative(appDirectory, serverRuntimePath)}` : __rspack_external_path.join('../', __rspack_external_path.relative(appDirectory, serverRuntimePath));
|
|
8
|
-
if ('development' === process.env.NODE_ENV || 'test' === process.env.NODE_ENV) relativeRuntimePath = `./${__rspack_external_path.relative(appDirectory, serverRuntimePath)}`;
|
|
9
|
-
return relativeRuntimePath;
|
|
10
|
-
};
|
|
11
|
-
const sortByLongestPrefix = (arr)=>arr.concat().sort((a, b)=>b.length - a.length);
|
|
12
|
-
const createMatchPath = (paths)=>{
|
|
13
|
-
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
14
|
-
const sortedPaths = {};
|
|
15
|
-
sortedKeys.forEach((key)=>{
|
|
16
|
-
sortedPaths[key] = paths[key];
|
|
17
|
-
});
|
|
18
|
-
return (request)=>{
|
|
19
|
-
const found = Object.keys(sortedPaths).find((key)=>request.startsWith(key));
|
|
20
|
-
if (found) {
|
|
21
|
-
let foundPaths = sortedPaths[found];
|
|
22
|
-
if (!Array.isArray(foundPaths)) foundPaths = [
|
|
23
|
-
foundPaths
|
|
24
|
-
];
|
|
25
|
-
foundPaths = foundPaths.filter((foundPath)=>__rspack_external_path.isAbsolute(foundPath));
|
|
26
|
-
for (const p of foundPaths){
|
|
27
|
-
const foundPath = request.replace(found, p);
|
|
28
|
-
if (fs.existsSync(foundPath)) return foundPath;
|
|
29
|
-
}
|
|
30
|
-
return request.replace(found, foundPaths[0]);
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
const registerPaths = (paths)=>{
|
|
36
|
-
const originalResolveFilename = module_0._resolveFilename;
|
|
37
|
-
const { builtinModules } = module_0;
|
|
38
|
-
const matchPath = createMatchPath(paths);
|
|
39
|
-
module_0._resolveFilename = function(request, _parent) {
|
|
40
|
-
const isCoreModule = builtinModules.includes(request);
|
|
41
|
-
if (!isCoreModule) {
|
|
42
|
-
const matched = matchPath(request);
|
|
43
|
-
if (matched) {
|
|
44
|
-
const modifiedArguments = [
|
|
45
|
-
matched,
|
|
46
|
-
...[].slice.call(arguments, 1)
|
|
47
|
-
];
|
|
48
|
-
return originalResolveFilename.apply(this, modifiedArguments);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return originalResolveFilename.apply(this, arguments);
|
|
52
|
-
};
|
|
53
|
-
return ()=>{
|
|
54
|
-
module_0._resolveFilename = originalResolveFilename;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
export { createMatchPath, getRelativeRuntimePath, registerPaths };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import module_0 from "module";
|
|
4
|
-
import * as __rspack_external_os from "os";
|
|
5
|
-
import * as __rspack_external_path from "path";
|
|
6
|
-
const getRelativeRuntimePath = (appDirectory, serverRuntimePath)=>{
|
|
7
|
-
let relativeRuntimePath = '';
|
|
8
|
-
relativeRuntimePath = 'win32' === __rspack_external_os.platform() ? `../${__rspack_external_path.relative(appDirectory, serverRuntimePath)}` : __rspack_external_path.join('../', __rspack_external_path.relative(appDirectory, serverRuntimePath));
|
|
9
|
-
if ('development' === process.env.NODE_ENV || 'test' === process.env.NODE_ENV) relativeRuntimePath = `./${__rspack_external_path.relative(appDirectory, serverRuntimePath)}`;
|
|
10
|
-
return relativeRuntimePath;
|
|
11
|
-
};
|
|
12
|
-
const sortByLongestPrefix = (arr)=>arr.concat().sort((a, b)=>b.length - a.length);
|
|
13
|
-
const createMatchPath = (paths)=>{
|
|
14
|
-
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
15
|
-
const sortedPaths = {};
|
|
16
|
-
sortedKeys.forEach((key)=>{
|
|
17
|
-
sortedPaths[key] = paths[key];
|
|
18
|
-
});
|
|
19
|
-
return (request)=>{
|
|
20
|
-
const found = Object.keys(sortedPaths).find((key)=>request.startsWith(key));
|
|
21
|
-
if (found) {
|
|
22
|
-
let foundPaths = sortedPaths[found];
|
|
23
|
-
if (!Array.isArray(foundPaths)) foundPaths = [
|
|
24
|
-
foundPaths
|
|
25
|
-
];
|
|
26
|
-
foundPaths = foundPaths.filter((foundPath)=>__rspack_external_path.isAbsolute(foundPath));
|
|
27
|
-
for (const p of foundPaths){
|
|
28
|
-
const foundPath = request.replace(found, p);
|
|
29
|
-
if (fs.existsSync(foundPath)) return foundPath;
|
|
30
|
-
}
|
|
31
|
-
return request.replace(found, foundPaths[0]);
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const registerPaths = (paths)=>{
|
|
37
|
-
const originalResolveFilename = module_0._resolveFilename;
|
|
38
|
-
const { builtinModules } = module_0;
|
|
39
|
-
const matchPath = createMatchPath(paths);
|
|
40
|
-
module_0._resolveFilename = function(request, _parent) {
|
|
41
|
-
const isCoreModule = builtinModules.includes(request);
|
|
42
|
-
if (!isCoreModule) {
|
|
43
|
-
const matched = matchPath(request);
|
|
44
|
-
if (matched) {
|
|
45
|
-
const modifiedArguments = [
|
|
46
|
-
matched,
|
|
47
|
-
...[].slice.call(arguments, 1)
|
|
48
|
-
];
|
|
49
|
-
return originalResolveFilename.apply(this, modifiedArguments);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return originalResolveFilename.apply(this, arguments);
|
|
53
|
-
};
|
|
54
|
-
return ()=>{
|
|
55
|
-
module_0._resolveFilename = originalResolveFilename;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export { createMatchPath, getRelativeRuntimePath, registerPaths };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
interface Paths {
|
|
2
|
-
[key: string]: string[] | string;
|
|
3
|
-
}
|
|
4
|
-
export declare const getRelativeRuntimePath: (appDirectory: string, serverRuntimePath: string) => string;
|
|
5
|
-
export declare const createMatchPath: (paths: Paths) => (request: string) => string | null;
|
|
6
|
-
export declare const registerPaths: (paths: Paths) => () => void;
|
|
7
|
-
export {};
|