@modern-js/plugin-bff 2.27.0 → 2.29.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @modern-js/plugin-bff
2
2
 
3
+ ## 2.29.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e6b5355]
8
+ - Updated dependencies [93db783]
9
+ - Updated dependencies [cba7675]
10
+ - Updated dependencies [99052ea]
11
+ - Updated dependencies [1d71d2e]
12
+ - @modern-js/utils@2.29.0
13
+ - @modern-js/bff-core@2.29.0
14
+ - @modern-js/create-request@2.29.0
15
+ - @modern-js/server-utils@2.29.0
16
+
17
+ ## 2.28.0
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [00b58a7]
22
+ - @modern-js/utils@2.28.0
23
+ - @modern-js/bff-core@2.28.0
24
+ - @modern-js/create-request@2.28.0
25
+ - @modern-js/server-utils@2.28.0
26
+
3
27
  ## 2.27.0
4
28
 
5
29
  ### Patch Changes
package/dist/cjs/cli.js CHANGED
@@ -25,164 +25,164 @@ const _bffcore = require("@modern-js/bff-core");
25
25
  const _helper = require("./helper");
26
26
  const DEFAULT_API_PREFIX = "/api";
27
27
  const TS_CONFIG_FILENAME = "tsconfig.json";
28
- const bffPlugin = () => {
29
- return {
30
- name: "@modern-js/plugin-bff",
31
- setup: (api) => {
32
- let unRegisterResolveRuntimePath = null;
33
- return {
34
- validateSchema() {
35
- return [
36
- {
37
- target: "bff",
38
- schema: {
39
- type: "object",
40
- properties: {
41
- prefix: {
42
- type: [
43
- "string",
44
- "array"
45
- ],
46
- items: {
47
- type: "string"
48
- }
49
- },
50
- fetcher: {
51
- type: "string"
52
- },
53
- proxy: {
54
- type: "object"
55
- },
56
- requestCreator: {
28
+ const bffPlugin = () => ({
29
+ name: "@modern-js/plugin-bff",
30
+ setup: (api) => {
31
+ let unRegisterResolveRuntimePath = null;
32
+ return {
33
+ validateSchema() {
34
+ return [
35
+ {
36
+ target: "bff",
37
+ schema: {
38
+ type: "object",
39
+ properties: {
40
+ prefix: {
41
+ type: [
42
+ "string",
43
+ "array"
44
+ ],
45
+ items: {
57
46
  type: "string"
58
47
  }
48
+ },
49
+ fetcher: {
50
+ type: "string"
51
+ },
52
+ proxy: {
53
+ type: "object"
54
+ },
55
+ requestCreator: {
56
+ type: "string"
59
57
  }
60
58
  }
61
59
  }
62
- ];
63
- },
64
- config() {
65
- return {
66
- tools: {
67
- bundlerChain: (chain, { CHAIN_ID, isServer }) => {
68
- const { port, appDirectory, apiDirectory, lambdaDirectory } = api.useAppContext();
69
- const modernConfig = api.useResolvedConfigContext();
70
- const { bff } = modernConfig || {};
71
- const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
72
- const httpMethodDecider = bff === null || bff === void 0 ? void 0 : bff.httpMethodDecider;
73
- chain.resolve.alias.set("@api", apiDirectory);
74
- const apiRouter = new _bffcore.ApiRouter({
75
- apiDir: apiDirectory,
76
- appDir: appDirectory,
77
- lambdaDir: lambdaDirectory,
78
- prefix,
79
- httpMethodDecider,
80
- isBuild: true
81
- });
82
- const lambdaDir = apiRouter.getLambdaDir();
83
- const existLambda = apiRouter.isExistLambda();
84
- const apiRegexp = new RegExp((0, _utils.normalizeOutputPath)(`${apiDirectory}${_path.default.sep}.*(.[tj]s)$`));
85
- const name = isServer ? "server" : "client";
86
- chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
87
- chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
88
- prefix,
89
- appDir: appDirectory,
90
- apiDir: apiDirectory,
91
- lambdaDir,
92
- existLambda,
93
- port,
94
- target: name,
95
- httpMethodDecider
96
- });
97
- }
98
- },
99
- source: {
100
- moduleScopes: [
101
- `./${_utils.API_DIR}`,
102
- /create-request/
103
- ]
104
- }
105
- };
106
- },
107
- modifyServerRoutes({ routes }) {
108
- const modernConfig = api.useResolvedConfigContext();
109
- const { bff } = modernConfig || {};
110
- const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || "/api";
111
- const prefixList = [];
112
- if (Array.isArray(prefix)) {
113
- prefixList.push(...prefix);
114
- } else {
115
- prefixList.push(prefix);
116
60
  }
117
- const apiServerRoutes = prefixList.map((pre) => ({
118
- urlPath: pre,
119
- isApi: true,
120
- entryPath: "",
121
- isSPA: false,
122
- isSSR: false
123
- }));
124
- if (bff === null || bff === void 0 ? void 0 : bff.enableHandleWeb) {
125
- return {
126
- routes: routes.map((route) => {
127
- return {
128
- ...route,
129
- isApi: true
130
- };
131
- }).concat(apiServerRoutes)
132
- };
61
+ ];
62
+ },
63
+ config() {
64
+ return {
65
+ tools: {
66
+ bundlerChain: (chain, { CHAIN_ID, isServer }) => {
67
+ var _bff, _bff1;
68
+ const { port, appDirectory, apiDirectory, lambdaDirectory } = api.useAppContext();
69
+ const modernConfig = api.useResolvedConfigContext();
70
+ const { bff } = modernConfig || {};
71
+ const prefix = ((_bff = bff) === null || _bff === void 0 ? void 0 : _bff.prefix) || DEFAULT_API_PREFIX;
72
+ const httpMethodDecider = (_bff1 = bff) === null || _bff1 === void 0 ? void 0 : _bff1.httpMethodDecider;
73
+ chain.resolve.alias.set("@api", apiDirectory);
74
+ const apiRouter = new _bffcore.ApiRouter({
75
+ apiDir: apiDirectory,
76
+ appDir: appDirectory,
77
+ lambdaDir: lambdaDirectory,
78
+ prefix,
79
+ httpMethodDecider,
80
+ isBuild: true
81
+ });
82
+ const lambdaDir = apiRouter.getLambdaDir();
83
+ const existLambda = apiRouter.isExistLambda();
84
+ const apiRegexp = new RegExp((0, _utils.normalizeOutputPath)(`${apiDirectory}${_path.default.sep}.*(.[tj]s)$`));
85
+ const name = isServer ? "server" : "client";
86
+ chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
87
+ chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
88
+ prefix,
89
+ appDir: appDirectory,
90
+ apiDir: apiDirectory,
91
+ lambdaDir,
92
+ existLambda,
93
+ port,
94
+ target: name,
95
+ httpMethodDecider
96
+ });
97
+ }
98
+ },
99
+ source: {
100
+ moduleScopes: [
101
+ `./${_utils.API_DIR}`,
102
+ /create-request/
103
+ ]
133
104
  }
105
+ };
106
+ },
107
+ modifyServerRoutes({ routes }) {
108
+ var _bff, _bff1;
109
+ const modernConfig = api.useResolvedConfigContext();
110
+ const { bff } = modernConfig || {};
111
+ const prefix = ((_bff = bff) === null || _bff === void 0 ? void 0 : _bff.prefix) || "/api";
112
+ const prefixList = [];
113
+ if (Array.isArray(prefix)) {
114
+ prefixList.push(...prefix);
115
+ } else {
116
+ prefixList.push(prefix);
117
+ }
118
+ const apiServerRoutes = prefixList.map((pre) => ({
119
+ urlPath: pre,
120
+ isApi: true,
121
+ entryPath: "",
122
+ isSPA: false,
123
+ isSSR: false
124
+ }));
125
+ if ((_bff1 = bff) === null || _bff1 === void 0 ? void 0 : _bff1.enableHandleWeb) {
134
126
  return {
135
- routes: routes.concat(apiServerRoutes)
127
+ routes: routes.map((route) => {
128
+ return {
129
+ ...route,
130
+ isApi: true
131
+ };
132
+ }).concat(apiServerRoutes)
136
133
  };
137
- },
138
- collectServerPlugins({ plugins }) {
139
- plugins.push({
140
- "@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
134
+ }
135
+ return {
136
+ routes: routes.concat(apiServerRoutes)
137
+ };
138
+ },
139
+ collectServerPlugins({ plugins }) {
140
+ plugins.push({
141
+ "@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
142
+ });
143
+ return {
144
+ plugins
145
+ };
146
+ },
147
+ async beforeBuild() {
148
+ if ((0, _utils.isProd)()) {
149
+ const { internalDirectory } = api.useAppContext();
150
+ unRegisterResolveRuntimePath = (0, _helper.registerModernRuntimePath)(internalDirectory);
151
+ }
152
+ },
153
+ async afterBuild() {
154
+ if (unRegisterResolveRuntimePath) {
155
+ unRegisterResolveRuntimePath();
156
+ }
157
+ const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
158
+ const modernConfig = api.useResolvedConfigContext();
159
+ const distDir = _path.default.resolve(distDirectory);
160
+ const apiDir = apiDirectory || _path.default.resolve(appDirectory, _utils.API_DIR);
161
+ const sharedDir = sharedDirectory || _path.default.resolve(appDirectory, _utils.SHARED_DIR);
162
+ const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
163
+ const sourceDirs = [];
164
+ if (_utils.fs.existsSync(apiDir)) {
165
+ sourceDirs.push(apiDir);
166
+ }
167
+ if (_utils.fs.existsSync(sharedDir)) {
168
+ sourceDirs.push(sharedDir);
169
+ }
170
+ const { server } = modernConfig;
171
+ const { alias } = modernConfig.source;
172
+ const { babel } = modernConfig.tools;
173
+ if (sourceDirs.length > 0) {
174
+ await (0, _serverutils.compile)(appDirectory, {
175
+ server,
176
+ alias,
177
+ babelConfig: babel
178
+ }, {
179
+ sourceDirs,
180
+ distDir,
181
+ tsconfigPath
141
182
  });
142
- return {
143
- plugins
144
- };
145
- },
146
- async beforeBuild() {
147
- if ((0, _utils.isProd)()) {
148
- const { internalDirectory } = api.useAppContext();
149
- unRegisterResolveRuntimePath = (0, _helper.registerModernRuntimePath)(internalDirectory);
150
- }
151
- },
152
- async afterBuild() {
153
- if (unRegisterResolveRuntimePath) {
154
- unRegisterResolveRuntimePath();
155
- }
156
- const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
157
- const modernConfig = api.useResolvedConfigContext();
158
- const distDir = _path.default.resolve(distDirectory);
159
- const apiDir = apiDirectory || _path.default.resolve(appDirectory, _utils.API_DIR);
160
- const sharedDir = sharedDirectory || _path.default.resolve(appDirectory, _utils.SHARED_DIR);
161
- const tsconfigPath = _path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
162
- const sourceDirs = [];
163
- if (_utils.fs.existsSync(apiDir)) {
164
- sourceDirs.push(apiDir);
165
- }
166
- if (_utils.fs.existsSync(sharedDir)) {
167
- sourceDirs.push(sharedDir);
168
- }
169
- const { server } = modernConfig;
170
- const { alias } = modernConfig.source;
171
- const { babel } = modernConfig.tools;
172
- if (sourceDirs.length > 0) {
173
- await (0, _serverutils.compile)(appDirectory, {
174
- server,
175
- alias,
176
- babelConfig: babel
177
- }, {
178
- sourceDirs,
179
- distDir,
180
- tsconfigPath
181
- });
182
- }
183
183
  }
184
- };
185
- }
186
- };
187
- };
184
+ }
185
+ };
186
+ }
187
+ });
188
188
  const _default = bffPlugin;
package/dist/esm/cli.js CHANGED
@@ -51,11 +51,12 @@ export var bffPlugin = function() {
51
51
  tools: {
52
52
  bundlerChain: function(chain, param) {
53
53
  var CHAIN_ID = param.CHAIN_ID, isServer = param.isServer;
54
+ var _bff, _bff1;
54
55
  var _api_useAppContext = api.useAppContext(), port = _api_useAppContext.port, appDirectory = _api_useAppContext.appDirectory, apiDirectory = _api_useAppContext.apiDirectory, lambdaDirectory = _api_useAppContext.lambdaDirectory;
55
56
  var modernConfig = api.useResolvedConfigContext();
56
57
  var bff = (modernConfig || {}).bff;
57
- var prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
58
- var httpMethodDecider = bff === null || bff === void 0 ? void 0 : bff.httpMethodDecider;
58
+ var prefix = ((_bff = bff) === null || _bff === void 0 ? void 0 : _bff.prefix) || DEFAULT_API_PREFIX;
59
+ var httpMethodDecider = (_bff1 = bff) === null || _bff1 === void 0 ? void 0 : _bff1.httpMethodDecider;
59
60
  chain.resolve.alias.set("@api", apiDirectory);
60
61
  var apiRouter = new ApiRouter({
61
62
  apiDir: apiDirectory,
@@ -92,9 +93,10 @@ export var bffPlugin = function() {
92
93
  },
93
94
  modifyServerRoutes: function modifyServerRoutes(param) {
94
95
  var routes = param.routes;
96
+ var _bff, _bff1;
95
97
  var modernConfig = api.useResolvedConfigContext();
96
98
  var bff = (modernConfig || {}).bff;
97
- var prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || "/api";
99
+ var prefix = ((_bff = bff) === null || _bff === void 0 ? void 0 : _bff.prefix) || "/api";
98
100
  var prefixList = [];
99
101
  if (Array.isArray(prefix)) {
100
102
  var _prefixList;
@@ -111,7 +113,7 @@ export var bffPlugin = function() {
111
113
  isSSR: false
112
114
  };
113
115
  });
114
- if (bff === null || bff === void 0 ? void 0 : bff.enableHandleWeb) {
116
+ if ((_bff1 = bff) === null || _bff1 === void 0 ? void 0 : _bff1.enableHandleWeb) {
115
117
  return {
116
118
  routes: routes.map(function(route) {
117
119
  return _object_spread_props(_object_spread({}, route), {
@@ -5,164 +5,164 @@ 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
- export const bffPlugin = () => {
9
- return {
10
- name: "@modern-js/plugin-bff",
11
- setup: (api) => {
12
- let unRegisterResolveRuntimePath = null;
13
- return {
14
- validateSchema() {
15
- return [
16
- {
17
- target: "bff",
18
- schema: {
19
- type: "object",
20
- properties: {
21
- prefix: {
22
- type: [
23
- "string",
24
- "array"
25
- ],
26
- items: {
27
- type: "string"
28
- }
29
- },
30
- fetcher: {
31
- type: "string"
32
- },
33
- proxy: {
34
- type: "object"
35
- },
36
- requestCreator: {
8
+ export const bffPlugin = () => ({
9
+ name: "@modern-js/plugin-bff",
10
+ setup: (api) => {
11
+ let unRegisterResolveRuntimePath = null;
12
+ 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: {
37
26
  type: "string"
38
27
  }
28
+ },
29
+ fetcher: {
30
+ type: "string"
31
+ },
32
+ proxy: {
33
+ type: "object"
34
+ },
35
+ requestCreator: {
36
+ type: "string"
39
37
  }
40
38
  }
41
39
  }
42
- ];
43
- },
44
- config() {
45
- return {
46
- tools: {
47
- bundlerChain: (chain, { CHAIN_ID, isServer }) => {
48
- const { port, appDirectory, apiDirectory, lambdaDirectory } = api.useAppContext();
49
- const modernConfig = api.useResolvedConfigContext();
50
- const { bff } = modernConfig || {};
51
- const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
52
- const httpMethodDecider = bff === null || bff === void 0 ? void 0 : bff.httpMethodDecider;
53
- chain.resolve.alias.set("@api", apiDirectory);
54
- const apiRouter = new ApiRouter({
55
- apiDir: apiDirectory,
56
- appDir: appDirectory,
57
- lambdaDir: lambdaDirectory,
58
- prefix,
59
- httpMethodDecider,
60
- isBuild: true
61
- });
62
- const lambdaDir = apiRouter.getLambdaDir();
63
- const existLambda = apiRouter.isExistLambda();
64
- const apiRegexp = new RegExp(normalizeOutputPath(`${apiDirectory}${path.sep}.*(.[tj]s)$`));
65
- const name = isServer ? "server" : "client";
66
- chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
67
- chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
68
- prefix,
69
- appDir: appDirectory,
70
- apiDir: apiDirectory,
71
- lambdaDir,
72
- existLambda,
73
- port,
74
- target: name,
75
- httpMethodDecider
76
- });
77
- }
78
- },
79
- source: {
80
- moduleScopes: [
81
- `./${API_DIR}`,
82
- /create-request/
83
- ]
84
- }
85
- };
86
- },
87
- modifyServerRoutes({ routes }) {
88
- const modernConfig = api.useResolvedConfigContext();
89
- const { bff } = modernConfig || {};
90
- const prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || "/api";
91
- const prefixList = [];
92
- if (Array.isArray(prefix)) {
93
- prefixList.push(...prefix);
94
- } else {
95
- prefixList.push(prefix);
96
40
  }
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 || bff === void 0 ? void 0 : bff.enableHandleWeb) {
105
- return {
106
- routes: routes.map((route) => {
107
- return {
108
- ...route,
109
- isApi: true
110
- };
111
- }).concat(apiServerRoutes)
112
- };
41
+ ];
42
+ },
43
+ config() {
44
+ return {
45
+ tools: {
46
+ bundlerChain: (chain, { CHAIN_ID, isServer }) => {
47
+ var _bff, _bff1;
48
+ const { port, appDirectory, apiDirectory, lambdaDirectory } = api.useAppContext();
49
+ const modernConfig = api.useResolvedConfigContext();
50
+ const { bff } = modernConfig || {};
51
+ const prefix = ((_bff = bff) === null || _bff === void 0 ? void 0 : _bff.prefix) || DEFAULT_API_PREFIX;
52
+ const httpMethodDecider = (_bff1 = bff) === null || _bff1 === void 0 ? void 0 : _bff1.httpMethodDecider;
53
+ chain.resolve.alias.set("@api", apiDirectory);
54
+ const apiRouter = new ApiRouter({
55
+ apiDir: apiDirectory,
56
+ appDir: appDirectory,
57
+ lambdaDir: lambdaDirectory,
58
+ prefix,
59
+ httpMethodDecider,
60
+ isBuild: true
61
+ });
62
+ const lambdaDir = apiRouter.getLambdaDir();
63
+ const existLambda = apiRouter.isExistLambda();
64
+ const apiRegexp = new RegExp(normalizeOutputPath(`${apiDirectory}${path.sep}.*(.[tj]s)$`));
65
+ const name = isServer ? "server" : "client";
66
+ chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
67
+ chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
68
+ prefix,
69
+ appDir: appDirectory,
70
+ apiDir: apiDirectory,
71
+ lambdaDir,
72
+ existLambda,
73
+ port,
74
+ target: name,
75
+ httpMethodDecider
76
+ });
77
+ }
78
+ },
79
+ source: {
80
+ moduleScopes: [
81
+ `./${API_DIR}`,
82
+ /create-request/
83
+ ]
113
84
  }
85
+ };
86
+ },
87
+ modifyServerRoutes({ routes }) {
88
+ var _bff, _bff1;
89
+ const modernConfig = api.useResolvedConfigContext();
90
+ const { bff } = modernConfig || {};
91
+ const prefix = ((_bff = bff) === null || _bff === void 0 ? void 0 : _bff.prefix) || "/api";
92
+ const prefixList = [];
93
+ if (Array.isArray(prefix)) {
94
+ prefixList.push(...prefix);
95
+ } else {
96
+ prefixList.push(prefix);
97
+ }
98
+ const apiServerRoutes = prefixList.map((pre) => ({
99
+ urlPath: pre,
100
+ isApi: true,
101
+ entryPath: "",
102
+ isSPA: false,
103
+ isSSR: false
104
+ }));
105
+ if ((_bff1 = bff) === null || _bff1 === void 0 ? void 0 : _bff1.enableHandleWeb) {
114
106
  return {
115
- routes: routes.concat(apiServerRoutes)
107
+ routes: routes.map((route) => {
108
+ return {
109
+ ...route,
110
+ isApi: true
111
+ };
112
+ }).concat(apiServerRoutes)
116
113
  };
117
- },
118
- collectServerPlugins({ plugins }) {
119
- plugins.push({
120
- "@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
114
+ }
115
+ return {
116
+ routes: routes.concat(apiServerRoutes)
117
+ };
118
+ },
119
+ collectServerPlugins({ plugins }) {
120
+ plugins.push({
121
+ "@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
122
+ });
123
+ return {
124
+ plugins
125
+ };
126
+ },
127
+ async beforeBuild() {
128
+ if (isProd()) {
129
+ const { internalDirectory } = api.useAppContext();
130
+ unRegisterResolveRuntimePath = registerModernRuntimePath(internalDirectory);
131
+ }
132
+ },
133
+ async afterBuild() {
134
+ if (unRegisterResolveRuntimePath) {
135
+ unRegisterResolveRuntimePath();
136
+ }
137
+ const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
138
+ const modernConfig = api.useResolvedConfigContext();
139
+ const distDir = path.resolve(distDirectory);
140
+ const apiDir = apiDirectory || path.resolve(appDirectory, API_DIR);
141
+ const sharedDir = sharedDirectory || path.resolve(appDirectory, SHARED_DIR);
142
+ const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
143
+ const sourceDirs = [];
144
+ if (fs.existsSync(apiDir)) {
145
+ sourceDirs.push(apiDir);
146
+ }
147
+ if (fs.existsSync(sharedDir)) {
148
+ sourceDirs.push(sharedDir);
149
+ }
150
+ const { server } = modernConfig;
151
+ const { alias } = modernConfig.source;
152
+ const { babel } = modernConfig.tools;
153
+ if (sourceDirs.length > 0) {
154
+ await compile(appDirectory, {
155
+ server,
156
+ alias,
157
+ babelConfig: babel
158
+ }, {
159
+ sourceDirs,
160
+ distDir,
161
+ tsconfigPath
121
162
  });
122
- return {
123
- plugins
124
- };
125
- },
126
- async beforeBuild() {
127
- if (isProd()) {
128
- const { internalDirectory } = api.useAppContext();
129
- unRegisterResolveRuntimePath = registerModernRuntimePath(internalDirectory);
130
- }
131
- },
132
- async afterBuild() {
133
- if (unRegisterResolveRuntimePath) {
134
- unRegisterResolveRuntimePath();
135
- }
136
- const { appDirectory, distDirectory, apiDirectory, sharedDirectory } = api.useAppContext();
137
- const modernConfig = api.useResolvedConfigContext();
138
- const distDir = path.resolve(distDirectory);
139
- const apiDir = apiDirectory || path.resolve(appDirectory, API_DIR);
140
- const sharedDir = sharedDirectory || path.resolve(appDirectory, SHARED_DIR);
141
- const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
142
- const sourceDirs = [];
143
- if (fs.existsSync(apiDir)) {
144
- sourceDirs.push(apiDir);
145
- }
146
- if (fs.existsSync(sharedDir)) {
147
- sourceDirs.push(sharedDir);
148
- }
149
- const { server } = modernConfig;
150
- const { alias } = modernConfig.source;
151
- const { babel } = modernConfig.tools;
152
- if (sourceDirs.length > 0) {
153
- await compile(appDirectory, {
154
- server,
155
- alias,
156
- babelConfig: babel
157
- }, {
158
- sourceDirs,
159
- distDir,
160
- tsconfigPath
161
- });
162
- }
163
163
  }
164
- };
165
- }
166
- };
167
- };
164
+ }
165
+ };
166
+ }
167
+ });
168
168
  export default bffPlugin;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.27.0",
18
+ "version": "2.29.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.21.8",
59
59
  "@swc/helpers": "0.5.1",
60
- "@modern-js/bff-core": "2.27.0",
61
- "@modern-js/create-request": "2.27.0",
62
- "@modern-js/server-utils": "2.27.0",
63
- "@modern-js/utils": "2.27.0"
60
+ "@modern-js/bff-core": "2.29.0",
61
+ "@modern-js/create-request": "2.29.0",
62
+ "@modern-js/server-utils": "2.29.0",
63
+ "@modern-js/utils": "2.29.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/babel__core": "^7.20.0",
@@ -72,14 +72,14 @@
72
72
  "typescript": "^5",
73
73
  "webpack": "^5.88.1",
74
74
  "webpack-chain": "^6.5.1",
75
- "@modern-js/runtime": "2.27.0",
76
- "@modern-js/core": "2.27.0",
77
- "@modern-js/bff-runtime": "2.27.0",
78
- "@modern-js/server-core": "2.27.0",
79
- "@modern-js/types": "2.27.0",
80
- "@modern-js/app-tools": "2.27.0",
81
- "@scripts/build": "2.27.0",
82
- "@scripts/jest-config": "2.27.0"
75
+ "@modern-js/runtime": "2.29.0",
76
+ "@modern-js/core": "2.29.0",
77
+ "@modern-js/bff-runtime": "2.29.0",
78
+ "@modern-js/server-core": "2.29.0",
79
+ "@modern-js/types": "2.29.0",
80
+ "@modern-js/app-tools": "2.29.0",
81
+ "@scripts/build": "2.29.0",
82
+ "@scripts/jest-config": "2.29.0"
83
83
  },
84
84
  "sideEffects": false,
85
85
  "publishConfig": {