@bleedingdev/modern-js-bff-core 3.9.0-ultramodern.9 → 3.9.3-ultramodern.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/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
@@ -174,10 +174,11 @@ var __webpack_exports__ = {};
174
174
  if ('test' !== process.env.NODE_ENV) _modern_js_utils__rspack_import_0.logger.warn(`Only api handlers are allowd to be exported, please remove the function ${originHandlerName} from exports`);
175
175
  return null;
176
176
  }
177
+ } else {
178
+ if (!handler) return null;
179
+ if ('function' == typeof handler && handler.length > 0) return _types__rspack_import_3.HttpMethod.Post;
180
+ return _types__rspack_import_3.HttpMethod.Get;
177
181
  }
178
- if (!handler) return null;
179
- if ('function' == typeof handler && handler.length > 0) return _types__rspack_import_3.HttpMethod.Post;
180
- return _types__rspack_import_3.HttpMethod.Get;
181
182
  }
182
183
  getAction(handler) {
183
184
  if (handler) {
@@ -226,9 +227,10 @@ var __webpack_exports__ = {};
226
227
  cause: err
227
228
  });
228
229
  throw error;
230
+ } else {
231
+ console.error(`Failed to load BFF module '${filename}':`, err);
232
+ return null;
229
233
  }
230
- console.error(`Failed to load BFF module '${filename}':`, err);
231
- return null;
232
234
  }
233
235
  }
234
236
  getHandlerInfos(moduleInfos) {
@@ -47,9 +47,9 @@ const utils_namespaceObject = require("@modern-js/utils");
47
47
  const external_path_namespaceObject = require("path");
48
48
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
49
49
  const external_constants_js_namespaceObject = require("./constants.js");
50
- const getFiles = (lambdaDir, rules)=>utils_namespaceObject.globby.sync(rules, {
50
+ const getFiles = (lambdaDir, rules)=>(0, utils_namespaceObject.globbySync)(rules, {
51
51
  cwd: lambdaDir,
52
- gitignore: true
52
+ ignoreFiles: '**/.gitignore'
53
53
  }).map((file)=>external_path_default().resolve(lambdaDir, file));
54
54
  const getPathFromFilename = (baseDir, filename)=>{
55
55
  const relativeName = filename.substring(baseDir.length);
@@ -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 _alias__rspack_import_0 = __webpack_require__("./alias");
67
- var __rspack_reexport = {};
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 _meta__rspack_import_2)if ([
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] = ()=>_meta__rspack_import_2[__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 _storage__rspack_import_3 = __webpack_require__("./storage");
71
+ var _storage__rspack_import_2 = __webpack_require__("./storage");
82
72
  var __rspack_reexport = {};
83
- for(const __rspack_import_key in _storage__rspack_import_3)if ([
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] = ()=>_storage__rspack_import_3[__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 _validate__rspack_import_4 = __webpack_require__("./validate");
78
+ var _validate__rspack_import_3 = __webpack_require__("./validate");
89
79
  var __rspack_reexport = {};
90
- for(const __rspack_import_key in _validate__rspack_import_4)if ([
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] = ()=>_validate__rspack_import_4[__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: ()=>_debug__rspack_import_1.debug
86
+ debug: ()=>_debug__rspack_import_0.debug
97
87
  });
98
88
  })();
99
89
  exports.debug = __webpack_exports__.debug;
@@ -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, getRelativeRuntimePath, isInputParamsDeciderHandler, isWithMetaHandler, registerPaths } from "./utils/index.mjs";
7
+ export { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage, isInputParamsDeciderHandler, isWithMetaHandler } from "./utils/index.mjs";
@@ -88,10 +88,11 @@ class ApiRouter {
88
88
  if ('test' !== process.env.NODE_ENV) logger.warn(`Only api handlers are allowd to be exported, please remove the function ${originHandlerName} from exports`);
89
89
  return null;
90
90
  }
91
+ } else {
92
+ if (!handler) return null;
93
+ if ('function' == typeof handler && handler.length > 0) return HttpMethod.Post;
94
+ return HttpMethod.Get;
91
95
  }
92
- if (!handler) return null;
93
- if ('function' == typeof handler && handler.length > 0) return HttpMethod.Post;
94
- return HttpMethod.Get;
95
96
  }
96
97
  getAction(handler) {
97
98
  if (handler) {
@@ -140,9 +141,10 @@ class ApiRouter {
140
141
  cause: err
141
142
  });
142
143
  throw error;
144
+ } else {
145
+ console.error(`Failed to load BFF module '${filename}':`, err);
146
+ return null;
143
147
  }
144
- console.error(`Failed to load BFF module '${filename}':`, err);
145
- return null;
146
148
  }
147
149
  }
148
150
  getHandlerInfos(moduleInfos) {
@@ -1,9 +1,9 @@
1
- import { compatibleRequire, globby } from "@modern-js/utils";
1
+ import { compatibleRequire, globbySync } from "@modern-js/utils";
2
2
  import path from "path";
3
3
  import { INDEX_SUFFIX } from "./constants.mjs";
4
- const getFiles = (lambdaDir, rules)=>globby.sync(rules, {
4
+ const getFiles = (lambdaDir, rules)=>globbySync(rules, {
5
5
  cwd: lambdaDir,
6
- gitignore: true
6
+ ignoreFiles: '**/.gitignore'
7
7
  }).map((file)=>path.resolve(lambdaDir, file));
8
8
  const getPathFromFilename = (baseDir, filename)=>{
9
9
  const relativeName = filename.substring(baseDir.length);
@@ -1,4 +1,3 @@
1
- export * from "./alias.mjs";
2
1
  export * from "./meta.mjs";
3
2
  export * from "./storage.mjs";
4
3
  export * from "./validate.mjs";
@@ -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, getRelativeRuntimePath, isInputParamsDeciderHandler, isWithMetaHandler, registerPaths } from "./utils/index.mjs";
8
+ export { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage, isInputParamsDeciderHandler, isWithMetaHandler } from "./utils/index.mjs";
@@ -89,10 +89,11 @@ class ApiRouter {
89
89
  if ('test' !== process.env.NODE_ENV) logger.warn(`Only api handlers are allowd to be exported, please remove the function ${originHandlerName} from exports`);
90
90
  return null;
91
91
  }
92
+ } else {
93
+ if (!handler) return null;
94
+ if ('function' == typeof handler && handler.length > 0) return HttpMethod.Post;
95
+ return HttpMethod.Get;
92
96
  }
93
- if (!handler) return null;
94
- if ('function' == typeof handler && handler.length > 0) return HttpMethod.Post;
95
- return HttpMethod.Get;
96
97
  }
97
98
  getAction(handler) {
98
99
  if (handler) {
@@ -141,9 +142,10 @@ class ApiRouter {
141
142
  cause: err
142
143
  });
143
144
  throw error;
145
+ } else {
146
+ console.error(`Failed to load BFF module '${filename}':`, err);
147
+ return null;
144
148
  }
145
- console.error(`Failed to load BFF module '${filename}':`, err);
146
- return null;
147
149
  }
148
150
  }
149
151
  getHandlerInfos(moduleInfos) {
@@ -1,10 +1,10 @@
1
1
  import "node:module";
2
- import { compatibleRequire, globby } from "@modern-js/utils";
2
+ import { compatibleRequire, globbySync } from "@modern-js/utils";
3
3
  import path from "path";
4
4
  import { INDEX_SUFFIX } from "./constants.mjs";
5
- const getFiles = (lambdaDir, rules)=>globby.sync(rules, {
5
+ const getFiles = (lambdaDir, rules)=>globbySync(rules, {
6
6
  cwd: lambdaDir,
7
- gitignore: true
7
+ ignoreFiles: '**/.gitignore'
8
8
  }).map((file)=>path.resolve(lambdaDir, file));
9
9
  const getPathFromFilename = (baseDir, filename)=>{
10
10
  const relativeName = filename.substring(baseDir.length);
@@ -1,5 +1,4 @@
1
1
  import "node:module";
2
- export * from "./alias.mjs";
3
2
  export * from "./meta.mjs";
4
3
  export * from "./storage.mjs";
5
4
  export * from "./validate.mjs";
@@ -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, getRelativeRuntimePath, HANDLER_WITH_META, INPUT_PARAMS_DECIDER, isInputParamsDeciderHandler, isWithMetaHandler, registerPaths, } from './utils/index.js';
8
+ export { createStorage, HANDLER_WITH_META, INPUT_PARAMS_DECIDER, isInputParamsDeciderHandler, isWithMetaHandler, } from './utils/index.js';
@@ -1,4 +1,3 @@
1
- export * from './alias.js';
2
1
  export { debug } from './debug.js';
3
2
  export * from './meta.js';
4
3
  export * from './storage.js';
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@bleedingdev/modern-js-bff-core",
3
3
  "description": "A Progressive React Framework for modern web development.",
4
- "homepage": "https://github.com/BleedingDev/ultramodern.js#readme",
4
+ "homepage": "https://github.com/ultramodernjs/ultramodern.js#readme",
5
5
  "bugs": {
6
- "url": "https://github.com/BleedingDev/ultramodern.js/issues"
6
+ "url": "https://github.com/ultramodernjs/ultramodern.js/issues"
7
7
  },
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/BleedingDev/ultramodern.js.git",
10
+ "url": "git+https://github.com/ultramodernjs/ultramodern.js.git",
11
11
  "directory": "packages/server/bff-core"
12
12
  },
13
13
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.9",
20
+ "version": "3.9.3-ultramodern.1",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -31,27 +31,24 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.9",
34
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.3-ultramodern.1",
35
35
  "@swc/helpers": "^0.5.23",
36
36
  "koa-compose": "^4.1.0",
37
37
  "reflect-metadata": "^0.2.2",
38
- "type-fest": "5.9.0"
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.9",
42
- "@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.9",
43
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.9",
44
- "@rslib/core": "1.0.0",
41
+ "@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.9.3-ultramodern.1",
42
+ "@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.3-ultramodern.1",
43
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.3-ultramodern.1",
44
+ "@rslib/core": "1.0.3",
45
45
  "@scripts/rstest-config": "2.66.0",
46
46
  "@types/koa-compose": "^3.2.9",
47
- "@types/node": "^26.4.1",
48
- "@typescript/native-preview": "7.0.0-dev.20260707.2",
47
+ "@types/node": "^26.6.3",
49
48
  "esbuild": "^0.28.2",
50
- "tsconfig-paths": "^4.2.0",
51
- "zod": "^4.5.4"
49
+ "zod": "^4.6.5"
52
50
  },
53
51
  "peerDependencies": {
54
- "tsconfig-paths": "^4.2.0",
55
52
  "zod": "^4.5.4"
56
53
  },
57
54
  "peerDependenciesMeta": {
@@ -65,6 +62,9 @@
65
62
  "scripts": {
66
63
  "dev": "rslib build --watch",
67
64
  "build": "rslib build",
68
- "test": "rstest --passWithNoTests"
65
+ "test": "rstest"
66
+ },
67
+ "ultramodern": {
68
+ "sourceName": "@modern-js/bff-core"
69
69
  }
70
70
  }
@@ -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
- });
@@ -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 {};