@modern-js/plugin-koa 1.5.0 → 1.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @modern-js/plugin-koa
2
2
 
3
+ ## 1.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f745969: fix: allow BFF function to return void
8
+ fix: 允许 BFF 函数返回 void
9
+ - Updated dependencies [aadd066]
10
+ - Updated dependencies [4fc801f]
11
+ - Updated dependencies [83660b6]
12
+ - Updated dependencies [c8614b8]
13
+ - @modern-js/bff-core@1.2.0
14
+ - @modern-js/utils@1.8.0
15
+ - @modern-js/bff-runtime@1.4.0
16
+
17
+ ## 1.5.1
18
+
19
+ ### Patch Changes
20
+
21
+ - 74f7fd7: fix: fix bff hot reload not works when has app.ts
22
+ fix: 修复有 app.ts 的时候, bff 热更新不生效的问题
23
+ - Updated dependencies [74f7fd7]
24
+ - @modern-js/bff-core@1.1.3
25
+
3
26
  ## 1.5.0
4
27
 
5
28
  ### Minor Changes
@@ -12,6 +12,8 @@ const findAppModule = async apiDir => {
12
12
 
13
13
  for (const filename of paths) {
14
14
  if (await fs.pathExists(filename)) {
15
+ // 每次获取 app.ts 的时候,避免使用缓存的 app.ts
16
+ delete require.cache[filename];
15
17
  return compatRequire(filename);
16
18
  }
17
19
  }
@@ -50,10 +50,10 @@ export const createRouteHandler = handler => {
50
50
  if (isWithMetaHandler(handler)) {
51
51
  try {
52
52
  handleResponseMeta(ctx, handler);
53
- const result = await handler(input);
53
+ const body = await handler(input);
54
54
 
55
- if (result) {
56
- ctx.body = result;
55
+ if (typeof body !== 'undefined') {
56
+ ctx.body = body;
57
57
  }
58
58
  } catch (error) {
59
59
  if (error instanceof Error) {
@@ -85,7 +85,11 @@ export const createRouteHandler = handler => {
85
85
  }
86
86
  } else {
87
87
  const args = Object.values(input.params).concat(input);
88
- ctx.body = await handler(...args);
88
+ const body = await handler(...args);
89
+
90
+ if (typeof body !== 'undefined') {
91
+ ctx.body = body;
92
+ }
89
93
  }
90
94
  };
91
95
 
@@ -31,6 +31,8 @@ const findAppModule = async apiDir => {
31
31
 
32
32
  for (const filename of paths) {
33
33
  if (await _utils.fs.pathExists(filename)) {
34
+ // 每次获取 app.ts 的时候,避免使用缓存的 app.ts
35
+ delete require.cache[filename];
34
36
  return (0, _utils.compatRequire)(filename);
35
37
  }
36
38
  }
@@ -61,10 +61,10 @@ const createRouteHandler = handler => {
61
61
  if ((0, _bffCore.isWithMetaHandler)(handler)) {
62
62
  try {
63
63
  handleResponseMeta(ctx, handler);
64
- const result = await handler(input);
64
+ const body = await handler(input);
65
65
 
66
- if (result) {
67
- ctx.body = result;
66
+ if (typeof body !== 'undefined') {
67
+ ctx.body = body;
68
68
  }
69
69
  } catch (error) {
70
70
  if (error instanceof Error) {
@@ -96,7 +96,11 @@ const createRouteHandler = handler => {
96
96
  }
97
97
  } else {
98
98
  const args = Object.values(input.params).concat(input);
99
- ctx.body = await handler(...args);
99
+ const body = await handler(...args);
100
+
101
+ if (typeof body !== 'undefined') {
102
+ ctx.body = body;
103
+ }
100
104
  }
101
105
  };
102
106
 
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.5.0",
14
+ "version": "1.5.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -35,16 +35,16 @@
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.18.0",
37
37
  "@modern-js/adapter-helpers": "^1.3.0",
38
- "@modern-js/bff-core": "^1.1.0",
39
- "@modern-js/bff-runtime": "^1.3.0",
40
- "@modern-js/utils": "^1.7.9",
38
+ "@modern-js/bff-core": "^1.2.0",
39
+ "@modern-js/bff-runtime": "^1.4.0",
40
+ "@modern-js/utils": "^1.8.0",
41
41
  "koa-body": "^4.2.0",
42
42
  "koa-router": "^10.0.0",
43
43
  "type-is": "^1.6.18"
44
44
  },
45
45
  "devDependencies": {
46
- "@modern-js/core": "1.12.2",
47
- "@modern-js/server-core": "1.4.0",
46
+ "@modern-js/core": "1.13.1",
47
+ "@modern-js/server-core": "1.4.1",
48
48
  "@scripts/build": "0.0.0",
49
49
  "@scripts/jest-config": "0.0.0",
50
50
  "@types/jest": "^27",