@modern-js/server 1.4.14 → 1.4.17
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 +56 -0
- package/dist/js/modern/constants.js +19 -16
- package/dist/js/modern/dev-tools/dev-server-plugin.js +9 -17
- package/dist/js/modern/server/dev-server.js +22 -10
- package/dist/js/node/constants.js +21 -17
- package/dist/js/node/dev-tools/dev-server-plugin.js +9 -20
- package/dist/js/node/server/dev-server.js +21 -10
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/dev-tools/dev-server-plugin.d.ts +2 -2
- package/dist/types/dev-tools/socket-server.d.ts +2 -2
- package/dist/types/server/dev-server.d.ts +1 -0
- package/dist/types/types.d.ts +7 -7
- package/package.json +11 -17
- package/dist/js/modern/dev-tools/launch-editor/index.js +0 -25
- package/dist/js/node/dev-tools/launch-editor/index.js +0 -35
- package/dist/types/dev-tools/launch-editor/index.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @modern-js/server
|
|
2
2
|
|
|
3
|
+
## 1.4.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d4afeba71: fix: remove cors for prod-server
|
|
8
|
+
- f8e713253: fix(server): using correct webpack instance
|
|
9
|
+
- Updated dependencies [6c8ab42dd]
|
|
10
|
+
- Updated dependencies [ed90859ba]
|
|
11
|
+
- Updated dependencies [0ef2431cb]
|
|
12
|
+
- Updated dependencies [d4afeba71]
|
|
13
|
+
- @modern-js/webpack@1.9.1
|
|
14
|
+
- @modern-js/prod-server@1.1.7
|
|
15
|
+
|
|
16
|
+
## 1.4.16
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- f7cbc771: feat: prebundle webpack-dev-middleware
|
|
21
|
+
- cdc2df9c: fix(server): remove launch-editor
|
|
22
|
+
- b39b399e: lock devcert version
|
|
23
|
+
- 430d417e: optimize server side hot reload
|
|
24
|
+
- 437367c6: fix(server): hmr not working when using proxy
|
|
25
|
+
- Updated dependencies [5f7fccf0]
|
|
26
|
+
- Updated dependencies [02b0a22e]
|
|
27
|
+
- Updated dependencies [da65bf12]
|
|
28
|
+
- Updated dependencies [8854c600]
|
|
29
|
+
- Updated dependencies [d57e7622]
|
|
30
|
+
- Updated dependencies [f7cbc771]
|
|
31
|
+
- Updated dependencies [6451a098]
|
|
32
|
+
- Updated dependencies [f5c48c3f]
|
|
33
|
+
- Updated dependencies [430d417e]
|
|
34
|
+
- Updated dependencies [658b4dd5]
|
|
35
|
+
- Updated dependencies [d5a2cfd8]
|
|
36
|
+
- Updated dependencies [45d5643a]
|
|
37
|
+
- Updated dependencies [0d161fa8]
|
|
38
|
+
- Updated dependencies [437367c6]
|
|
39
|
+
- Updated dependencies [280eebf9]
|
|
40
|
+
- Updated dependencies [2ba8d62f]
|
|
41
|
+
- Updated dependencies [7394df61]
|
|
42
|
+
- @modern-js/webpack@1.9.0
|
|
43
|
+
- @modern-js/bff-utils@1.2.8
|
|
44
|
+
- @modern-js/utils@1.7.6
|
|
45
|
+
- @modern-js/prod-server@1.1.6
|
|
46
|
+
- @modern-js/server-utils@1.2.9
|
|
47
|
+
|
|
48
|
+
## 1.4.15
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- b8cfc42cd: feat: prebundle tsconfig-paths and nanoid
|
|
53
|
+
- Updated dependencies [b8cfc42cd]
|
|
54
|
+
- Updated dependencies [804a5bb8a]
|
|
55
|
+
- @modern-js/utils@1.7.4
|
|
56
|
+
- @modern-js/prod-server@1.1.5
|
|
57
|
+
- @modern-js/server-utils@1.2.6
|
|
58
|
+
|
|
3
59
|
## 1.4.14
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { HMR_SOCK_PATH } from '@modern-js/utils';
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { getIpv4Interfaces, HMR_SOCK_PATH } from '@modern-js/utils';
|
|
2
|
+
export const getDefaultDevOptions = () => {
|
|
3
|
+
const network = getIpv4Interfaces().find(item => !item.internal);
|
|
4
|
+
return {
|
|
5
|
+
client: {
|
|
6
|
+
port: '8080',
|
|
7
|
+
overlay: false,
|
|
8
|
+
logging: 'none',
|
|
9
|
+
path: HMR_SOCK_PATH,
|
|
10
|
+
host: (network === null || network === void 0 ? void 0 : network.address) || 'localhost'
|
|
11
|
+
},
|
|
12
|
+
https: false,
|
|
13
|
+
devMiddleware: {
|
|
14
|
+
writeToDisk: true
|
|
15
|
+
},
|
|
16
|
+
watch: true,
|
|
17
|
+
hot: true,
|
|
18
|
+
liveReload: true
|
|
19
|
+
};
|
|
17
20
|
};
|
|
@@ -1,14 +1,9 @@
|
|
|
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
1
|
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
2
|
|
|
7
|
-
import
|
|
8
|
-
import { DEFAULT_DEV_OPTIONS } from "../constants";
|
|
3
|
+
import { webpack } from '@modern-js/webpack';
|
|
9
4
|
const {
|
|
10
5
|
EntryPlugin
|
|
11
|
-
} =
|
|
6
|
+
} = webpack;
|
|
12
7
|
export default class DevServerPlugin {
|
|
13
8
|
constructor(options) {
|
|
14
9
|
_defineProperty(this, "options", void 0);
|
|
@@ -18,14 +13,11 @@ export default class DevServerPlugin {
|
|
|
18
13
|
|
|
19
14
|
apply(compiler) {
|
|
20
15
|
const {
|
|
21
|
-
|
|
22
|
-
} = this;
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const host = `&host=${client.host}`;
|
|
27
|
-
const path = `&path=${client.path}`;
|
|
28
|
-
const port = `&port=${client.port}`;
|
|
16
|
+
client
|
|
17
|
+
} = this.options;
|
|
18
|
+
const host = client.host ? `&host=${client.host}` : '';
|
|
19
|
+
const path = client.path ? `&path=${client.path}` : '';
|
|
20
|
+
const port = client.port ? `&port=${client.port}` : '';
|
|
29
21
|
const clientEntry = `${require.resolve('@modern-js/hmr-client')}?${host}${path}${port}`;
|
|
30
22
|
const additionalEntries = [clientEntry]; // use a hook to add entries if available
|
|
31
23
|
|
|
@@ -39,9 +31,9 @@ export default class DevServerPlugin {
|
|
|
39
31
|
const compilerOptions = compiler.options;
|
|
40
32
|
compilerOptions.plugins = compilerOptions.plugins || [];
|
|
41
33
|
|
|
42
|
-
if (!compilerOptions.plugins.find(p => p.constructor ===
|
|
34
|
+
if (!compilerOptions.plugins.find(p => p.constructor === webpack.HotModuleReplacementPlugin)) {
|
|
43
35
|
// apply the HMR plugin, if it didn't exist before.
|
|
44
|
-
const plugin = new
|
|
36
|
+
const plugin = new webpack.HotModuleReplacementPlugin();
|
|
45
37
|
plugin.apply(compiler);
|
|
46
38
|
}
|
|
47
39
|
}
|
|
@@ -8,13 +8,12 @@ import { createServer } from 'http';
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import { createServer as createHttpsServer } from 'https';
|
|
10
10
|
import { API_DIR, SERVER_DIR, SHARED_DIR } from '@modern-js/utils';
|
|
11
|
-
import webpackDevMiddleware from 'webpack-dev-middleware';
|
|
11
|
+
import webpackDevMiddleware from '@modern-js/webpack/webpack-dev-middleware';
|
|
12
12
|
import { createProxyHandler, ModernServer, AGGRED_DIR } from '@modern-js/prod-server';
|
|
13
|
-
import {
|
|
13
|
+
import { getDefaultDevOptions } from "../constants";
|
|
14
14
|
import { createMockHandler } from "../dev-tools/mock";
|
|
15
15
|
import SocketServer from "../dev-tools/socket-server";
|
|
16
16
|
import DevServerPlugin from "../dev-tools/dev-server-plugin";
|
|
17
|
-
import { createLaunchEditorHandler } from "../dev-tools/launch-editor";
|
|
18
17
|
import { enableRegister } from "../dev-tools/babel/register";
|
|
19
18
|
import Watcher from "../dev-tools/watcher";
|
|
20
19
|
export class ModernDevServer extends ModernServer {
|
|
@@ -37,8 +36,16 @@ export class ModernDevServer extends ModernServer {
|
|
|
37
36
|
|
|
38
37
|
this.compiler = options.compiler; // set dev server options, like webpack-dev-server
|
|
39
38
|
|
|
40
|
-
this.dev =
|
|
39
|
+
this.dev = this.getDevOptions(options);
|
|
41
40
|
enableRegister(this.pwd, this.conf);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getDevOptions(options) {
|
|
44
|
+
const devOptions = typeof options.dev === 'boolean' ? {} : options.dev;
|
|
45
|
+
const defaultOptions = getDefaultDevOptions();
|
|
46
|
+
return _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), devOptions), {}, {
|
|
47
|
+
client: _objectSpread(_objectSpread({}, defaultOptions.client), devOptions === null || devOptions === void 0 ? void 0 : devOptions.client)
|
|
48
|
+
});
|
|
42
49
|
} // Complete the preparation of services
|
|
43
50
|
|
|
44
51
|
|
|
@@ -62,6 +69,15 @@ export class ModernDevServer extends ModernServer {
|
|
|
62
69
|
} = ctx;
|
|
63
70
|
return handler(req, res, next);
|
|
64
71
|
});
|
|
72
|
+
});
|
|
73
|
+
this.addHandler((ctx, next) => {
|
|
74
|
+
// allow hmr request cross-domain, because the user may use global proxy
|
|
75
|
+
if (ctx.path.includes('hot-update')) {
|
|
76
|
+
ctx.res.setHeader('Access-Control-Allow-Origin', '*');
|
|
77
|
+
ctx.res.setHeader('Access-Control-Allow-Credentials', 'false');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
next();
|
|
65
81
|
}); // mock handler
|
|
66
82
|
|
|
67
83
|
this.mockHandler = createMockHandler({
|
|
@@ -86,9 +102,7 @@ export class ModernDevServer extends ModernServer {
|
|
|
86
102
|
|
|
87
103
|
if (compiler) {
|
|
88
104
|
// init socket server
|
|
89
|
-
this.socketServer = new SocketServer(dev); //
|
|
90
|
-
|
|
91
|
-
this.addHandler(createLaunchEditorHandler()); // setup compiler in server, also add dev-middleware to handler static file in memory
|
|
105
|
+
this.socketServer = new SocketServer(dev); // setup compiler in server, also add dev-middleware to handler static file in memory
|
|
92
106
|
|
|
93
107
|
const devMiddlewareHandler = this.setupCompiler(compiler);
|
|
94
108
|
this.addHandler(devMiddlewareHandler);
|
|
@@ -138,9 +152,7 @@ export class ModernDevServer extends ModernServer {
|
|
|
138
152
|
|
|
139
153
|
this.cleanSSRCache(); // reset static file
|
|
140
154
|
|
|
141
|
-
this.reader.updateFile();
|
|
142
|
-
|
|
143
|
-
this.runner.reset();
|
|
155
|
+
this.reader.updateFile();
|
|
144
156
|
super.onRepack(options);
|
|
145
157
|
}
|
|
146
158
|
|
|
@@ -3,24 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getDefaultDevOptions = void 0;
|
|
7
7
|
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
const getDefaultDevOptions = () => {
|
|
11
|
+
const network = (0, _utils.getIpv4Interfaces)().find(item => !item.internal);
|
|
12
|
+
return {
|
|
13
|
+
client: {
|
|
14
|
+
port: '8080',
|
|
15
|
+
overlay: false,
|
|
16
|
+
logging: 'none',
|
|
17
|
+
path: _utils.HMR_SOCK_PATH,
|
|
18
|
+
host: (network === null || network === void 0 ? void 0 : network.address) || 'localhost'
|
|
19
|
+
},
|
|
20
|
+
https: false,
|
|
21
|
+
devMiddleware: {
|
|
22
|
+
writeToDisk: true
|
|
23
|
+
},
|
|
24
|
+
watch: true,
|
|
25
|
+
hot: true,
|
|
26
|
+
liveReload: true
|
|
27
|
+
};
|
|
25
28
|
};
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
exports.getDefaultDevOptions = getDefaultDevOptions;
|
|
@@ -5,21 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _webpack =
|
|
9
|
-
|
|
10
|
-
var _constants = require("../constants");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
8
|
+
var _webpack = require("@modern-js/webpack");
|
|
17
9
|
|
|
18
10
|
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; }
|
|
19
11
|
|
|
20
12
|
const {
|
|
21
13
|
EntryPlugin
|
|
22
|
-
} = _webpack.
|
|
14
|
+
} = _webpack.webpack;
|
|
23
15
|
|
|
24
16
|
class DevServerPlugin {
|
|
25
17
|
constructor(options) {
|
|
@@ -30,14 +22,11 @@ class DevServerPlugin {
|
|
|
30
22
|
|
|
31
23
|
apply(compiler) {
|
|
32
24
|
const {
|
|
33
|
-
|
|
34
|
-
} = this;
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const host = `&host=${client.host}`;
|
|
39
|
-
const path = `&path=${client.path}`;
|
|
40
|
-
const port = `&port=${client.port}`;
|
|
25
|
+
client
|
|
26
|
+
} = this.options;
|
|
27
|
+
const host = client.host ? `&host=${client.host}` : '';
|
|
28
|
+
const path = client.path ? `&path=${client.path}` : '';
|
|
29
|
+
const port = client.port ? `&port=${client.port}` : '';
|
|
41
30
|
const clientEntry = `${require.resolve('@modern-js/hmr-client')}?${host}${path}${port}`;
|
|
42
31
|
const additionalEntries = [clientEntry]; // use a hook to add entries if available
|
|
43
32
|
|
|
@@ -51,9 +40,9 @@ class DevServerPlugin {
|
|
|
51
40
|
const compilerOptions = compiler.options;
|
|
52
41
|
compilerOptions.plugins = compilerOptions.plugins || [];
|
|
53
42
|
|
|
54
|
-
if (!compilerOptions.plugins.find(p => p.constructor === _webpack.
|
|
43
|
+
if (!compilerOptions.plugins.find(p => p.constructor === _webpack.webpack.HotModuleReplacementPlugin)) {
|
|
55
44
|
// apply the HMR plugin, if it didn't exist before.
|
|
56
|
-
const plugin = new _webpack.
|
|
45
|
+
const plugin = new _webpack.webpack.HotModuleReplacementPlugin();
|
|
57
46
|
plugin.apply(compiler);
|
|
58
47
|
}
|
|
59
48
|
}
|
|
@@ -13,7 +13,7 @@ var _https = require("https");
|
|
|
13
13
|
|
|
14
14
|
var _utils = require("@modern-js/utils");
|
|
15
15
|
|
|
16
|
-
var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
|
|
16
|
+
var _webpackDevMiddleware = _interopRequireDefault(require("@modern-js/webpack/webpack-dev-middleware"));
|
|
17
17
|
|
|
18
18
|
var _prodServer = require("@modern-js/prod-server");
|
|
19
19
|
|
|
@@ -25,8 +25,6 @@ var _socketServer = _interopRequireDefault(require("../dev-tools/socket-server")
|
|
|
25
25
|
|
|
26
26
|
var _devServerPlugin = _interopRequireDefault(require("../dev-tools/dev-server-plugin"));
|
|
27
27
|
|
|
28
|
-
var _launchEditor = require("../dev-tools/launch-editor");
|
|
29
|
-
|
|
30
28
|
var _register = require("../dev-tools/babel/register");
|
|
31
29
|
|
|
32
30
|
var _watcher = _interopRequireDefault(require("../dev-tools/watcher"));
|
|
@@ -59,8 +57,16 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
59
57
|
|
|
60
58
|
this.compiler = options.compiler; // set dev server options, like webpack-dev-server
|
|
61
59
|
|
|
62
|
-
this.dev =
|
|
60
|
+
this.dev = this.getDevOptions(options);
|
|
63
61
|
(0, _register.enableRegister)(this.pwd, this.conf);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getDevOptions(options) {
|
|
65
|
+
const devOptions = typeof options.dev === 'boolean' ? {} : options.dev;
|
|
66
|
+
const defaultOptions = (0, _constants.getDefaultDevOptions)();
|
|
67
|
+
return _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), devOptions), {}, {
|
|
68
|
+
client: _objectSpread(_objectSpread({}, defaultOptions.client), devOptions === null || devOptions === void 0 ? void 0 : devOptions.client)
|
|
69
|
+
});
|
|
64
70
|
} // Complete the preparation of services
|
|
65
71
|
|
|
66
72
|
|
|
@@ -84,6 +90,15 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
84
90
|
} = ctx;
|
|
85
91
|
return handler(req, res, next);
|
|
86
92
|
});
|
|
93
|
+
});
|
|
94
|
+
this.addHandler((ctx, next) => {
|
|
95
|
+
// allow hmr request cross-domain, because the user may use global proxy
|
|
96
|
+
if (ctx.path.includes('hot-update')) {
|
|
97
|
+
ctx.res.setHeader('Access-Control-Allow-Origin', '*');
|
|
98
|
+
ctx.res.setHeader('Access-Control-Allow-Credentials', 'false');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
next();
|
|
87
102
|
}); // mock handler
|
|
88
103
|
|
|
89
104
|
this.mockHandler = (0, _mock.createMockHandler)({
|
|
@@ -108,9 +123,7 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
108
123
|
|
|
109
124
|
if (compiler) {
|
|
110
125
|
// init socket server
|
|
111
|
-
this.socketServer = new _socketServer.default(dev); //
|
|
112
|
-
|
|
113
|
-
this.addHandler((0, _launchEditor.createLaunchEditorHandler)()); // setup compiler in server, also add dev-middleware to handler static file in memory
|
|
126
|
+
this.socketServer = new _socketServer.default(dev); // setup compiler in server, also add dev-middleware to handler static file in memory
|
|
114
127
|
|
|
115
128
|
const devMiddlewareHandler = this.setupCompiler(compiler);
|
|
116
129
|
this.addHandler(devMiddlewareHandler);
|
|
@@ -160,9 +173,7 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
160
173
|
|
|
161
174
|
this.cleanSSRCache(); // reset static file
|
|
162
175
|
|
|
163
|
-
this.reader.updateFile();
|
|
164
|
-
|
|
165
|
-
this.runner.reset();
|
|
176
|
+
this.reader.updateFile();
|
|
166
177
|
super.onRepack(options);
|
|
167
178
|
}
|
|
168
179
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DevServerOptions } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getDefaultDevOptions: () => DevServerOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { webpack } from '@modern-js/webpack';
|
|
2
2
|
import { DevServerOptions } from '../types';
|
|
3
3
|
export default class DevServerPlugin {
|
|
4
4
|
private readonly options;
|
|
5
5
|
constructor(options: DevServerOptions);
|
|
6
|
-
apply(compiler:
|
|
6
|
+
apply(compiler: webpack.Compiler): void;
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Server } from 'http';
|
|
3
3
|
import ws from 'ws';
|
|
4
|
-
import type {
|
|
4
|
+
import type { webpack } from '@modern-js/webpack';
|
|
5
5
|
import { DevServerOptions } from '../types';
|
|
6
6
|
export default class SocketServer {
|
|
7
7
|
private wsServer;
|
|
@@ -12,7 +12,7 @@ export default class SocketServer {
|
|
|
12
12
|
private timer;
|
|
13
13
|
constructor(options: DevServerOptions);
|
|
14
14
|
prepare(app: Server): void;
|
|
15
|
-
updateStats(stats: Stats): void;
|
|
15
|
+
updateStats(stats: webpack.Stats): void;
|
|
16
16
|
sockWrite(type: string, data?: Record<string, any> | string | boolean): void;
|
|
17
17
|
singleWrite(socket: ws, type: string, data?: Record<string, any> | string | boolean): void;
|
|
18
18
|
close(): void;
|
|
@@ -10,6 +10,7 @@ export declare class ModernDevServer extends ModernServer {
|
|
|
10
10
|
private watcher;
|
|
11
11
|
private devMiddleware;
|
|
12
12
|
constructor(options: ModernDevServerOptions);
|
|
13
|
+
private getDevOptions;
|
|
13
14
|
onInit(runner: ServerHookRunner): Promise<void>;
|
|
14
15
|
onClose(): Promise<void>;
|
|
15
16
|
onRepack(options?: BuildOptions): void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ModernServerOptions } from '@modern-js/prod-server';
|
|
2
|
-
import type
|
|
2
|
+
import type { webpack } from '@modern-js/webpack';
|
|
3
3
|
export declare type DevServerOptions = {
|
|
4
4
|
client: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
path?: string;
|
|
6
|
+
port?: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
logging?: string;
|
|
9
|
+
overlay?: boolean;
|
|
10
10
|
progress?: boolean;
|
|
11
11
|
};
|
|
12
12
|
devMiddleware: {
|
|
@@ -23,6 +23,6 @@ export declare type DevServerOptions = {
|
|
|
23
23
|
};
|
|
24
24
|
export declare type ExtraOptions = {
|
|
25
25
|
dev?: boolean | Partial<DevServerOptions>;
|
|
26
|
-
compiler?:
|
|
26
|
+
compiler?: webpack.MultiCompiler | webpack.Compiler | null;
|
|
27
27
|
};
|
|
28
28
|
export declare type ModernDevServerOptions = ModernServerOptions & ExtraOptions;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.17",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -30,38 +30,31 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/core": "^7.17.0",
|
|
32
32
|
"@babel/register": "^7.15.3",
|
|
33
|
-
"@modern-js/bff-utils": "^1.2.
|
|
33
|
+
"@modern-js/bff-utils": "^1.2.8",
|
|
34
34
|
"@modern-js/hmr-client": "^1.2.7",
|
|
35
|
-
"@modern-js/prod-server": "^1.1.
|
|
36
|
-
"@modern-js/server-utils": "^1.2.
|
|
37
|
-
"@modern-js/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
35
|
+
"@modern-js/prod-server": "^1.1.7",
|
|
36
|
+
"@modern-js/server-utils": "^1.2.9",
|
|
37
|
+
"@modern-js/webpack": "^1.9.1",
|
|
38
|
+
"@modern-js/utils": "^1.7.6",
|
|
39
|
+
"devcert": "1.2.0",
|
|
40
40
|
"minimatch": "^3.0.4",
|
|
41
41
|
"path-to-regexp": "^6.2.0",
|
|
42
|
-
"tsconfig-paths": "^3.11.0",
|
|
43
|
-
"webpack-dev-middleware": "^5.0.0",
|
|
44
42
|
"ws": "^8.2.0"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
|
-
"@modern-js/core": "1.
|
|
45
|
+
"@modern-js/core": "1.11.1",
|
|
48
46
|
"@modern-js/server-core": "1.3.5",
|
|
49
|
-
"@modern-js/types": "1.5.
|
|
47
|
+
"@modern-js/types": "1.5.4",
|
|
50
48
|
"@scripts/build": "0.0.0",
|
|
51
49
|
"@scripts/jest-config": "0.0.0",
|
|
52
50
|
"@types/jest": "^27",
|
|
53
51
|
"@types/minimatch": "^3.0.5",
|
|
54
52
|
"@types/node": "^14",
|
|
55
|
-
"@types/webpack-dev-middleware": "^5.0.2",
|
|
56
53
|
"@types/ws": "^7.4.7",
|
|
57
54
|
"jest": "^27",
|
|
58
55
|
"typescript": "^4",
|
|
59
|
-
"webpack": "^5.71.0",
|
|
60
56
|
"websocket": "^1"
|
|
61
57
|
},
|
|
62
|
-
"peerDependencies": {
|
|
63
|
-
"webpack": "^5.54.0"
|
|
64
|
-
},
|
|
65
58
|
"sideEffects": false,
|
|
66
59
|
"modernConfig": {
|
|
67
60
|
"output": {
|
|
@@ -89,7 +82,8 @@
|
|
|
89
82
|
"files": [
|
|
90
83
|
"src/**/*",
|
|
91
84
|
"tsconfig.json",
|
|
92
|
-
"package.json"
|
|
85
|
+
"package.json",
|
|
86
|
+
"tests/**/*"
|
|
93
87
|
],
|
|
94
88
|
"output": []
|
|
95
89
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { LAUNCH_EDITOR_ENDPOINT, logger } from '@modern-js/utils';
|
|
2
|
-
export const createLaunchEditorHandler = // eslint-disable-next-line consistent-return
|
|
3
|
-
() => (ctx, next) => {
|
|
4
|
-
if (ctx.url.startsWith(LAUNCH_EDITOR_ENDPOINT)) {
|
|
5
|
-
const {
|
|
6
|
-
filename,
|
|
7
|
-
line = 1,
|
|
8
|
-
column = 1
|
|
9
|
-
} = ctx.query;
|
|
10
|
-
|
|
11
|
-
if (!filename) {
|
|
12
|
-
ctx.status = 500;
|
|
13
|
-
ctx.res.end(`launch-editor-middleware: required query param "filename" is missing.`);
|
|
14
|
-
} else {
|
|
15
|
-
require('launch-editor')(`${filename}:${line}:${column}`, 'code', (file, errorMessage) => {
|
|
16
|
-
logger.error(`Launch ${file} in editor failed.\n${errorMessage}`);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
ctx.status = 200;
|
|
20
|
-
ctx.res.end();
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
return next();
|
|
24
|
-
}
|
|
25
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createLaunchEditorHandler = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
|
-
const createLaunchEditorHandler = // eslint-disable-next-line consistent-return
|
|
11
|
-
() => (ctx, next) => {
|
|
12
|
-
if (ctx.url.startsWith(_utils.LAUNCH_EDITOR_ENDPOINT)) {
|
|
13
|
-
const {
|
|
14
|
-
filename,
|
|
15
|
-
line = 1,
|
|
16
|
-
column = 1
|
|
17
|
-
} = ctx.query;
|
|
18
|
-
|
|
19
|
-
if (!filename) {
|
|
20
|
-
ctx.status = 500;
|
|
21
|
-
ctx.res.end(`launch-editor-middleware: required query param "filename" is missing.`);
|
|
22
|
-
} else {
|
|
23
|
-
require('launch-editor')(`${filename}:${line}:${column}`, 'code', (file, errorMessage) => {
|
|
24
|
-
_utils.logger.error(`Launch ${file} in editor failed.\n${errorMessage}`);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
ctx.status = 200;
|
|
28
|
-
ctx.res.end();
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
return next();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
exports.createLaunchEditorHandler = createLaunchEditorHandler;
|