@modern-js/server 1.4.2 → 1.4.3

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,17 @@
1
1
  # @modern-js/server
2
2
 
3
+ ## 1.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - deeaa602: support svg/proxy/multi-version in unbundled
8
+ - fab92861: fix: @modern-js/core phantom dep
9
+ - Updated dependencies [deeaa602]
10
+ - Updated dependencies [54786e58]
11
+ - @modern-js/hmr-client@1.2.2
12
+ - @modern-js/utils@1.3.2
13
+ - @modern-js/core@1.4.3
14
+
3
15
  ## 1.4.2
4
16
 
5
17
  ### Patch Changes
@@ -1,10 +1,5 @@
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
-
7
1
  import { createProxyMiddleware } from 'http-proxy-middleware';
2
+ import { formatProxyOptions } from '@modern-js/utils';
8
3
  export const createProxyHandler = proxyOptions => {
9
4
  if (!proxyOptions) {
10
5
  return null;
@@ -12,28 +7,7 @@ export const createProxyHandler = proxyOptions => {
12
7
  // or an object in the form of { source: ProxyDetail }
13
8
 
14
9
 
15
- const formatedProxy = [];
16
-
17
- if (!Array.isArray(proxyOptions)) {
18
- if ('target' in proxyOptions) {
19
- formatedProxy.push(proxyOptions);
20
- } else {
21
- Array.prototype.push.apply(formatedProxy, Object.keys(proxyOptions).reduce((total, source) => {
22
- const option = proxyOptions[source];
23
- total.push(_objectSpread({
24
- context: source,
25
- changeOrigin: true,
26
- logLevel: 'warn'
27
- }, typeof option === 'string' ? {
28
- target: option
29
- } : option));
30
- return total;
31
- }, []));
32
- }
33
- } else {
34
- formatedProxy.push(...proxyOptions);
35
- }
36
-
10
+ const formatedProxy = formatProxyOptions(proxyOptions);
37
11
  const middlewares = formatedProxy.map(option => {
38
12
  const middleware = createProxyMiddleware(option.context, option); // eslint-disable-next-line consistent-return
39
13
 
@@ -7,11 +7,7 @@ exports.createProxyHandler = void 0;
7
7
 
8
8
  var _httpProxyMiddleware = require("http-proxy-middleware");
9
9
 
10
- 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; }
11
-
12
- 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; }
13
-
14
- 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; }
10
+ var _utils = require("@modern-js/utils");
15
11
 
16
12
  const createProxyHandler = proxyOptions => {
17
13
  if (!proxyOptions) {
@@ -20,28 +16,7 @@ const createProxyHandler = proxyOptions => {
20
16
  // or an object in the form of { source: ProxyDetail }
21
17
 
22
18
 
23
- const formatedProxy = [];
24
-
25
- if (!Array.isArray(proxyOptions)) {
26
- if ('target' in proxyOptions) {
27
- formatedProxy.push(proxyOptions);
28
- } else {
29
- Array.prototype.push.apply(formatedProxy, Object.keys(proxyOptions).reduce((total, source) => {
30
- const option = proxyOptions[source];
31
- total.push(_objectSpread({
32
- context: source,
33
- changeOrigin: true,
34
- logLevel: 'warn'
35
- }, typeof option === 'string' ? {
36
- target: option
37
- } : option));
38
- return total;
39
- }, []));
40
- }
41
- } else {
42
- formatedProxy.push(...proxyOptions);
43
- }
44
-
19
+ const formatedProxy = (0, _utils.formatProxyOptions)(proxyOptions);
45
20
  const middlewares = formatedProxy.map(option => {
46
21
  const middleware = (0, _httpProxyMiddleware.createProxyMiddleware)(option.context, option); // eslint-disable-next-line consistent-return
47
22
 
@@ -1,16 +1,4 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage, ServerResponse } from 'http';
3
- import { NextFunction } from '../type';
1
+ import { NextFunction, ProxyOptions } from '@modern-js/types';
4
2
  import { ModernServerContext } from './context';
5
- declare type ProxyDetail = {
6
- target: string;
7
- pathRewrite?: Record<string, string>;
8
- secure?: boolean;
9
- logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
10
- bypass?: (req: IncomingMessage, res: ServerResponse, proxyOptions: ProxyOptions) => string | undefined | null | false;
11
- context?: string | string[];
12
- changeOrigin?: boolean;
13
- };
14
- export declare type ProxyOptions = Record<string, string> | Record<string, ProxyDetail> | ProxyDetail[] | ProxyDetail;
15
- export declare const createProxyHandler: (proxyOptions: ProxyOptions) => ((ctx: ModernServerContext, next: NextFunction) => Promise<void>)[] | null;
16
- export {};
3
+ export type { ProxyOptions };
4
+ export declare const createProxyHandler: (proxyOptions: ProxyOptions) => ((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.4.2",
14
+ "version": "1.4.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -34,12 +34,11 @@
34
34
  "@babel/preset-typescript": "^7.15.0",
35
35
  "@babel/register": "^7.15.3",
36
36
  "@babel/runtime": "^7",
37
- "@modern-js/core": "^1.4.2",
38
- "@modern-js/hmr-client": "^1.2.1",
37
+ "@modern-js/hmr-client": "^1.2.2",
39
38
  "@modern-js/server-core": "^1.2.2",
40
39
  "@modern-js/server-utils": "^1.2.1",
41
40
  "@modern-js/bff-utils": "^1.2.2",
42
- "@modern-js/utils": "^1.3.1",
41
+ "@modern-js/utils": "^1.3.2",
43
42
  "axios": "^0.24.0",
44
43
  "babel-plugin-module-resolver": "^4.1.0",
45
44
  "chokidar": "^3.5.2",
@@ -64,8 +63,9 @@
64
63
  "cookie": "^0.4.2"
65
64
  },
66
65
  "devDependencies": {
66
+ "@modern-js/core": "^1.4.3",
67
67
  "@scripts/build": "0.0.0",
68
- "@modern-js/types": "^1.3.2",
68
+ "@modern-js/types": "^1.3.3",
69
69
  "@types/jest": "^26",
70
70
  "@types/lru-cache": "^5.1.1",
71
71
  "@types/mime-types": "^2.1.0",
@@ -90,7 +90,8 @@
90
90
  "websocket": "^1"
91
91
  },
92
92
  "peerDependencies": {
93
- "webpack": "^5.54.0"
93
+ "webpack": "^5.54.0",
94
+ "@modern-js/core": "^1.4.3"
94
95
  },
95
96
  "sideEffects": false,
96
97
  "modernConfig": {