source: trip-planner-front/node_modules/webpack-dev-server/lib/utils/getSocketClientPath.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2
3function getSocketClientPath(options) {
4 let ClientImplementation;
5 let clientImplFound = true;
6 switch (typeof options.transportMode.client) {
7 case 'string':
8 // could be 'sockjs', 'ws', or a path that should be required
9 if (options.transportMode.client === 'sockjs') {
10 ClientImplementation = require('../../client/clients/SockJSClient');
11 } else if (options.transportMode.client === 'ws') {
12 ClientImplementation = require('../../client/clients/WebsocketClient');
13 } else {
14 try {
15 // eslint-disable-next-line import/no-dynamic-require
16 ClientImplementation = require(options.transportMode.client);
17 } catch (e) {
18 clientImplFound = false;
19 }
20 }
21 break;
22 default:
23 clientImplFound = false;
24 }
25
26 if (!clientImplFound) {
27 throw new Error(
28 "transportMode.client must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to " +
29 'a JS file which exports a class extending BaseClient (webpack-dev-server/client-src/clients/BaseClient) ' +
30 'via require.resolve(...)'
31 );
32 }
33
34 return ClientImplementation.getClientPath(options);
35}
36
37module.exports = getSocketClientPath;
Note: See TracBrowser for help on using the repository browser.