@modern-js/prod-server 1.15.0 → 1.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
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @modern-js/prod-server
|
|
2
2
|
|
|
3
|
+
## 1.16.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 81c66e4a4: fix: compatibility issues of dev server in iOS 10
|
|
8
|
+
|
|
9
|
+
fix: 修复 dev server 代码在 iOS 10 下的兼容性问题
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [641592f52]
|
|
12
|
+
- Updated dependencies [3904b30a5]
|
|
13
|
+
- Updated dependencies [1100dd58c]
|
|
14
|
+
- Updated dependencies [e04e6e76a]
|
|
15
|
+
- Updated dependencies [81c66e4a4]
|
|
16
|
+
- Updated dependencies [2c305b6f5]
|
|
17
|
+
- @modern-js/utils@1.16.0
|
|
18
|
+
- @modern-js/server-core@1.16.0
|
|
19
|
+
|
|
3
20
|
## 1.15.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,6 +1,36 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
1
7
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
2
|
-
import { formatProxyOptions } from '@modern-js/utils';
|
|
3
8
|
import { debug } from "../utils";
|
|
9
|
+
export function formatProxyOptions(proxyOptions) {
|
|
10
|
+
const formattedProxy = [];
|
|
11
|
+
|
|
12
|
+
if (!Array.isArray(proxyOptions)) {
|
|
13
|
+
if ('target' in proxyOptions) {
|
|
14
|
+
formattedProxy.push(proxyOptions);
|
|
15
|
+
} else {
|
|
16
|
+
Array.prototype.push.apply(formattedProxy, Object.keys(proxyOptions).reduce((total, source) => {
|
|
17
|
+
const option = proxyOptions[source];
|
|
18
|
+
total.push(_objectSpread({
|
|
19
|
+
context: source,
|
|
20
|
+
changeOrigin: true,
|
|
21
|
+
logLevel: 'warn'
|
|
22
|
+
}, typeof option === 'string' ? {
|
|
23
|
+
target: option
|
|
24
|
+
} : option));
|
|
25
|
+
return total;
|
|
26
|
+
}, []));
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
formattedProxy.push(...proxyOptions);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return formattedProxy;
|
|
33
|
+
}
|
|
4
34
|
export const createProxyHandler = proxyOptions => {
|
|
5
35
|
debug('createProxyHandler', proxyOptions);
|
|
6
36
|
|
|
@@ -4,15 +4,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createProxyHandler = void 0;
|
|
7
|
+
exports.formatProxyOptions = formatProxyOptions;
|
|
7
8
|
|
|
8
9
|
var _httpProxyMiddleware = require("http-proxy-middleware");
|
|
9
10
|
|
|
10
|
-
var _utils = require("
|
|
11
|
+
var _utils = require("../utils");
|
|
11
12
|
|
|
12
|
-
var
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
|
|
17
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
|
|
19
|
+
function formatProxyOptions(proxyOptions) {
|
|
20
|
+
const formattedProxy = [];
|
|
21
|
+
|
|
22
|
+
if (!Array.isArray(proxyOptions)) {
|
|
23
|
+
if ('target' in proxyOptions) {
|
|
24
|
+
formattedProxy.push(proxyOptions);
|
|
25
|
+
} else {
|
|
26
|
+
Array.prototype.push.apply(formattedProxy, Object.keys(proxyOptions).reduce((total, source) => {
|
|
27
|
+
const option = proxyOptions[source];
|
|
28
|
+
total.push(_objectSpread({
|
|
29
|
+
context: source,
|
|
30
|
+
changeOrigin: true,
|
|
31
|
+
logLevel: 'warn'
|
|
32
|
+
}, typeof option === 'string' ? {
|
|
33
|
+
target: option
|
|
34
|
+
} : option));
|
|
35
|
+
return total;
|
|
36
|
+
}, []));
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
formattedProxy.push(...proxyOptions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return formattedProxy;
|
|
43
|
+
}
|
|
13
44
|
|
|
14
45
|
const createProxyHandler = proxyOptions => {
|
|
15
|
-
(0,
|
|
46
|
+
(0, _utils.debug)('createProxyHandler', proxyOptions);
|
|
16
47
|
|
|
17
48
|
if (!proxyOptions) {
|
|
18
49
|
return null;
|
|
@@ -20,7 +51,7 @@ const createProxyHandler = proxyOptions => {
|
|
|
20
51
|
// or an object in the form of { source: ProxyDetail }
|
|
21
52
|
|
|
22
53
|
|
|
23
|
-
const formattedProxy =
|
|
54
|
+
const formattedProxy = formatProxyOptions(proxyOptions);
|
|
24
55
|
const middlewares = formattedProxy.map(option => {
|
|
25
56
|
const middleware = (0, _httpProxyMiddleware.createProxyMiddleware)(option.context, option); // eslint-disable-next-line consistent-return
|
|
26
57
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { NextFunction, BffProxyOptions } from '@modern-js/types';
|
|
1
|
+
import { ProxyDetail, NextFunction, BffProxyOptions } from '@modern-js/types';
|
|
2
2
|
import { ModernServerContext } from './context';
|
|
3
3
|
export type { BffProxyOptions };
|
|
4
|
+
export declare function formatProxyOptions(proxyOptions: BffProxyOptions): ProxyDetail[];
|
|
4
5
|
export declare const createProxyHandler: (proxyOptions?: BffProxyOptions) => ((ctx: ModernServerContext, next: NextFunction) => Promise<void>)[] | null;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.16.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@modern-js/utils": "1.
|
|
31
|
+
"@modern-js/utils": "1.16.0",
|
|
32
32
|
"@babel/compat-data": "^7.17.10",
|
|
33
|
-
"@modern-js/server-core": "1.
|
|
33
|
+
"@modern-js/server-core": "1.16.0",
|
|
34
34
|
"axios": "^0.24.0",
|
|
35
35
|
"compare-versions": "^3.6.0",
|
|
36
36
|
"cookie": "^0.4.2",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"ua-parser-js": "^0.7.28"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@modern-js/types": "1.
|
|
47
|
-
"@modern-js/core": "1.
|
|
46
|
+
"@modern-js/types": "1.16.0",
|
|
47
|
+
"@modern-js/core": "1.16.0",
|
|
48
48
|
"@scripts/jest-config": "1.15.0",
|
|
49
49
|
"@scripts/build": "1.15.0",
|
|
50
50
|
"@types/cookie": "^0.4.1",
|