Skip to content

Commit d26b444

Browse files
knagaitsevhiroppy
authored andcommittedJun 17, 2019
fix(client): add default fallback for client (#2015)
* fix(client): add default fallback for client * test(server): update entry snapshot * fix(client): move SockJSClient definition * fix(client): update SockJSClient path resolution * fix(client): add correct entry path
1 parent 84955f8 commit d26b444

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed
 

Diff for: ‎client-src/default/socket.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
/* eslint-disable
55
camelcase
66
*/
7-
const Client = __webpack_dev_server_client__;
7+
8+
// this SockJSClient is here as a default fallback, in case inline mode
9+
// is off or the client is not injected. This will be switched to
10+
// WebsocketClient when it becomes the default
11+
12+
// important: the path to SockJSClient here is made to work in the 'client'
13+
// directory, but is updated via the webpack compilation when compiled from
14+
// the 'client-src' directory
15+
const Client =
16+
typeof __webpack_dev_server_client__ !== 'undefined'
17+
? __webpack_dev_server_client__
18+
: // eslint-disable-next-line import/no-unresolved
19+
require('./clients/SockJSClient');
820

921
let retries = 0;
1022
let client = null;

Diff for: ‎client-src/default/webpack.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const webpack = require('webpack');
4+
35
module.exports = {
46
mode: 'production',
57
module: {
@@ -15,4 +17,12 @@ module.exports = {
1517
},
1618
],
1719
},
20+
plugins: [
21+
new webpack.NormalModuleReplacementPlugin(/\/clients\//, (resource) => {
22+
resource.request = resource.request.replace(
23+
/\/clients\//,
24+
'/../clients/'
25+
);
26+
}),
27+
],
1828
};

Diff for: ‎client-src/live/webpack.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const path = require('path');
4+
const webpack = require('webpack');
45
const CopyPlugin = require('copy-webpack-plugin');
56

67
module.exports = {
@@ -33,5 +34,11 @@ module.exports = {
3334
to: path.resolve(__dirname, '../../client/live.html'),
3435
},
3536
]),
37+
new webpack.NormalModuleReplacementPlugin(/\/clients\//, (resource) => {
38+
resource.request = resource.request.replace(
39+
/\/clients\//,
40+
'/../clients/'
41+
);
42+
}),
3643
],
3744
};

Diff for: ‎test/e2e/ClientOptions.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe('Client complex inline script path with sockPort', () => {
166166
});
167167

168168
// previously, using sockPort without sockPath had the ability
169-
// to alter the sockPath (based on a bug in client-src/index.js)
169+
// to alter the sockPath (based on a bug in client-src/default/index.js)
170170
// so we need to make sure sockPath is not altered in this case
171171
describe('Client complex inline script path with sockPort, no sockPath', () => {
172172
beforeAll((done) => {

0 commit comments

Comments
 (0)
Please sign in to comment.