@modern-js/plugin-bff 2.5.1-alpha.3 → 2.6.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 +13 -0
- package/dist/cjs/cli.js +16 -14
- package/dist/cjs/helper.js +4 -0
- package/dist/cjs/loader.js +1 -3
- package/dist/cjs/server.js +7 -6
- package/dist/esm/cli.js +12 -15
- package/dist/esm/loader.js +1 -3
- package/dist/esm/server.js +3 -6
- package/dist/esm-node/cli.js +12 -14
- package/dist/esm-node/loader.js +1 -3
- package/dist/esm-node/server.js +3 -6
- package/dist/types/loader.d.ts +0 -2
- package/package.json +14 -14
- package/dist/js/modern/cli.js +0 -184
- package/dist/js/modern/constants.js +0 -14
- package/dist/js/modern/helper.js +0 -14
- package/dist/js/modern/index.js +0 -1
- package/dist/js/modern/loader.js +0 -67
- package/dist/js/modern/server.js +0 -88
- package/dist/js/node/cli.js +0 -202
- package/dist/js/node/constants.js +0 -38
- package/dist/js/node/helper.js +0 -43
- package/dist/js/node/index.js +0 -17
- package/dist/js/node/loader.js +0 -88
- package/dist/js/node/server.js +0 -113
- package/dist/js/treeshaking/cli.js +0 -370
- package/dist/js/treeshaking/constants.js +0 -11
- package/dist/js/treeshaking/helper.js +0 -23
- package/dist/js/treeshaking/index.js +0 -1
- package/dist/js/treeshaking/loader.js +0 -191
- package/dist/js/treeshaking/server.js +0 -151
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @modern-js/plugin-bff
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ba6db6e]
|
|
8
|
+
- Updated dependencies [e1f799e]
|
|
9
|
+
- Updated dependencies [7915ab3]
|
|
10
|
+
- Updated dependencies [0fe658a]
|
|
11
|
+
- @modern-js/create-request@2.6.0
|
|
12
|
+
- @modern-js/utils@2.6.0
|
|
13
|
+
- @modern-js/bff-core@2.6.0
|
|
14
|
+
- @modern-js/server-utils@2.6.0
|
|
15
|
+
|
|
3
16
|
## 2.5.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/cjs/cli.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -45,32 +49,29 @@ var cli_default = () => ({
|
|
|
45
49
|
return {
|
|
46
50
|
tools: {
|
|
47
51
|
webpackChain: (chain, { name, CHAIN_ID }) => {
|
|
48
|
-
const {
|
|
52
|
+
const { appDirectory, port } = api.useAppContext();
|
|
49
53
|
const modernConfig = api.useResolvedConfigContext();
|
|
50
54
|
const { bff } = modernConfig || {};
|
|
51
55
|
const prefix = (bff == null ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
52
|
-
const
|
|
53
|
-
chain.resolve.alias.set("@api",
|
|
56
|
+
const rootDir = import_path.default.resolve(appDirectory, import_utils.API_DIR);
|
|
57
|
+
chain.resolve.alias.set("@api", rootDir);
|
|
54
58
|
const apiRouter = new import_bff_core.ApiRouter({
|
|
55
|
-
apiDir:
|
|
56
|
-
|
|
57
|
-
prefix,
|
|
58
|
-
httpMethodDecider
|
|
59
|
+
apiDir: rootDir,
|
|
60
|
+
prefix
|
|
59
61
|
});
|
|
60
62
|
const lambdaDir = apiRouter.getLambdaDir();
|
|
61
63
|
const existLambda = apiRouter.isExistLambda();
|
|
62
64
|
const apiRegexp = new RegExp(
|
|
63
|
-
(0, import_utils.normalizeOutputPath)(`${
|
|
65
|
+
(0, import_utils.normalizeOutputPath)(`${rootDir}${import_path.default.sep}.*(.[tj]s)$`)
|
|
64
66
|
);
|
|
65
67
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
66
68
|
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
67
69
|
prefix,
|
|
68
|
-
apiDir:
|
|
70
|
+
apiDir: rootDir,
|
|
69
71
|
lambdaDir,
|
|
70
72
|
existLambda,
|
|
71
73
|
port,
|
|
72
|
-
target: name
|
|
73
|
-
httpMethodDecider
|
|
74
|
+
target: name
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
},
|
|
@@ -95,6 +96,7 @@ var cli_default = () => ({
|
|
|
95
96
|
entryPath: "",
|
|
96
97
|
isSPA: false,
|
|
97
98
|
isSSR: false
|
|
99
|
+
// FIXME: })) as IAppContext[`serverRoutes`];
|
|
98
100
|
}));
|
|
99
101
|
if (bff == null ? void 0 : bff.enableHandleWeb) {
|
|
100
102
|
return {
|
|
@@ -124,11 +126,11 @@ var cli_default = () => ({
|
|
|
124
126
|
if (unRegisterResolveRuntimePath) {
|
|
125
127
|
unRegisterResolveRuntimePath();
|
|
126
128
|
}
|
|
127
|
-
const { appDirectory, distDirectory
|
|
129
|
+
const { appDirectory, distDirectory } = api.useAppContext();
|
|
128
130
|
const modernConfig = api.useResolvedConfigContext();
|
|
129
131
|
const distDir = import_path.default.resolve(distDirectory);
|
|
130
|
-
const apiDir =
|
|
131
|
-
const sharedDir =
|
|
132
|
+
const apiDir = import_path.default.resolve(appDirectory, import_utils.API_DIR);
|
|
133
|
+
const sharedDir = import_path.default.resolve(appDirectory, import_utils.SHARED_DIR);
|
|
132
134
|
const tsconfigPath = import_path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
133
135
|
const sourceDirs = [];
|
|
134
136
|
if (import_utils.fs.existsSync(apiDir)) {
|
package/dist/cjs/helper.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/cjs/loader.js
CHANGED
|
@@ -36,12 +36,10 @@ async function loader(source) {
|
|
|
36
36
|
const options = {
|
|
37
37
|
prefix: Array.isArray(draftOptions.prefix) ? draftOptions.prefix[0] : draftOptions.prefix,
|
|
38
38
|
apiDir: draftOptions.apiDir,
|
|
39
|
-
lambdaDir: draftOptions.lambdaDir,
|
|
40
39
|
target: draftOptions.target,
|
|
41
40
|
port: Number(draftOptions.port),
|
|
42
41
|
source,
|
|
43
|
-
resourcePath
|
|
44
|
-
httpMethodDecider: draftOptions.httpMethodDecider
|
|
42
|
+
resourcePath
|
|
45
43
|
};
|
|
46
44
|
const { lambdaDir } = draftOptions;
|
|
47
45
|
if (!resourcePath.startsWith(lambdaDir)) {
|
package/dist/cjs/server.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -73,15 +77,12 @@ var server_default = () => ({
|
|
|
73
77
|
});
|
|
74
78
|
},
|
|
75
79
|
prepareApiServer(props, next) {
|
|
76
|
-
const { pwd, prefix
|
|
80
|
+
const { pwd, prefix } = props;
|
|
77
81
|
const apiDir = import_path.default.resolve(pwd, import_utils.API_DIR);
|
|
78
82
|
const appContext = api.useAppContext();
|
|
79
|
-
const { apiDirectory, lambdaDirectory } = appContext;
|
|
80
83
|
const apiRouter = new import_bff_core.ApiRouter({
|
|
81
|
-
apiDir
|
|
82
|
-
|
|
83
|
-
prefix,
|
|
84
|
-
httpMethodDecider
|
|
84
|
+
apiDir,
|
|
85
|
+
prefix
|
|
85
86
|
});
|
|
86
87
|
const apiMode = apiRouter.getApiMode();
|
|
87
88
|
const apiHandlerInfos = apiRouter.getApiHandlers();
|
package/dist/esm/cli.js
CHANGED
|
@@ -220,30 +220,27 @@ var cli_default = function() {
|
|
|
220
220
|
tools: {
|
|
221
221
|
webpackChain: function(chain, param) {
|
|
222
222
|
var name = param.name, CHAIN_ID = param.CHAIN_ID;
|
|
223
|
-
var _api_useAppContext = api.useAppContext(),
|
|
223
|
+
var _api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, port = _api_useAppContext.port;
|
|
224
224
|
var modernConfig = api.useResolvedConfigContext();
|
|
225
225
|
var bff = (modernConfig || {}).bff;
|
|
226
226
|
var prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
227
|
-
var
|
|
228
|
-
chain.resolve.alias.set("@api",
|
|
227
|
+
var rootDir = path.resolve(appDirectory, API_DIR);
|
|
228
|
+
chain.resolve.alias.set("@api", rootDir);
|
|
229
229
|
var apiRouter = new ApiRouter({
|
|
230
|
-
apiDir:
|
|
231
|
-
|
|
232
|
-
prefix: prefix,
|
|
233
|
-
httpMethodDecider: httpMethodDecider
|
|
230
|
+
apiDir: rootDir,
|
|
231
|
+
prefix: prefix
|
|
234
232
|
});
|
|
235
233
|
var lambdaDir = apiRouter.getLambdaDir();
|
|
236
234
|
var existLambda = apiRouter.isExistLambda();
|
|
237
|
-
var apiRegexp = new RegExp(normalizeOutputPath("".concat(
|
|
235
|
+
var apiRegexp = new RegExp(normalizeOutputPath("".concat(rootDir).concat(path.sep, ".*(.[tj]s)$")));
|
|
238
236
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
239
237
|
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
240
238
|
prefix: prefix,
|
|
241
|
-
apiDir:
|
|
239
|
+
apiDir: rootDir,
|
|
242
240
|
lambdaDir: lambdaDir,
|
|
243
241
|
existLambda: existLambda,
|
|
244
242
|
port: port,
|
|
245
|
-
target: name
|
|
246
|
-
httpMethodDecider: httpMethodDecider
|
|
243
|
+
target: name
|
|
247
244
|
});
|
|
248
245
|
}
|
|
249
246
|
},
|
|
@@ -314,18 +311,18 @@ var cli_default = function() {
|
|
|
314
311
|
},
|
|
315
312
|
afterBuild: function afterBuild() {
|
|
316
313
|
return _asyncToGenerator(function() {
|
|
317
|
-
var _api_useAppContext, appDirectory, distDirectory,
|
|
314
|
+
var _api_useAppContext, appDirectory, distDirectory, modernConfig, distDir, apiDir, sharedDir, tsconfigPath, sourceDirs, server, _modernConfig_source, alias, define, globalVars, babel;
|
|
318
315
|
return __generator(this, function(_state) {
|
|
319
316
|
switch(_state.label){
|
|
320
317
|
case 0:
|
|
321
318
|
if (unRegisterResolveRuntimePath) {
|
|
322
319
|
unRegisterResolveRuntimePath();
|
|
323
320
|
}
|
|
324
|
-
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory
|
|
321
|
+
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory;
|
|
325
322
|
modernConfig = api.useResolvedConfigContext();
|
|
326
323
|
distDir = path.resolve(distDirectory);
|
|
327
|
-
apiDir =
|
|
328
|
-
sharedDir =
|
|
324
|
+
apiDir = path.resolve(appDirectory, API_DIR);
|
|
325
|
+
sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
329
326
|
tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
330
327
|
sourceDirs = [];
|
|
331
328
|
if (fs.existsSync(apiDir)) {
|
package/dist/esm/loader.js
CHANGED
|
@@ -148,12 +148,10 @@ function _loader() {
|
|
|
148
148
|
options = {
|
|
149
149
|
prefix: Array.isArray(draftOptions.prefix) ? draftOptions.prefix[0] : draftOptions.prefix,
|
|
150
150
|
apiDir: draftOptions.apiDir,
|
|
151
|
-
lambdaDir: draftOptions.lambdaDir,
|
|
152
151
|
target: draftOptions.target,
|
|
153
152
|
port: Number(draftOptions.port),
|
|
154
153
|
source: source,
|
|
155
|
-
resourcePath: resourcePath
|
|
156
|
-
httpMethodDecider: draftOptions.httpMethodDecider
|
|
154
|
+
resourcePath: resourcePath
|
|
157
155
|
};
|
|
158
156
|
lambdaDir = draftOptions.lambdaDir;
|
|
159
157
|
if (!resourcePath.startsWith(lambdaDir)) {
|
package/dist/esm/server.js
CHANGED
|
@@ -128,15 +128,12 @@ var server_default = function() {
|
|
|
128
128
|
});
|
|
129
129
|
},
|
|
130
130
|
prepareApiServer: function prepareApiServer(props, next) {
|
|
131
|
-
var pwd = props.pwd, prefix = props.prefix
|
|
131
|
+
var pwd = props.pwd, prefix = props.prefix;
|
|
132
132
|
var apiDir = path.resolve(pwd, API_DIR);
|
|
133
133
|
var appContext = api.useAppContext();
|
|
134
|
-
var apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory;
|
|
135
134
|
var apiRouter = new ApiRouter({
|
|
136
|
-
apiDir:
|
|
137
|
-
|
|
138
|
-
prefix: prefix,
|
|
139
|
-
httpMethodDecider: httpMethodDecider
|
|
135
|
+
apiDir: apiDir,
|
|
136
|
+
prefix: prefix
|
|
140
137
|
});
|
|
141
138
|
var apiMode = apiRouter.getApiMode();
|
|
142
139
|
var apiHandlerInfos = apiRouter.getApiHandlers();
|
package/dist/esm-node/cli.js
CHANGED
|
@@ -24,32 +24,29 @@ var cli_default = () => ({
|
|
|
24
24
|
return {
|
|
25
25
|
tools: {
|
|
26
26
|
webpackChain: (chain, { name, CHAIN_ID }) => {
|
|
27
|
-
const {
|
|
27
|
+
const { appDirectory, port } = api.useAppContext();
|
|
28
28
|
const modernConfig = api.useResolvedConfigContext();
|
|
29
29
|
const { bff } = modernConfig || {};
|
|
30
30
|
const prefix = (bff == null ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
31
|
-
const
|
|
32
|
-
chain.resolve.alias.set("@api",
|
|
31
|
+
const rootDir = path.resolve(appDirectory, API_DIR);
|
|
32
|
+
chain.resolve.alias.set("@api", rootDir);
|
|
33
33
|
const apiRouter = new ApiRouter({
|
|
34
|
-
apiDir:
|
|
35
|
-
|
|
36
|
-
prefix,
|
|
37
|
-
httpMethodDecider
|
|
34
|
+
apiDir: rootDir,
|
|
35
|
+
prefix
|
|
38
36
|
});
|
|
39
37
|
const lambdaDir = apiRouter.getLambdaDir();
|
|
40
38
|
const existLambda = apiRouter.isExistLambda();
|
|
41
39
|
const apiRegexp = new RegExp(
|
|
42
|
-
normalizeOutputPath(`${
|
|
40
|
+
normalizeOutputPath(`${rootDir}${path.sep}.*(.[tj]s)$`)
|
|
43
41
|
);
|
|
44
42
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
45
43
|
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
46
44
|
prefix,
|
|
47
|
-
apiDir:
|
|
45
|
+
apiDir: rootDir,
|
|
48
46
|
lambdaDir,
|
|
49
47
|
existLambda,
|
|
50
48
|
port,
|
|
51
|
-
target: name
|
|
52
|
-
httpMethodDecider
|
|
49
|
+
target: name
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
52
|
},
|
|
@@ -74,6 +71,7 @@ var cli_default = () => ({
|
|
|
74
71
|
entryPath: "",
|
|
75
72
|
isSPA: false,
|
|
76
73
|
isSSR: false
|
|
74
|
+
// FIXME: })) as IAppContext[`serverRoutes`];
|
|
77
75
|
}));
|
|
78
76
|
if (bff == null ? void 0 : bff.enableHandleWeb) {
|
|
79
77
|
return {
|
|
@@ -103,11 +101,11 @@ var cli_default = () => ({
|
|
|
103
101
|
if (unRegisterResolveRuntimePath) {
|
|
104
102
|
unRegisterResolveRuntimePath();
|
|
105
103
|
}
|
|
106
|
-
const { appDirectory, distDirectory
|
|
104
|
+
const { appDirectory, distDirectory } = api.useAppContext();
|
|
107
105
|
const modernConfig = api.useResolvedConfigContext();
|
|
108
106
|
const distDir = path.resolve(distDirectory);
|
|
109
|
-
const apiDir =
|
|
110
|
-
const sharedDir =
|
|
107
|
+
const apiDir = path.resolve(appDirectory, API_DIR);
|
|
108
|
+
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
111
109
|
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
112
110
|
const sourceDirs = [];
|
|
113
111
|
if (fs.existsSync(apiDir)) {
|
package/dist/esm-node/loader.js
CHANGED
|
@@ -14,12 +14,10 @@ async function loader(source) {
|
|
|
14
14
|
const options = {
|
|
15
15
|
prefix: Array.isArray(draftOptions.prefix) ? draftOptions.prefix[0] : draftOptions.prefix,
|
|
16
16
|
apiDir: draftOptions.apiDir,
|
|
17
|
-
lambdaDir: draftOptions.lambdaDir,
|
|
18
17
|
target: draftOptions.target,
|
|
19
18
|
port: Number(draftOptions.port),
|
|
20
19
|
source,
|
|
21
|
-
resourcePath
|
|
22
|
-
httpMethodDecider: draftOptions.httpMethodDecider
|
|
20
|
+
resourcePath
|
|
23
21
|
};
|
|
24
22
|
const { lambdaDir } = draftOptions;
|
|
25
23
|
if (!resourcePath.startsWith(lambdaDir)) {
|
package/dist/esm-node/server.js
CHANGED
|
@@ -45,15 +45,12 @@ var server_default = () => ({
|
|
|
45
45
|
});
|
|
46
46
|
},
|
|
47
47
|
prepareApiServer(props, next) {
|
|
48
|
-
const { pwd, prefix
|
|
48
|
+
const { pwd, prefix } = props;
|
|
49
49
|
const apiDir = path.resolve(pwd, API_DIR);
|
|
50
50
|
const appContext = api.useAppContext();
|
|
51
|
-
const { apiDirectory, lambdaDirectory } = appContext;
|
|
52
51
|
const apiRouter = new ApiRouter({
|
|
53
|
-
apiDir
|
|
54
|
-
|
|
55
|
-
prefix,
|
|
56
|
-
httpMethodDecider
|
|
52
|
+
apiDir,
|
|
53
|
+
prefix
|
|
57
54
|
});
|
|
58
55
|
const apiMode = apiRouter.getApiMode();
|
|
59
56
|
const apiHandlerInfos = apiRouter.getApiHandlers();
|
package/dist/types/loader.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HttpMethodDecider } from '@modern-js/types';
|
|
2
1
|
import type { LoaderContext } from 'webpack';
|
|
3
2
|
export type APILoaderOptions = {
|
|
4
3
|
prefix: string;
|
|
@@ -9,7 +8,6 @@ export type APILoaderOptions = {
|
|
|
9
8
|
fetcher?: string;
|
|
10
9
|
requestCreator?: string;
|
|
11
10
|
target: string;
|
|
12
|
-
httpMethodDecider: HttpMethodDecider;
|
|
13
11
|
};
|
|
14
12
|
declare function loader(this: LoaderContext<APILoaderOptions>, source: string): Promise<void>;
|
|
15
13
|
export default loader;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.6.0",
|
|
15
15
|
"jsnext:source": "./src/cli.ts",
|
|
16
16
|
"types": "./dist/types/cli.d.ts",
|
|
17
17
|
"main": "./dist/cjs/cli.js",
|
|
@@ -50,20 +50,12 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/core": "^7.18.0",
|
|
52
52
|
"@babel/runtime": "^7.18.0",
|
|
53
|
-
"@modern-js/bff-core": "2.
|
|
54
|
-
"@modern-js/create-request": "2.
|
|
55
|
-
"@modern-js/server-utils": "2.
|
|
56
|
-
"@modern-js/utils": "2.
|
|
53
|
+
"@modern-js/bff-core": "2.6.0",
|
|
54
|
+
"@modern-js/create-request": "2.6.0",
|
|
55
|
+
"@modern-js/server-utils": "2.6.0",
|
|
56
|
+
"@modern-js/utils": "2.6.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@modern-js/runtime": "2.5.0",
|
|
60
|
-
"@modern-js/core": "2.5.1-alpha.0",
|
|
61
|
-
"@modern-js/bff-runtime": "2.5.0",
|
|
62
|
-
"@modern-js/server-core": "2.5.1-alpha.0",
|
|
63
|
-
"@modern-js/types": "2.5.1-alpha.0",
|
|
64
|
-
"@modern-js/app-tools": "2.5.1-alpha.0",
|
|
65
|
-
"@scripts/build": "2.5.0",
|
|
66
|
-
"@scripts/jest-config": "2.5.0",
|
|
67
59
|
"@types/babel__core": "^7.1.15",
|
|
68
60
|
"@types/jest": "^27",
|
|
69
61
|
"@types/node": "^14",
|
|
@@ -72,7 +64,15 @@
|
|
|
72
64
|
"ts-jest": "^27.0.5",
|
|
73
65
|
"typescript": "^4",
|
|
74
66
|
"webpack": "^5.75.0",
|
|
75
|
-
"webpack-chain": "^6.5.1"
|
|
67
|
+
"webpack-chain": "^6.5.1",
|
|
68
|
+
"@modern-js/runtime": "2.6.0",
|
|
69
|
+
"@modern-js/core": "2.6.0",
|
|
70
|
+
"@modern-js/bff-runtime": "2.6.0",
|
|
71
|
+
"@modern-js/server-core": "2.6.0",
|
|
72
|
+
"@modern-js/types": "2.6.0",
|
|
73
|
+
"@modern-js/app-tools": "2.6.0",
|
|
74
|
+
"@scripts/build": "2.6.0",
|
|
75
|
+
"@scripts/jest-config": "2.6.0"
|
|
76
76
|
},
|
|
77
77
|
"sideEffects": false,
|
|
78
78
|
"publishConfig": {
|
package/dist/js/modern/cli.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import path from "path";
|
|
41
|
-
import {
|
|
42
|
-
fs,
|
|
43
|
-
API_DIR,
|
|
44
|
-
PLUGIN_SCHEMAS,
|
|
45
|
-
normalizeOutputPath,
|
|
46
|
-
SHARED_DIR,
|
|
47
|
-
isProd
|
|
48
|
-
} from "@modern-js/utils";
|
|
49
|
-
import { compile } from "@modern-js/server-utils";
|
|
50
|
-
import { ApiRouter } from "@modern-js/bff-core";
|
|
51
|
-
import { registerModernRuntimePath } from "./helper";
|
|
52
|
-
const DEFAULT_API_PREFIX = "/api";
|
|
53
|
-
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
54
|
-
var cli_default = () => ({
|
|
55
|
-
name: "@modern-js/plugin-bff",
|
|
56
|
-
setup: (api) => {
|
|
57
|
-
let unRegisterResolveRuntimePath = null;
|
|
58
|
-
return {
|
|
59
|
-
validateSchema() {
|
|
60
|
-
return PLUGIN_SCHEMAS["@modern-js/plugin-bff"];
|
|
61
|
-
},
|
|
62
|
-
config() {
|
|
63
|
-
return {
|
|
64
|
-
tools: {
|
|
65
|
-
webpackChain: (chain, { name, CHAIN_ID }) => {
|
|
66
|
-
const { appDirectory, port } = api.useAppContext();
|
|
67
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
68
|
-
const { bff } = modernConfig || {};
|
|
69
|
-
const prefix = (bff == null ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
70
|
-
const rootDir = path.resolve(appDirectory, API_DIR);
|
|
71
|
-
chain.resolve.alias.set("@api", rootDir);
|
|
72
|
-
const apiRouter = new ApiRouter({
|
|
73
|
-
apiDir: rootDir,
|
|
74
|
-
prefix
|
|
75
|
-
});
|
|
76
|
-
const lambdaDir = apiRouter.getLambdaDir();
|
|
77
|
-
const existLambda = apiRouter.isExistLambda();
|
|
78
|
-
const apiRegexp = new RegExp(
|
|
79
|
-
normalizeOutputPath(`${rootDir}${path.sep}.*(.[tj]s)$`)
|
|
80
|
-
);
|
|
81
|
-
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
82
|
-
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
83
|
-
prefix,
|
|
84
|
-
apiDir: rootDir,
|
|
85
|
-
lambdaDir,
|
|
86
|
-
existLambda,
|
|
87
|
-
port,
|
|
88
|
-
target: name
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
source: {
|
|
93
|
-
moduleScopes: [`./${API_DIR}`, /create-request/]
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
modifyServerRoutes({ routes }) {
|
|
98
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
99
|
-
const { bff } = modernConfig || {};
|
|
100
|
-
const prefix = (bff == null ? void 0 : bff.prefix) || "/api";
|
|
101
|
-
const prefixList = [];
|
|
102
|
-
if (Array.isArray(prefix)) {
|
|
103
|
-
prefixList.push(...prefix);
|
|
104
|
-
} else {
|
|
105
|
-
prefixList.push(prefix);
|
|
106
|
-
}
|
|
107
|
-
const apiServerRoutes = prefixList.map((pre) => ({
|
|
108
|
-
urlPath: pre,
|
|
109
|
-
isApi: true,
|
|
110
|
-
entryPath: "",
|
|
111
|
-
isSPA: false,
|
|
112
|
-
isSSR: false
|
|
113
|
-
}));
|
|
114
|
-
if (bff == null ? void 0 : bff.enableHandleWeb) {
|
|
115
|
-
return {
|
|
116
|
-
routes: routes.map((route) => {
|
|
117
|
-
return __spreadProps(__spreadValues({}, route), {
|
|
118
|
-
isApi: true
|
|
119
|
-
});
|
|
120
|
-
}).concat(apiServerRoutes)
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return { routes: routes.concat(apiServerRoutes) };
|
|
124
|
-
},
|
|
125
|
-
collectServerPlugins({ plugins }) {
|
|
126
|
-
plugins.push({
|
|
127
|
-
"@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
|
|
128
|
-
});
|
|
129
|
-
return { plugins };
|
|
130
|
-
},
|
|
131
|
-
beforeBuild() {
|
|
132
|
-
return __async(this, null, function* () {
|
|
133
|
-
if (isProd()) {
|
|
134
|
-
const { internalDirectory } = api.useAppContext();
|
|
135
|
-
unRegisterResolveRuntimePath = registerModernRuntimePath(internalDirectory);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
},
|
|
139
|
-
afterBuild() {
|
|
140
|
-
return __async(this, null, function* () {
|
|
141
|
-
if (unRegisterResolveRuntimePath) {
|
|
142
|
-
unRegisterResolveRuntimePath();
|
|
143
|
-
}
|
|
144
|
-
const { appDirectory, distDirectory } = api.useAppContext();
|
|
145
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
146
|
-
const distDir = path.resolve(distDirectory);
|
|
147
|
-
const apiDir = path.resolve(appDirectory, API_DIR);
|
|
148
|
-
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
149
|
-
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
150
|
-
const sourceDirs = [];
|
|
151
|
-
if (fs.existsSync(apiDir)) {
|
|
152
|
-
sourceDirs.push(apiDir);
|
|
153
|
-
}
|
|
154
|
-
if (fs.existsSync(sharedDir)) {
|
|
155
|
-
sourceDirs.push(sharedDir);
|
|
156
|
-
}
|
|
157
|
-
const { server } = modernConfig;
|
|
158
|
-
const { alias, define, globalVars } = modernConfig.source;
|
|
159
|
-
const { babel } = modernConfig.tools;
|
|
160
|
-
if (sourceDirs.length > 0) {
|
|
161
|
-
yield compile(
|
|
162
|
-
appDirectory,
|
|
163
|
-
{
|
|
164
|
-
server,
|
|
165
|
-
alias,
|
|
166
|
-
define,
|
|
167
|
-
globalVars,
|
|
168
|
-
babelConfig: babel
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
sourceDirs,
|
|
172
|
-
distDir,
|
|
173
|
-
tsconfigPath
|
|
174
|
-
}
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
export {
|
|
183
|
-
cli_default as default
|
|
184
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const API_APP_NAME = "_app";
|
|
2
|
-
const BUILD_FILES = [
|
|
3
|
-
"**/*.[tj]sx?",
|
|
4
|
-
"!**/*.test.jsx?",
|
|
5
|
-
"!**/*.test.tsx?",
|
|
6
|
-
"!**/*.spec.jsx?",
|
|
7
|
-
"!**/*.spec.tsx?",
|
|
8
|
-
"!__tests__/*.tsx?",
|
|
9
|
-
"!__tests__/*.jsx?"
|
|
10
|
-
];
|
|
11
|
-
export {
|
|
12
|
-
API_APP_NAME,
|
|
13
|
-
BUILD_FILES
|
|
14
|
-
};
|
package/dist/js/modern/helper.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import { registerPaths } from "@modern-js/bff-core";
|
|
3
|
-
const serverRuntimeAlias = "@modern-js/runtime/server";
|
|
4
|
-
const serverRuntimePath = ".runtime-exports/server";
|
|
5
|
-
const registerModernRuntimePath = (internalDirectory) => {
|
|
6
|
-
const paths = {
|
|
7
|
-
[serverRuntimeAlias]: path.join(internalDirectory, serverRuntimePath)
|
|
8
|
-
};
|
|
9
|
-
const unRegister = registerPaths(paths);
|
|
10
|
-
return unRegister;
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
registerModernRuntimePath
|
|
14
|
-
};
|
package/dist/js/modern/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./constants";
|