@modern-js/plugin-bff 2.69.7 → 3.0.0-alpha.1

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.
Files changed (76) hide show
  1. package/dist/cjs/cli.js +256 -272
  2. package/dist/cjs/constants.js +43 -34
  3. package/dist/cjs/index.js +55 -19
  4. package/dist/cjs/loader.js +69 -65
  5. package/dist/cjs/runtime/create-request/index.js +39 -29
  6. package/dist/cjs/runtime/hono/adapter.js +128 -126
  7. package/dist/cjs/runtime/hono/index.js +78 -30
  8. package/dist/cjs/runtime/hono/operators.js +64 -67
  9. package/dist/cjs/server.js +159 -165
  10. package/dist/cjs/utils/clientGenerator.js +204 -206
  11. package/dist/cjs/utils/createHonoRoutes.js +128 -144
  12. package/dist/cjs/utils/crossProjectApiPlugin.js +91 -81
  13. package/dist/cjs/utils/pluginGenerator.js +66 -54
  14. package/dist/cjs/utils/runtimeGenerator.js +67 -45
  15. package/dist/esm/cli.mjs +214 -0
  16. package/dist/esm/constants.mjs +11 -0
  17. package/dist/esm/loader.mjs +39 -0
  18. package/dist/esm/runtime/create-request/{index.js → index.mjs} +1 -5
  19. package/dist/esm/runtime/hono/adapter.mjs +95 -0
  20. package/dist/{esm-node/runtime/hono/index.js → esm/runtime/hono/index.mjs} +2 -4
  21. package/dist/esm/runtime/hono/operators.mjs +31 -0
  22. package/dist/esm/server.mjs +122 -0
  23. package/dist/esm/utils/clientGenerator.mjs +175 -0
  24. package/dist/esm/utils/createHonoRoutes.mjs +91 -0
  25. package/dist/esm/utils/crossProjectApiPlugin.mjs +34 -0
  26. package/dist/esm/utils/pluginGenerator.mjs +29 -0
  27. package/dist/esm/utils/runtimeGenerator.mjs +43 -0
  28. package/dist/esm-node/cli.mjs +214 -0
  29. package/dist/esm-node/constants.mjs +11 -0
  30. package/dist/esm-node/index.mjs +1 -0
  31. package/dist/esm-node/loader.mjs +39 -0
  32. package/dist/esm-node/runtime/create-request/{index.js → index.mjs} +1 -5
  33. package/dist/esm-node/runtime/hono/adapter.mjs +95 -0
  34. package/dist/{esm/runtime/hono/index.js → esm-node/runtime/hono/index.mjs} +3 -5
  35. package/dist/esm-node/runtime/hono/operators.mjs +31 -0
  36. package/dist/esm-node/server.mjs +122 -0
  37. package/dist/esm-node/utils/clientGenerator.mjs +175 -0
  38. package/dist/esm-node/utils/createHonoRoutes.mjs +91 -0
  39. package/dist/esm-node/utils/crossProjectApiPlugin.mjs +34 -0
  40. package/dist/esm-node/utils/pluginGenerator.mjs +29 -0
  41. package/dist/esm-node/utils/runtimeGenerator.mjs +43 -0
  42. package/dist/types/loader.d.ts +2 -2
  43. package/dist/types/runtime/hono/adapter.d.ts +3 -3
  44. package/dist/types/server.d.ts +2 -2
  45. package/dist/types/utils/runtimeGenerator.d.ts +2 -1
  46. package/package.json +55 -33
  47. package/rslib.config.mts +4 -0
  48. package/dist/cjs/helper.js +0 -48
  49. package/dist/esm/cli.js +0 -425
  50. package/dist/esm/constants.js +0 -14
  51. package/dist/esm/helper.js +0 -13
  52. package/dist/esm/index.js +0 -1
  53. package/dist/esm/loader.js +0 -75
  54. package/dist/esm/runtime/hono/adapter.js +0 -243
  55. package/dist/esm/runtime/hono/operators.js +0 -79
  56. package/dist/esm/server.js +0 -258
  57. package/dist/esm/utils/clientGenerator.js +0 -517
  58. package/dist/esm/utils/createHonoRoutes.js +0 -319
  59. package/dist/esm/utils/crossProjectApiPlugin.js +0 -49
  60. package/dist/esm/utils/pluginGenerator.js +0 -94
  61. package/dist/esm/utils/runtimeGenerator.js +0 -55
  62. package/dist/esm-node/cli.js +0 -246
  63. package/dist/esm-node/constants.js +0 -14
  64. package/dist/esm-node/helper.js +0 -14
  65. package/dist/esm-node/loader.js +0 -49
  66. package/dist/esm-node/runtime/hono/adapter.js +0 -103
  67. package/dist/esm-node/runtime/hono/operators.js +0 -46
  68. package/dist/esm-node/server.js +0 -142
  69. package/dist/esm-node/utils/clientGenerator.js +0 -192
  70. package/dist/esm-node/utils/createHonoRoutes.js +0 -120
  71. package/dist/esm-node/utils/crossProjectApiPlugin.js +0 -47
  72. package/dist/esm-node/utils/pluginGenerator.js +0 -31
  73. package/dist/esm-node/utils/runtimeGenerator.js +0 -35
  74. package/dist/types/helper.d.ts +0 -2
  75. package/types.d.ts +0 -3
  76. /package/dist/{esm-node/index.js → esm/index.mjs} +0 -0
@@ -1,154 +1,138 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var createHonoRoutes_exports = {};
30
- __export(createHonoRoutes_exports, {
31
- createHonoHandler: () => createHonoHandler,
32
- default: () => createHonoRoutes_default
33
- });
34
- module.exports = __toCommonJS(createHonoRoutes_exports);
35
- var import_bff_core = require("@modern-js/bff-core");
36
- var import_qs = require("@modern-js/create-request/qs");
37
- var import_type_is = __toESM(require("type-is"));
38
- const createHonoRoutes = (handlerInfos = []) => {
39
- return handlerInfos.map(({ routePath, handler, httpMethod }) => {
40
- const routeMiddlwares = Reflect.getMetadata("middleware", handler) || [];
41
- const honoHandler = createHonoHandler(handler);
42
- return {
43
- method: httpMethod.toLowerCase(),
44
- path: routePath,
45
- handler: routeMiddlwares.length > 0 ? [
46
- ...routeMiddlwares,
47
- honoHandler
48
- ] : honoHandler
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
49
10
  };
50
- });
51
- };
52
- const handleResponseMeta = (c, handler) => {
53
- const responseMeta = Reflect.getMetadata(import_bff_core.HttpMetadata.Response, handler);
54
- if (Array.isArray(responseMeta)) {
55
- for (const meta of responseMeta) {
56
- switch (meta.type) {
57
- case import_bff_core.ResponseMetaType.Headers:
58
- for (const [key, value] of Object.entries(meta.value)) {
59
- c.header(key, value);
60
- }
61
- break;
62
- case import_bff_core.ResponseMetaType.Redirect:
63
- return c.redirect(meta.value);
64
- case import_bff_core.ResponseMetaType.StatusCode:
65
- c.status(meta.value);
66
- break;
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ default: ()=>utils_createHonoRoutes,
37
+ createHonoHandler: ()=>createHonoHandler
38
+ });
39
+ const bff_core_namespaceObject = require("@modern-js/bff-core");
40
+ const qs_namespaceObject = require("@modern-js/create-request/qs");
41
+ const external_type_is_namespaceObject = require("type-is");
42
+ var external_type_is_default = /*#__PURE__*/ __webpack_require__.n(external_type_is_namespaceObject);
43
+ const createHonoRoutes = (handlerInfos = [])=>handlerInfos.map(({ routePath, handler, httpMethod })=>{
44
+ const routeMiddlwares = Reflect.getMetadata('middleware', handler) || [];
45
+ const honoHandler = createHonoHandler(handler);
46
+ return {
47
+ method: httpMethod.toLowerCase(),
48
+ path: routePath,
49
+ handler: routeMiddlwares.length > 0 ? [
50
+ ...routeMiddlwares,
51
+ honoHandler
52
+ ] : honoHandler
53
+ };
54
+ });
55
+ const handleResponseMeta = (c, handler)=>{
56
+ const responseMeta = Reflect.getMetadata(bff_core_namespaceObject.HttpMetadata.Response, handler);
57
+ if (Array.isArray(responseMeta)) for (const meta of responseMeta)switch(meta.type){
58
+ case bff_core_namespaceObject.ResponseMetaType.Headers:
59
+ for (const [key, value] of Object.entries(meta.value))c.header(key, value);
60
+ break;
61
+ case bff_core_namespaceObject.ResponseMetaType.Redirect:
62
+ return c.redirect(meta.value);
63
+ case bff_core_namespaceObject.ResponseMetaType.StatusCode:
64
+ c.status(meta.value);
65
+ break;
67
66
  default:
68
- break;
69
- }
67
+ break;
70
68
  }
71
- }
72
- return null;
69
+ return null;
73
70
  };
74
- const createHonoHandler = (handler) => {
75
- return async (c) => {
76
- const input = await getHonoInput(c);
77
- if ((0, import_bff_core.isWithMetaHandler)(handler)) {
78
- try {
79
- const response = handleResponseMeta(c, handler);
80
- if (response) {
81
- return response;
71
+ const createHonoHandler = (handler)=>async (c)=>{
72
+ const input = await getHonoInput(c);
73
+ if ((0, bff_core_namespaceObject.isWithMetaHandler)(handler)) try {
74
+ const response = handleResponseMeta(c, handler);
75
+ if (response) return response;
76
+ if (c.finalized) return;
77
+ const result = await handler(input);
78
+ if (result instanceof Response) return result;
79
+ return result && 'object' == typeof result ? c.json(result) : c.body(result);
80
+ } catch (error) {
81
+ if (error instanceof bff_core_namespaceObject.ValidationError) {
82
+ c.status(error.status);
83
+ return c.json({
84
+ message: error.message
85
+ });
86
+ }
87
+ throw error;
82
88
  }
83
- if (c.finalized)
84
- return;
85
- const result = await handler(input);
86
- if (result instanceof Response) {
87
- return result;
89
+ {
90
+ const routePath = c.req.routePath;
91
+ const paramNames = routePath.match(/:\w+/g)?.map((s)=>s.slice(1)) || [];
92
+ const params = Object.fromEntries(paramNames.map((name)=>[
93
+ name,
94
+ input.params[name]
95
+ ]));
96
+ const args = Object.values(params).concat(input);
97
+ const body = await handler(...args);
98
+ if (c.finalized) return await Promise.resolve();
99
+ if (void 0 !== body) {
100
+ if (body instanceof Response) return body;
101
+ return c.json(body);
102
+ }
88
103
  }
89
- return result && typeof result === "object" ? c.json(result) : c.body(result);
90
- } catch (error) {
91
- if (error instanceof import_bff_core.ValidationError) {
92
- c.status(error.status);
93
- return c.json({
94
- message: error.message
95
- });
96
- }
97
- throw error;
98
- }
99
- } else {
100
- var _routePath_match;
101
- const routePath = c.req.routePath;
102
- const paramNames = ((_routePath_match = routePath.match(/:\w+/g)) === null || _routePath_match === void 0 ? void 0 : _routePath_match.map((s) => s.slice(1))) || [];
103
- const params = Object.fromEntries(paramNames.map((name) => [
104
- name,
105
- input.params[name]
106
- ]));
107
- const args = Object.values(params).concat(input);
108
- const body = await handler(...args);
109
- if (c.finalized) {
110
- return await Promise.resolve();
111
- }
112
- if (typeof body !== "undefined") {
113
- if (body instanceof Response) {
114
- return body;
115
- }
116
- return c.json(body);
117
- }
118
- }
119
- };
120
- };
121
- const getHonoInput = async (c) => {
122
- const draft = {
123
- params: c.req.param(),
124
- query: (0, import_qs.parse)(c.req.query()),
125
- headers: c.req.header(),
126
- cookies: c.req.header("cookie")
127
- };
128
- try {
129
- const contentType = c.req.header("content-type") || "";
130
- if (import_type_is.default.is(contentType, [
131
- "application/json"
132
- ])) {
133
- draft.data = await c.req.json();
134
- } else if (import_type_is.default.is(contentType, [
135
- "multipart/form-data"
136
- ])) {
137
- draft.formData = await c.req.parseBody();
138
- } else if (import_type_is.default.is(contentType, [
139
- "application/x-www-form-urlencoded"
140
- ])) {
141
- draft.formUrlencoded = await c.req.parseBody();
142
- } else {
143
- draft.body = await c.req.json();
104
+ };
105
+ const getHonoInput = async (c)=>{
106
+ const draft = {
107
+ params: c.req.param(),
108
+ query: (0, qs_namespaceObject.parse)(c.req.query()),
109
+ headers: c.req.header(),
110
+ cookies: c.req.header('cookie')
111
+ };
112
+ try {
113
+ const contentType = c.req.header('content-type') || '';
114
+ if (external_type_is_default().is(contentType, [
115
+ 'application/json'
116
+ ])) draft.data = await c.req.json();
117
+ else if (external_type_is_default().is(contentType, [
118
+ 'multipart/form-data'
119
+ ])) draft.formData = await c.req.parseBody();
120
+ else if (external_type_is_default().is(contentType, [
121
+ 'application/x-www-form-urlencoded'
122
+ ])) draft.formUrlencoded = await c.req.parseBody();
123
+ else draft.body = await c.req.json();
124
+ } catch (error) {
125
+ draft.body = null;
144
126
  }
145
- } catch (error) {
146
- draft.body = null;
147
- }
148
- return draft;
127
+ return draft;
149
128
  };
150
- var createHonoRoutes_default = createHonoRoutes;
151
- // Annotate the CommonJS export names for ESM import in node:
152
- 0 && (module.exports = {
153
- createHonoHandler
129
+ const utils_createHonoRoutes = createHonoRoutes;
130
+ exports.createHonoHandler = __webpack_exports__.createHonoHandler;
131
+ exports["default"] = __webpack_exports__["default"];
132
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
133
+ "createHonoHandler",
134
+ "default"
135
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
136
+ Object.defineProperty(exports, '__esModule', {
137
+ value: true
154
138
  });
@@ -1,86 +1,96 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var crossProjectApiPlugin_exports = {};
30
- __export(crossProjectApiPlugin_exports, {
31
- API_DIR: () => API_DIR,
32
- DIST_DIR: () => DIST_DIR,
33
- LAMBDA_DIR: () => LAMBDA_DIR,
34
- PACKAGE_NAME: () => PACKAGE_NAME,
35
- PREFIX: () => PREFIX,
36
- crossProjectApiPlugin: () => crossProjectApiPlugin,
37
- default: () => crossProjectApiPlugin_default
38
- });
39
- module.exports = __toCommonJS(crossProjectApiPlugin_exports);
40
- var import_path = __toESM(require("path"));
41
- const PACKAGE_NAME = "{packageName}";
42
- const PREFIX = "{prefix}";
43
- const API_DIR = "{apiDirectory}";
44
- const LAMBDA_DIR = "{lambdaDirectory}";
45
- const DIST_DIR = "{distDirectory}";
46
- const NODE_MODULES = "node_modules";
47
- const crossProjectApiPlugin = () => ({
48
- name: "@modern-js/plugin-independent-bff",
49
- post: [
50
- "@modern-js/plugin-bff"
51
- ],
52
- setup: (api) => {
53
- return {
54
- config() {
55
- const { appDirectory: originAppDirectory } = api.useAppContext();
56
- const sdkPath = import_path.default.join(originAppDirectory, NODE_MODULES, PACKAGE_NAME);
57
- const sdkDistPath = import_path.default.join(sdkPath, DIST_DIR);
58
- const apiDirectory = import_path.default.join(sdkDistPath, API_DIR);
59
- const lambdaDirectory = import_path.default.resolve(sdkDistPath, LAMBDA_DIR);
60
- const appContext = api.useAppContext();
61
- api.setAppContext({
62
- ...appContext,
63
- apiDirectory,
64
- lambdaDirectory
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
65
30
  });
66
- const config = api.useConfigContext();
67
- config.bff = {
68
- ...config.bff,
69
- prefix: PREFIX,
70
- isCrossProjectServer: true
71
- };
72
- return {};
73
- }
74
31
  };
75
- }
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ crossProjectApiPlugin: ()=>crossProjectApiPlugin,
37
+ API_DIR: ()=>API_DIR,
38
+ default: ()=>utils_crossProjectApiPlugin,
39
+ DIST_DIR: ()=>DIST_DIR,
40
+ PACKAGE_NAME: ()=>PACKAGE_NAME,
41
+ PREFIX: ()=>PREFIX,
42
+ LAMBDA_DIR: ()=>LAMBDA_DIR
76
43
  });
77
- var crossProjectApiPlugin_default = crossProjectApiPlugin;
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- API_DIR,
81
- DIST_DIR,
82
- LAMBDA_DIR,
83
- PACKAGE_NAME,
84
- PREFIX,
85
- crossProjectApiPlugin
44
+ const external_path_namespaceObject = require("path");
45
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
46
+ const PACKAGE_NAME = '{packageName}';
47
+ const PREFIX = '{prefix}';
48
+ const API_DIR = '{apiDirectory}';
49
+ const LAMBDA_DIR = '{lambdaDirectory}';
50
+ const DIST_DIR = '{distDirectory}';
51
+ const NODE_MODULES = 'node_modules';
52
+ const crossProjectApiPlugin = ()=>({
53
+ name: '@modern-js/plugin-independent-bff',
54
+ post: [
55
+ '@modern-js/plugin-bff'
56
+ ],
57
+ setup: (api)=>{
58
+ api.modifyResolvedConfig((resolvedConfig)=>{
59
+ const { appDirectory: originAppDirectory } = api.getAppContext();
60
+ const sdkPath = external_path_default().join(originAppDirectory, NODE_MODULES, PACKAGE_NAME);
61
+ const sdkDistPath = external_path_default().join(sdkPath, DIST_DIR);
62
+ const apiDirectory = external_path_default().join(sdkDistPath, API_DIR);
63
+ const lambdaDirectory = external_path_default().resolve(sdkDistPath, LAMBDA_DIR);
64
+ api.updateAppContext({
65
+ apiDirectory,
66
+ lambdaDirectory
67
+ });
68
+ const config = api.getConfig();
69
+ if (config?.bff?.prefix) console.warn(`[WARNING] Detected bff.prefix configuration: "${config.bff.prefix}".
70
+ When using cross-project BFF, you should not configure bff.prefix as it may cause API path conflicts or access issues. Please remove the bff.prefix configuration.`);
71
+ resolvedConfig.bff.prefix = PREFIX;
72
+ resolvedConfig.bff.isCrossProjectServer = true;
73
+ return resolvedConfig;
74
+ });
75
+ }
76
+ });
77
+ const utils_crossProjectApiPlugin = crossProjectApiPlugin;
78
+ exports.API_DIR = __webpack_exports__.API_DIR;
79
+ exports.DIST_DIR = __webpack_exports__.DIST_DIR;
80
+ exports.LAMBDA_DIR = __webpack_exports__.LAMBDA_DIR;
81
+ exports.PACKAGE_NAME = __webpack_exports__.PACKAGE_NAME;
82
+ exports.PREFIX = __webpack_exports__.PREFIX;
83
+ exports.crossProjectApiPlugin = __webpack_exports__.crossProjectApiPlugin;
84
+ exports["default"] = __webpack_exports__["default"];
85
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
86
+ "API_DIR",
87
+ "DIST_DIR",
88
+ "LAMBDA_DIR",
89
+ "PACKAGE_NAME",
90
+ "PREFIX",
91
+ "crossProjectApiPlugin",
92
+ "default"
93
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
94
+ Object.defineProperty(exports, '__esModule', {
95
+ value: true
86
96
  });
@@ -1,61 +1,73 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var pluginGenerator_exports = {};
30
- __export(pluginGenerator_exports, {
31
- default: () => pluginGenerator_default
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ default: ()=>utils_pluginGenerator
32
37
  });
33
- module.exports = __toCommonJS(pluginGenerator_exports);
34
- var import_path = __toESM(require("path"));
35
- var import_utils = require("@modern-js/utils");
36
- var import_crossProjectApiPlugin = require("./crossProjectApiPlugin");
38
+ const external_path_namespaceObject = require("path");
39
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
40
+ const utils_namespaceObject = require("@modern-js/utils");
41
+ const external_crossProjectApiPlugin_js_namespaceObject = require("./crossProjectApiPlugin.js");
37
42
  function replaceContent(source, packageName, prefix, relativeDistPath, relativeApiPath, relativeLambdaPath) {
38
- const updatedSource = source.replace(new RegExp(import_crossProjectApiPlugin.PACKAGE_NAME, "g"), packageName).replace(new RegExp(import_crossProjectApiPlugin.PREFIX, "g"), prefix).replace(new RegExp(import_crossProjectApiPlugin.DIST_DIR, "g"), relativeDistPath).replace(new RegExp(import_crossProjectApiPlugin.API_DIR, "g"), relativeApiPath).replace(new RegExp(import_crossProjectApiPlugin.LAMBDA_DIR, "g"), relativeLambdaPath);
39
- return updatedSource;
43
+ const updatedSource = source.replace(new RegExp(external_crossProjectApiPlugin_js_namespaceObject.PACKAGE_NAME, 'g'), packageName).replace(new RegExp(external_crossProjectApiPlugin_js_namespaceObject.PREFIX, 'g'), prefix).replace(new RegExp(external_crossProjectApiPlugin_js_namespaceObject.DIST_DIR, 'g'), (0, utils_namespaceObject.normalizeToPosixPath)(relativeDistPath)).replace(new RegExp(external_crossProjectApiPlugin_js_namespaceObject.API_DIR, 'g'), (0, utils_namespaceObject.normalizeToPosixPath)(relativeApiPath)).replace(new RegExp(external_crossProjectApiPlugin_js_namespaceObject.LAMBDA_DIR, 'g'), (0, utils_namespaceObject.normalizeToPosixPath)(relativeLambdaPath));
44
+ return updatedSource;
40
45
  }
41
46
  async function pluginGenerator({ prefix, appDirectory, relativeDistPath, relativeApiPath, relativeLambdaPath }) {
42
- try {
43
- const packageContent = await import_utils.fs.readFile(import_path.default.resolve(appDirectory, "./package.json"), "utf8");
44
- const packageJson = JSON.parse(packageContent);
45
- const pluginDir = import_path.default.resolve(appDirectory, `./${relativeDistPath}`, "plugin");
46
- const pluginPath = import_path.default.join(pluginDir, "index.js");
47
- const pluginTemplate = await import_utils.fs.readFile(import_path.default.resolve(__dirname, "crossProjectApiPlugin.js"), "utf8");
48
- const updatedPlugin = replaceContent(pluginTemplate, packageJson.name, prefix, relativeDistPath, relativeApiPath, relativeLambdaPath);
49
- await import_utils.fs.ensureFile(pluginPath);
50
- await import_utils.fs.writeFile(pluginPath, updatedPlugin);
51
- const typeContent = `import type { AppTools, CliPlugin } from '@modern-js/app-tools';
47
+ try {
48
+ const packageContent = await utils_namespaceObject.fs.readFile(external_path_default().resolve(appDirectory, './package.json'), 'utf8');
49
+ const packageJson = JSON.parse(packageContent);
50
+ const pluginDir = external_path_default().resolve(appDirectory, `./${relativeDistPath}`, 'plugin');
51
+ const pluginPath = external_path_default().join(pluginDir, 'index.js');
52
+ const pluginTemplate = await utils_namespaceObject.fs.readFile(external_path_default().resolve(__dirname, 'crossProjectApiPlugin.js'), 'utf8');
53
+ const updatedPlugin = replaceContent(pluginTemplate, packageJson.name, prefix, relativeDistPath, relativeApiPath, relativeLambdaPath);
54
+ await utils_namespaceObject.fs.ensureFile(pluginPath);
55
+ await utils_namespaceObject.fs.writeFile(pluginPath, updatedPlugin);
56
+ const typeContent = `import type { AppTools, CliPlugin } from '@modern-js/app-tools';
52
57
  export declare const crossProjectApiPlugin: () => CliPlugin<AppTools>`;
53
- const pluginTypePath = import_path.default.join(pluginDir, "index.d.ts");
54
- await import_utils.fs.ensureFile(pluginTypePath);
55
- await import_utils.fs.writeFile(pluginTypePath, typeContent);
56
- import_utils.logger.info("Api plugin generate succeed");
57
- } catch (error) {
58
- import_utils.logger.error("Api plugin generate failed:", error);
59
- }
58
+ const pluginTypePath = external_path_default().join(pluginDir, 'index.d.ts');
59
+ await utils_namespaceObject.fs.ensureFile(pluginTypePath);
60
+ await utils_namespaceObject.fs.writeFile(pluginTypePath, typeContent);
61
+ utils_namespaceObject.logger.info('Api plugin generate succeed');
62
+ } catch (error) {
63
+ utils_namespaceObject.logger.error('Api plugin generate failed:', error);
64
+ }
60
65
  }
61
- var pluginGenerator_default = pluginGenerator;
66
+ const utils_pluginGenerator = pluginGenerator;
67
+ exports["default"] = __webpack_exports__["default"];
68
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
69
+ "default"
70
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
71
+ Object.defineProperty(exports, '__esModule', {
72
+ value: true
73
+ });