@modern-js/plugin-bff 2.5.1-alpha.0 → 2.5.1-alpha.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/dist/cjs/cli.js +6 -8
- package/dist/cjs/loader.js +1 -0
- package/dist/cjs/server.js +3 -1
- package/dist/esm/cli.js +6 -8
- package/dist/esm/loader.js +1 -0
- package/dist/esm/server.js +3 -1
- package/dist/esm-node/cli.js +6 -8
- package/dist/esm-node/loader.js +1 -0
- package/dist/esm-node/server.js +3 -1
- package/package.json +6 -6
package/dist/cjs/cli.js
CHANGED
|
@@ -42,32 +42,30 @@ var cli_default = () => ({
|
|
|
42
42
|
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-bff"];
|
|
43
43
|
},
|
|
44
44
|
config() {
|
|
45
|
-
const configContext = api.useConfigContext();
|
|
46
|
-
console.log("22222222222222222", configContext.bff);
|
|
47
45
|
return {
|
|
48
46
|
tools: {
|
|
49
47
|
webpackChain: (chain, { name, CHAIN_ID }) => {
|
|
50
|
-
const {
|
|
48
|
+
const { port, apiDirectory, lambdaDirectory } = api.useAppContext();
|
|
51
49
|
const modernConfig = api.useResolvedConfigContext();
|
|
52
50
|
const { bff } = modernConfig || {};
|
|
53
51
|
const prefix = (bff == null ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
54
52
|
const { httpMethodDecider } = bff;
|
|
55
|
-
|
|
56
|
-
chain.resolve.alias.set("@api", rootDir);
|
|
53
|
+
chain.resolve.alias.set("@api", apiDirectory);
|
|
57
54
|
const apiRouter = new import_bff_core.ApiRouter({
|
|
58
|
-
apiDir:
|
|
55
|
+
apiDir: apiDirectory,
|
|
56
|
+
lambdaDir: lambdaDirectory,
|
|
59
57
|
prefix,
|
|
60
58
|
httpMethodDecider
|
|
61
59
|
});
|
|
62
60
|
const lambdaDir = apiRouter.getLambdaDir();
|
|
63
61
|
const existLambda = apiRouter.isExistLambda();
|
|
64
62
|
const apiRegexp = new RegExp(
|
|
65
|
-
(0, import_utils.normalizeOutputPath)(`${
|
|
63
|
+
(0, import_utils.normalizeOutputPath)(`${apiDirectory}${import_path.default.sep}.*(.[tj]s)$`)
|
|
66
64
|
);
|
|
67
65
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
68
66
|
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
69
67
|
prefix,
|
|
70
|
-
apiDir:
|
|
68
|
+
apiDir: apiDirectory,
|
|
71
69
|
lambdaDir,
|
|
72
70
|
existLambda,
|
|
73
71
|
port,
|
package/dist/cjs/loader.js
CHANGED
|
@@ -36,6 +36,7 @@ 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,
|
|
39
40
|
target: draftOptions.target,
|
|
40
41
|
port: Number(draftOptions.port),
|
|
41
42
|
source,
|
package/dist/cjs/server.js
CHANGED
|
@@ -76,8 +76,10 @@ var server_default = () => ({
|
|
|
76
76
|
const { pwd, prefix, httpMethodDecider } = props;
|
|
77
77
|
const apiDir = import_path.default.resolve(pwd, import_utils.API_DIR);
|
|
78
78
|
const appContext = api.useAppContext();
|
|
79
|
+
const { apiDirectory, lambdaDirectory } = appContext;
|
|
79
80
|
const apiRouter = new import_bff_core.ApiRouter({
|
|
80
|
-
apiDir,
|
|
81
|
+
apiDir: apiDirectory || apiDir,
|
|
82
|
+
lambdaDir: lambdaDirectory,
|
|
81
83
|
prefix,
|
|
82
84
|
httpMethodDecider
|
|
83
85
|
});
|
package/dist/esm/cli.js
CHANGED
|
@@ -216,31 +216,29 @@ var cli_default = function() {
|
|
|
216
216
|
return PLUGIN_SCHEMAS["@modern-js/plugin-bff"];
|
|
217
217
|
},
|
|
218
218
|
config: function config() {
|
|
219
|
-
var configContext = api.useConfigContext();
|
|
220
|
-
console.log("22222222222222222", configContext.bff);
|
|
221
219
|
return {
|
|
222
220
|
tools: {
|
|
223
221
|
webpackChain: function(chain, param) {
|
|
224
222
|
var name = param.name, CHAIN_ID = param.CHAIN_ID;
|
|
225
|
-
var _api_useAppContext = api.useAppContext(),
|
|
223
|
+
var _api_useAppContext = api.useAppContext(), port = _api_useAppContext.port, apiDirectory = _api_useAppContext.apiDirectory, lambdaDirectory = _api_useAppContext.lambdaDirectory;
|
|
226
224
|
var modernConfig = api.useResolvedConfigContext();
|
|
227
225
|
var bff = (modernConfig || {}).bff;
|
|
228
226
|
var prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
229
227
|
var httpMethodDecider = bff.httpMethodDecider;
|
|
230
|
-
|
|
231
|
-
chain.resolve.alias.set("@api", rootDir);
|
|
228
|
+
chain.resolve.alias.set("@api", apiDirectory);
|
|
232
229
|
var apiRouter = new ApiRouter({
|
|
233
|
-
apiDir:
|
|
230
|
+
apiDir: apiDirectory,
|
|
231
|
+
lambdaDir: lambdaDirectory,
|
|
234
232
|
prefix: prefix,
|
|
235
233
|
httpMethodDecider: httpMethodDecider
|
|
236
234
|
});
|
|
237
235
|
var lambdaDir = apiRouter.getLambdaDir();
|
|
238
236
|
var existLambda = apiRouter.isExistLambda();
|
|
239
|
-
var apiRegexp = new RegExp(normalizeOutputPath("".concat(
|
|
237
|
+
var apiRegexp = new RegExp(normalizeOutputPath("".concat(apiDirectory).concat(path.sep, ".*(.[tj]s)$")));
|
|
240
238
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
241
239
|
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
242
240
|
prefix: prefix,
|
|
243
|
-
apiDir:
|
|
241
|
+
apiDir: apiDirectory,
|
|
244
242
|
lambdaDir: lambdaDir,
|
|
245
243
|
existLambda: existLambda,
|
|
246
244
|
port: port,
|
package/dist/esm/loader.js
CHANGED
|
@@ -148,6 +148,7 @@ 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,
|
|
151
152
|
target: draftOptions.target,
|
|
152
153
|
port: Number(draftOptions.port),
|
|
153
154
|
source: source,
|
package/dist/esm/server.js
CHANGED
|
@@ -131,8 +131,10 @@ var server_default = function() {
|
|
|
131
131
|
var pwd = props.pwd, prefix = props.prefix, httpMethodDecider = props.httpMethodDecider;
|
|
132
132
|
var apiDir = path.resolve(pwd, API_DIR);
|
|
133
133
|
var appContext = api.useAppContext();
|
|
134
|
+
var apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory;
|
|
134
135
|
var apiRouter = new ApiRouter({
|
|
135
|
-
apiDir: apiDir,
|
|
136
|
+
apiDir: apiDirectory || apiDir,
|
|
137
|
+
lambdaDir: lambdaDirectory,
|
|
136
138
|
prefix: prefix,
|
|
137
139
|
httpMethodDecider: httpMethodDecider
|
|
138
140
|
});
|
package/dist/esm-node/cli.js
CHANGED
|
@@ -21,32 +21,30 @@ var cli_default = () => ({
|
|
|
21
21
|
return PLUGIN_SCHEMAS["@modern-js/plugin-bff"];
|
|
22
22
|
},
|
|
23
23
|
config() {
|
|
24
|
-
const configContext = api.useConfigContext();
|
|
25
|
-
console.log("22222222222222222", configContext.bff);
|
|
26
24
|
return {
|
|
27
25
|
tools: {
|
|
28
26
|
webpackChain: (chain, { name, CHAIN_ID }) => {
|
|
29
|
-
const {
|
|
27
|
+
const { port, apiDirectory, lambdaDirectory } = api.useAppContext();
|
|
30
28
|
const modernConfig = api.useResolvedConfigContext();
|
|
31
29
|
const { bff } = modernConfig || {};
|
|
32
30
|
const prefix = (bff == null ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
33
31
|
const { httpMethodDecider } = bff;
|
|
34
|
-
|
|
35
|
-
chain.resolve.alias.set("@api", rootDir);
|
|
32
|
+
chain.resolve.alias.set("@api", apiDirectory);
|
|
36
33
|
const apiRouter = new ApiRouter({
|
|
37
|
-
apiDir:
|
|
34
|
+
apiDir: apiDirectory,
|
|
35
|
+
lambdaDir: lambdaDirectory,
|
|
38
36
|
prefix,
|
|
39
37
|
httpMethodDecider
|
|
40
38
|
});
|
|
41
39
|
const lambdaDir = apiRouter.getLambdaDir();
|
|
42
40
|
const existLambda = apiRouter.isExistLambda();
|
|
43
41
|
const apiRegexp = new RegExp(
|
|
44
|
-
normalizeOutputPath(`${
|
|
42
|
+
normalizeOutputPath(`${apiDirectory}${path.sep}.*(.[tj]s)$`)
|
|
45
43
|
);
|
|
46
44
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
47
45
|
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
48
46
|
prefix,
|
|
49
|
-
apiDir:
|
|
47
|
+
apiDir: apiDirectory,
|
|
50
48
|
lambdaDir,
|
|
51
49
|
existLambda,
|
|
52
50
|
port,
|
package/dist/esm-node/loader.js
CHANGED
|
@@ -14,6 +14,7 @@ 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,
|
|
17
18
|
target: draftOptions.target,
|
|
18
19
|
port: Number(draftOptions.port),
|
|
19
20
|
source,
|
package/dist/esm-node/server.js
CHANGED
|
@@ -48,8 +48,10 @@ var server_default = () => ({
|
|
|
48
48
|
const { pwd, prefix, httpMethodDecider } = props;
|
|
49
49
|
const apiDir = path.resolve(pwd, API_DIR);
|
|
50
50
|
const appContext = api.useAppContext();
|
|
51
|
+
const { apiDirectory, lambdaDirectory } = appContext;
|
|
51
52
|
const apiRouter = new ApiRouter({
|
|
52
|
-
apiDir,
|
|
53
|
+
apiDir: apiDirectory || apiDir,
|
|
54
|
+
lambdaDir: lambdaDirectory,
|
|
53
55
|
prefix,
|
|
54
56
|
httpMethodDecider
|
|
55
57
|
});
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.5.1-alpha.
|
|
14
|
+
"version": "2.5.1-alpha.2",
|
|
15
15
|
"jsnext:source": "./src/cli.ts",
|
|
16
16
|
"types": "./dist/types/cli.d.ts",
|
|
17
17
|
"main": "./dist/cjs/cli.js",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/core": "^7.18.0",
|
|
52
52
|
"@babel/runtime": "^7.18.0",
|
|
53
|
-
"@modern-js/bff-core": "2.5.
|
|
54
|
-
"@modern-js/create-request": "2.5.
|
|
53
|
+
"@modern-js/bff-core": "2.5.1-alpha.1",
|
|
54
|
+
"@modern-js/create-request": "2.5.1-alpha.5",
|
|
55
55
|
"@modern-js/server-utils": "2.5.0",
|
|
56
56
|
"@modern-js/utils": "2.5.0"
|
|
57
57
|
},
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"@modern-js/runtime": "2.5.0",
|
|
60
60
|
"@modern-js/core": "2.5.1-alpha.0",
|
|
61
61
|
"@modern-js/bff-runtime": "2.5.0",
|
|
62
|
-
"@modern-js/server-core": "2.5.0",
|
|
63
|
-
"@modern-js/types": "2.5.0",
|
|
64
|
-
"@modern-js/app-tools": "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
65
|
"@scripts/build": "2.5.0",
|
|
66
66
|
"@scripts/jest-config": "2.5.0",
|
|
67
67
|
"@types/babel__core": "^7.1.15",
|