@modern-js/server 2.0.0-beta.0 → 2.0.0-beta.2

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/dist/js/modern/dev-tools/dev-middleware/dev-server-plugin.js +4 -9
  3. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +2 -5
  4. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/index.js +43 -50
  5. package/dist/js/modern/dev-tools/dev-middleware/index.js +14 -32
  6. package/dist/js/modern/dev-tools/dev-middleware/socket-server.js +18 -43
  7. package/dist/js/modern/dev-tools/https/index.js +0 -2
  8. package/dist/js/modern/dev-tools/mock/getMockData.js +4 -23
  9. package/dist/js/modern/dev-tools/mock/index.js +0 -8
  10. package/dist/js/modern/dev-tools/register/index.js +5 -20
  11. package/dist/js/modern/dev-tools/watcher/dependency-tree.js +5 -15
  12. package/dist/js/modern/dev-tools/watcher/index.js +0 -18
  13. package/dist/js/modern/dev-tools/watcher/stats-cache.js +0 -16
  14. package/dist/js/modern/index.js +0 -1
  15. package/dist/js/modern/server/dev-server.js +38 -56
  16. package/dist/js/modern/server/index.js +0 -4
  17. package/dist/js/node/constants.js +0 -3
  18. package/dist/js/node/dev-tools/dev-middleware/dev-server-plugin.js +4 -11
  19. package/dist/js/node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +2 -8
  20. package/dist/js/node/dev-tools/dev-middleware/hmr-client/index.js +41 -53
  21. package/dist/js/node/dev-tools/dev-middleware/index.js +14 -38
  22. package/dist/js/node/dev-tools/dev-middleware/socket-server.js +18 -48
  23. package/dist/js/node/dev-tools/https/index.js +0 -7
  24. package/dist/js/node/dev-tools/mock/getMockData.js +4 -29
  25. package/dist/js/node/dev-tools/mock/index.js +0 -17
  26. package/dist/js/node/dev-tools/register/index.js +5 -29
  27. package/dist/js/node/dev-tools/watcher/dependency-tree.js +5 -19
  28. package/dist/js/node/dev-tools/watcher/index.js +0 -32
  29. package/dist/js/node/dev-tools/watcher/stats-cache.js +0 -23
  30. package/dist/js/node/index.js +0 -4
  31. package/dist/js/node/server/dev-server.js +38 -75
  32. package/dist/js/node/server/index.js +0 -7
  33. package/dist/types/dev-tools/mock/getMockData.d.ts +0 -2
  34. package/dist/types/dev-tools/watcher/dependency-tree.d.ts +0 -2
  35. package/dist/types/index.d.ts +0 -2
  36. package/package.json +13 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,100 @@
1
1
  # @modern-js/server
2
2
 
3
+ ## 2.0.0-beta.2
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Patch Changes
10
+
11
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
12
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
13
+ - 61f21d1e77: fix: ignore the entire distPath for pia ssr bundle
14
+ fix: dist 目录的产物不应该被 ts-node 编译
15
+ - ebbeed1: chore: dev server default cross origin
16
+ chore: 开发环境 Server 默认跨域
17
+ - 14b712da84: fix: use consistent alias type and default value across packages
18
+
19
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
20
+
21
+ - Updated dependencies [9b915e0c10]
22
+ - Updated dependencies [c9e800d39a]
23
+ - Updated dependencies [d032d49]
24
+ - Updated dependencies [15bf09d9c8]
25
+ - Updated dependencies [92f0ead]
26
+ - Updated dependencies [edd1cfb1af]
27
+ - Updated dependencies [cc971eabfc]
28
+ - Updated dependencies [5b9049f2e9]
29
+ - Updated dependencies [6bda14ed71]
30
+ - Updated dependencies [a8642da58f]
31
+ - Updated dependencies [92004d1]
32
+ - Updated dependencies [b8bbe036c7]
33
+ - Updated dependencies [40ed587]
34
+ - Updated dependencies [87c1ff8]
35
+ - Updated dependencies [c2bb0f1]
36
+ - Updated dependencies [d5a31df781]
37
+ - Updated dependencies [dda38c9c3e]
38
+ - Updated dependencies [102d32e4ba]
39
+ - Updated dependencies [8b8e1bb571]
40
+ - Updated dependencies [3bbea92b2a]
41
+ - Updated dependencies [73cd29dd9f]
42
+ - Updated dependencies [18aaf42]
43
+ - Updated dependencies [abf3421a75]
44
+ - Updated dependencies [543be9558e]
45
+ - Updated dependencies [14b712da84]
46
+ - @modern-js/server-utils@2.0.0-beta.2
47
+ - @modern-js/prod-server@2.0.0-beta.2
48
+ - @modern-js/utils@2.0.0-beta.2
49
+ - @modern-js/types@2.0.0-beta.2
50
+
51
+ ## 2.0.0-beta.1
52
+
53
+ ### Major Changes
54
+
55
+ - dda38c9: chore: v2
56
+
57
+ ### Patch Changes
58
+
59
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
60
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
61
+ - 61f21d1e77: fix: ignore the entire distPath for pia ssr bundle
62
+ fix: dist 目录的产物不应该被 ts-node 编译
63
+ - ebbeed1: chore: dev server default cross origin
64
+ chore: 开发环境 Server 默认跨域
65
+ - 14b712d: fix: use consistent alias type and default value across packages
66
+
67
+ fix: 在各个包中使用一致的 alias 类型定义和默认值
68
+
69
+ - Updated dependencies [9b915e0c10]
70
+ - Updated dependencies [c9e800d39a]
71
+ - Updated dependencies [d032d49]
72
+ - Updated dependencies [15bf09d9c8]
73
+ - Updated dependencies [92f0ead]
74
+ - Updated dependencies [edd1cfb1af]
75
+ - Updated dependencies [cc971eabfc]
76
+ - Updated dependencies [5b9049f]
77
+ - Updated dependencies [6bda14ed71]
78
+ - Updated dependencies [a8642da]
79
+ - Updated dependencies [92004d1]
80
+ - Updated dependencies [b8bbe036c7]
81
+ - Updated dependencies [40ed587]
82
+ - Updated dependencies [87c1ff8]
83
+ - Updated dependencies [d5a31df781]
84
+ - Updated dependencies [dda38c9]
85
+ - Updated dependencies [102d32e4ba]
86
+ - Updated dependencies [8b8e1bb571]
87
+ - Updated dependencies [3bbea92b2a]
88
+ - Updated dependencies [73cd29dd9f]
89
+ - Updated dependencies [18aaf42]
90
+ - Updated dependencies [abf3421]
91
+ - Updated dependencies [543be9558e]
92
+ - Updated dependencies [14b712d]
93
+ - @modern-js/server-utils@2.0.0-beta.1
94
+ - @modern-js/prod-server@2.0.0-beta.1
95
+ - @modern-js/utils@2.0.0-beta.1
96
+ - @modern-js/types@2.0.0-beta.1
97
+
3
98
  ## 2.0.0-beta.0
4
99
 
5
100
  ### Major Changes
@@ -1,12 +1,9 @@
1
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; }
2
-
3
2
  export default class DevServerPlugin {
4
3
  constructor(options) {
5
4
  _defineProperty(this, "options", void 0);
6
-
7
5
  this.options = options;
8
6
  }
9
-
10
7
  injectHMRClient(compiler) {
11
8
  const {
12
9
  client
@@ -14,30 +11,28 @@ export default class DevServerPlugin {
14
11
  const host = client !== null && client !== void 0 && client.host ? `&host=${client.host}` : '';
15
12
  const path = client !== null && client !== void 0 && client.path ? `&path=${client.path}` : '';
16
13
  const port = client !== null && client !== void 0 && client.port ? `&port=${client.port}` : '';
17
- const clientEntry = `${require.resolve("./hmr-client")}?${host}${path}${port}`; // use a hook to add entries if available
14
+ const clientEntry = `${require.resolve("./hmr-client")}?${host}${path}${port}`;
18
15
 
16
+ // use a hook to add entries if available
19
17
  new compiler.webpack.EntryPlugin(compiler.context, clientEntry, {
20
18
  name: undefined
21
19
  }).apply(compiler);
22
20
  }
23
-
24
21
  apply(compiler) {
25
22
  if (this.options.hot || this.options.liveReload) {
26
23
  this.injectHMRClient(compiler);
27
- } // Todo remove, client must inject.
28
-
24
+ }
29
25
 
26
+ // Todo remove, client must inject.
30
27
  const compilerOptions = compiler.options;
31
28
  const {
32
29
  HotModuleReplacementPlugin
33
30
  } = compiler.webpack;
34
31
  compilerOptions.plugins = compilerOptions.plugins || [];
35
-
36
32
  if (!compilerOptions.plugins.find(p => p.constructor === HotModuleReplacementPlugin)) {
37
33
  // apply the HMR plugin, if it didn't exist before.
38
34
  const plugin = new HotModuleReplacementPlugin();
39
35
  plugin.apply(compiler);
40
36
  }
41
37
  }
42
-
43
38
  }
@@ -3,12 +3,10 @@ export function createSocketUrl(resourceQuery) {
3
3
  // ?host=localhost&port=8080&path=modern_js_hmr_ws
4
4
  const searchParams = resourceQuery.substr(1).split('&');
5
5
  const options = {};
6
-
7
6
  for (const pair of searchParams) {
8
7
  const ary = pair.split('=');
9
8
  options[ary[0]] = decodeURIComponent(ary[1]);
10
9
  }
11
-
12
10
  const currentLocation = self.location;
13
11
  return getSocketUrl(options, currentLocation);
14
12
  }
@@ -26,13 +24,12 @@ export function formatURL({
26
24
  url.protocol = protocol;
27
25
  url.pathname = pathname;
28
26
  return url.toString();
29
- } // compatible with IE11
30
-
27
+ }
31
28
 
29
+ // compatible with IE11
32
30
  const colon = protocol.indexOf(':') === -1 ? ':' : '';
33
31
  return `${protocol}${colon}//${hostname}:${port}${pathname}`;
34
32
  }
35
-
36
33
  function getSocketUrl(urlParts, location) {
37
34
  const {
38
35
  host,
@@ -6,7 +6,9 @@
6
6
  */
7
7
  import stripAnsi from '@modern-js/utils/strip-ansi';
8
8
  import { formatWebpackMessages } from '@modern-js/utils/format';
9
- import { createSocketUrl } from "./createSocketUrl"; // declare any to fix the type of `module.hot`
9
+ import { createSocketUrl } from "./createSocketUrl";
10
+
11
+ // declare any to fix the type of `module.hot`
10
12
 
11
13
  // TODO hadRuntimeError should be fixed.
12
14
  // We need to keep track of if there has been a runtime error.
@@ -15,24 +17,25 @@ import { createSocketUrl } from "./createSocketUrl"; // declare any to fix the t
15
17
  // application. This is handled below when we are notified of a compile (code
16
18
  // change).
17
19
  // See https://github.com/facebook/create-react-app/issues/3096
18
- const hadRuntimeError = false; // Connect to Dev Server
20
+ const hadRuntimeError = false;
19
21
 
22
+ // Connect to Dev Server
20
23
  const socketUrl = createSocketUrl(__resourceQuery);
21
- const connection = new WebSocket(socketUrl); // Unlike WebpackDevServer client, we won't try to reconnect
24
+ const connection = new WebSocket(socketUrl);
25
+
26
+ // Unlike WebpackDevServer client, we won't try to reconnect
22
27
  // to avoid spamming the console. Disconnect usually happens
23
28
  // when developer stops the server.
24
-
25
29
  connection.onclose = function () {
26
30
  if (typeof console !== 'undefined' && typeof console.info === 'function') {
27
31
  console.info('The development server has disconnected.\nRefresh the page if necessary.');
28
32
  }
29
- }; // Remember some state related to hot module replacement.
30
-
33
+ };
31
34
 
35
+ // Remember some state related to hot module replacement.
32
36
  let isFirstCompilation = true;
33
37
  let mostRecentCompilationHash = null;
34
38
  let hasCompileErrors = false;
35
-
36
39
  function clearOutdatedErrors() {
37
40
  // Clean up outdated compile errors, if any.
38
41
  // eslint-disable-next-line node/no-unsupported-features/node-builtins, no-console
@@ -42,154 +45,144 @@ function clearOutdatedErrors() {
42
45
  console.clear();
43
46
  }
44
47
  }
45
- } // Successful compilation.
46
-
48
+ }
47
49
 
50
+ // Successful compilation.
48
51
  function handleSuccess() {
49
52
  clearOutdatedErrors();
50
53
  const isHotUpdate = !isFirstCompilation;
51
54
  isFirstCompilation = false;
52
- hasCompileErrors = false; // Attempt to apply hot updates or reload.
55
+ hasCompileErrors = false;
53
56
 
57
+ // Attempt to apply hot updates or reload.
54
58
  if (isHotUpdate) {
55
59
  tryApplyUpdates();
56
60
  }
57
- } // Compilation with warnings (e.g. ESLint).
58
-
61
+ }
59
62
 
63
+ // Compilation with warnings (e.g. ESLint).
60
64
  function handleWarnings(warnings) {
61
65
  clearOutdatedErrors();
62
66
  const isHotUpdate = !isFirstCompilation;
63
67
  isFirstCompilation = false;
64
68
  hasCompileErrors = false;
65
-
66
69
  function printWarnings() {
67
70
  // Print warnings to the console.
68
71
  const formatted = formatWebpackMessages({
69
72
  warnings,
70
73
  errors: []
71
74
  });
72
-
73
75
  if (typeof console !== 'undefined' && typeof console.warn === 'function') {
74
76
  for (let i = 0; i < formatted.warnings.length; i++) {
75
77
  if (i === 5) {
76
78
  console.warn('There were more warnings in other files.\n' + 'You can find a complete log in the terminal.');
77
79
  break;
78
80
  }
79
-
80
81
  console.warn(stripAnsi(formatted.warnings[i]));
81
82
  }
82
83
  }
83
84
  }
85
+ printWarnings();
84
86
 
85
- printWarnings(); // Attempt to apply hot updates or reload.
86
-
87
+ // Attempt to apply hot updates or reload.
87
88
  if (isHotUpdate) {
88
89
  tryApplyUpdates();
89
90
  }
90
- } // Compilation with errors (e.g. syntax error or missing modules).
91
-
91
+ }
92
92
 
93
+ // Compilation with errors (e.g. syntax error or missing modules).
93
94
  function handleErrors(errors) {
94
95
  clearOutdatedErrors();
95
96
  isFirstCompilation = false;
96
- hasCompileErrors = true; // "Massage" webpack messages.
97
+ hasCompileErrors = true;
97
98
 
99
+ // "Massage" webpack messages.
98
100
  const formatted = formatWebpackMessages({
99
101
  errors,
100
102
  warnings: []
101
- }); // Also log them to the console.
103
+ });
102
104
 
105
+ // Also log them to the console.
103
106
  if (typeof console !== 'undefined' && typeof console.error === 'function') {
104
107
  for (const error of formatted.errors) {
105
108
  console.error(stripAnsi(error));
106
109
  }
107
- } // Do not attempt to reload now.
108
- // We will reload on next success instead.
109
-
110
- } // There is a newer version of the code available.
110
+ }
111
111
 
112
+ // Do not attempt to reload now.
113
+ // We will reload on next success instead.
114
+ }
112
115
 
116
+ // There is a newer version of the code available.
113
117
  function handleAvailableHash(hash) {
114
118
  // Update last known compilation hash.
115
119
  mostRecentCompilationHash = hash;
116
- } // Handle messages from the server.
117
-
120
+ }
118
121
 
122
+ // Handle messages from the server.
119
123
  connection.onmessage = function (e) {
120
124
  const message = JSON.parse(e.data);
121
-
122
125
  switch (message.type) {
123
126
  case 'hash':
124
127
  handleAvailableHash(message.data);
125
128
  break;
126
-
127
129
  case 'still-ok':
128
130
  case 'ok':
129
131
  handleSuccess();
130
132
  break;
131
-
132
133
  case 'content-changed':
133
134
  // Triggered when a file from `contentBase` changed.
134
135
  window.location.reload();
135
136
  break;
136
-
137
137
  case 'warnings':
138
138
  handleWarnings(message.data);
139
139
  break;
140
-
141
140
  case 'errors':
142
141
  handleErrors(message.data);
143
142
  break;
144
-
145
- default: // Do nothing.
146
-
143
+ default:
144
+ // Do nothing.
147
145
  }
148
- }; // Is there a newer version of this code available?
149
-
146
+ };
150
147
 
148
+ // Is there a newer version of this code available?
151
149
  function isUpdateAvailable() {
152
150
  // __webpack_hash__ is the hash of the current compilation.
153
151
  // It's a global variable injected by webpack.
154
152
  return mostRecentCompilationHash !== __webpack_hash__;
155
- } // webpack disallows updates in other states.
156
-
153
+ }
157
154
 
155
+ // webpack disallows updates in other states.
158
156
  function canApplyUpdates() {
159
157
  return module.hot.status() === 'idle';
160
- } // Attempt to update code on the fly, fall back to a hard reload.
161
-
158
+ }
162
159
 
160
+ // Attempt to update code on the fly, fall back to a hard reload.
163
161
  function tryApplyUpdates() {
164
162
  if (!module.hot) {
165
163
  // HotModuleReplacementPlugin is not in webpack configuration.
166
164
  window.location.reload();
167
165
  return;
168
166
  }
169
-
170
167
  if (!isUpdateAvailable() || !canApplyUpdates()) {
171
168
  return;
172
169
  }
173
-
174
170
  function handleApplyUpdates(err, updatedModules) {
175
171
  const wantsForcedReload = err || !updatedModules || hadRuntimeError;
176
-
177
172
  if (wantsForcedReload) {
178
173
  window.location.reload();
179
174
  return;
180
175
  }
181
-
182
176
  if (isUpdateAvailable()) {
183
177
  // While we were updating, there was a new update! Do it again.
184
178
  tryApplyUpdates();
185
179
  }
186
- } // https://webpack.github.io/docs/hot-module-replacement.html#check
187
-
180
+ }
188
181
 
189
- const result = module.hot.check(
190
- /* autoApply */
191
- true, handleApplyUpdates); // // webpack 2 returns a Promise instead of invoking a callback
182
+ // https://webpack.github.io/docs/hot-module-replacement.html#check
183
+ const result = module.hot.check( /* autoApply */true, handleApplyUpdates);
192
184
 
185
+ // // webpack 2 returns a Promise instead of invoking a callback
193
186
  if (result !== null && result !== void 0 && result.then) {
194
187
  result.then(updatedModules => {
195
188
  handleApplyUpdates(null, updatedModules);
@@ -1,17 +1,13 @@
1
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
2
  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
3
  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
4
  import { EventEmitter } from 'events';
8
5
  import webpackDevMiddleware from '@modern-js/utils/webpack-dev-middleware';
9
6
  import DevServerPlugin from "./dev-server-plugin";
10
7
  import SocketServer from "./socket-server";
11
-
12
- const noop = () => {// noop
8
+ const noop = () => {
9
+ // noop
13
10
  };
14
-
15
11
  export default class DevMiddleware extends EventEmitter {
16
12
  constructor({
17
13
  compiler,
@@ -19,48 +15,43 @@ export default class DevMiddleware extends EventEmitter {
19
15
  devMiddleware
20
16
  }) {
21
17
  super();
22
-
23
18
  _defineProperty(this, "middleware", void 0);
24
-
25
19
  _defineProperty(this, "compiler", void 0);
26
-
27
20
  _defineProperty(this, "devOptions", void 0);
28
-
29
21
  _defineProperty(this, "socketServer", void 0);
30
-
31
22
  this.compiler = compiler;
32
- this.devOptions = dev; // init socket server
23
+ this.devOptions = dev;
33
24
 
34
- this.socketServer = new SocketServer(dev); // Todo: should remove after abstract dev middleware
25
+ // init socket server
26
+ this.socketServer = new SocketServer(dev);
35
27
 
28
+ // Todo: should remove after abstract dev middleware
36
29
  if (this.compiler) {
37
30
  // setup compiler in server, also add dev-middleware to handler static file in memory
38
31
  // set up plugin to each compiler
39
- this.setupDevServerPlugin(); // register hooks for each compilation, update socket stats if recompiled
40
-
41
- this.setupHooks(); // start dev middleware
42
-
32
+ this.setupDevServerPlugin();
33
+ // register hooks for each compilation, update socket stats if recompiled
34
+ this.setupHooks();
35
+ // start dev middleware
43
36
  this.middleware = this.setupDevMiddleware(devMiddleware);
44
37
  }
45
38
  }
46
-
47
39
  init(app) {
48
40
  app.on('listening', () => {
49
41
  this.socketServer.prepare(app);
50
42
  });
51
43
  app.on('close', async () => {
52
44
  var _this$middleware;
53
-
54
45
  (_this$middleware = this.middleware) === null || _this$middleware === void 0 ? void 0 : _this$middleware.close(noop);
55
46
  this.socketServer.close();
56
47
  });
57
48
  }
58
-
59
49
  setupDevServerPlugin() {
60
50
  const {
61
51
  devOptions
62
- } = this; // apply dev server to client compiler, add hmr client to entry.
52
+ } = this;
63
53
 
54
+ // apply dev server to client compiler, add hmr client to entry.
64
55
  if (this.compiler.compilers) {
65
56
  this.compiler.compilers.forEach(target => {
66
57
  if (this.isClientCompiler(target)) {
@@ -71,21 +62,17 @@ export default class DevMiddleware extends EventEmitter {
71
62
  new DevServerPlugin(devOptions).apply(this.compiler);
72
63
  }
73
64
  }
74
-
75
65
  sockWrite(type, data) {
76
66
  this.socketServer.sockWrite(type, data);
77
67
  }
78
-
79
68
  setupHooks() {
80
69
  const invalidPlugin = () => {
81
70
  this.socketServer.sockWrite('invalid');
82
71
  };
83
-
84
72
  const addHooks = compiler => {
85
73
  if (compiler.name === 'server') {
86
74
  return;
87
75
  }
88
-
89
76
  const {
90
77
  compile,
91
78
  invalid,
@@ -98,14 +85,12 @@ export default class DevMiddleware extends EventEmitter {
98
85
  this.emit('change', stats);
99
86
  });
100
87
  };
101
-
102
88
  if (this.compiler.compilers) {
103
89
  this.compiler.compilers.forEach(addHooks);
104
90
  } else {
105
91
  addHooks(this.compiler);
106
92
  }
107
93
  }
108
-
109
94
  setupDevMiddleware(devMiddleware = webpackDevMiddleware) {
110
95
  const {
111
96
  devOptions
@@ -116,21 +101,18 @@ export default class DevMiddleware extends EventEmitter {
116
101
  }, devOptions.devMiddleware));
117
102
  return middleware;
118
103
  }
119
-
120
104
  isClientCompiler(compiler) {
121
105
  const {
122
106
  target
123
- } = compiler.options; // if target not contains `node`, it's a client compiler
107
+ } = compiler.options;
124
108
 
109
+ // if target not contains `node`, it's a client compiler
125
110
  if (target) {
126
111
  if (Array.isArray(target)) {
127
112
  return !target.includes('node');
128
113
  }
129
-
130
114
  return target !== 'node';
131
115
  }
132
-
133
116
  return compiler.name === 'client';
134
117
  }
135
-
136
118
  }