@modern-js/plugin-proxy 1.2.2 → 1.2.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,21 @@
1
1
  # @modern-js/plugin-proxy
2
2
 
3
+ ## 1.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 9b2640fe: fix: dev.proxy type not work
8
+ - Updated dependencies [5bf5868d]
9
+ - Updated dependencies [80d3cfb7]
10
+ - Updated dependencies [42c6b136]
11
+ - Updated dependencies [4e7dcbd5]
12
+ - Updated dependencies [9e8bc4ab]
13
+ - Updated dependencies [0c556e59]
14
+ - Updated dependencies [80d8ddfe]
15
+ - Updated dependencies [2008fdbd]
16
+ - @modern-js/utils@1.3.5
17
+ - @modern-js/core@1.5.0
18
+
3
19
  ## 1.2.2
4
20
 
5
21
  ### Patch Changes
@@ -1,42 +1,43 @@
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
+ import "./types";
5
+ export default (() => {
6
+ let proxyServer;
7
+ return {
8
+ name: '@modern-js/plugin-proxy',
9
+ setup: api => ({
10
+ validateSchema() {
11
+ return PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
12
+ },
10
13
 
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 */
14
+ async afterDev() {
15
+ const {
16
+ dev
17
+ } = api.useResolvedConfigContext();
18
+ const {
19
+ internalDirectory
20
+ } = api.useAppContext();
20
21
 
21
- if (!(dev !== null && dev !== void 0 && dev.proxy)) {
22
- return;
23
- }
22
+ if (!(dev !== null && dev !== void 0 && dev.proxy)) {
23
+ return;
24
+ }
24
25
 
25
- const rule = createProxyRule(internalDirectory, dev.proxy);
26
- proxyServer = new WhistleProxy({
27
- port: 8899,
28
- rule
29
- });
30
- await proxyServer.start();
31
- },
26
+ const rule = createProxyRule(internalDirectory, dev.proxy);
27
+ proxyServer = new WhistleProxy({
28
+ port: 8899,
29
+ rule
30
+ });
31
+ await proxyServer.start();
32
+ },
32
33
 
33
- beforeExit() {
34
- var _proxyServer;
34
+ beforeExit() {
35
+ var _proxyServer;
35
36
 
36
- // terminate whistle proxy
37
- (_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
38
- }
37
+ // terminate whistle proxy
38
+ (_proxyServer = proxyServer) === null || _proxyServer === void 0 ? void 0 : _proxyServer.close();
39
+ }
39
40
 
40
- }), {
41
- name: '@modern-js/plugin-proxy'
41
+ })
42
+ };
42
43
  });
@@ -0,0 +1 @@
1
+ import '@modern-js/core';
@@ -5,54 +5,54 @@ 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");
13
11
 
14
12
  var _whistleProxy = _interopRequireDefault(require("./utils/whistleProxy"));
15
13
 
14
+ require("./types");
15
+
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
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
- });
18
+ var _default = () => {
19
+ let proxyServer;
20
+ return {
21
+ name: '@modern-js/plugin-proxy',
22
+ setup: api => ({
23
+ validateSchema() {
24
+ return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-proxy'];
25
+ },
26
+
27
+ async afterDev() {
28
+ const {
29
+ dev
30
+ } = api.useResolvedConfigContext();
31
+ const {
32
+ internalDirectory
33
+ } = api.useAppContext();
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
+ };
56
+ };
57
57
 
58
58
  exports.default = _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ require("@modern-js/core");
@@ -1,9 +1,6 @@
1
- declare const _default: any;
1
+ import type { CliPlugin } from '@modern-js/core';
2
+ import './types';
2
3
 
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
- }
4
+ declare const _default: () => CliPlugin;
5
+
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import '@modern-js/core';
2
+ export declare type ProxyOptions = string | Record<string, string>;
3
+ declare module '@modern-js/core' {
4
+ interface DevConfig {
5
+ proxy?: ProxyOptions;
6
+ }
7
+ }
@@ -1,2 +1,2 @@
1
- import type { ProxyOptions } from '..';
1
+ import type { ProxyOptions } from '../types';
2
2
  export declare const createProxyRule: (appDirectory: string, proxyOptions: ProxyOptions) => string;
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,12 +11,22 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.2",
14
+ "version": "1.2.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
18
18
  "module": "./dist/js/treeshaking/index.js",
19
19
  "jsnext:modern": "./dist/js/modern/index.js",
20
+ "typesVersions": {
21
+ "*": {
22
+ ".": [
23
+ "./dist/types/index.d.ts"
24
+ ],
25
+ "types": [
26
+ "./dist/types/types.d.ts"
27
+ ]
28
+ }
29
+ },
20
30
  "exports": {
21
31
  ".": {
22
32
  "node": {
@@ -29,38 +39,41 @@
29
39
  "./cli": {
30
40
  "jsnext:source": "./src/index.ts",
31
41
  "default": "./dist/js/node/index.js"
42
+ },
43
+ "./types": {
44
+ "node": {
45
+ "import": "./dist/js/modern/types.js",
46
+ "require": "./dist/js/node/types.js",
47
+ "types": "./dist/types/types.d.ts"
48
+ },
49
+ "default": "./dist/js/treeshaking/types.js"
32
50
  }
33
51
  },
34
52
  "dependencies": {
35
53
  "@babel/runtime": "^7",
36
- "@modern-js/utils": "^1.2.2",
54
+ "@modern-js/utils": "^1.3.5",
37
55
  "whistle": "^2.7.18"
38
56
  },
39
57
  "devDependencies": {
40
58
  "@types/jest": "^26",
41
59
  "@types/node": "^14",
42
60
  "typescript": "^4",
43
- "@modern-js/core": "^1.3.2",
61
+ "@modern-js/core": "^1.5.0",
44
62
  "@scripts/build": "0.0.0",
45
63
  "jest": "^27",
46
64
  "@scripts/jest-config": "0.0.0"
47
65
  },
48
66
  "peerDependencies": {
49
- "@modern-js/core": "^1.3.2"
67
+ "@modern-js/core": "^1.5.0"
50
68
  },
51
69
  "sideEffects": false,
52
- "modernConfig": {
53
- "output": {
54
- "packageMode": "node-js"
55
- }
56
- },
57
70
  "publishConfig": {
58
71
  "registry": "https://registry.npmjs.org/",
59
- "access": "public",
60
- "types": "./dist/types/index.d.ts"
72
+ "access": "public"
61
73
  },
62
74
  "scripts": {
63
75
  "new": "modern new",
76
+ "dev": "modern build --watch",
64
77
  "build": "modern build",
65
78
  "test": "jest --passWithNoTests"
66
79
  },