@modern-js/bff-core 1.2.2-beta.1 → 1.2.2

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.
@@ -70,10 +70,8 @@ const enableRegister = requireFn => {
70
70
 
71
71
  const isFunction = input => input && {}.toString.call(input) === '[object Function]';
72
72
 
73
- export const requireHandlerModule = modulePath => {
74
- // 测试环境不走缓存,因为缓存的 handler 文件,会被 mockAPI 函数进行 mock,升级 jest28,setupFilesAfterEnv 能做异步操作的话,可解此问题
75
- const originRequire = process.env.NODE_ENV === 'test' ? jest.requireActual : require;
76
- const module = originRequire(modulePath);
73
+ export const requireHandlerModule = enableRegister(modulePath => {
74
+ const module = require(modulePath);
77
75
 
78
76
  if (isFunction(module)) {
79
77
  return {
@@ -82,7 +80,7 @@ export const requireHandlerModule = modulePath => {
82
80
  }
83
81
 
84
82
  return module;
85
- };
83
+ });
86
84
 
87
85
  const routeValue = routePath => {
88
86
  if (routePath.includes(':')) {
@@ -89,10 +89,8 @@ const enableRegister = requireFn => {
89
89
 
90
90
  const isFunction = input => input && {}.toString.call(input) === '[object Function]';
91
91
 
92
- const requireHandlerModule = modulePath => {
93
- // 测试环境不走缓存,因为缓存的 handler 文件,会被 mockAPI 函数进行 mock,升级 jest28,setupFilesAfterEnv 能做异步操作的话,可解此问题
94
- const originRequire = process.env.NODE_ENV === 'test' ? jest.requireActual : require;
95
- const module = originRequire(modulePath);
92
+ const requireHandlerModule = enableRegister(modulePath => {
93
+ const module = require(modulePath);
96
94
 
97
95
  if (isFunction(module)) {
98
96
  return {
@@ -101,8 +99,7 @@ const requireHandlerModule = modulePath => {
101
99
  }
102
100
 
103
101
  return module;
104
- };
105
-
102
+ });
106
103
  exports.requireHandlerModule = requireHandlerModule;
107
104
 
108
105
  const routeValue = routePath => {
@@ -1,10 +1,10 @@
1
- import { APIHandlerInfo } from './types';
1
+ import { APIHandlerInfo, HandlerModule } from './types';
2
2
  declare type MaybeAsync<I> = I | Promise<I>;
3
3
  export declare type NormalHandler = (...args: any[]) => any;
4
4
  export declare type Handler<I, O> = (input: I) => MaybeAsync<O>;
5
5
  export declare const getFiles: (lambdaDir: string, rules: string | string[]) => string[];
6
6
  export declare const getPathFromFilename: (baseDir: string, filename: string) => string;
7
7
  export declare const isHandler: (input: any) => input is Handler<any, any>;
8
- export declare const requireHandlerModule: (modulePath: string) => any;
8
+ export declare const requireHandlerModule: (modulePath: string) => HandlerModule;
9
9
  export declare const sortRoutes: (apiHandlers: APIHandlerInfo[]) => APIHandlerInfo[];
10
10
  export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.2-beta.1",
14
+ "version": "1.2.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.18.0",
28
28
  "@modern-js/bff-runtime": "^1.4.0",
29
- "@modern-js/utils": "^1.8.0",
29
+ "@modern-js/utils": "^1.9.0",
30
30
  "esbuild": "^0.14.38",
31
31
  "esbuild-register": "^3.3.3",
32
32
  "koa-compose": "^4.1.0",
@@ -58,8 +58,7 @@
58
58
  },
59
59
  "publishConfig": {
60
60
  "registry": "https://registry.npmjs.org/",
61
- "access": "public",
62
- "types": "./dist/types/index.d.ts"
61
+ "access": "public"
63
62
  },
64
63
  "wireit": {
65
64
  "build": {