@modern-js/plugin-bff 2.15.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 +16 -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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @modern-js/plugin-bff
|
|
2
2
|
|
|
3
|
+
## 2.16.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4e876ab: chore: package.json include the monorepo-relative directory
|
|
8
|
+
|
|
9
|
+
chore: 在 package.json 中声明 monorepo 的子路径
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [5954330]
|
|
12
|
+
- Updated dependencies [7596520]
|
|
13
|
+
- Updated dependencies [4e876ab]
|
|
14
|
+
- @modern-js/utils@2.16.0
|
|
15
|
+
- @modern-js/create-request@2.16.0
|
|
16
|
+
- @modern-js/bff-core@2.16.0
|
|
17
|
+
- @modern-js/server-utils@2.16.0
|
|
18
|
+
|
|
3
19
|
## 2.15.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/cli.js
CHANGED
|
@@ -1,168 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
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.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var cli_exports = {};
|
|
29
|
-
__export(cli_exports, {
|
|
30
|
-
default: () => cli_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _default
|
|
31
8
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _serverutils = require("@modern-js/server-utils");
|
|
12
|
+
const _bffcore = require("@modern-js/bff-core");
|
|
13
|
+
const _helper = require("./helper");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
38
19
|
const DEFAULT_API_PREFIX = "/api";
|
|
39
20
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(0,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
21
|
+
const _default = () => {
|
|
22
|
+
return {
|
|
23
|
+
name: "@modern-js/plugin-bff",
|
|
24
|
+
setup: (api) => {
|
|
25
|
+
let unRegisterResolveRuntimePath = null;
|
|
26
|
+
return {
|
|
27
|
+
validateSchema() {
|
|
28
|
+
return _utils.PLUGIN_SCHEMAS["@modern-js/plugin-bff"];
|
|
29
|
+
},
|
|
30
|
+
config() {
|
|
31
|
+
return {
|
|
32
|
+
tools: {
|
|
33
|
+
bundlerChain: (chain, { CHAIN_ID, isServer }) => {
|
|
34
|
+
const { port, apiDirectory, lambdaDirectory } = api.useAppContext();
|
|
35
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
36
|
+
const { bff } = modernConfig || {};
|
|
37
|
+
const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
38
|
+
const httpMethodDecider = bff === null || bff === void 0 ? void 0 : bff.httpMethodDecider;
|
|
39
|
+
chain.resolve.alias.set("@api", apiDirectory);
|
|
40
|
+
const apiRouter = new _bffcore.ApiRouter({
|
|
41
|
+
apiDir: apiDirectory,
|
|
42
|
+
lambdaDir: lambdaDirectory,
|
|
43
|
+
prefix,
|
|
44
|
+
httpMethodDecider
|
|
45
|
+
});
|
|
46
|
+
const lambdaDir = apiRouter.getLambdaDir();
|
|
47
|
+
const existLambda = apiRouter.isExistLambda();
|
|
48
|
+
const apiRegexp = new RegExp((0, _utils.normalizeOutputPath)(`${apiDirectory}${_path.default.sep}.*(.[tj]s)$`));
|
|
49
|
+
const name = isServer ? "server" : "client";
|
|
50
|
+
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
|
|
51
|
+
chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
|
|
52
|
+
prefix,
|
|
53
|
+
apiDir: apiDirectory,
|
|
54
|
+
lambdaDir,
|
|
55
|
+
existLambda,
|
|
56
|
+
port,
|
|
57
|
+
target: name,
|
|
58
|
+
httpMethodDecider
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
source: {
|
|
63
|
+
moduleScopes: [
|
|
64
|
+
`./${_utils.API_DIR}`,
|
|
65
|
+
/create-request/
|
|
66
|
+
]
|
|
80
67
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
modifyServerRoutes({ routes }) {
|
|
71
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
72
|
+
const { bff } = modernConfig || {};
|
|
73
|
+
const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || "/api";
|
|
74
|
+
const prefixList = [];
|
|
75
|
+
if (Array.isArray(prefix)) {
|
|
76
|
+
prefixList.push(...prefix);
|
|
77
|
+
} else {
|
|
78
|
+
prefixList.push(prefix);
|
|
79
|
+
}
|
|
80
|
+
const apiServerRoutes = prefixList.map((pre) => ({
|
|
81
|
+
urlPath: pre,
|
|
82
|
+
isApi: true,
|
|
83
|
+
entryPath: "",
|
|
84
|
+
isSPA: false,
|
|
85
|
+
isSSR: false
|
|
86
|
+
}));
|
|
87
|
+
if (bff === null || bff === void 0 ? void 0 : bff.enableHandleWeb) {
|
|
88
|
+
return {
|
|
89
|
+
routes: routes.map((route) => {
|
|
90
|
+
return {
|
|
91
|
+
...route,
|
|
92
|
+
isApi: true
|
|
93
|
+
};
|
|
94
|
+
}).concat(apiServerRoutes)
|
|
95
|
+
};
|
|
84
96
|
}
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
modifyServerRoutes({ routes }) {
|
|
88
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
89
|
-
const { bff } = modernConfig || {};
|
|
90
|
-
const prefix = (bff == null ? void 0 : bff.prefix) || "/api";
|
|
91
|
-
const prefixList = [];
|
|
92
|
-
if (Array.isArray(prefix)) {
|
|
93
|
-
prefixList.push(...prefix);
|
|
94
|
-
} else {
|
|
95
|
-
prefixList.push(prefix);
|
|
96
|
-
}
|
|
97
|
-
const apiServerRoutes = prefixList.map((pre) => ({
|
|
98
|
-
urlPath: pre,
|
|
99
|
-
isApi: true,
|
|
100
|
-
entryPath: "",
|
|
101
|
-
isSPA: false,
|
|
102
|
-
isSSR: false
|
|
103
|
-
}));
|
|
104
|
-
if (bff == null ? void 0 : bff.enableHandleWeb) {
|
|
105
97
|
return {
|
|
106
|
-
routes: routes.
|
|
107
|
-
return {
|
|
108
|
-
...route,
|
|
109
|
-
isApi: true
|
|
110
|
-
};
|
|
111
|
-
}).concat(apiServerRoutes)
|
|
98
|
+
routes: routes.concat(apiServerRoutes)
|
|
112
99
|
};
|
|
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
|
-
appDirectory,
|
|
151
|
-
{
|
|
100
|
+
},
|
|
101
|
+
collectServerPlugins({ plugins }) {
|
|
102
|
+
plugins.push({
|
|
103
|
+
"@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
plugins
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
async beforeBuild() {
|
|
110
|
+
if ((0, _utils.isProd)()) {
|
|
111
|
+
const { internalDirectory } = api.useAppContext();
|
|
112
|
+
unRegisterResolveRuntimePath = (0, _helper.registerModernRuntimePath)(internalDirectory);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
async afterBuild() {
|
|
116
|
+
if (unRegisterResolveRuntimePath) {
|
|
117
|
+
unRegisterResolveRuntimePath();
|
|
118
|
+
}
|
|
119
|
+
const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
|
|
120
|
+
const modernConfig = api.useResolvedConfigContext();
|
|
121
|
+
const distDir = _path.default.resolve(distDirectory);
|
|
122
|
+
const apiDir = apiDirectory || _path.default.resolve(appDirectory, _utils.API_DIR);
|
|
123
|
+
const sharedDir = sharedDirectory || _path.default.resolve(appDirectory, _utils.SHARED_DIR);
|
|
124
|
+
const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
125
|
+
const sourceDirs = [];
|
|
126
|
+
if (_utils.fs.existsSync(apiDir)) {
|
|
127
|
+
sourceDirs.push(apiDir);
|
|
128
|
+
}
|
|
129
|
+
if (_utils.fs.existsSync(sharedDir)) {
|
|
130
|
+
sourceDirs.push(sharedDir);
|
|
131
|
+
}
|
|
132
|
+
const { server } = modernConfig;
|
|
133
|
+
const { alias } = modernConfig.source;
|
|
134
|
+
const { babel } = modernConfig.tools;
|
|
135
|
+
if (sourceDirs.length > 0) {
|
|
136
|
+
await (0, _serverutils.compile)(appDirectory, {
|
|
152
137
|
server,
|
|
153
138
|
alias,
|
|
154
139
|
babelConfig: babel
|
|
155
|
-
},
|
|
156
|
-
{
|
|
140
|
+
}, {
|
|
157
141
|
sourceDirs,
|
|
158
142
|
distDir,
|
|
159
143
|
tsconfigPath
|
|
160
|
-
}
|
|
161
|
-
|
|
144
|
+
});
|
|
145
|
+
}
|
|
162
146
|
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
-
0 && (module.exports = {});
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
};
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
6
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var constants_exports = {};
|
|
19
|
-
__export(constants_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
20
13
|
API_APP_NAME: () => API_APP_NAME,
|
|
21
14
|
BUILD_FILES: () => BUILD_FILES
|
|
22
15
|
});
|
|
23
|
-
module.exports = __toCommonJS(constants_exports);
|
|
24
16
|
const API_APP_NAME = "_app";
|
|
25
17
|
const BUILD_FILES = [
|
|
26
18
|
"**/*.[tj]sx?",
|
|
@@ -31,8 +23,3 @@ const BUILD_FILES = [
|
|
|
31
23
|
"!__tests__/*.tsx?",
|
|
32
24
|
"!__tests__/*.jsx?"
|
|
33
25
|
];
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
API_APP_NAME,
|
|
37
|
-
BUILD_FILES
|
|
38
|
-
});
|
package/dist/cjs/helper.js
CHANGED
|
@@ -1,47 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
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.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var helper_exports = {};
|
|
29
|
-
__export(helper_exports, {
|
|
30
|
-
registerModernRuntimePath: () => registerModernRuntimePath
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
5
|
+
Object.defineProperty(exports, "registerModernRuntimePath", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => registerModernRuntimePath
|
|
8
|
+
});
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
10
|
+
const _bffcore = require("@modern-js/bff-core");
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
12
|
+
if (typeof WeakMap !== "function")
|
|
13
|
+
return null;
|
|
14
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
17
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
18
|
+
})(nodeInterop);
|
|
19
|
+
}
|
|
20
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
21
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
25
|
+
return {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
30
|
+
if (cache && cache.has(obj)) {
|
|
31
|
+
return cache.get(obj);
|
|
32
|
+
}
|
|
33
|
+
var newObj = {};
|
|
34
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
35
|
+
for (var key in obj) {
|
|
36
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
37
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
38
|
+
if (desc && (desc.get || desc.set)) {
|
|
39
|
+
Object.defineProperty(newObj, key, desc);
|
|
40
|
+
} else {
|
|
41
|
+
newObj[key] = obj[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
newObj.default = obj;
|
|
46
|
+
if (cache) {
|
|
47
|
+
cache.set(obj, newObj);
|
|
48
|
+
}
|
|
49
|
+
return newObj;
|
|
50
|
+
}
|
|
35
51
|
const serverRuntimeAlias = "@modern-js/runtime/server";
|
|
36
52
|
const serverRuntimePath = ".runtime-exports/server";
|
|
37
53
|
const registerModernRuntimePath = (internalDirectory) => {
|
|
38
54
|
const paths = {
|
|
39
|
-
[serverRuntimeAlias]:
|
|
55
|
+
[serverRuntimeAlias]: _path.join(internalDirectory, serverRuntimePath)
|
|
40
56
|
};
|
|
41
|
-
const unRegister = (0,
|
|
57
|
+
const unRegister = (0, _bffcore.registerPaths)(paths);
|
|
42
58
|
return unRegister;
|
|
43
59
|
};
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
registerModernRuntimePath
|
|
47
|
-
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./constants"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
package/dist/cjs/loader.js
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var loader_exports = {};
|
|
19
|
-
__export(loader_exports, {
|
|
20
|
-
default: () => loader_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _default
|
|
21
8
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var import_utils = require("@modern-js/utils");
|
|
9
|
+
const _bffcore = require("@modern-js/bff-core");
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
25
11
|
async function loader(source) {
|
|
26
12
|
this.cacheable();
|
|
27
13
|
const { resourcePath } = this;
|
|
@@ -30,7 +16,7 @@ async function loader(source) {
|
|
|
30
16
|
const draftOptions = this.getOptions();
|
|
31
17
|
const warning = `The file ${resourcePath} is not allowd to be imported in src directory, only API definition files are allowed.`;
|
|
32
18
|
if (!draftOptions.existLambda) {
|
|
33
|
-
|
|
19
|
+
_utils.logger.warn(warning);
|
|
34
20
|
callback(null, `throw new Error('${warning}')`);
|
|
35
21
|
return;
|
|
36
22
|
}
|
|
@@ -46,7 +32,7 @@ async function loader(source) {
|
|
|
46
32
|
};
|
|
47
33
|
const { lambdaDir } = draftOptions;
|
|
48
34
|
if (!resourcePath.startsWith(lambdaDir)) {
|
|
49
|
-
|
|
35
|
+
_utils.logger.warn(warning);
|
|
50
36
|
callback(null, `throw new Error('${warning}')`);
|
|
51
37
|
return;
|
|
52
38
|
}
|
|
@@ -57,13 +43,11 @@ async function loader(source) {
|
|
|
57
43
|
options.requestCreator = draftOptions.requestCreator;
|
|
58
44
|
}
|
|
59
45
|
options.requireResolve = require.resolve;
|
|
60
|
-
const result = await (0,
|
|
46
|
+
const result = await (0, _bffcore.generateClient)(options);
|
|
61
47
|
if (result.isOk) {
|
|
62
48
|
callback(void 0, result.value);
|
|
63
49
|
} else {
|
|
64
50
|
callback(void 0, `throw new Error('${result.value}')`);
|
|
65
51
|
}
|
|
66
52
|
}
|
|
67
|
-
|
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
-
0 && (module.exports = {});
|
|
53
|
+
const _default = loader;
|