@modern-js/plugin-bff 2.58.1 → 2.58.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 +5 -15
- package/dist/cjs/server.js +6 -6
- package/dist/esm/cli.js +21 -29
- package/dist/esm/server.js +91 -44
- package/dist/esm-node/cli.js +6 -16
- package/dist/esm-node/server.js +6 -6
- package/dist/types/server.d.ts +1 -1
- package/package.json +14 -13
package/dist/cjs/cli.js
CHANGED
|
@@ -36,13 +36,11 @@ var import_path = __toESM(require("path"));
|
|
|
36
36
|
var import_utils = require("@modern-js/utils");
|
|
37
37
|
var import_server_utils = require("@modern-js/server-utils");
|
|
38
38
|
var import_bff_core = require("@modern-js/bff-core");
|
|
39
|
-
var import_helper = require("./helper");
|
|
40
39
|
const DEFAULT_API_PREFIX = "/api";
|
|
41
40
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
42
41
|
const bffPlugin = () => ({
|
|
43
42
|
name: "@modern-js/plugin-bff",
|
|
44
43
|
setup: (api) => {
|
|
45
|
-
let unRegisterResolveRuntimePath = null;
|
|
46
44
|
return {
|
|
47
45
|
config() {
|
|
48
46
|
return {
|
|
@@ -129,27 +127,18 @@ const bffPlugin = () => ({
|
|
|
129
127
|
plugins
|
|
130
128
|
};
|
|
131
129
|
},
|
|
132
|
-
async beforeBuild() {
|
|
133
|
-
if ((0, import_utils.isProd)()) {
|
|
134
|
-
const { internalDirectory } = api.useAppContext();
|
|
135
|
-
unRegisterResolveRuntimePath = (0, import_helper.registerModernRuntimePath)(internalDirectory);
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
130
|
async afterBuild() {
|
|
139
|
-
|
|
140
|
-
unRegisterResolveRuntimePath();
|
|
141
|
-
}
|
|
142
|
-
const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
|
|
131
|
+
const { appDirectory, distDirectory, apiDirectory, sharedDirectory, moduleType } = api.useAppContext();
|
|
143
132
|
const modernConfig = api.useResolvedConfigContext();
|
|
144
133
|
const distDir = import_path.default.resolve(distDirectory);
|
|
145
134
|
const apiDir = apiDirectory || import_path.default.resolve(appDirectory, import_utils.API_DIR);
|
|
146
135
|
const sharedDir = sharedDirectory || import_path.default.resolve(appDirectory, import_utils.SHARED_DIR);
|
|
147
136
|
const tsconfigPath = import_path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
148
137
|
const sourceDirs = [];
|
|
149
|
-
if (import_utils.fs.
|
|
138
|
+
if (await import_utils.fs.pathExists(apiDir)) {
|
|
150
139
|
sourceDirs.push(apiDir);
|
|
151
140
|
}
|
|
152
|
-
if (import_utils.fs.
|
|
141
|
+
if (await import_utils.fs.pathExists(sharedDir)) {
|
|
153
142
|
sourceDirs.push(sharedDir);
|
|
154
143
|
}
|
|
155
144
|
const { server } = modernConfig;
|
|
@@ -163,7 +152,8 @@ const bffPlugin = () => ({
|
|
|
163
152
|
}, {
|
|
164
153
|
sourceDirs,
|
|
165
154
|
distDir,
|
|
166
|
-
tsconfigPath
|
|
155
|
+
tsconfigPath,
|
|
156
|
+
moduleType
|
|
167
157
|
});
|
|
168
158
|
}
|
|
169
159
|
}
|
package/dist/cjs/server.js
CHANGED
|
@@ -63,7 +63,7 @@ var server_default = () => ({
|
|
|
63
63
|
const root = (0, import_utils.isProd)() ? distDirectory : appDirectory;
|
|
64
64
|
const apiPath = import_path.default.resolve(root || process.cwd(), import_utils.API_DIR);
|
|
65
65
|
apiAppPath = import_path.default.resolve(apiPath, import_constants.API_APP_NAME);
|
|
66
|
-
const apiMod = (0, import_utils.requireExistModule)(apiAppPath);
|
|
66
|
+
const apiMod = await (0, import_utils.requireExistModule)(apiAppPath);
|
|
67
67
|
if (apiMod && typeof apiMod === "function") {
|
|
68
68
|
apiMod(transformAPI);
|
|
69
69
|
}
|
|
@@ -115,10 +115,10 @@ var server_default = () => ({
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
|
-
reset({ event }) {
|
|
118
|
+
async reset({ event }) {
|
|
119
119
|
storage.reset();
|
|
120
120
|
const appContext = api.useAppContext();
|
|
121
|
-
const newApiModule = (0, import_utils.requireExistModule)(apiAppPath);
|
|
121
|
+
const newApiModule = await (0, import_utils.requireExistModule)(apiAppPath);
|
|
122
122
|
if (newApiModule && typeof newApiModule === "function") {
|
|
123
123
|
newApiModule(transformAPI);
|
|
124
124
|
}
|
|
@@ -128,7 +128,7 @@ var server_default = () => ({
|
|
|
128
128
|
apiMiddlewares: middlewares
|
|
129
129
|
});
|
|
130
130
|
if (event.type === "file-change") {
|
|
131
|
-
const apiHandlerInfos = apiRouter.getApiHandlers();
|
|
131
|
+
const apiHandlerInfos = await apiRouter.getApiHandlers();
|
|
132
132
|
const appContext2 = api.useAppContext();
|
|
133
133
|
api.setAppContext({
|
|
134
134
|
...appContext2,
|
|
@@ -136,7 +136,7 @@ var server_default = () => ({
|
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
|
-
prepareApiServer(props, next) {
|
|
139
|
+
async prepareApiServer(props, next) {
|
|
140
140
|
const { pwd, prefix, httpMethodDecider } = props;
|
|
141
141
|
const apiDir = import_path.default.resolve(pwd, import_utils.API_DIR);
|
|
142
142
|
const appContext = api.useAppContext();
|
|
@@ -149,7 +149,7 @@ var server_default = () => ({
|
|
|
149
149
|
httpMethodDecider
|
|
150
150
|
});
|
|
151
151
|
const apiMode = apiRouter.getApiMode();
|
|
152
|
-
const apiHandlerInfos = apiRouter.getApiHandlers();
|
|
152
|
+
const apiHandlerInfos = await apiRouter.getApiHandlers();
|
|
153
153
|
api.setAppContext({
|
|
154
154
|
...appContext,
|
|
155
155
|
apiRouter,
|
package/dist/esm/cli.js
CHANGED
|
@@ -4,17 +4,15 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
4
4
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import path from "path";
|
|
7
|
-
import { fs, API_DIR, normalizeOutputPath, SHARED_DIR
|
|
7
|
+
import { fs, API_DIR, normalizeOutputPath, SHARED_DIR } from "@modern-js/utils";
|
|
8
8
|
import { compile } from "@modern-js/server-utils";
|
|
9
9
|
import { ApiRouter } from "@modern-js/bff-core";
|
|
10
|
-
import { registerModernRuntimePath } from "./helper";
|
|
11
10
|
var DEFAULT_API_PREFIX = "/api";
|
|
12
11
|
var TS_CONFIG_FILENAME = "tsconfig.json";
|
|
13
12
|
var bffPlugin = function() {
|
|
14
13
|
return {
|
|
15
14
|
name: "@modern-js/plugin-bff",
|
|
16
15
|
setup: function(api) {
|
|
17
|
-
var unRegisterResolveRuntimePath = null;
|
|
18
16
|
return {
|
|
19
17
|
config: function config() {
|
|
20
18
|
return {
|
|
@@ -106,40 +104,33 @@ var bffPlugin = function() {
|
|
|
106
104
|
plugins
|
|
107
105
|
};
|
|
108
106
|
},
|
|
109
|
-
beforeBuild: function beforeBuild() {
|
|
110
|
-
return _async_to_generator(function() {
|
|
111
|
-
var internalDirectory;
|
|
112
|
-
return _ts_generator(this, function(_state) {
|
|
113
|
-
if (isProd()) {
|
|
114
|
-
internalDirectory = api.useAppContext().internalDirectory;
|
|
115
|
-
unRegisterResolveRuntimePath = registerModernRuntimePath(internalDirectory);
|
|
116
|
-
}
|
|
117
|
-
return [
|
|
118
|
-
2
|
|
119
|
-
];
|
|
120
|
-
});
|
|
121
|
-
})();
|
|
122
|
-
},
|
|
123
107
|
afterBuild: function afterBuild() {
|
|
124
108
|
return _async_to_generator(function() {
|
|
125
|
-
var _api_useAppContext, appDirectory, distDirectory, apiDirectory, sharedDirectory, modernConfig, distDir, apiDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
|
|
109
|
+
var _api_useAppContext, appDirectory, distDirectory, apiDirectory, sharedDirectory, moduleType, modernConfig, distDir, apiDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
|
|
126
110
|
return _ts_generator(this, function(_state) {
|
|
127
111
|
switch (_state.label) {
|
|
128
112
|
case 0:
|
|
129
|
-
|
|
130
|
-
unRegisterResolveRuntimePath();
|
|
131
|
-
}
|
|
132
|
-
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory, apiDirectory = _api_useAppContext.apiDirectory, sharedDirectory = _api_useAppContext.sharedDirectory;
|
|
113
|
+
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory, apiDirectory = _api_useAppContext.apiDirectory, sharedDirectory = _api_useAppContext.sharedDirectory, moduleType = _api_useAppContext.moduleType;
|
|
133
114
|
modernConfig = api.useResolvedConfigContext();
|
|
134
115
|
distDir = path.resolve(distDirectory);
|
|
135
116
|
apiDir = apiDirectory || path.resolve(appDirectory, API_DIR);
|
|
136
117
|
sharedDir = sharedDirectory || path.resolve(appDirectory, SHARED_DIR);
|
|
137
118
|
tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
138
119
|
sourceDirs = [];
|
|
139
|
-
|
|
120
|
+
return [
|
|
121
|
+
4,
|
|
122
|
+
fs.pathExists(apiDir)
|
|
123
|
+
];
|
|
124
|
+
case 1:
|
|
125
|
+
if (_state.sent()) {
|
|
140
126
|
sourceDirs.push(apiDir);
|
|
141
127
|
}
|
|
142
|
-
|
|
128
|
+
return [
|
|
129
|
+
4,
|
|
130
|
+
fs.pathExists(sharedDir)
|
|
131
|
+
];
|
|
132
|
+
case 2:
|
|
133
|
+
if (_state.sent()) {
|
|
143
134
|
sourceDirs.push(sharedDir);
|
|
144
135
|
}
|
|
145
136
|
server = modernConfig.server;
|
|
@@ -148,7 +139,7 @@ var bffPlugin = function() {
|
|
|
148
139
|
if (!(sourceDirs.length > 0))
|
|
149
140
|
return [
|
|
150
141
|
3,
|
|
151
|
-
|
|
142
|
+
4
|
|
152
143
|
];
|
|
153
144
|
return [
|
|
154
145
|
4,
|
|
@@ -159,13 +150,14 @@ var bffPlugin = function() {
|
|
|
159
150
|
}, {
|
|
160
151
|
sourceDirs,
|
|
161
152
|
distDir,
|
|
162
|
-
tsconfigPath
|
|
153
|
+
tsconfigPath,
|
|
154
|
+
moduleType
|
|
163
155
|
})
|
|
164
156
|
];
|
|
165
|
-
case
|
|
157
|
+
case 3:
|
|
166
158
|
_state.sent();
|
|
167
|
-
_state.label =
|
|
168
|
-
case
|
|
159
|
+
_state.label = 4;
|
|
160
|
+
case 4:
|
|
169
161
|
return [
|
|
170
162
|
2
|
|
171
163
|
];
|
package/dist/esm/server.js
CHANGED
|
@@ -46,7 +46,12 @@ function server_default() {
|
|
|
46
46
|
root = isProd() ? distDirectory : appDirectory;
|
|
47
47
|
apiPath = path.resolve(root || process.cwd(), API_DIR);
|
|
48
48
|
apiAppPath = path.resolve(apiPath, API_APP_NAME);
|
|
49
|
-
|
|
49
|
+
return [
|
|
50
|
+
4,
|
|
51
|
+
requireExistModule(apiAppPath)
|
|
52
|
+
];
|
|
53
|
+
case 1:
|
|
54
|
+
apiMod = _state.sent();
|
|
50
55
|
if (apiMod && typeof apiMod === "function") {
|
|
51
56
|
apiMod(transformAPI);
|
|
52
57
|
}
|
|
@@ -63,12 +68,12 @@ function server_default() {
|
|
|
63
68
|
4,
|
|
64
69
|
isWebOnly()
|
|
65
70
|
];
|
|
66
|
-
case
|
|
71
|
+
case 2:
|
|
67
72
|
webOnly = _state.sent();
|
|
68
73
|
if (!webOnly)
|
|
69
74
|
return [
|
|
70
75
|
3,
|
|
71
|
-
|
|
76
|
+
3
|
|
72
77
|
];
|
|
73
78
|
handler = function() {
|
|
74
79
|
var _ref = _async_to_generator(function(c, next) {
|
|
@@ -94,9 +99,9 @@ function server_default() {
|
|
|
94
99
|
}();
|
|
95
100
|
return [
|
|
96
101
|
3,
|
|
97
|
-
|
|
102
|
+
5
|
|
98
103
|
];
|
|
99
|
-
case
|
|
104
|
+
case 3:
|
|
100
105
|
runner = api.useHookRunners();
|
|
101
106
|
renderHandler = enableHandleWeb ? render : null;
|
|
102
107
|
return [
|
|
@@ -112,10 +117,10 @@ function server_default() {
|
|
|
112
117
|
}
|
|
113
118
|
})
|
|
114
119
|
];
|
|
115
|
-
case 3:
|
|
116
|
-
handler = _state.sent();
|
|
117
|
-
_state.label = 4;
|
|
118
120
|
case 4:
|
|
121
|
+
handler = _state.sent();
|
|
122
|
+
_state.label = 5;
|
|
123
|
+
case 5:
|
|
119
124
|
if (handler) {
|
|
120
125
|
globalMiddlewares.push({
|
|
121
126
|
name: "bind-bff",
|
|
@@ -143,44 +148,86 @@ function server_default() {
|
|
|
143
148
|
},
|
|
144
149
|
reset: function reset(param) {
|
|
145
150
|
var event = param.event;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
return _async_to_generator(function() {
|
|
152
|
+
var appContext, newApiModule, middlewares, apiHandlerInfos, appContext1;
|
|
153
|
+
return _ts_generator(this, function(_state) {
|
|
154
|
+
switch (_state.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
storage.reset();
|
|
157
|
+
appContext = api.useAppContext();
|
|
158
|
+
return [
|
|
159
|
+
4,
|
|
160
|
+
requireExistModule(apiAppPath)
|
|
161
|
+
];
|
|
162
|
+
case 1:
|
|
163
|
+
newApiModule = _state.sent();
|
|
164
|
+
if (newApiModule && typeof newApiModule === "function") {
|
|
165
|
+
newApiModule(transformAPI);
|
|
166
|
+
}
|
|
167
|
+
middlewares = storage.middlewares;
|
|
168
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
|
|
169
|
+
apiMiddlewares: middlewares
|
|
170
|
+
}));
|
|
171
|
+
if (!(event.type === "file-change"))
|
|
172
|
+
return [
|
|
173
|
+
3,
|
|
174
|
+
3
|
|
175
|
+
];
|
|
176
|
+
return [
|
|
177
|
+
4,
|
|
178
|
+
apiRouter.getApiHandlers()
|
|
179
|
+
];
|
|
180
|
+
case 2:
|
|
181
|
+
apiHandlerInfos = _state.sent();
|
|
182
|
+
appContext1 = api.useAppContext();
|
|
183
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext1), {
|
|
184
|
+
apiHandlerInfos
|
|
185
|
+
}));
|
|
186
|
+
_state.label = 3;
|
|
187
|
+
case 3:
|
|
188
|
+
return [
|
|
189
|
+
2
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
})();
|
|
163
194
|
},
|
|
164
195
|
prepareApiServer: function prepareApiServer(props, next) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
196
|
+
return _async_to_generator(function() {
|
|
197
|
+
var pwd, prefix, httpMethodDecider, apiDir, appContext, apiDirectory, lambdaDirectory, apiMode, apiHandlerInfos;
|
|
198
|
+
return _ts_generator(this, function(_state) {
|
|
199
|
+
switch (_state.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
pwd = props.pwd, prefix = props.prefix, httpMethodDecider = props.httpMethodDecider;
|
|
202
|
+
apiDir = path.resolve(pwd, API_DIR);
|
|
203
|
+
appContext = api.useAppContext();
|
|
204
|
+
apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory;
|
|
205
|
+
apiRouter = new ApiRouter({
|
|
206
|
+
appDir: pwd,
|
|
207
|
+
apiDir: apiDirectory || apiDir,
|
|
208
|
+
lambdaDir: lambdaDirectory,
|
|
209
|
+
prefix,
|
|
210
|
+
httpMethodDecider
|
|
211
|
+
});
|
|
212
|
+
apiMode = apiRouter.getApiMode();
|
|
213
|
+
return [
|
|
214
|
+
4,
|
|
215
|
+
apiRouter.getApiHandlers()
|
|
216
|
+
];
|
|
217
|
+
case 1:
|
|
218
|
+
apiHandlerInfos = _state.sent();
|
|
219
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
|
|
220
|
+
apiRouter,
|
|
221
|
+
apiHandlerInfos,
|
|
222
|
+
apiMode
|
|
223
|
+
}));
|
|
224
|
+
return [
|
|
225
|
+
2,
|
|
226
|
+
next(props)
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
})();
|
|
184
231
|
}
|
|
185
232
|
};
|
|
186
233
|
}
|
package/dist/esm-node/cli.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { fs, API_DIR, normalizeOutputPath, SHARED_DIR
|
|
2
|
+
import { fs, API_DIR, normalizeOutputPath, SHARED_DIR } from "@modern-js/utils";
|
|
3
3
|
import { compile } from "@modern-js/server-utils";
|
|
4
4
|
import { ApiRouter } from "@modern-js/bff-core";
|
|
5
|
-
import { registerModernRuntimePath } from "./helper";
|
|
6
5
|
const DEFAULT_API_PREFIX = "/api";
|
|
7
6
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
8
7
|
const bffPlugin = () => ({
|
|
9
8
|
name: "@modern-js/plugin-bff",
|
|
10
9
|
setup: (api) => {
|
|
11
|
-
let unRegisterResolveRuntimePath = null;
|
|
12
10
|
return {
|
|
13
11
|
config() {
|
|
14
12
|
return {
|
|
@@ -95,27 +93,18 @@ const bffPlugin = () => ({
|
|
|
95
93
|
plugins
|
|
96
94
|
};
|
|
97
95
|
},
|
|
98
|
-
async beforeBuild() {
|
|
99
|
-
if (isProd()) {
|
|
100
|
-
const { internalDirectory } = api.useAppContext();
|
|
101
|
-
unRegisterResolveRuntimePath = registerModernRuntimePath(internalDirectory);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
96
|
async afterBuild() {
|
|
105
|
-
|
|
106
|
-
unRegisterResolveRuntimePath();
|
|
107
|
-
}
|
|
108
|
-
const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
|
|
97
|
+
const { appDirectory, distDirectory, apiDirectory, sharedDirectory, moduleType } = api.useAppContext();
|
|
109
98
|
const modernConfig = api.useResolvedConfigContext();
|
|
110
99
|
const distDir = path.resolve(distDirectory);
|
|
111
100
|
const apiDir = apiDirectory || path.resolve(appDirectory, API_DIR);
|
|
112
101
|
const sharedDir = sharedDirectory || path.resolve(appDirectory, SHARED_DIR);
|
|
113
102
|
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
114
103
|
const sourceDirs = [];
|
|
115
|
-
if (fs.
|
|
104
|
+
if (await fs.pathExists(apiDir)) {
|
|
116
105
|
sourceDirs.push(apiDir);
|
|
117
106
|
}
|
|
118
|
-
if (fs.
|
|
107
|
+
if (await fs.pathExists(sharedDir)) {
|
|
119
108
|
sourceDirs.push(sharedDir);
|
|
120
109
|
}
|
|
121
110
|
const { server } = modernConfig;
|
|
@@ -129,7 +118,8 @@ const bffPlugin = () => ({
|
|
|
129
118
|
}, {
|
|
130
119
|
sourceDirs,
|
|
131
120
|
distDir,
|
|
132
|
-
tsconfigPath
|
|
121
|
+
tsconfigPath,
|
|
122
|
+
moduleType
|
|
133
123
|
});
|
|
134
124
|
}
|
|
135
125
|
}
|
package/dist/esm-node/server.js
CHANGED
|
@@ -30,7 +30,7 @@ var server_default = () => ({
|
|
|
30
30
|
const root = isProd() ? distDirectory : appDirectory;
|
|
31
31
|
const apiPath = path.resolve(root || process.cwd(), API_DIR);
|
|
32
32
|
apiAppPath = path.resolve(apiPath, API_APP_NAME);
|
|
33
|
-
const apiMod = requireExistModule(apiAppPath);
|
|
33
|
+
const apiMod = await requireExistModule(apiAppPath);
|
|
34
34
|
if (apiMod && typeof apiMod === "function") {
|
|
35
35
|
apiMod(transformAPI);
|
|
36
36
|
}
|
|
@@ -82,10 +82,10 @@ var server_default = () => ({
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
-
reset({ event }) {
|
|
85
|
+
async reset({ event }) {
|
|
86
86
|
storage.reset();
|
|
87
87
|
const appContext = api.useAppContext();
|
|
88
|
-
const newApiModule = requireExistModule(apiAppPath);
|
|
88
|
+
const newApiModule = await requireExistModule(apiAppPath);
|
|
89
89
|
if (newApiModule && typeof newApiModule === "function") {
|
|
90
90
|
newApiModule(transformAPI);
|
|
91
91
|
}
|
|
@@ -95,7 +95,7 @@ var server_default = () => ({
|
|
|
95
95
|
apiMiddlewares: middlewares
|
|
96
96
|
});
|
|
97
97
|
if (event.type === "file-change") {
|
|
98
|
-
const apiHandlerInfos = apiRouter.getApiHandlers();
|
|
98
|
+
const apiHandlerInfos = await apiRouter.getApiHandlers();
|
|
99
99
|
const appContext2 = api.useAppContext();
|
|
100
100
|
api.setAppContext({
|
|
101
101
|
...appContext2,
|
|
@@ -103,7 +103,7 @@ var server_default = () => ({
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
|
-
prepareApiServer(props, next) {
|
|
106
|
+
async prepareApiServer(props, next) {
|
|
107
107
|
const { pwd, prefix, httpMethodDecider } = props;
|
|
108
108
|
const apiDir = path.resolve(pwd, API_DIR);
|
|
109
109
|
const appContext = api.useAppContext();
|
|
@@ -116,7 +116,7 @@ var server_default = () => ({
|
|
|
116
116
|
httpMethodDecider
|
|
117
117
|
});
|
|
118
118
|
const apiMode = apiRouter.getApiMode();
|
|
119
|
-
const apiHandlerInfos = apiRouter.getApiHandlers();
|
|
119
|
+
const apiHandlerInfos = await apiRouter.getApiHandlers();
|
|
120
120
|
api.setAppContext({
|
|
121
121
|
...appContext,
|
|
122
122
|
apiRouter,
|
package/dist/types/server.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.58.
|
|
18
|
+
"version": "2.58.2",
|
|
19
19
|
"jsnext:source": "./src/cli.ts",
|
|
20
20
|
"types": "./dist/types/cli.d.ts",
|
|
21
21
|
"main": "./dist/cjs/cli.js",
|
|
22
22
|
"module": "./dist/esm/cli.js",
|
|
23
23
|
"exports": {
|
|
24
|
+
"./types": "./types.d.ts",
|
|
24
25
|
".": {
|
|
25
26
|
"types": "./dist/types/cli.d.ts",
|
|
26
27
|
"jsnext:source": "./src/cli.ts",
|
|
@@ -58,11 +59,11 @@
|
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"@babel/core": "^7.24.7",
|
|
60
61
|
"@swc/helpers": "0.5.3",
|
|
61
|
-
"@modern-js/bff-core": "2.58.
|
|
62
|
-
"@modern-js/create-request": "2.58.
|
|
63
|
-
"@modern-js/server-
|
|
64
|
-
"@modern-js/
|
|
65
|
-
"@modern-js/utils": "2.58.
|
|
62
|
+
"@modern-js/bff-core": "2.58.2",
|
|
63
|
+
"@modern-js/create-request": "2.58.2",
|
|
64
|
+
"@modern-js/server-core": "2.58.2",
|
|
65
|
+
"@modern-js/utils": "2.58.2",
|
|
66
|
+
"@modern-js/server-utils": "2.58.2"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@types/babel__core": "^7.20.5",
|
|
@@ -73,13 +74,13 @@
|
|
|
73
74
|
"ts-jest": "^29.1.0",
|
|
74
75
|
"typescript": "^5",
|
|
75
76
|
"webpack": "^5.93.0",
|
|
76
|
-
"@modern-js/
|
|
77
|
-
"@modern-js/
|
|
78
|
-
"@modern-js/
|
|
79
|
-
"@modern-js/
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"@scripts/jest-config": "2.58.
|
|
77
|
+
"@modern-js/bff-runtime": "2.58.2",
|
|
78
|
+
"@modern-js/app-tools": "2.58.2",
|
|
79
|
+
"@modern-js/core": "2.58.2",
|
|
80
|
+
"@modern-js/types": "2.58.2",
|
|
81
|
+
"@scripts/build": "2.58.2",
|
|
82
|
+
"@modern-js/runtime": "2.58.2",
|
|
83
|
+
"@scripts/jest-config": "2.58.2"
|
|
83
84
|
},
|
|
84
85
|
"sideEffects": false,
|
|
85
86
|
"publishConfig": {
|