@modern-js/plugin-proxy 1.2.2 → 1.2.5
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 +33 -0
- package/dist/js/modern/index.js +32 -32
- package/dist/js/node/index.js +39 -41
- package/dist/types/index.d.ts +4 -8
- package/dist/types/utils/createProxyRule.d.ts +2 -2
- package/jest.config.js +0 -1
- package/modern.config.js +5 -1
- package/package.json +5 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @modern-js/plugin-proxy
|
|
2
2
|
|
|
3
|
+
## 1.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bebb39b6: chore: improve devDependencies and peerDependencies
|
|
8
|
+
- 132f7b53: feat: move config declarations to @modern-js/core
|
|
9
|
+
- Updated dependencies [132f7b53]
|
|
10
|
+
- @modern-js/utils@1.3.7
|
|
11
|
+
|
|
12
|
+
## 1.2.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 681a1ff9: feat: remove unnecessary peerDependencies
|
|
17
|
+
- Updated dependencies [c2046f37]
|
|
18
|
+
- @modern-js/utils@1.3.6
|
|
19
|
+
|
|
20
|
+
## 1.2.3
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 9b2640fe: fix: dev.proxy type not work
|
|
25
|
+
- Updated dependencies [5bf5868d]
|
|
26
|
+
- Updated dependencies [80d3cfb7]
|
|
27
|
+
- Updated dependencies [42c6b136]
|
|
28
|
+
- Updated dependencies [4e7dcbd5]
|
|
29
|
+
- Updated dependencies [9e8bc4ab]
|
|
30
|
+
- Updated dependencies [0c556e59]
|
|
31
|
+
- Updated dependencies [80d8ddfe]
|
|
32
|
+
- Updated dependencies [2008fdbd]
|
|
33
|
+
- @modern-js/utils@1.3.5
|
|
34
|
+
- @modern-js/core@1.5.0
|
|
35
|
+
|
|
3
36
|
## 1.2.2
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { createPlugin, useAppContext, useResolvedConfigContext } from '@modern-js/core';
|
|
2
1
|
import { PLUGIN_SCHEMAS } from '@modern-js/utils';
|
|
3
2
|
import { createProxyRule } from "./utils/createProxyRule";
|
|
4
3
|
import WhistleProxy from "./utils/whistleProxy";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export default (() => {
|
|
5
|
+
let proxyServer;
|
|
6
|
+
return {
|
|
7
|
+
name: '@modern-js/plugin-proxy',
|
|
8
|
+
setup: api => ({
|
|
9
|
+
validateSchema() {
|
|
10
|
+
return PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
|
|
11
|
+
},
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = useAppContext();
|
|
19
|
-
/* eslint-enable react-hooks/rules-of-hooks */
|
|
13
|
+
async afterDev() {
|
|
14
|
+
const {
|
|
15
|
+
dev
|
|
16
|
+
} = api.useResolvedConfigContext();
|
|
17
|
+
const {
|
|
18
|
+
internalDirectory
|
|
19
|
+
} = api.useAppContext();
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (!(dev !== null && dev !== void 0 && dev.proxy)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const rule = createProxyRule(internalDirectory, dev.proxy);
|
|
26
|
+
proxyServer = new WhistleProxy({
|
|
27
|
+
port: 8899,
|
|
28
|
+
rule
|
|
29
|
+
});
|
|
30
|
+
await proxyServer.start();
|
|
31
|
+
},
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
beforeExit() {
|
|
34
|
+
var _proxyServer;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// terminate whistle proxy
|
|
37
|
+
(_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
})
|
|
41
|
-
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
42
|
});
|
package/dist/js/node/index.js
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _core = require("@modern-js/core");
|
|
9
|
-
|
|
10
8
|
var _utils = require("@modern-js/utils");
|
|
11
9
|
|
|
12
10
|
var _createProxyRule = require("./utils/createProxyRule");
|
|
@@ -15,44 +13,44 @@ var _whistleProxy = _interopRequireDefault(require("./utils/whistleProxy"));
|
|
|
15
13
|
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
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
|
-
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
}
|
|
16
|
+
var _default = () => {
|
|
17
|
+
let proxyServer;
|
|
18
|
+
return {
|
|
19
|
+
name: '@modern-js/plugin-proxy',
|
|
20
|
+
setup: api => ({
|
|
21
|
+
validateSchema() {
|
|
22
|
+
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
async afterDev() {
|
|
26
|
+
const {
|
|
27
|
+
dev
|
|
28
|
+
} = api.useResolvedConfigContext();
|
|
29
|
+
const {
|
|
30
|
+
internalDirectory
|
|
31
|
+
} = api.useAppContext();
|
|
32
|
+
|
|
33
|
+
if (!(dev !== null && dev !== void 0 && dev.proxy)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const rule = (0, _createProxyRule.createProxyRule)(internalDirectory, dev.proxy);
|
|
38
|
+
proxyServer = new _whistleProxy.default({
|
|
39
|
+
port: 8899,
|
|
40
|
+
rule
|
|
41
|
+
});
|
|
42
|
+
await proxyServer.start();
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
beforeExit() {
|
|
46
|
+
var _proxyServer;
|
|
47
|
+
|
|
48
|
+
// terminate whistle proxy
|
|
49
|
+
(_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
};
|
|
57
55
|
|
|
58
56
|
exports.default = _default;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CliPlugin } from '@modern-js/core';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface DevConfig {
|
|
7
|
-
proxy?: ProxyOptions;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
3
|
+
declare const _default: () => CliPlugin;
|
|
4
|
+
|
|
5
|
+
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createProxyRule: (appDirectory: string, proxyOptions:
|
|
1
|
+
import type { DevProxyOptions } from '@modern-js/core';
|
|
2
|
+
export declare const createProxyRule: (appDirectory: string, proxyOptions: DevProxyOptions) => string;
|
package/jest.config.js
CHANGED
package/modern.config.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.2.
|
|
14
|
+
"version": "1.2.5",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -33,34 +33,26 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7",
|
|
36
|
-
"@modern-js/utils": "^1.
|
|
36
|
+
"@modern-js/utils": "^1.3.7",
|
|
37
37
|
"whistle": "^2.7.18"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/jest": "^26",
|
|
41
41
|
"@types/node": "^14",
|
|
42
42
|
"typescript": "^4",
|
|
43
|
-
"@modern-js/core": "
|
|
43
|
+
"@modern-js/core": "1.6.1",
|
|
44
44
|
"@scripts/build": "0.0.0",
|
|
45
45
|
"jest": "^27",
|
|
46
46
|
"@scripts/jest-config": "0.0.0"
|
|
47
47
|
},
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"@modern-js/core": "^1.3.2"
|
|
50
|
-
},
|
|
51
48
|
"sideEffects": false,
|
|
52
|
-
"modernConfig": {
|
|
53
|
-
"output": {
|
|
54
|
-
"packageMode": "node-js"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
49
|
"publishConfig": {
|
|
58
50
|
"registry": "https://registry.npmjs.org/",
|
|
59
|
-
"access": "public"
|
|
60
|
-
"types": "./dist/types/index.d.ts"
|
|
51
|
+
"access": "public"
|
|
61
52
|
},
|
|
62
53
|
"scripts": {
|
|
63
54
|
"new": "modern new",
|
|
55
|
+
"dev": "modern build --watch",
|
|
64
56
|
"build": "modern build",
|
|
65
57
|
"test": "jest --passWithNoTests"
|
|
66
58
|
},
|