@modern-js/plugin-koa 1.5.1-beta.0 → 1.15.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.
- package/CHANGELOG.md +42 -0
- package/dist/js/modern/cli/index.js +2 -14
- package/dist/js/modern/context.js +1 -1
- package/dist/js/modern/plugin.js +1 -0
- package/dist/js/modern/runtime.js +1 -0
- package/dist/js/modern/utils.js +8 -4
- package/dist/js/node/cli/index.js +3 -15
- package/dist/js/node/context.js +2 -2
- package/dist/js/node/plugin.js +1 -0
- package/dist/js/node/runtime.js +7 -1
- package/dist/js/node/utils.js +8 -4
- package/dist/types/runtime.d.ts +2 -0
- package/package.json +9 -11
- package/types.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @modern-js/plugin-koa
|
|
2
2
|
|
|
3
|
+
## 1.15.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c0d8dac: fix: remove package adapter-helpers and bff runtime export
|
|
8
|
+
- 4524de6: fix: add server hook and types
|
|
9
|
+
fix: 增加 server hook API
|
|
10
|
+
- Updated dependencies [c0d8dac]
|
|
11
|
+
- Updated dependencies [8658a78]
|
|
12
|
+
- Updated dependencies [05d4a4f]
|
|
13
|
+
- Updated dependencies [7bfaaf9]
|
|
14
|
+
- Updated dependencies [b1f7000]
|
|
15
|
+
- Updated dependencies [ad05af9]
|
|
16
|
+
- Updated dependencies [5d53d1c]
|
|
17
|
+
- Updated dependencies [37cd159]
|
|
18
|
+
- @modern-js/bff-core@1.15.0
|
|
19
|
+
- @modern-js/utils@1.15.0
|
|
20
|
+
- @modern-js/bff-runtime@1.15.0
|
|
21
|
+
|
|
22
|
+
## 1.5.2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- f745969: fix: allow BFF function to return void
|
|
27
|
+
fix: 允许 BFF 函数返回 void
|
|
28
|
+
- Updated dependencies [aadd066]
|
|
29
|
+
- Updated dependencies [4fc801f]
|
|
30
|
+
- Updated dependencies [83660b6]
|
|
31
|
+
- Updated dependencies [c8614b8]
|
|
32
|
+
- @modern-js/bff-core@1.2.0
|
|
33
|
+
- @modern-js/utils@1.8.0
|
|
34
|
+
- @modern-js/bff-runtime@1.4.0
|
|
35
|
+
|
|
36
|
+
## 1.5.1
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 74f7fd7: fix: fix bff hot reload not works when has app.ts
|
|
41
|
+
fix: 修复有 app.ts 的时候, bff 热更新不生效的问题
|
|
42
|
+
- Updated dependencies [74f7fd7]
|
|
43
|
+
- @modern-js/bff-core@1.1.3
|
|
44
|
+
|
|
3
45
|
## 1.5.0
|
|
4
46
|
|
|
5
47
|
### Minor Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import { createRuntimeExportsUtils } from '@modern-js/utils';
|
|
3
|
-
import { getRelativeRuntimePath } from '@modern-js/
|
|
3
|
+
import { getRelativeRuntimePath } from '@modern-js/bff-core';
|
|
4
4
|
export default (() => ({
|
|
5
5
|
name: '@modern-js/plugin-koa',
|
|
6
6
|
setup: api => {
|
|
@@ -39,25 +39,13 @@ export default (() => ({
|
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
addRuntimeExports(input) {
|
|
42
|
-
const {
|
|
43
|
-
appDirectory
|
|
44
|
-
} = useAppContext();
|
|
45
|
-
|
|
46
|
-
const runtimePath = require.resolve(`@modern-js/runtime`, {
|
|
47
|
-
paths: [appDirectory]
|
|
48
|
-
});
|
|
49
|
-
|
|
50
42
|
const currentFile = bffExportsUtils.getPath();
|
|
51
|
-
const runtimeDir = path.dirname(runtimePath);
|
|
52
|
-
const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
|
|
53
43
|
const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
|
|
54
44
|
const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('koa'));
|
|
55
|
-
bffExportsUtils.addExport(`const
|
|
56
|
-
const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
45
|
+
bffExportsUtils.addExport(`const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
57
46
|
const Koa = require('${relativeFramePath}')
|
|
58
47
|
module.exports = {
|
|
59
48
|
Koa: Koa,
|
|
60
|
-
...bffRuntime,
|
|
61
49
|
...pluginRuntime
|
|
62
50
|
}
|
|
63
51
|
`);
|
package/dist/js/modern/plugin.js
CHANGED
package/dist/js/modern/utils.js
CHANGED
|
@@ -50,10 +50,10 @@ export const createRouteHandler = handler => {
|
|
|
50
50
|
if (isWithMetaHandler(handler)) {
|
|
51
51
|
try {
|
|
52
52
|
handleResponseMeta(ctx, handler);
|
|
53
|
-
const
|
|
53
|
+
const body = await handler(input);
|
|
54
54
|
|
|
55
|
-
if (
|
|
56
|
-
ctx.body =
|
|
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
|
-
|
|
88
|
+
const body = await handler(...args);
|
|
89
|
+
|
|
90
|
+
if (typeof body !== 'undefined') {
|
|
91
|
+
ctx.body = body;
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
94
|
};
|
|
91
95
|
|
|
@@ -9,7 +9,7 @@ var path = _interopRequireWildcard(require("path"));
|
|
|
9
9
|
|
|
10
10
|
var _utils = require("@modern-js/utils");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _bffCore = require("@modern-js/bff-core");
|
|
13
13
|
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
15
|
|
|
@@ -31,7 +31,7 @@ var _default = () => ({
|
|
|
31
31
|
} = appContext;
|
|
32
32
|
bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
|
|
33
33
|
const serverRuntimePath = bffExportsUtils.getPath();
|
|
34
|
-
const relativeRuntimePath = (0,
|
|
34
|
+
const relativeRuntimePath = (0, _bffCore.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
|
|
35
35
|
|
|
36
36
|
if (process.env.NODE_ENV === 'production') {
|
|
37
37
|
return {
|
|
@@ -53,25 +53,13 @@ var _default = () => ({
|
|
|
53
53
|
},
|
|
54
54
|
|
|
55
55
|
addRuntimeExports(input) {
|
|
56
|
-
const {
|
|
57
|
-
appDirectory
|
|
58
|
-
} = useAppContext();
|
|
59
|
-
|
|
60
|
-
const runtimePath = require.resolve(`@modern-js/runtime`, {
|
|
61
|
-
paths: [appDirectory]
|
|
62
|
-
});
|
|
63
|
-
|
|
64
56
|
const currentFile = bffExportsUtils.getPath();
|
|
65
|
-
const runtimeDir = path.dirname(runtimePath);
|
|
66
|
-
const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
|
|
67
57
|
const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
|
|
68
58
|
const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('koa'));
|
|
69
|
-
bffExportsUtils.addExport(`const
|
|
70
|
-
const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
59
|
+
bffExportsUtils.addExport(`const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
71
60
|
const Koa = require('${relativeFramePath}')
|
|
72
61
|
module.exports = {
|
|
73
62
|
Koa: Koa,
|
|
74
|
-
...bffRuntime,
|
|
75
63
|
...pluginRuntime
|
|
76
64
|
}
|
|
77
65
|
`);
|
package/dist/js/node/context.js
CHANGED
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useContext = exports.run = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _bffCore = require("@modern-js/bff-core");
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
run,
|
|
12
12
|
useContext
|
|
13
|
-
} = (0,
|
|
13
|
+
} = (0, _bffCore.createStorage)();
|
|
14
14
|
exports.useContext = useContext;
|
|
15
15
|
exports.run = run;
|
package/dist/js/node/plugin.js
CHANGED
package/dist/js/node/runtime.js
CHANGED
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
+
hook: true,
|
|
7
8
|
useContext: true
|
|
8
9
|
};
|
|
10
|
+
exports.hook = void 0;
|
|
9
11
|
Object.defineProperty(exports, "useContext", {
|
|
10
12
|
enumerable: true,
|
|
11
13
|
get: function () {
|
|
@@ -27,4 +29,8 @@ Object.keys(_bffCore).forEach(function (key) {
|
|
|
27
29
|
return _bffCore[key];
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
|
-
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const hook = attacher => attacher;
|
|
35
|
+
|
|
36
|
+
exports.hook = hook;
|
package/dist/js/node/utils.js
CHANGED
|
@@ -61,10 +61,10 @@ const createRouteHandler = handler => {
|
|
|
61
61
|
if ((0, _bffCore.isWithMetaHandler)(handler)) {
|
|
62
62
|
try {
|
|
63
63
|
handleResponseMeta(ctx, handler);
|
|
64
|
-
const
|
|
64
|
+
const body = await handler(input);
|
|
65
65
|
|
|
66
|
-
if (
|
|
67
|
-
ctx.body =
|
|
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
|
-
|
|
99
|
+
const body = await handler(...args);
|
|
100
|
+
|
|
101
|
+
if (typeof body !== 'undefined') {
|
|
102
|
+
ctx.body = body;
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
};
|
|
102
106
|
|
package/dist/types/runtime.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.15.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -34,19 +34,18 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.18.0",
|
|
37
|
-
"@modern-js/
|
|
38
|
-
"@modern-js/bff-
|
|
39
|
-
"@modern-js/
|
|
40
|
-
"@modern-js/utils": "^1.7.11",
|
|
37
|
+
"@modern-js/bff-core": "1.15.0",
|
|
38
|
+
"@modern-js/bff-runtime": "1.15.0",
|
|
39
|
+
"@modern-js/utils": "1.15.0",
|
|
41
40
|
"koa-body": "^4.2.0",
|
|
42
41
|
"koa-router": "^10.0.0",
|
|
43
42
|
"type-is": "^1.6.18"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
|
-
"@modern-js/core": "1.
|
|
47
|
-
"@modern-js/server-core": "1.
|
|
48
|
-
"@scripts/build": "
|
|
49
|
-
"@scripts/jest-config": "
|
|
45
|
+
"@modern-js/core": "1.15.0",
|
|
46
|
+
"@modern-js/server-core": "1.15.0",
|
|
47
|
+
"@scripts/build": "1.15.0",
|
|
48
|
+
"@scripts/jest-config": "1.15.0",
|
|
50
49
|
"@types/jest": "^27",
|
|
51
50
|
"@types/koa": "^2.13.4",
|
|
52
51
|
"@types/koa-router": "^7.4.4",
|
|
@@ -69,8 +68,7 @@
|
|
|
69
68
|
},
|
|
70
69
|
"publishConfig": {
|
|
71
70
|
"registry": "https://registry.npmjs.org/",
|
|
72
|
-
"access": "public"
|
|
73
|
-
"types": "./dist/types/index.d.ts"
|
|
71
|
+
"access": "public"
|
|
74
72
|
},
|
|
75
73
|
"wireit": {
|
|
76
74
|
"build": {
|