@modern-js/bff-core 3.0.4 → 3.1.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.
@@ -209,7 +209,8 @@ var __webpack_exports__ = {};
209
209
  if ('string' == typeof filename && !path__rspack_import_0_default().isAbsolute(filename)) throw new Error(`The ${paramsName} ${filename} is not a abolute path`);
210
210
  }
211
211
  async getModuleInfos(filenames) {
212
- return Promise.all(filenames.map((filename)=>this.getModuleInfo(filename)).filter((moduleInfo)=>Boolean(moduleInfo)));
212
+ const moduleInfos = await Promise.all(filenames.map((filename)=>this.getModuleInfo(filename)));
213
+ return moduleInfos.filter(Boolean);
213
214
  }
214
215
  async getModuleInfo(filename) {
215
216
  try {
@@ -219,8 +220,13 @@ var __webpack_exports__ = {};
219
220
  module
220
221
  };
221
222
  } catch (err) {
222
- if ('production' === process.env.NODE_ENV) throw err;
223
- console.error(err);
223
+ if ('production' === process.env.NODE_ENV) {
224
+ const error = new Error(`Failed to load BFF module '${filename}': ${err.message}`, {
225
+ cause: err
226
+ });
227
+ throw error;
228
+ }
229
+ console.error(`Failed to load BFF module '${filename}':`, err);
224
230
  return null;
225
231
  }
226
232
  }
@@ -69,8 +69,7 @@ const clearRouteName = (routeName)=>{
69
69
  const isHandler = (input)=>input && 'function' == typeof input;
70
70
  const isFunction = (input)=>input && '[object Function]' === ({}).toString.call(input);
71
71
  const requireHandlerModule = async (modulePath)=>{
72
- const originRequire = 'test' === process.env.NODE_ENV ? require : utils_namespaceObject.compatibleRequire;
73
- const module = await originRequire(modulePath, false);
72
+ const module = await (0, utils_namespaceObject.compatibleRequire)(modulePath, false);
74
73
  if (isFunction(module)) return {
75
74
  default: module
76
75
  };
@@ -124,7 +124,8 @@ class ApiRouter {
124
124
  if ('string' == typeof filename && !path.isAbsolute(filename)) throw new Error(`The ${paramsName} ${filename} is not a abolute path`);
125
125
  }
126
126
  async getModuleInfos(filenames) {
127
- return Promise.all(filenames.map((filename)=>this.getModuleInfo(filename)).filter((moduleInfo)=>Boolean(moduleInfo)));
127
+ const moduleInfos = await Promise.all(filenames.map((filename)=>this.getModuleInfo(filename)));
128
+ return moduleInfos.filter(Boolean);
128
129
  }
129
130
  async getModuleInfo(filename) {
130
131
  try {
@@ -134,8 +135,13 @@ class ApiRouter {
134
135
  module
135
136
  };
136
137
  } catch (err) {
137
- if ('production' === process.env.NODE_ENV) throw err;
138
- console.error(err);
138
+ if ('production' === process.env.NODE_ENV) {
139
+ const error = new Error(`Failed to load BFF module '${filename}': ${err.message}`, {
140
+ cause: err
141
+ });
142
+ throw error;
143
+ }
144
+ console.error(`Failed to load BFF module '${filename}':`, err);
139
145
  return null;
140
146
  }
141
147
  }
@@ -27,8 +27,7 @@ const clearRouteName = (routeName)=>{
27
27
  const isHandler = (input)=>input && 'function' == typeof input;
28
28
  const isFunction = (input)=>input && '[object Function]' === ({}).toString.call(input);
29
29
  const requireHandlerModule = async (modulePath)=>{
30
- const originRequire = 'test' === process.env.NODE_ENV ? require : compatibleRequire;
31
- const module = await originRequire(modulePath, false);
30
+ const module = await compatibleRequire(modulePath, false);
32
31
  if (isFunction(module)) return {
33
32
  default: module
34
33
  };
@@ -125,7 +125,8 @@ class ApiRouter {
125
125
  if ('string' == typeof filename && !path.isAbsolute(filename)) throw new Error(`The ${paramsName} ${filename} is not a abolute path`);
126
126
  }
127
127
  async getModuleInfos(filenames) {
128
- return Promise.all(filenames.map((filename)=>this.getModuleInfo(filename)).filter((moduleInfo)=>Boolean(moduleInfo)));
128
+ const moduleInfos = await Promise.all(filenames.map((filename)=>this.getModuleInfo(filename)));
129
+ return moduleInfos.filter(Boolean);
129
130
  }
130
131
  async getModuleInfo(filename) {
131
132
  try {
@@ -135,8 +136,13 @@ class ApiRouter {
135
136
  module
136
137
  };
137
138
  } catch (err) {
138
- if ('production' === process.env.NODE_ENV) throw err;
139
- console.error(err);
139
+ if ('production' === process.env.NODE_ENV) {
140
+ const error = new Error(`Failed to load BFF module '${filename}': ${err.message}`, {
141
+ cause: err
142
+ });
143
+ throw error;
144
+ }
145
+ console.error(`Failed to load BFF module '${filename}':`, err);
140
146
  return null;
141
147
  }
142
148
  }
@@ -1,5 +1,4 @@
1
- import __rslib_shim_module__ from "node:module";
2
- const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
1
+ import "node:module";
3
2
  import path from "path";
4
3
  import { compatibleRequire, globby } from "@modern-js/utils";
5
4
  import { INDEX_SUFFIX } from "./constants.mjs";
@@ -29,8 +28,7 @@ const clearRouteName = (routeName)=>{
29
28
  const isHandler = (input)=>input && 'function' == typeof input;
30
29
  const isFunction = (input)=>input && '[object Function]' === ({}).toString.call(input);
31
30
  const requireHandlerModule = async (modulePath)=>{
32
- const originRequire = 'test' === process.env.NODE_ENV ? require : compatibleRequire;
33
- const module = await originRequire(modulePath, false);
31
+ const module = await compatibleRequire(modulePath, false);
34
32
  if (isFunction(module)) return {
35
33
  default: module
36
34
  };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.0.4",
18
+ "version": "3.1.0",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "main": "./dist/cjs/index.js",
21
21
  "exports": {
@@ -33,7 +33,7 @@
33
33
  "koa-compose": "^4.1.0",
34
34
  "reflect-metadata": "^0.2.2",
35
35
  "type-fest": "2.19.0",
36
- "@modern-js/utils": "3.0.4"
36
+ "@modern-js/utils": "3.1.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rslib/core": "0.19.6",
@@ -44,8 +44,8 @@
44
44
  "typescript": "^5",
45
45
  "zod": "^3.25.76",
46
46
  "@modern-js/rslib": "2.68.10",
47
- "@modern-js/types": "3.0.4",
48
- "@scripts/rstest-config": "2.66.0"
47
+ "@scripts/rstest-config": "2.66.0",
48
+ "@modern-js/types": "3.1.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "ts-node": "^10.9.2",