@modern-js/plugin-bff 2.14.0 → 2.16.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 +25 -0
- package/dist/cjs/cli.js +136 -154
- package/dist/cjs/constants.js +11 -24
- package/dist/cjs/helper.js +51 -39
- package/dist/cjs/index.js +18 -17
- package/dist/cjs/loader.js +13 -29
- package/dist/cjs/server.js +40 -48
- package/dist/esm/cli.js +358 -341
- package/dist/esm/constants.js +9 -10
- package/dist/esm/helper.js +15 -15
- package/dist/esm/loader.js +185 -179
- package/dist/esm/server.js +137 -134
- package/dist/esm-node/cli.js +119 -126
- package/dist/esm-node/constants.js +2 -6
- package/dist/esm-node/helper.js +1 -3
- package/dist/esm-node/loader.js +1 -4
- package/dist/esm-node/server.js +17 -7
- package/package.json +18 -14
package/dist/esm/server.js
CHANGED
|
@@ -1,154 +1,157 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
5
|
}
|
|
6
6
|
function _defineProperties(target, props) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
for (var i = 0; i < props.length; i++) {
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor)
|
|
12
|
+
descriptor.writable = true;
|
|
13
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14
|
+
}
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
17
|
+
if (protoProps)
|
|
18
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
19
|
+
if (staticProps)
|
|
20
|
+
_defineProperties(Constructor, staticProps);
|
|
21
|
+
return Constructor;
|
|
19
22
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
function _define_property(obj, key, value) {
|
|
24
|
+
if (key in obj) {
|
|
25
|
+
Object.defineProperty(obj, key, {
|
|
26
|
+
value,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
obj[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return obj;
|
|
32
35
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
ownKeys.forEach(function(key) {
|
|
43
|
-
_defineProperty(target, key, source[key]);
|
|
44
|
-
});
|
|
36
|
+
function _object_spread(target) {
|
|
37
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
38
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
39
|
+
var ownKeys2 = Object.keys(source);
|
|
40
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
41
|
+
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
42
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
43
|
+
}));
|
|
45
44
|
}
|
|
46
|
-
|
|
45
|
+
ownKeys2.forEach(function(key) {
|
|
46
|
+
_define_property(target, key, source[key]);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return target;
|
|
47
50
|
}
|
|
48
51
|
function ownKeys(object, enumerableOnly) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
keys.push.apply(keys, symbols);
|
|
52
|
+
var keys = Object.keys(object);
|
|
53
|
+
if (Object.getOwnPropertySymbols) {
|
|
54
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
55
|
+
if (enumerableOnly) {
|
|
56
|
+
symbols = symbols.filter(function(sym) {
|
|
57
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
58
|
+
});
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
keys.push.apply(keys, symbols);
|
|
61
|
+
}
|
|
62
|
+
return keys;
|
|
60
63
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
function _object_spread_props(target, source) {
|
|
65
|
+
source = source != null ? source : {};
|
|
66
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
67
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
68
|
+
} else {
|
|
69
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
70
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return target;
|
|
71
74
|
}
|
|
72
75
|
import path from "path";
|
|
73
76
|
import { ApiRouter } from "@modern-js/bff-core";
|
|
74
77
|
import { API_DIR, isProd, requireExistModule } from "@modern-js/utils";
|
|
75
78
|
import { API_APP_NAME } from "./constants";
|
|
76
|
-
var Storage =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
var Storage = /* @__PURE__ */ function() {
|
|
80
|
+
"use strict";
|
|
81
|
+
function Storage2() {
|
|
82
|
+
_class_call_check(this, Storage2);
|
|
83
|
+
_define_property(this, "middlewares", []);
|
|
84
|
+
}
|
|
85
|
+
_create_class(Storage2, [
|
|
86
|
+
{
|
|
87
|
+
key: "reset",
|
|
88
|
+
value: function reset() {
|
|
89
|
+
this.middlewares = [];
|
|
90
|
+
}
|
|
81
91
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
key: "reset",
|
|
85
|
-
value: function reset() {
|
|
86
|
-
this.middlewares = [];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
]);
|
|
90
|
-
return Storage;
|
|
92
|
+
]);
|
|
93
|
+
return Storage2;
|
|
91
94
|
}();
|
|
92
95
|
var createTransformAPI = function(storage) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
return {
|
|
97
|
+
addMiddleware: function addMiddleware(fn) {
|
|
98
|
+
storage.middlewares.push(fn);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
98
101
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
};
|
|
102
|
+
export default function() {
|
|
103
|
+
return {
|
|
104
|
+
name: "@modern-js/plugin-bff",
|
|
105
|
+
setup: function(api) {
|
|
106
|
+
var storage = new Storage();
|
|
107
|
+
var transformAPI = createTransformAPI(storage);
|
|
108
|
+
var apiAppPath = "";
|
|
109
|
+
return {
|
|
110
|
+
prepare: function prepare() {
|
|
111
|
+
var _api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory;
|
|
112
|
+
var root = isProd() ? distDirectory : appDirectory;
|
|
113
|
+
var apiPath = path.resolve(root || process.cwd(), API_DIR);
|
|
114
|
+
apiAppPath = path.resolve(apiPath, API_APP_NAME);
|
|
115
|
+
var apiMod = requireExistModule(apiAppPath);
|
|
116
|
+
if (apiMod && typeof apiMod === "function") {
|
|
117
|
+
apiMod(transformAPI);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
reset: function reset() {
|
|
121
|
+
storage.reset();
|
|
122
|
+
var newApiModule = requireExistModule(apiAppPath);
|
|
123
|
+
if (newApiModule && typeof newApiModule === "function") {
|
|
124
|
+
newApiModule(transformAPI);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
gather: function gather(param) {
|
|
128
|
+
var addAPIMiddleware = param.addAPIMiddleware;
|
|
129
|
+
storage.middlewares.forEach(function(mid) {
|
|
130
|
+
addAPIMiddleware(mid);
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
prepareApiServer: function prepareApiServer(props, next) {
|
|
134
|
+
var pwd = props.pwd, prefix = props.prefix, httpMethodDecider = props.httpMethodDecider;
|
|
135
|
+
var apiDir = path.resolve(pwd, API_DIR);
|
|
136
|
+
var appContext = api.useAppContext();
|
|
137
|
+
var apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory;
|
|
138
|
+
var apiRouter = new ApiRouter({
|
|
139
|
+
apiDir: apiDirectory || apiDir,
|
|
140
|
+
lambdaDir: lambdaDirectory,
|
|
141
|
+
prefix,
|
|
142
|
+
httpMethodDecider
|
|
143
|
+
});
|
|
144
|
+
var apiMode = apiRouter.getApiMode();
|
|
145
|
+
var apiHandlerInfos = apiRouter.getApiHandlers();
|
|
146
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
|
|
147
|
+
apiRouter,
|
|
148
|
+
apiHandlerInfos,
|
|
149
|
+
apiMode
|
|
150
|
+
}));
|
|
151
|
+
return next(props);
|
|
151
152
|
}
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
;
|
package/dist/esm-node/cli.js
CHANGED
|
@@ -1,144 +1,137 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import {
|
|
3
|
-
fs,
|
|
4
|
-
API_DIR,
|
|
5
|
-
PLUGIN_SCHEMAS,
|
|
6
|
-
normalizeOutputPath,
|
|
7
|
-
SHARED_DIR,
|
|
8
|
-
isProd
|
|
9
|
-
} from "@modern-js/utils";
|
|
2
|
+
import { fs, API_DIR, PLUGIN_SCHEMAS, normalizeOutputPath, SHARED_DIR, isProd } from "@modern-js/utils";
|
|
10
3
|
import { compile } from "@modern-js/server-utils";
|
|
11
4
|
import { ApiRouter } from "@modern-js/bff-core";
|
|
12
5
|
import { registerModernRuntimePath } from "./helper";
|
|
13
6
|
const DEFAULT_API_PREFIX = "/api";
|
|
14
7
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
normalizeOutputPath(`${apiDirectory}${path.sep}.*(.[tj]s)$`)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
8
|
+
export default () => {
|
|
9
|
+
return {
|
|
10
|
+
name: "@modern-js/plugin-bff",
|
|
11
|
+
setup: (api) => {
|
|
12
|
+
let unRegisterResolveRuntimePath = null;
|
|
13
|
+
return {
|
|
14
|
+
validateSchema() {
|
|
15
|
+
return PLUGIN_SCHEMAS["@modern-js/plugin-bff"];
|
|
16
|
+
},
|
|
17
|
+
config() {
|
|
18
|
+
return {
|
|
19
|
+
tools: {
|
|
20
|
+
bundlerChain: (chain, { CHAIN_ID, isServer }) => {
|
|
21
|
+
const { port, apiDirectory, lambdaDirectory } = api.useAppContext();
|
|
22
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
23
|
+
const { bff } = modernConfig || {};
|
|
24
|
+
const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
25
|
+
const httpMethodDecider = bff === null || bff === void 0 ? void 0 : bff.httpMethodDecider;
|
|
26
|
+
chain.resolve.alias.set("@api", apiDirectory);
|
|
27
|
+
const apiRouter = new ApiRouter({
|
|
28
|
+
apiDir: apiDirectory,
|
|
29
|
+
lambdaDir: lambdaDirectory,
|
|
30
|
+
prefix,
|
|
31
|
+
httpMethodDecider
|
|
32
|
+
});
|
|
33
|
+
const lambdaDir = apiRouter.getLambdaDir();
|
|
34
|
+
const existLambda = apiRouter.isExistLambda();
|
|
35
|
+
const apiRegexp = new RegExp(normalizeOutputPath(`${apiDirectory}${path.sep}.*(.[tj]s)$`));
|
|
36
|
+
const name = isServer ? "server" : "client";
|
|
37
|
+
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
38
|
+
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
39
|
+
prefix,
|
|
40
|
+
apiDir: apiDirectory,
|
|
41
|
+
lambdaDir,
|
|
42
|
+
existLambda,
|
|
43
|
+
port,
|
|
44
|
+
target: name,
|
|
45
|
+
httpMethodDecider
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
source: {
|
|
50
|
+
moduleScopes: [
|
|
51
|
+
`./${API_DIR}`,
|
|
52
|
+
/create-request/
|
|
53
|
+
]
|
|
55
54
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
modifyServerRoutes({ routes }) {
|
|
58
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
59
|
+
const { bff } = modernConfig || {};
|
|
60
|
+
const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || "/api";
|
|
61
|
+
const prefixList = [];
|
|
62
|
+
if (Array.isArray(prefix)) {
|
|
63
|
+
prefixList.push(...prefix);
|
|
64
|
+
} else {
|
|
65
|
+
prefixList.push(prefix);
|
|
66
|
+
}
|
|
67
|
+
const apiServerRoutes = prefixList.map((pre) => ({
|
|
68
|
+
urlPath: pre,
|
|
69
|
+
isApi: true,
|
|
70
|
+
entryPath: "",
|
|
71
|
+
isSPA: false,
|
|
72
|
+
isSSR: false
|
|
73
|
+
}));
|
|
74
|
+
if (bff === null || bff === void 0 ? void 0 : bff.enableHandleWeb) {
|
|
75
|
+
return {
|
|
76
|
+
routes: routes.map((route) => {
|
|
77
|
+
return {
|
|
78
|
+
...route,
|
|
79
|
+
isApi: true
|
|
80
|
+
};
|
|
81
|
+
}).concat(apiServerRoutes)
|
|
82
|
+
};
|
|
59
83
|
}
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
modifyServerRoutes({ routes }) {
|
|
63
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
64
|
-
const { bff } = modernConfig || {};
|
|
65
|
-
const prefix = (bff == null ? void 0 : bff.prefix) || "/api";
|
|
66
|
-
const prefixList = [];
|
|
67
|
-
if (Array.isArray(prefix)) {
|
|
68
|
-
prefixList.push(...prefix);
|
|
69
|
-
} else {
|
|
70
|
-
prefixList.push(prefix);
|
|
71
|
-
}
|
|
72
|
-
const apiServerRoutes = prefixList.map((pre) => ({
|
|
73
|
-
urlPath: pre,
|
|
74
|
-
isApi: true,
|
|
75
|
-
entryPath: "",
|
|
76
|
-
isSPA: false,
|
|
77
|
-
isSSR: false
|
|
78
|
-
}));
|
|
79
|
-
if (bff == null ? void 0 : bff.enableHandleWeb) {
|
|
80
84
|
return {
|
|
81
|
-
routes: routes.
|
|
82
|
-
return {
|
|
83
|
-
...route,
|
|
84
|
-
isApi: true
|
|
85
|
-
};
|
|
86
|
-
}).concat(apiServerRoutes)
|
|
85
|
+
routes: routes.concat(apiServerRoutes)
|
|
87
86
|
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
appDirectory,
|
|
126
|
-
{
|
|
87
|
+
},
|
|
88
|
+
collectServerPlugins({ plugins }) {
|
|
89
|
+
plugins.push({
|
|
90
|
+
"@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
plugins
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
async beforeBuild() {
|
|
97
|
+
if (isProd()) {
|
|
98
|
+
const { internalDirectory } = api.useAppContext();
|
|
99
|
+
unRegisterResolveRuntimePath = registerModernRuntimePath(internalDirectory);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
async afterBuild() {
|
|
103
|
+
if (unRegisterResolveRuntimePath) {
|
|
104
|
+
unRegisterResolveRuntimePath();
|
|
105
|
+
}
|
|
106
|
+
const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
|
|
107
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
108
|
+
const distDir = path.resolve(distDirectory);
|
|
109
|
+
const apiDir = apiDirectory || path.resolve(appDirectory, API_DIR);
|
|
110
|
+
const sharedDir = sharedDirectory || path.resolve(appDirectory, SHARED_DIR);
|
|
111
|
+
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
112
|
+
const sourceDirs = [];
|
|
113
|
+
if (fs.existsSync(apiDir)) {
|
|
114
|
+
sourceDirs.push(apiDir);
|
|
115
|
+
}
|
|
116
|
+
if (fs.existsSync(sharedDir)) {
|
|
117
|
+
sourceDirs.push(sharedDir);
|
|
118
|
+
}
|
|
119
|
+
const { server } = modernConfig;
|
|
120
|
+
const { alias } = modernConfig.source;
|
|
121
|
+
const { babel } = modernConfig.tools;
|
|
122
|
+
if (sourceDirs.length > 0) {
|
|
123
|
+
await compile(appDirectory, {
|
|
127
124
|
server,
|
|
128
125
|
alias,
|
|
129
126
|
babelConfig: babel
|
|
130
|
-
},
|
|
131
|
-
{
|
|
127
|
+
}, {
|
|
132
128
|
sourceDirs,
|
|
133
129
|
distDir,
|
|
134
130
|
tsconfigPath
|
|
135
|
-
}
|
|
136
|
-
|
|
131
|
+
});
|
|
132
|
+
}
|
|
137
133
|
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
export {
|
|
143
|
-
cli_default as default
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
};
|
|
144
137
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const API_APP_NAME = "_app";
|
|
2
|
-
const BUILD_FILES = [
|
|
1
|
+
export const API_APP_NAME = "_app";
|
|
2
|
+
export const BUILD_FILES = [
|
|
3
3
|
"**/*.[tj]sx?",
|
|
4
4
|
"!**/*.test.jsx?",
|
|
5
5
|
"!**/*.test.tsx?",
|
|
@@ -8,7 +8,3 @@ const BUILD_FILES = [
|
|
|
8
8
|
"!__tests__/*.tsx?",
|
|
9
9
|
"!__tests__/*.jsx?"
|
|
10
10
|
];
|
|
11
|
-
export {
|
|
12
|
-
API_APP_NAME,
|
|
13
|
-
BUILD_FILES
|
|
14
|
-
};
|
package/dist/esm-node/helper.js
CHANGED
package/dist/esm-node/loader.js
CHANGED
package/dist/esm-node/server.js
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
1
14
|
import path from "path";
|
|
2
15
|
import { ApiRouter } from "@modern-js/bff-core";
|
|
3
16
|
import { API_DIR, isProd, requireExistModule } from "@modern-js/utils";
|
|
4
17
|
import { API_APP_NAME } from "./constants";
|
|
5
18
|
class Storage {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.middlewares = [];
|
|
8
|
-
}
|
|
9
19
|
reset() {
|
|
10
20
|
this.middlewares = [];
|
|
11
21
|
}
|
|
22
|
+
constructor() {
|
|
23
|
+
_define_property(this, "middlewares", []);
|
|
24
|
+
}
|
|
12
25
|
}
|
|
13
26
|
const createTransformAPI = (storage) => ({
|
|
14
27
|
addMiddleware(fn) {
|
|
15
28
|
storage.middlewares.push(fn);
|
|
16
29
|
}
|
|
17
30
|
});
|
|
18
|
-
|
|
31
|
+
export default () => ({
|
|
19
32
|
name: "@modern-js/plugin-bff",
|
|
20
33
|
setup: (api) => {
|
|
21
34
|
const storage = new Storage();
|
|
@@ -68,6 +81,3 @@ var server_default = () => ({
|
|
|
68
81
|
};
|
|
69
82
|
}
|
|
70
83
|
});
|
|
71
|
-
export {
|
|
72
|
-
server_default as default
|
|
73
|
-
};
|