@modern-js/plugin-koa 1.5.2 → 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 CHANGED
@@ -1,5 +1,24 @@
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
+
3
22
  ## 1.5.2
4
23
 
5
24
  ### Patch 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/adapter-helpers';
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 bffRuntime = require('${relativeBffPath}');
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
  `);
@@ -1,4 +1,4 @@
1
- import { createStorage } from '@modern-js/adapter-helpers';
1
+ import { createStorage } from '@modern-js/bff-core';
2
2
  const {
3
3
  run,
4
4
  useContext
@@ -1,2 +1,3 @@
1
+ export const hook = attacher => attacher;
1
2
  export { useContext } from "./context";
2
3
  export * from '@modern-js/bff-core';
@@ -9,7 +9,7 @@ var path = _interopRequireWildcard(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
- var _adapterHelpers = require("@modern-js/adapter-helpers");
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, _adapterHelpers.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
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 bffRuntime = require('${relativeBffPath}');
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
  `);
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useContext = exports.run = void 0;
7
7
 
8
- var _adapterHelpers = require("@modern-js/adapter-helpers");
8
+ var _bffCore = require("@modern-js/bff-core");
9
9
 
10
10
  const {
11
11
  run,
12
12
  useContext
13
- } = (0, _adapterHelpers.createStorage)();
13
+ } = (0, _bffCore.createStorage)();
14
14
  exports.useContext = useContext;
15
15
  exports.run = run;
@@ -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;
@@ -1,2 +1,4 @@
1
+ import type { Middleware } from 'koa';
2
+ export declare const hook: (attacher: Middleware) => Middleware<import("koa").DefaultState, import("koa").DefaultContext, any>;
1
3
  export { useContext } from './context';
2
4
  export * from '@modern-js/bff-core';
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.5.2",
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/adapter-helpers": "^1.3.0",
38
- "@modern-js/bff-core": "^1.2.0",
39
- "@modern-js/bff-runtime": "^1.4.0",
40
- "@modern-js/utils": "^1.8.0",
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.13.1",
47
- "@modern-js/server-core": "1.4.1",
48
- "@scripts/build": "0.0.0",
49
- "@scripts/jest-config": "0.0.0",
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",
package/types.d.ts CHANGED
@@ -14,6 +14,4 @@ declare module '@modern-js/runtime/server' {
14
14
  export function hook(attacher: KoaAttacher): KoaAttacher;
15
15
 
16
16
  export * from '@modern-js/bff-core';
17
-
18
- export * from '@modern-js/bff-runtime';
19
17
  }