@modern-js/plugin-koa 1.4.6 → 1.4.8-canary.1

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,15 @@
1
1
  # @modern-js/plugin-koa
2
2
 
3
+ ## 1.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 69a728375: fix: remove exports.jsnext:source after publish
8
+ - Updated dependencies [cd7346b0d]
9
+ - Updated dependencies [69a728375]
10
+ - @modern-js/utils@1.7.2
11
+ - @modern-js/bff-utils@1.2.5
12
+
3
13
  ## 1.4.6
4
14
 
5
15
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import * as path from 'path';
2
- import { createRuntimeExportsUtils } from '@modern-js/utils';
2
+ import { createRuntimeExportsUtils, TEST_ENV } from '@modern-js/utils';
3
3
  import { getRelativeRuntimePath } from '@modern-js/adapter-helpers';
4
4
  export default (() => ({
5
5
  name: '@modern-js/plugin-koa',
@@ -11,25 +11,27 @@ export default (() => ({
11
11
  const runtimeModulePath = path.resolve(__dirname, '../runtime');
12
12
  return {
13
13
  config() {
14
- // eslint-disable-next-line react-hooks/rules-of-hooks
15
14
  const appContext = useAppContext();
16
15
  const {
17
16
  appDirectory
18
17
  } = appContext;
19
18
  bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'server');
20
- const serverRuntimePath = bffExportsUtils.getPath();
21
- const relativeRuntimePath = getRelativeRuntimePath(appDirectory, serverRuntimePath);
19
+ let serverRuntimePath = bffExportsUtils.getPath(); // Basedir is not a fixed path when the test is executed,so server runtime path must be absolute path.
20
+
21
+ if (process.env.NODE_ENV !== TEST_ENV) {
22
+ serverRuntimePath = getRelativeRuntimePath(appDirectory, serverRuntimePath);
23
+ }
24
+
22
25
  return {
23
26
  source: {
24
27
  alias: {
25
- '@modern-js/runtime/server': relativeRuntimePath
28
+ '@modern-js/runtime/server': serverRuntimePath
26
29
  }
27
30
  }
28
31
  };
29
32
  },
30
33
 
31
34
  addRuntimeExports(input) {
32
- // eslint-disable-next-line react-hooks/rules-of-hooks
33
35
  const {
34
36
  appDirectory
35
37
  } = useAppContext();
@@ -20,7 +20,7 @@ const registerRoutes = (router, prefix) => {
20
20
  method,
21
21
  name
22
22
  }) => {
23
- const wrapedHandler = async ctx => {
23
+ const wrappedHandler = async ctx => {
24
24
  const input = await getInputFromRequest(ctx);
25
25
 
26
26
  if (isSchemaHandler(handler)) {
@@ -45,11 +45,11 @@ const registerRoutes = (router, prefix) => {
45
45
  }
46
46
  };
47
47
 
48
- Object.defineProperties(wrapedHandler, Object.getOwnPropertyDescriptors(handler));
48
+ Object.defineProperties(wrappedHandler, Object.getOwnPropertyDescriptors(handler));
49
49
 
50
50
  if (isNormalMethod(method)) {
51
51
  const routeName = method.toLowerCase();
52
- router[routeName](name, wrapedHandler);
52
+ router[routeName](name, wrappedHandler);
53
53
  } else {
54
54
  throw new Error(`Unknown HTTP Method: ${method}`);
55
55
  }
@@ -25,25 +25,27 @@ var _default = () => ({
25
25
  const runtimeModulePath = path.resolve(__dirname, '../runtime');
26
26
  return {
27
27
  config() {
28
- // eslint-disable-next-line react-hooks/rules-of-hooks
29
28
  const appContext = useAppContext();
30
29
  const {
31
30
  appDirectory
32
31
  } = appContext;
33
32
  bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
34
- const serverRuntimePath = bffExportsUtils.getPath();
35
- const relativeRuntimePath = (0, _adapterHelpers.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
33
+ let serverRuntimePath = bffExportsUtils.getPath(); // Basedir is not a fixed path when the test is executed,so server runtime path must be absolute path.
34
+
35
+ if (process.env.NODE_ENV !== _utils.TEST_ENV) {
36
+ serverRuntimePath = (0, _adapterHelpers.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
37
+ }
38
+
36
39
  return {
37
40
  source: {
38
41
  alias: {
39
- '@modern-js/runtime/server': relativeRuntimePath
42
+ '@modern-js/runtime/server': serverRuntimePath
40
43
  }
41
44
  }
42
45
  };
43
46
  },
44
47
 
45
48
  addRuntimeExports(input) {
46
- // eslint-disable-next-line react-hooks/rules-of-hooks
47
49
  const {
48
50
  appDirectory
49
51
  } = useAppContext();
@@ -34,7 +34,7 @@ const registerRoutes = (router, prefix) => {
34
34
  method,
35
35
  name
36
36
  }) => {
37
- const wrapedHandler = async ctx => {
37
+ const wrappedHandler = async ctx => {
38
38
  const input = await getInputFromRequest(ctx);
39
39
 
40
40
  if ((0, _bffRuntime.isSchemaHandler)(handler)) {
@@ -59,11 +59,11 @@ const registerRoutes = (router, prefix) => {
59
59
  }
60
60
  };
61
61
 
62
- Object.defineProperties(wrapedHandler, Object.getOwnPropertyDescriptors(handler));
62
+ Object.defineProperties(wrappedHandler, Object.getOwnPropertyDescriptors(handler));
63
63
 
64
64
  if (isNormalMethod(method)) {
65
65
  const routeName = method.toLowerCase();
66
- router[routeName](name, wrapedHandler);
66
+ router[routeName](name, wrappedHandler);
67
67
  } else {
68
68
  throw new Error(`Unknown HTTP Method: ${method}`);
69
69
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.4.6",
14
+ "version": "1.4.8-canary.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -36,8 +36,8 @@
36
36
  "@babel/runtime": "^7.15.3",
37
37
  "@modern-js/adapter-helpers": "^1.2.3",
38
38
  "@modern-js/bff-runtime": "^1.2.2",
39
- "@modern-js/bff-utils": "^1.2.3",
40
- "@modern-js/utils": "^1.5.0",
39
+ "@modern-js/bff-utils": "^1.2.5",
40
+ "@modern-js/utils": "^1.7.2",
41
41
  "koa-body": "^4.2.0",
42
42
  "koa-router": "^10.0.0",
43
43
  "type-is": "^1.6.18"
@@ -52,8 +52,8 @@
52
52
  "@types/supertest": "^2.0.11",
53
53
  "@types/type-is": "^1.6.3",
54
54
  "jest": "^27",
55
- "@modern-js/server-core": "1.3.1",
56
- "@modern-js/core": "1.8.0",
55
+ "@modern-js/server-core": "1.3.4",
56
+ "@modern-js/core": "1.10.1",
57
57
  "supertest": "^6.1.6",
58
58
  "koa": "^2.13.3",
59
59
  "typescript": "^4"
@@ -68,12 +68,35 @@
68
68
  },
69
69
  "publishConfig": {
70
70
  "registry": "https://registry.npmjs.org/",
71
- "access": "public"
71
+ "access": "public",
72
+ "types": "./dist/types/index.d.ts"
73
+ },
74
+ "wireit": {
75
+ "build": {
76
+ "command": "modern build",
77
+ "files": [
78
+ "src/**/*",
79
+ "tsconfig.json",
80
+ "package.json"
81
+ ],
82
+ "output": [
83
+ "dist/**/*"
84
+ ]
85
+ },
86
+ "test": {
87
+ "command": "jest --passWithNoTests",
88
+ "files": [
89
+ "src/**/*",
90
+ "tsconfig.json",
91
+ "package.json"
92
+ ],
93
+ "output": []
94
+ }
72
95
  },
73
96
  "scripts": {
74
97
  "new": "modern new",
75
- "build": "modern build",
76
- "test": "jest --passWithNoTests"
98
+ "build": "wireit",
99
+ "test": "wireit"
77
100
  },
78
101
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> 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.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
79
102
  }
package/.eslintrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- ignorePatterns: ['types.d.ts'],
7
- };
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- const sharedConfig = require('@scripts/jest-config');
2
-
3
- /** @type {import('@jest/types').Config.InitialOptions} */
4
- module.exports = {
5
- ...sharedConfig,
6
- rootDir: __dirname,
7
- };
package/modern.config.js DELETED
@@ -1,2 +0,0 @@
1
- /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {};
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true
8
- },
9
- "include": ["src"]
10
- }