@modern-js/plugin-bff 1.15.0 → 1.15.1-beta.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/js/modern/cli.js +40 -41
- package/dist/js/node/cli.js +40 -44
- package/dist/js/treeshaking/cli.js +64 -109
- package/package.json +4 -3
package/dist/js/modern/cli.js
CHANGED
|
@@ -1,49 +1,48 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { compiler } from '@modern-js/babel-compiler';
|
|
3
2
|
import { fs, API_DIR, PLUGIN_SCHEMAS, normalizeOutputPath, SHARED_DIR, isProd } from '@modern-js/utils';
|
|
4
|
-
import {
|
|
3
|
+
import { compile } from '@modern-js/server-utils';
|
|
5
4
|
import { registerModernRuntimePath } from "./helper";
|
|
6
5
|
const DEFAULT_API_PREFIX = '/api';
|
|
7
6
|
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
8
|
-
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; //
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
7
|
+
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // const compile = async (
|
|
8
|
+
// appDirectory: string,
|
|
9
|
+
// modernConfig: NormalizedConfig,
|
|
10
|
+
// compileOptions: CompileOptions,
|
|
11
|
+
// ) => {
|
|
12
|
+
// const { patterns } = compileOptions;
|
|
13
|
+
// const results = await Promise.all(
|
|
14
|
+
// patterns.map(async pattern => {
|
|
15
|
+
// const { from, to, tsconfigPath } = pattern;
|
|
16
|
+
// const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
|
|
17
|
+
// tsconfigPath: tsconfigPath ? tsconfigPath : '',
|
|
18
|
+
// syntax: 'es6+',
|
|
19
|
+
// type: 'commonjs',
|
|
20
|
+
// });
|
|
21
|
+
// if (await fs.pathExists(from)) {
|
|
22
|
+
// const basename = path.basename(from);
|
|
23
|
+
// const targetDir = path.join(to, basename);
|
|
24
|
+
// await fs.copy(from, targetDir, {
|
|
25
|
+
// filter: src =>
|
|
26
|
+
// !['.ts', '.js'].includes(path.extname(src)) && src !== tsconfigPath,
|
|
27
|
+
// });
|
|
28
|
+
// }
|
|
29
|
+
// return compiler(
|
|
30
|
+
// {
|
|
31
|
+
// rootDir: appDirectory,
|
|
32
|
+
// distDir: to,
|
|
33
|
+
// sourceDir: from,
|
|
34
|
+
// extensions: FILE_EXTENSIONS,
|
|
35
|
+
// },
|
|
36
|
+
// babelConfig,
|
|
37
|
+
// );
|
|
38
|
+
// }),
|
|
39
|
+
// );
|
|
40
|
+
// results.forEach(result => {
|
|
41
|
+
// if (result.code === 1) {
|
|
42
|
+
// throw new Error(result.message);
|
|
43
|
+
// }
|
|
44
|
+
// });
|
|
45
|
+
// };
|
|
47
46
|
|
|
48
47
|
export default (() => ({
|
|
49
48
|
name: '@modern-js/plugin-bff',
|
package/dist/js/node/cli.js
CHANGED
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
10
|
-
var _babelCompiler = require("@modern-js/babel-compiler");
|
|
11
|
-
|
|
12
10
|
var _utils = require("@modern-js/utils");
|
|
13
11
|
|
|
14
12
|
var _serverUtils = require("@modern-js/server-utils");
|
|
@@ -19,47 +17,45 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
17
|
|
|
20
18
|
const DEFAULT_API_PREFIX = '/api';
|
|
21
19
|
const TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
22
|
-
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; //
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
};
|
|
20
|
+
const FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // const compile = async (
|
|
21
|
+
// appDirectory: string,
|
|
22
|
+
// modernConfig: NormalizedConfig,
|
|
23
|
+
// compileOptions: CompileOptions,
|
|
24
|
+
// ) => {
|
|
25
|
+
// const { patterns } = compileOptions;
|
|
26
|
+
// const results = await Promise.all(
|
|
27
|
+
// patterns.map(async pattern => {
|
|
28
|
+
// const { from, to, tsconfigPath } = pattern;
|
|
29
|
+
// const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
|
|
30
|
+
// tsconfigPath: tsconfigPath ? tsconfigPath : '',
|
|
31
|
+
// syntax: 'es6+',
|
|
32
|
+
// type: 'commonjs',
|
|
33
|
+
// });
|
|
34
|
+
// if (await fs.pathExists(from)) {
|
|
35
|
+
// const basename = path.basename(from);
|
|
36
|
+
// const targetDir = path.join(to, basename);
|
|
37
|
+
// await fs.copy(from, targetDir, {
|
|
38
|
+
// filter: src =>
|
|
39
|
+
// !['.ts', '.js'].includes(path.extname(src)) && src !== tsconfigPath,
|
|
40
|
+
// });
|
|
41
|
+
// }
|
|
42
|
+
// return compiler(
|
|
43
|
+
// {
|
|
44
|
+
// rootDir: appDirectory,
|
|
45
|
+
// distDir: to,
|
|
46
|
+
// sourceDir: from,
|
|
47
|
+
// extensions: FILE_EXTENSIONS,
|
|
48
|
+
// },
|
|
49
|
+
// babelConfig,
|
|
50
|
+
// );
|
|
51
|
+
// }),
|
|
52
|
+
// );
|
|
53
|
+
// results.forEach(result => {
|
|
54
|
+
// if (result.code === 1) {
|
|
55
|
+
// throw new Error(result.message);
|
|
56
|
+
// }
|
|
57
|
+
// });
|
|
58
|
+
// };
|
|
63
59
|
|
|
64
60
|
var _default = () => ({
|
|
65
61
|
name: '@modern-js/plugin-bff',
|
|
@@ -187,7 +183,7 @@ var _default = () => ({
|
|
|
187
183
|
}
|
|
188
184
|
|
|
189
185
|
if (patterns.length > 0) {
|
|
190
|
-
await compile(appDirectory, modernConfig, {
|
|
186
|
+
await (0, _serverUtils.compile)(appDirectory, modernConfig, {
|
|
191
187
|
patterns
|
|
192
188
|
});
|
|
193
189
|
}
|
|
@@ -1,96 +1,51 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import { compiler } from '@modern-js/babel-compiler';
|
|
6
5
|
import { fs, API_DIR, PLUGIN_SCHEMAS, normalizeOutputPath, SHARED_DIR, isProd } from '@modern-js/utils';
|
|
7
|
-
import {
|
|
6
|
+
import { compile } from '@modern-js/server-utils';
|
|
8
7
|
import { registerModernRuntimePath } from "./helper";
|
|
9
8
|
var DEFAULT_API_PREFIX = '/api';
|
|
10
9
|
var TS_CONFIG_FILENAME = 'tsconfig.json';
|
|
11
|
-
var FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; //
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
case 9:
|
|
54
|
-
return _context.abrupt("return", compiler({
|
|
55
|
-
rootDir: appDirectory,
|
|
56
|
-
distDir: to,
|
|
57
|
-
sourceDir: from,
|
|
58
|
-
extensions: FILE_EXTENSIONS
|
|
59
|
-
}, babelConfig));
|
|
60
|
-
|
|
61
|
-
case 10:
|
|
62
|
-
case "end":
|
|
63
|
-
return _context.stop();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}, _callee);
|
|
67
|
-
}));
|
|
68
|
-
|
|
69
|
-
return function (_x4) {
|
|
70
|
-
return _ref2.apply(this, arguments);
|
|
71
|
-
};
|
|
72
|
-
}()));
|
|
73
|
-
|
|
74
|
-
case 3:
|
|
75
|
-
results = _context2.sent;
|
|
76
|
-
results.forEach(function (result) {
|
|
77
|
-
if (result.code === 1) {
|
|
78
|
-
throw new Error(result.message);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
case 5:
|
|
83
|
-
case "end":
|
|
84
|
-
return _context2.stop();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, _callee2);
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
return function compile(_x, _x2, _x3) {
|
|
91
|
-
return _ref.apply(this, arguments);
|
|
92
|
-
};
|
|
93
|
-
}();
|
|
10
|
+
var FILE_EXTENSIONS = ['.js', '.ts', '.mjs', '.ejs']; // const compile = async (
|
|
11
|
+
// appDirectory: string,
|
|
12
|
+
// modernConfig: NormalizedConfig,
|
|
13
|
+
// compileOptions: CompileOptions,
|
|
14
|
+
// ) => {
|
|
15
|
+
// const { patterns } = compileOptions;
|
|
16
|
+
// const results = await Promise.all(
|
|
17
|
+
// patterns.map(async pattern => {
|
|
18
|
+
// const { from, to, tsconfigPath } = pattern;
|
|
19
|
+
// const babelConfig = resolveBabelConfig(appDirectory, modernConfig, {
|
|
20
|
+
// tsconfigPath: tsconfigPath ? tsconfigPath : '',
|
|
21
|
+
// syntax: 'es6+',
|
|
22
|
+
// type: 'commonjs',
|
|
23
|
+
// });
|
|
24
|
+
// if (await fs.pathExists(from)) {
|
|
25
|
+
// const basename = path.basename(from);
|
|
26
|
+
// const targetDir = path.join(to, basename);
|
|
27
|
+
// await fs.copy(from, targetDir, {
|
|
28
|
+
// filter: src =>
|
|
29
|
+
// !['.ts', '.js'].includes(path.extname(src)) && src !== tsconfigPath,
|
|
30
|
+
// });
|
|
31
|
+
// }
|
|
32
|
+
// return compiler(
|
|
33
|
+
// {
|
|
34
|
+
// rootDir: appDirectory,
|
|
35
|
+
// distDir: to,
|
|
36
|
+
// sourceDir: from,
|
|
37
|
+
// extensions: FILE_EXTENSIONS,
|
|
38
|
+
// },
|
|
39
|
+
// babelConfig,
|
|
40
|
+
// );
|
|
41
|
+
// }),
|
|
42
|
+
// );
|
|
43
|
+
// results.forEach(result => {
|
|
44
|
+
// if (result.code === 1) {
|
|
45
|
+
// throw new Error(result.message);
|
|
46
|
+
// }
|
|
47
|
+
// });
|
|
48
|
+
// };
|
|
94
49
|
|
|
95
50
|
export default (function () {
|
|
96
51
|
return {
|
|
@@ -104,9 +59,9 @@ export default (function () {
|
|
|
104
59
|
config: function config() {
|
|
105
60
|
return {
|
|
106
61
|
tools: {
|
|
107
|
-
webpackChain: function webpackChain(chain,
|
|
108
|
-
var name =
|
|
109
|
-
CHAIN_ID =
|
|
62
|
+
webpackChain: function webpackChain(chain, _ref) {
|
|
63
|
+
var name = _ref.name,
|
|
64
|
+
CHAIN_ID = _ref.CHAIN_ID;
|
|
110
65
|
|
|
111
66
|
var _api$useAppContext = api.useAppContext(),
|
|
112
67
|
appDirectory = _api$useAppContext.appDirectory,
|
|
@@ -114,11 +69,11 @@ export default (function () {
|
|
|
114
69
|
|
|
115
70
|
var modernConfig = api.useResolvedConfigContext();
|
|
116
71
|
|
|
117
|
-
var
|
|
118
|
-
bff =
|
|
72
|
+
var _ref2 = modernConfig || {},
|
|
73
|
+
bff = _ref2.bff;
|
|
119
74
|
|
|
120
|
-
var
|
|
121
|
-
fetcher =
|
|
75
|
+
var _ref3 = bff || {},
|
|
76
|
+
fetcher = _ref3.fetcher;
|
|
122
77
|
|
|
123
78
|
var prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
|
|
124
79
|
var rootDir = path.resolve(appDirectory, API_DIR);
|
|
@@ -139,12 +94,12 @@ export default (function () {
|
|
|
139
94
|
}
|
|
140
95
|
};
|
|
141
96
|
},
|
|
142
|
-
modifyServerRoutes: function modifyServerRoutes(
|
|
143
|
-
var routes =
|
|
97
|
+
modifyServerRoutes: function modifyServerRoutes(_ref4) {
|
|
98
|
+
var routes = _ref4.routes;
|
|
144
99
|
var modernConfig = api.useResolvedConfigContext();
|
|
145
100
|
|
|
146
|
-
var
|
|
147
|
-
bff =
|
|
101
|
+
var _ref5 = modernConfig || {},
|
|
102
|
+
bff = _ref5.bff;
|
|
148
103
|
|
|
149
104
|
var prefix = (bff === null || bff === void 0 ? void 0 : bff.prefix) || '/api';
|
|
150
105
|
var prefixList = [];
|
|
@@ -170,12 +125,12 @@ export default (function () {
|
|
|
170
125
|
};
|
|
171
126
|
},
|
|
172
127
|
beforeBuild: function beforeBuild() {
|
|
173
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
128
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
174
129
|
var _api$useAppContext2, internalDirectory;
|
|
175
130
|
|
|
176
|
-
return _regeneratorRuntime().wrap(function
|
|
131
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
177
132
|
while (1) {
|
|
178
|
-
switch (
|
|
133
|
+
switch (_context.prev = _context.next) {
|
|
179
134
|
case 0:
|
|
180
135
|
// help esbuild-register resolve @modern-js/server/runtime
|
|
181
136
|
if (isProd()) {
|
|
@@ -185,19 +140,19 @@ export default (function () {
|
|
|
185
140
|
|
|
186
141
|
case 1:
|
|
187
142
|
case "end":
|
|
188
|
-
return
|
|
143
|
+
return _context.stop();
|
|
189
144
|
}
|
|
190
145
|
}
|
|
191
|
-
},
|
|
146
|
+
}, _callee);
|
|
192
147
|
}))();
|
|
193
148
|
},
|
|
194
149
|
afterBuild: function afterBuild() {
|
|
195
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
150
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
196
151
|
var _api$useAppContext3, appDirectory, distDirectory, modernConfig, distDir, apiDir, sharedDir, tsconfigPath, patterns;
|
|
197
152
|
|
|
198
|
-
return _regeneratorRuntime().wrap(function
|
|
153
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
199
154
|
while (1) {
|
|
200
|
-
switch (
|
|
155
|
+
switch (_context2.prev = _context2.next) {
|
|
201
156
|
case 0:
|
|
202
157
|
if (unRegisterResolveRuntimePath) {
|
|
203
158
|
unRegisterResolveRuntimePath();
|
|
@@ -228,21 +183,21 @@ export default (function () {
|
|
|
228
183
|
}
|
|
229
184
|
|
|
230
185
|
if (!(patterns.length > 0)) {
|
|
231
|
-
|
|
186
|
+
_context2.next = 13;
|
|
232
187
|
break;
|
|
233
188
|
}
|
|
234
189
|
|
|
235
|
-
|
|
190
|
+
_context2.next = 13;
|
|
236
191
|
return compile(appDirectory, modernConfig, {
|
|
237
192
|
patterns: patterns
|
|
238
193
|
});
|
|
239
194
|
|
|
240
195
|
case 13:
|
|
241
196
|
case "end":
|
|
242
|
-
return
|
|
197
|
+
return _context2.stop();
|
|
243
198
|
}
|
|
244
199
|
}
|
|
245
|
-
},
|
|
200
|
+
}, _callee2);
|
|
246
201
|
}))();
|
|
247
202
|
}
|
|
248
203
|
};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.15.0",
|
|
14
|
+
"version": "1.15.1-beta.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@modern-js/babel-compiler": "1.15.0",
|
|
59
59
|
"@modern-js/bff-core": "1.15.0",
|
|
60
60
|
"@modern-js/create-request": "1.15.0",
|
|
61
|
-
"@modern-js/server-utils": "1.15.0",
|
|
61
|
+
"@modern-js/server-utils": "1.15.1-beta.0",
|
|
62
62
|
"@modern-js/utils": "1.15.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
"sideEffects": false,
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"registry": "https://registry.npmjs.org/",
|
|
85
|
-
"access": "public"
|
|
85
|
+
"access": "public",
|
|
86
|
+
"types": "./dist/types/index.d.ts"
|
|
86
87
|
},
|
|
87
88
|
"wireit": {
|
|
88
89
|
"build": {
|