@modern-js/plugin-bff 2.39.2 → 2.40.1-alpha.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/dist/cjs/cli.js CHANGED
@@ -39,38 +39,12 @@ var import_bff_core = require("@modern-js/bff-core");
39
39
  var import_helper = require("./helper");
40
40
  const DEFAULT_API_PREFIX = "/api";
41
41
  const TS_CONFIG_FILENAME = "tsconfig.json";
42
+ const SERVER_TS_CONFIG = "tsconfig.server.json";
42
43
  const bffPlugin = () => ({
43
44
  name: "@modern-js/plugin-bff",
44
45
  setup: (api) => {
45
46
  let unRegisterResolveRuntimePath = null;
46
47
  return {
47
- validateSchema() {
48
- return [
49
- {
50
- target: "bff",
51
- schema: {
52
- type: "object",
53
- properties: {
54
- prefix: {
55
- type: [
56
- "string",
57
- "array"
58
- ],
59
- items: {
60
- type: "string"
61
- }
62
- },
63
- fetcher: {
64
- type: "string"
65
- },
66
- proxy: {
67
- type: "object"
68
- }
69
- }
70
- }
71
- }
72
- ];
73
- },
74
48
  config() {
75
49
  return {
76
50
  tools: {
@@ -171,7 +145,13 @@ const bffPlugin = () => ({
171
145
  const distDir = import_path.default.resolve(distDirectory);
172
146
  const apiDir = apiDirectory || import_path.default.resolve(appDirectory, import_utils.API_DIR);
173
147
  const sharedDir = sharedDirectory || import_path.default.resolve(appDirectory, import_utils.SHARED_DIR);
174
- const tsconfigPath = import_path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
148
+ let tsconfigPath = "";
149
+ const serverTsconfigPath = import_path.default.resolve(appDirectory, SERVER_TS_CONFIG);
150
+ if (await import_utils.fs.pathExists(serverTsconfigPath)) {
151
+ tsconfigPath = serverTsconfigPath;
152
+ } else {
153
+ tsconfigPath = import_path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
154
+ }
175
155
  const sourceDirs = [];
176
156
  if (import_utils.fs.existsSync(apiDir)) {
177
157
  sourceDirs.push(apiDir);
package/dist/esm/cli.js CHANGED
@@ -10,39 +10,13 @@ import { ApiRouter } from "@modern-js/bff-core";
10
10
  import { registerModernRuntimePath } from "./helper";
11
11
  var DEFAULT_API_PREFIX = "/api";
12
12
  var TS_CONFIG_FILENAME = "tsconfig.json";
13
+ var SERVER_TS_CONFIG = "tsconfig.server.json";
13
14
  var bffPlugin = function() {
14
15
  return {
15
16
  name: "@modern-js/plugin-bff",
16
17
  setup: function(api) {
17
18
  var unRegisterResolveRuntimePath = null;
18
19
  return {
19
- validateSchema: function validateSchema() {
20
- return [
21
- {
22
- target: "bff",
23
- schema: {
24
- type: "object",
25
- properties: {
26
- prefix: {
27
- type: [
28
- "string",
29
- "array"
30
- ],
31
- items: {
32
- type: "string"
33
- }
34
- },
35
- fetcher: {
36
- type: "string"
37
- },
38
- proxy: {
39
- type: "object"
40
- }
41
- }
42
- }
43
- }
44
- ];
45
- },
46
20
  config: function config() {
47
21
  return {
48
22
  tools: {
@@ -149,7 +123,7 @@ var bffPlugin = function() {
149
123
  },
150
124
  afterBuild: function afterBuild() {
151
125
  return _async_to_generator(function() {
152
- var _api_useAppContext, appDirectory, distDirectory, apiDirectory, sharedDirectory, modernConfig, distDir, apiDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
126
+ var _api_useAppContext, appDirectory, distDirectory, apiDirectory, sharedDirectory, modernConfig, distDir, apiDir, sharedDir, tsconfigPath, serverTsconfigPath, sourceDirs, server, alias, babel;
153
127
  return _ts_generator(this, function(_state) {
154
128
  switch (_state.label) {
155
129
  case 0:
@@ -161,7 +135,18 @@ var bffPlugin = function() {
161
135
  distDir = path.resolve(distDirectory);
162
136
  apiDir = apiDirectory || path.resolve(appDirectory, API_DIR);
163
137
  sharedDir = sharedDirectory || path.resolve(appDirectory, SHARED_DIR);
164
- tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
138
+ tsconfigPath = "";
139
+ serverTsconfigPath = path.resolve(appDirectory, SERVER_TS_CONFIG);
140
+ return [
141
+ 4,
142
+ fs.pathExists(serverTsconfigPath)
143
+ ];
144
+ case 1:
145
+ if (_state.sent()) {
146
+ tsconfigPath = serverTsconfigPath;
147
+ } else {
148
+ tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
149
+ }
165
150
  sourceDirs = [];
166
151
  if (fs.existsSync(apiDir)) {
167
152
  sourceDirs.push(apiDir);
@@ -175,7 +160,7 @@ var bffPlugin = function() {
175
160
  if (!(sourceDirs.length > 0))
176
161
  return [
177
162
  3,
178
- 2
163
+ 3
179
164
  ];
180
165
  return [
181
166
  4,
@@ -189,10 +174,10 @@ var bffPlugin = function() {
189
174
  tsconfigPath
190
175
  })
191
176
  ];
192
- case 1:
193
- _state.sent();
194
- _state.label = 2;
195
177
  case 2:
178
+ _state.sent();
179
+ _state.label = 3;
180
+ case 3:
196
181
  return [
197
182
  2
198
183
  ];
@@ -5,38 +5,12 @@ import { ApiRouter } from "@modern-js/bff-core";
5
5
  import { registerModernRuntimePath } from "./helper";
6
6
  const DEFAULT_API_PREFIX = "/api";
7
7
  const TS_CONFIG_FILENAME = "tsconfig.json";
8
+ const SERVER_TS_CONFIG = "tsconfig.server.json";
8
9
  const bffPlugin = () => ({
9
10
  name: "@modern-js/plugin-bff",
10
11
  setup: (api) => {
11
12
  let unRegisterResolveRuntimePath = null;
12
13
  return {
13
- validateSchema() {
14
- return [
15
- {
16
- target: "bff",
17
- schema: {
18
- type: "object",
19
- properties: {
20
- prefix: {
21
- type: [
22
- "string",
23
- "array"
24
- ],
25
- items: {
26
- type: "string"
27
- }
28
- },
29
- fetcher: {
30
- type: "string"
31
- },
32
- proxy: {
33
- type: "object"
34
- }
35
- }
36
- }
37
- }
38
- ];
39
- },
40
14
  config() {
41
15
  return {
42
16
  tools: {
@@ -137,7 +111,13 @@ const bffPlugin = () => ({
137
111
  const distDir = path.resolve(distDirectory);
138
112
  const apiDir = apiDirectory || path.resolve(appDirectory, API_DIR);
139
113
  const sharedDir = sharedDirectory || path.resolve(appDirectory, SHARED_DIR);
140
- const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
114
+ let tsconfigPath = "";
115
+ const serverTsconfigPath = path.resolve(appDirectory, SERVER_TS_CONFIG);
116
+ if (await fs.pathExists(serverTsconfigPath)) {
117
+ tsconfigPath = serverTsconfigPath;
118
+ } else {
119
+ tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
120
+ }
141
121
  const sourceDirs = [];
142
122
  if (fs.existsSync(apiDir)) {
143
123
  sourceDirs.push(apiDir);
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.39.2",
18
+ "version": "2.40.1-alpha.0",
19
19
  "jsnext:source": "./src/cli.ts",
20
20
  "types": "./dist/types/cli.d.ts",
21
21
  "main": "./dist/cjs/cli.js",
@@ -57,10 +57,10 @@
57
57
  "dependencies": {
58
58
  "@babel/core": "^7.23.2",
59
59
  "@swc/helpers": "0.5.1",
60
- "@modern-js/bff-core": "2.39.2",
61
- "@modern-js/server-utils": "2.39.2",
62
- "@modern-js/create-request": "2.39.2",
63
- "@modern-js/utils": "2.39.2"
60
+ "@modern-js/bff-core": "2.40.1-alpha.0",
61
+ "@modern-js/utils": "2.40.0",
62
+ "@modern-js/server-utils": "2.40.0",
63
+ "@modern-js/create-request": "2.40.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/babel__core": "^7.20.0",
@@ -71,14 +71,14 @@
71
71
  "ts-jest": "^29.1.0",
72
72
  "typescript": "^5",
73
73
  "webpack": "^5.88.1",
74
- "@modern-js/runtime": "2.39.2",
75
- "@modern-js/core": "2.39.2",
76
- "@modern-js/bff-runtime": "2.39.2",
77
- "@modern-js/server-core": "2.39.2",
78
- "@modern-js/types": "2.39.2",
79
- "@modern-js/app-tools": "2.39.2",
80
- "@scripts/build": "2.39.2",
81
- "@scripts/jest-config": "2.39.2"
74
+ "@modern-js/core": "2.40.0",
75
+ "@modern-js/server-core": "2.40.0",
76
+ "@modern-js/runtime": "2.40.0",
77
+ "@modern-js/bff-runtime": "2.40.0",
78
+ "@modern-js/app-tools": "2.40.0",
79
+ "@scripts/jest-config": "2.40.0",
80
+ "@scripts/build": "2.40.0",
81
+ "@modern-js/types": "2.40.0"
82
82
  },
83
83
  "sideEffects": false,
84
84
  "publishConfig": {