@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 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
@@ -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
- let proxyServer;
6
- export default createPlugin(() => ({
7
- validateSchema() {
8
- return PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
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
- async afterDev() {
12
- /* eslint-disable react-hooks/rules-of-hooks */
13
- const {
14
- dev
15
- } = useResolvedConfigContext();
16
- const {
17
- internalDirectory
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
- if (!(dev !== null && dev !== void 0 && dev.proxy)) {
22
- return;
23
- }
21
+ if (!(dev !== null && dev !== void 0 && dev.proxy)) {
22
+ return;
23
+ }
24
24
 
25
- const rule = createProxyRule(internalDirectory, dev.proxy);
26
- proxyServer = new WhistleProxy({
27
- port: 8899,
28
- rule
29
- });
30
- await proxyServer.start();
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
- beforeExit() {
34
- var _proxyServer;
33
+ beforeExit() {
34
+ var _proxyServer;
35
35
 
36
- // terminate whistle proxy
37
- (_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
38
- }
36
+ // terminate whistle proxy
37
+ (_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
38
+ }
39
39
 
40
- }), {
41
- name: '@modern-js/plugin-proxy'
40
+ })
41
+ };
42
42
  });
@@ -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
- let proxyServer;
19
-
20
- var _default = (0, _core.createPlugin)(() => ({
21
- validateSchema() {
22
- return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
23
- },
24
-
25
- async afterDev() {
26
- /* eslint-disable react-hooks/rules-of-hooks */
27
- const {
28
- dev
29
- } = (0, _core.useResolvedConfigContext)();
30
- const {
31
- internalDirectory
32
- } = (0, _core.useAppContext)();
33
- /* eslint-enable react-hooks/rules-of-hooks */
34
-
35
- if (!(dev !== null && dev !== void 0 && dev.proxy)) {
36
- return;
37
- }
38
-
39
- const rule = (0, _createProxyRule.createProxyRule)(internalDirectory, dev.proxy);
40
- proxyServer = new _whistleProxy.default({
41
- port: 8899,
42
- rule
43
- });
44
- await proxyServer.start();
45
- },
46
-
47
- beforeExit() {
48
- var _proxyServer;
49
-
50
- // terminate whistle proxy
51
- (_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
52
- }
53
-
54
- }), {
55
- name: '@modern-js/plugin-proxy'
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;
@@ -1,9 +1,5 @@
1
- declare const _default: any;
1
+ import type { CliPlugin } from '@modern-js/core';
2
2
 
3
- export default _default;
4
- export declare type ProxyOptions = string | Record<string, string>;
5
- declare module '@modern-js/core' {
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 { ProxyOptions } from '..';
2
- export declare const createProxyRule: (appDirectory: string, proxyOptions: ProxyOptions) => string;
1
+ import type { DevProxyOptions } from '@modern-js/core';
2
+ export declare const createProxyRule: (appDirectory: string, proxyOptions: DevProxyOptions) => string;
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };
package/modern.config.js CHANGED
@@ -1,2 +1,6 @@
1
1
  /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {};
2
+ module.exports = {
3
+ output: {
4
+ packageMode: 'node-js',
5
+ },
6
+ };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.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.2.2",
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": "^1.3.2",
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
  },