@modern-js/plugin-koa 1.0.0 → 1.1.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/.eslintrc.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ extends: ['@modern-js'],
3
+ parserOptions: {
4
+ project: require.resolve('./tsconfig.json'),
5
+ },
6
+ ignorePatterns: ['types.d.ts'],
7
+ };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @modern-js/plugin-koa
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 0fa83663: support more .env files
8
+ - Updated dependencies [6f7fe574]
9
+ - Updated dependencies [0fa83663]
10
+ - Updated dependencies [f594fbc8]
11
+ - @modern-js/core@1.1.2
12
+ - @modern-js/adapter-helpers@1.1.1
13
+ - @modern-js/bff-runtime@1.1.1
14
+ - @modern-js/bff-utils@1.1.1
15
+ - @modern-js/server-plugin@1.1.1
16
+ - @modern-js/utils@1.1.2
17
+
18
+ ## 1.1.1
19
+
20
+ ### Patch Changes
21
+
22
+ - 6ffd1a50: Refactor to base on farrow-pipeline
23
+ - Updated dependencies [687c92c7]
24
+ - Updated dependencies [c0fc0700]
25
+ - @modern-js/core@1.1.1
26
+ - @modern-js/utils@1.1.1
27
+
28
+ ## 1.1.0
29
+
30
+ ### Minor Changes
31
+
32
+ - 96119db2: Relese v1.1.0
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [96119db2]
37
+ - @modern-js/core@1.1.0
38
+ - @modern-js/adapter-helpers@1.1.0
39
+ - @modern-js/bff-runtime@1.1.0
40
+ - @modern-js/bff-utils@1.1.0
41
+ - @modern-js/server-plugin@1.1.0
42
+ - @modern-js/utils@1.1.0
43
+
3
44
  ## 1.0.0
4
45
 
5
46
  ### Patch Changes
package/README.md CHANGED
@@ -17,10 +17,7 @@
17
17
 
18
18
  > The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.
19
19
 
20
- - 介绍 Modern.js (即将上线)
21
- - [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
22
- - [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
23
- - [字节跳动是如何落地微前端的](https://mp.weixin.qq.com/s/L9wbfNG5fTXF5bx7dcgj4Q)
20
+ - [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)
24
21
 
25
22
  ## Getting Started
26
23
 
@@ -1,6 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import { useAppContext, createPlugin } from '@modern-js/core';
3
- import { createRuntimeExportsUtils, upath } from '@modern-js/utils';
3
+ import { createRuntimeExportsUtils } from '@modern-js/utils';
4
4
  export default createPlugin(() => {
5
5
  let bffExportsUtils;
6
6
  const runtimeModulePath = path.resolve(__dirname, '../runtime');
@@ -18,14 +18,16 @@ export default createPlugin(() => {
18
18
  };
19
19
  },
20
20
 
21
- modifyEntryImports() {
21
+ modifyEntryImports(input) {
22
22
  // eslint-disable-next-line react-hooks/rules-of-hooks
23
23
  const {
24
24
  appDirectory
25
25
  } = useAppContext();
26
- const runtimePath = upath.normalizeSafe(require.resolve(`@modern-js/runtime`, {
26
+
27
+ const runtimePath = require.resolve(`@modern-js/runtime`, {
27
28
  paths: [appDirectory]
28
- }));
29
+ });
30
+
29
31
  const currentFile = bffExportsUtils.getPath();
30
32
  const runtimeDir = path.dirname(runtimePath);
31
33
  const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
@@ -40,6 +42,7 @@ export default createPlugin(() => {
40
42
  ...pluginRuntime
41
43
  }
42
44
  `);
45
+ return input;
43
46
  }
44
47
 
45
48
  };
@@ -40,7 +40,8 @@ const registerRoutes = (router, prefix) => {
40
40
  } else {
41
41
  // eslint-disable-next-line require-atomic-updates
42
42
  ctx.status = 500;
43
- }
43
+ } // eslint-disable-next-line require-atomic-updates
44
+
44
45
 
45
46
  ctx.body = result.message;
46
47
  } else {
@@ -48,8 +49,11 @@ const registerRoutes = (router, prefix) => {
48
49
  ctx.body = result.value;
49
50
  }
50
51
  } else {
51
- const args = Object.values(input.params).concat(input); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
+ const args = Object.values(input.params).concat(input); // eslint-disable-next-line require-atomic-updates
53
+
54
+ ctx.type = 'json'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
55
  // @ts-expect-error
56
+ // eslint-disable-next-line require-atomic-updates
53
57
 
54
58
  ctx.body = await handler(...args);
55
59
  }
@@ -32,15 +32,15 @@ var _default = (0, _core.createPlugin)(() => {
32
32
  };
33
33
  },
34
34
 
35
- modifyEntryImports() {
35
+ modifyEntryImports(input) {
36
36
  // eslint-disable-next-line react-hooks/rules-of-hooks
37
37
  const {
38
38
  appDirectory
39
39
  } = (0, _core.useAppContext)();
40
40
 
41
- const runtimePath = _utils.upath.normalizeSafe(require.resolve(`@modern-js/runtime`, {
41
+ const runtimePath = require.resolve(`@modern-js/runtime`, {
42
42
  paths: [appDirectory]
43
- }));
43
+ });
44
44
 
45
45
  const currentFile = bffExportsUtils.getPath();
46
46
  const runtimeDir = path.dirname(runtimePath);
@@ -56,6 +56,7 @@ var _default = (0, _core.createPlugin)(() => {
56
56
  ...pluginRuntime
57
57
  }
58
58
  `);
59
+ return input;
59
60
  }
60
61
 
61
62
  };
@@ -55,7 +55,8 @@ const registerRoutes = (router, prefix) => {
55
55
  } else {
56
56
  // eslint-disable-next-line require-atomic-updates
57
57
  ctx.status = 500;
58
- }
58
+ } // eslint-disable-next-line require-atomic-updates
59
+
59
60
 
60
61
  ctx.body = result.message;
61
62
  } else {
@@ -63,8 +64,11 @@ const registerRoutes = (router, prefix) => {
63
64
  ctx.body = result.value;
64
65
  }
65
66
  } else {
66
- const args = Object.values(input.params).concat(input); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
67
+ const args = Object.values(input.params).concat(input); // eslint-disable-next-line require-atomic-updates
68
+
69
+ ctx.type = 'json'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
67
70
  // @ts-expect-error
71
+ // eslint-disable-next-line require-atomic-updates
68
72
 
69
73
  ctx.body = await handler(...args);
70
74
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.0.0",
14
+ "version": "1.1.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.15.3",
32
- "@modern-js/adapter-helpers": "^1.0.0",
33
- "@modern-js/utils": "^1.0.0",
32
+ "@modern-js/adapter-helpers": "^1.1.1",
33
+ "@modern-js/utils": "^1.1.2",
34
34
  "formidable": "^1.2.2",
35
35
  "koa-body": "^4.2.0",
36
36
  "koa-router": "^10.0.0",
@@ -47,12 +47,12 @@
47
47
  "@types/type-is": "^1.6.3",
48
48
  "supertest": "^6.1.6",
49
49
  "typescript": "^4",
50
- "@modern-js/bff-runtime": "^1.0.0",
51
- "@modern-js/bff-utils": "^1.0.0",
52
- "@modern-js/core": "^1.0.0",
53
- "@modern-js/server-plugin": "^1.0.0",
54
- "@modern-js/plugin-testing": "^1.0.0",
55
- "@modern-js/module-tools": "^1.0.0"
50
+ "@modern-js/bff-runtime": "^1.1.1",
51
+ "@modern-js/bff-utils": "^1.1.1",
52
+ "@modern-js/core": "^1.1.2",
53
+ "@modern-js/server-plugin": "^1.1.1",
54
+ "@modern-js/plugin-testing": "^1.1.0",
55
+ "@modern-js/module-tools": "^1.1.0"
56
56
  },
57
57
  "modernConfig": {
58
58
  "output": {
@@ -60,10 +60,10 @@
60
60
  }
61
61
  },
62
62
  "peerDependencies": {
63
- "@modern-js/bff-utils": "^1.0.0",
64
- "@modern-js/core": "^1.0.0",
65
- "@modern-js/server-plugin": "^1.0.0",
66
- "@modern-js/bff-runtime": "^1.0.0",
63
+ "@modern-js/bff-utils": "^1.1.1",
64
+ "@modern-js/core": "^1.1.2",
65
+ "@modern-js/server-plugin": "^1.1.1",
66
+ "@modern-js/bff-runtime": "^1.1.1",
67
67
  "koa": "^2.13.3"
68
68
  },
69
69
  "publishConfig": {
package/src/cli/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import { useAppContext, createPlugin } from '@modern-js/core';
3
- import { createRuntimeExportsUtils, upath } from '@modern-js/utils';
3
+ import { createRuntimeExportsUtils } from '@modern-js/utils';
4
4
 
5
5
  export default createPlugin(
6
6
  () => {
@@ -22,12 +22,12 @@ export default createPlugin(
22
22
  },
23
23
  };
24
24
  },
25
- modifyEntryImports() {
25
+ modifyEntryImports(input) {
26
26
  // eslint-disable-next-line react-hooks/rules-of-hooks
27
27
  const { appDirectory } = useAppContext();
28
- const runtimePath = upath.normalizeSafe(require.resolve(`@modern-js/runtime`, {
28
+ const runtimePath = require.resolve(`@modern-js/runtime`, {
29
29
  paths: [appDirectory],
30
- }));
30
+ });
31
31
 
32
32
  const currentFile = bffExportsUtils.getPath();
33
33
 
@@ -56,6 +56,7 @@ export default createPlugin(
56
56
  ...pluginRuntime
57
57
  }
58
58
  `);
59
+ return input;
59
60
  },
60
61
  };
61
62
  },
@@ -33,6 +33,7 @@ const registerRoutes = (router: Router, prefix?: string) => {
33
33
  // eslint-disable-next-line require-atomic-updates
34
34
  ctx.status = 500;
35
35
  }
36
+ // eslint-disable-next-line require-atomic-updates
36
37
  ctx.body = result.message;
37
38
  } else {
38
39
  // eslint-disable-next-line require-atomic-updates
@@ -40,8 +41,11 @@ const registerRoutes = (router: Router, prefix?: string) => {
40
41
  }
41
42
  } else {
42
43
  const args = Object.values(input.params as any).concat(input);
44
+ // eslint-disable-next-line require-atomic-updates
45
+ ctx.type = 'json';
43
46
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
47
  // @ts-expect-error
48
+ // eslint-disable-next-line require-atomic-updates
45
49
  ctx.body = await handler(...args);
46
50
  }
47
51
  };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: ['@modern-js'],
3
+ parserOptions: {
4
+ project: require.resolve('./tsconfig.json'),
5
+ },
6
+ };
package/tests/helpers.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { path } from '@modern-js/utils';
1
+ import path from 'path';
2
2
  import { createPlugin } from '@modern-js/server-plugin';
3
3
  import { injectAPIHandlerInfos, API_DIR } from '@modern-js/bff-utils';
4
4