@modern-js/plugin-koa 2.8.0 → 2.10.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,36 @@
1
1
  # @modern-js/plugin-koa
2
2
 
3
+ ## 2.10.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 3e0bd50: feat: when enable bff handle render, support use `useContext` to get framework plugin context in data loader.
8
+ feat: 当开启 BFF 托管渲染时,支持在 data loader 中使用 `useContext` 获取框架插件提供的上下文。
9
+ - 0da32d0: chore: upgrade jest and puppeteer
10
+ chore: 升级 jest 和 puppeteer 到 latest
11
+ - 0d9962b: fix: add types field in package.json
12
+ fix: 添加 package.json 中的 types 字段
13
+ - Updated dependencies [3e0bd50]
14
+ - Updated dependencies [92d247f]
15
+ - Updated dependencies [0da32d0]
16
+ - Updated dependencies [0d9962b]
17
+ - Updated dependencies [fbefa7e]
18
+ - Updated dependencies [4d54233]
19
+ - Updated dependencies [6db4864]
20
+ - @modern-js/types@2.10.0
21
+ - @modern-js/bff-runtime@2.10.0
22
+ - @modern-js/bff-core@2.10.0
23
+ - @modern-js/utils@2.10.0
24
+
25
+ ## 2.9.0
26
+
27
+ ### Patch Changes
28
+
29
+ - @modern-js/bff-core@2.9.0
30
+ - @modern-js/bff-runtime@2.9.0
31
+ - @modern-js/types@2.9.0
32
+ - @modern-js/utils@2.9.0
33
+
3
34
  ## 2.8.0
4
35
 
5
36
  ### Patch Changes
@@ -32,7 +32,6 @@ __export(cli_exports, {
32
32
  module.exports = __toCommonJS(cli_exports);
33
33
  var path = __toESM(require("path"));
34
34
  var import_utils = require("@modern-js/utils");
35
- var import_bff_core = require("@modern-js/bff-core");
36
35
  var cli_default = () => ({
37
36
  name: "@modern-js/plugin-koa",
38
37
  setup: (api) => {
@@ -42,35 +41,25 @@ var cli_default = () => ({
42
41
  return {
43
42
  config() {
44
43
  const appContext = useAppContext();
45
- const { appDirectory } = appContext;
46
44
  bffExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
47
45
  appContext.internalDirectory,
48
46
  "server"
49
47
  );
50
- const serverRuntimePath = bffExportsUtils.getPath();
51
- const relativeRuntimePath = (0, import_bff_core.getRelativeRuntimePath)(
52
- appDirectory,
53
- serverRuntimePath
54
- );
55
- if (process.env.NODE_ENV === "production") {
56
- return {
57
- source: {
58
- alias: {
59
- "@modern-js/runtime/server": relativeRuntimePath,
60
- "@modern-js/runtime/koa": relativeRuntimePath
61
- }
48
+ const runtimePath = "@modern-js/plugin-koa/runtime";
49
+ const alias = process.env.NODE_ENV === "production" ? runtimePath : require.resolve(runtimePath);
50
+ return {
51
+ output: {
52
+ externals: {
53
+ "@modern-js/runtime/koa": runtimePath
62
54
  }
63
- };
64
- } else {
65
- return {
66
- source: {
67
- alias: {
68
- "@modern-js/runtime/server": serverRuntimePath,
69
- "@modern-js/runtime/koa": serverRuntimePath
70
- }
55
+ },
56
+ source: {
57
+ alias: {
58
+ "@modern-js/runtime/server": alias,
59
+ "@modern-js/runtime/koa": alias
71
60
  }
72
- };
73
- }
61
+ }
62
+ };
74
63
  },
75
64
  collectServerPlugins({ plugins }) {
76
65
  plugins.push({
@@ -1,6 +1,5 @@
1
1
  import * as path from "path";
2
2
  import { createRuntimeExportsUtils } from "@modern-js/utils";
3
- import { getRelativeRuntimePath } from "@modern-js/bff-core";
4
3
  var cli_default = function() {
5
4
  return {
6
5
  name: "@modern-js/plugin-koa",
@@ -11,29 +10,22 @@ var cli_default = function() {
11
10
  return {
12
11
  config: function config() {
13
12
  var appContext = useAppContext();
14
- var appDirectory = appContext.appDirectory;
15
13
  bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "server");
16
- var serverRuntimePath = bffExportsUtils.getPath();
17
- var relativeRuntimePath = getRelativeRuntimePath(appDirectory, serverRuntimePath);
18
- if (process.env.NODE_ENV === "production") {
19
- return {
20
- source: {
21
- alias: {
22
- "@modern-js/runtime/server": relativeRuntimePath,
23
- "@modern-js/runtime/koa": relativeRuntimePath
24
- }
14
+ var runtimePath = "@modern-js/plugin-koa/runtime";
15
+ var alias = process.env.NODE_ENV === "production" ? runtimePath : require.resolve(runtimePath);
16
+ return {
17
+ output: {
18
+ externals: {
19
+ "@modern-js/runtime/koa": runtimePath
25
20
  }
26
- };
27
- } else {
28
- return {
29
- source: {
30
- alias: {
31
- "@modern-js/runtime/server": serverRuntimePath,
32
- "@modern-js/runtime/koa": serverRuntimePath
33
- }
21
+ },
22
+ source: {
23
+ alias: {
24
+ "@modern-js/runtime/server": alias,
25
+ "@modern-js/runtime/koa": alias
34
26
  }
35
- };
36
- }
27
+ }
28
+ };
37
29
  },
38
30
  collectServerPlugins: function collectServerPlugins(param) {
39
31
  var plugins = param.plugins;
@@ -1,6 +1,5 @@
1
1
  import * as path from "path";
2
2
  import { createRuntimeExportsUtils } from "@modern-js/utils";
3
- import { getRelativeRuntimePath } from "@modern-js/bff-core";
4
3
  var cli_default = () => ({
5
4
  name: "@modern-js/plugin-koa",
6
5
  setup: (api) => {
@@ -10,35 +9,25 @@ var cli_default = () => ({
10
9
  return {
11
10
  config() {
12
11
  const appContext = useAppContext();
13
- const { appDirectory } = appContext;
14
12
  bffExportsUtils = createRuntimeExportsUtils(
15
13
  appContext.internalDirectory,
16
14
  "server"
17
15
  );
18
- const serverRuntimePath = bffExportsUtils.getPath();
19
- const relativeRuntimePath = getRelativeRuntimePath(
20
- appDirectory,
21
- serverRuntimePath
22
- );
23
- if (process.env.NODE_ENV === "production") {
24
- return {
25
- source: {
26
- alias: {
27
- "@modern-js/runtime/server": relativeRuntimePath,
28
- "@modern-js/runtime/koa": relativeRuntimePath
29
- }
16
+ const runtimePath = "@modern-js/plugin-koa/runtime";
17
+ const alias = process.env.NODE_ENV === "production" ? runtimePath : require.resolve(runtimePath);
18
+ return {
19
+ output: {
20
+ externals: {
21
+ "@modern-js/runtime/koa": runtimePath
30
22
  }
31
- };
32
- } else {
33
- return {
34
- source: {
35
- alias: {
36
- "@modern-js/runtime/server": serverRuntimePath,
37
- "@modern-js/runtime/koa": serverRuntimePath
38
- }
23
+ },
24
+ source: {
25
+ alias: {
26
+ "@modern-js/runtime/server": alias,
27
+ "@modern-js/runtime/koa": alias
39
28
  }
40
- };
41
- }
29
+ }
30
+ };
42
31
  },
43
32
  collectServerPlugins({ plugins }) {
44
33
  plugins.push({
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.8.0",
14
+ "version": "2.10.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/cli/index.d.ts",
17
17
  "main": "./dist/cjs/cli/index.js",
@@ -20,18 +20,25 @@
20
20
  "./types": "./types.d.ts",
21
21
  ".": {
22
22
  "jsnext:source": "./src/cli/index.ts",
23
+ "types": "./dist/types/cli/index.d.ts",
23
24
  "default": "./dist/cjs/cli/index.js"
24
25
  },
25
26
  "./cli": {
26
27
  "jsnext:source": "./src/cli/index.ts",
28
+ "types": "./dist/types/cli.d.ts",
27
29
  "default": "./dist/cjs/cli/index.js"
28
30
  },
31
+ "./runtime": {
32
+ "jsnext:source": "./src/runtime.ts",
33
+ "default": "./dist/cjs/runtime.js"
34
+ },
29
35
  "./server": {
30
36
  "node": {
31
37
  "jsnext:source": "./src/index.ts",
32
38
  "import": "./dist/esm-node/index.js",
33
39
  "require": "./dist/cjs/index.js"
34
40
  },
41
+ "types": "./dist/types/index.d.ts",
35
42
  "default": "./dist/esm/index.js"
36
43
  }
37
44
  },
@@ -43,6 +50,9 @@
43
50
  "cli": [
44
51
  "./dist/types/cli"
45
52
  ],
53
+ "runtime": [
54
+ "./dist/types/runtime.d.ts"
55
+ ],
46
56
  "server": [
47
57
  "./dist/types/index.d.ts"
48
58
  ]
@@ -53,28 +63,28 @@
53
63
  "koa-body": "^4.2.0",
54
64
  "koa-router": "^10.0.0",
55
65
  "type-is": "^1.6.18",
56
- "@modern-js/bff-core": "2.8.0",
57
- "@modern-js/bff-runtime": "2.8.0",
58
- "@modern-js/utils": "2.8.0",
59
- "@modern-js/types": "2.8.0"
66
+ "@modern-js/bff-core": "2.10.0",
67
+ "@modern-js/utils": "2.10.0",
68
+ "@modern-js/bff-runtime": "2.10.0",
69
+ "@modern-js/types": "2.10.0"
60
70
  },
61
71
  "devDependencies": {
62
- "@types/jest": "^27",
72
+ "@types/jest": "^29",
63
73
  "@types/koa": "^2.13.4",
64
74
  "@types/koa-router": "^7.4.4",
65
75
  "@types/node": "^14",
66
76
  "@types/supertest": "^2.0.11",
67
77
  "@types/type-is": "^1.6.3",
68
- "jest": "^27",
78
+ "jest": "^29",
69
79
  "koa": "^2.13.3",
70
80
  "supertest": "^6.1.6",
71
81
  "typescript": "^4",
72
82
  "zod": "^3.17.3",
73
- "@modern-js/core": "2.8.0",
74
- "@modern-js/server-core": "2.8.0",
75
- "@modern-js/app-tools": "2.8.0",
76
- "@scripts/build": "2.8.0",
77
- "@scripts/jest-config": "2.8.0"
83
+ "@modern-js/core": "2.10.0",
84
+ "@modern-js/server-core": "2.10.0",
85
+ "@modern-js/app-tools": "2.10.0",
86
+ "@scripts/build": "2.10.0",
87
+ "@scripts/jest-config": "2.10.0"
78
88
  },
79
89
  "peerDependencies": {
80
90
  "koa": "^2.13.3"