@modern-js/plugin-koa 1.4.2 → 1.4.3
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 +13 -0
- package/dist/js/modern/cli/index.js +47 -44
- package/dist/js/node/cli/index.js +46 -44
- package/dist/types/cli/index.d.ts +3 -18
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @modern-js/plugin-koa
|
|
2
2
|
|
|
3
|
+
## 1.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ef7b0a54: feat: convert to new plugin
|
|
8
|
+
- Updated dependencies [5bf5868d]
|
|
9
|
+
- Updated dependencies [d95f28c3]
|
|
10
|
+
- Updated dependencies [2e8dec93]
|
|
11
|
+
- Updated dependencies [2008fdbd]
|
|
12
|
+
- Updated dependencies [2e8dec93]
|
|
13
|
+
- @modern-js/utils@1.3.5
|
|
14
|
+
- @modern-js/server-core@1.2.3
|
|
15
|
+
|
|
3
16
|
## 1.4.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,50 +1,54 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
import { useAppContext, createPlugin } from '@modern-js/core';
|
|
3
2
|
import { createRuntimeExportsUtils } from '@modern-js/utils';
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
export default (() => ({
|
|
4
|
+
name: '@modern-js/plugin-koa',
|
|
5
|
+
setup: api => {
|
|
6
|
+
let bffExportsUtils;
|
|
7
|
+
const {
|
|
8
|
+
useAppContext
|
|
9
|
+
} = api;
|
|
10
|
+
const runtimeModulePath = path.resolve(__dirname, '../runtime');
|
|
11
|
+
return {
|
|
12
|
+
config() {
|
|
13
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14
|
+
const appContext = useAppContext();
|
|
15
|
+
const {
|
|
16
|
+
appDirectory
|
|
17
|
+
} = appContext;
|
|
18
|
+
bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'server');
|
|
19
|
+
const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
24
|
+
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
25
|
+
}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
return {
|
|
28
|
+
source: {
|
|
29
|
+
alias: {
|
|
30
|
+
'@modern-js/runtime/server': relativeRuntimePath
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
addRuntimeExports(input) {
|
|
37
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
38
|
+
const {
|
|
39
|
+
appDirectory
|
|
40
|
+
} = useAppContext();
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
const runtimePath = require.resolve(`@modern-js/runtime`, {
|
|
43
|
+
paths: [appDirectory]
|
|
44
|
+
});
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const currentFile = bffExportsUtils.getPath();
|
|
47
|
+
const runtimeDir = path.dirname(runtimePath);
|
|
48
|
+
const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
|
|
49
|
+
const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
|
|
50
|
+
const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('koa'));
|
|
51
|
+
bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
|
|
48
52
|
const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
49
53
|
const Koa = require('${relativeFramePath}')
|
|
50
54
|
module.exports = {
|
|
@@ -53,10 +57,9 @@ export default createPlugin(() => {
|
|
|
53
57
|
...pluginRuntime
|
|
54
58
|
}
|
|
55
59
|
`);
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
return input;
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
@@ -7,58 +7,61 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var path = _interopRequireWildcard(require("path"));
|
|
9
9
|
|
|
10
|
-
var _core = require("@modern-js/core");
|
|
11
|
-
|
|
12
10
|
var _utils = require("@modern-js/utils");
|
|
13
11
|
|
|
14
12
|
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
13
|
|
|
16
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
15
|
|
|
18
|
-
var _default = (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
var _default = () => ({
|
|
17
|
+
name: '@modern-js/plugin-koa',
|
|
18
|
+
setup: api => {
|
|
19
|
+
let bffExportsUtils;
|
|
20
|
+
const {
|
|
21
|
+
useAppContext
|
|
22
|
+
} = api;
|
|
23
|
+
const runtimeModulePath = path.resolve(__dirname, '../runtime');
|
|
24
|
+
return {
|
|
25
|
+
config() {
|
|
26
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
27
|
+
const appContext = useAppContext();
|
|
28
|
+
const {
|
|
29
|
+
appDirectory
|
|
30
|
+
} = appContext;
|
|
31
|
+
bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
|
|
32
|
+
const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
37
|
+
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
38
|
+
}
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
return {
|
|
41
|
+
source: {
|
|
42
|
+
alias: {
|
|
43
|
+
'@modern-js/runtime/server': relativeRuntimePath
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
addRuntimeExports(input) {
|
|
50
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
51
|
+
const {
|
|
52
|
+
appDirectory
|
|
53
|
+
} = useAppContext();
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const runtimePath = require.resolve(`@modern-js/runtime`, {
|
|
56
|
+
paths: [appDirectory]
|
|
57
|
+
});
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const currentFile = bffExportsUtils.getPath();
|
|
60
|
+
const runtimeDir = path.dirname(runtimePath);
|
|
61
|
+
const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
|
|
62
|
+
const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
|
|
63
|
+
const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('koa'));
|
|
64
|
+
bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
|
|
62
65
|
const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
63
66
|
const Koa = require('${relativeFramePath}')
|
|
64
67
|
module.exports = {
|
|
@@ -67,12 +70,11 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
67
70
|
...pluginRuntime
|
|
68
71
|
}
|
|
69
72
|
`);
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
return input;
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
name: '@modern-js/plugin-koa'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
exports.default = _default;
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
resolved: import("@modern-js/core").NormalizedConfig;
|
|
5
|
-
}>;
|
|
6
|
-
validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
7
|
-
prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
8
|
-
commands: import("@modern-js/core").AsyncWorkflow<{
|
|
9
|
-
program: import("commander").Command;
|
|
10
|
-
}, void>;
|
|
11
|
-
watchFiles: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
12
|
-
fileChange: import("@modern-js/core").AsyncWorkflow<{
|
|
13
|
-
filename: string;
|
|
14
|
-
eventType: "add" | "unlink" | "change";
|
|
15
|
-
}, void>;
|
|
16
|
-
beforeExit: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
17
|
-
beforeRestart: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
18
|
-
} & import("@modern-js/core").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
|
|
1
|
+
import type { CliPlugin } from '@modern-js/core';
|
|
2
|
+
|
|
3
|
+
declare const _default: () => CliPlugin;
|
|
19
4
|
|
|
20
5
|
export default _default;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.3",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -35,14 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.15.3",
|
|
37
37
|
"@modern-js/adapter-helpers": "^1.2.1",
|
|
38
|
-
"@modern-js/utils": "^1.3.
|
|
38
|
+
"@modern-js/utils": "^1.3.5",
|
|
39
39
|
"formidable": "^1.2.2",
|
|
40
40
|
"koa-body": "^4.2.0",
|
|
41
41
|
"koa-router": "^10.0.0",
|
|
42
42
|
"type-is": "^1.6.18",
|
|
43
43
|
"@modern-js/bff-utils": "^1.2.2",
|
|
44
|
-
"@modern-js/core": "^1.
|
|
45
|
-
"@modern-js/server-core": "^1.2.2",
|
|
44
|
+
"@modern-js/server-core": "^1.2.3",
|
|
46
45
|
"@modern-js/bff-runtime": "^1.2.1"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
@@ -58,7 +57,8 @@
|
|
|
58
57
|
"typescript": "^4",
|
|
59
58
|
"@scripts/build": "0.0.0",
|
|
60
59
|
"jest": "^27",
|
|
61
|
-
"@scripts/jest-config": "0.0.0"
|
|
60
|
+
"@scripts/jest-config": "0.0.0",
|
|
61
|
+
"@modern-js/core": "^1.5.0"
|
|
62
62
|
},
|
|
63
63
|
"modernConfig": {
|
|
64
64
|
"output": {
|