Skip to content

fix: disable socket injection when hot & liveReload are disabled #2133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/client
!/test/client
coverage
client-src/live/web_modules/
node_modules
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/client
!/test/client
coverage
client-src/live/web_modules/
node_modules
CHANGELOG.md
18 changes: 0 additions & 18 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ jobs:
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-6:
node_version: ^6.9.0
webpack_version: latest
node-10-canary:
node_version: ^10.13.0
webpack_version: next
Expand Down Expand Up @@ -111,12 +105,6 @@ jobs:
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-6:
node_version: ^6.9.0
webpack_version: latest
node-10-canary:
node_version: ^10.13.0
webpack_version: next
Expand Down Expand Up @@ -170,12 +158,6 @@ jobs:
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-6:
node_version: ^6.9.0
webpack_version: latest
node-10-canary:
node_version: ^10.13.0
webpack_version: next
Expand Down
42 changes: 0 additions & 42 deletions bin/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ module.exports = {
type: Boolean,
describe: 'Broadcasts the server via ZeroConf networking on start',
},
{
name: 'lazy',
type: Boolean,
describe: 'Lazy',
},
{
name: 'liveReload',
type: Boolean,
Expand All @@ -31,13 +26,6 @@ module.exports = {
describe: 'Enables/Disables serveIndex middleware',
defaultValue: true,
},
{
name: 'inline',
type: Boolean,
defaultValue: true,
describe:
'Inline mode (set to false to disable including client scripts like livereload)',
},
{
name: 'profile',
type: Boolean,
Expand Down Expand Up @@ -96,36 +84,6 @@ module.exports = {
group: SSL_GROUP,
describe: 'HTTP/2, must be used with HTTPS',
},
{
name: 'key',
type: String,
describe: 'Path to a SSL key.',
group: SSL_GROUP,
},
{
name: 'cert',
type: String,
describe: 'Path to a SSL certificate.',
group: SSL_GROUP,
},
{
name: 'cacert',
type: String,
describe: 'Path to a SSL CA certificate.',
group: SSL_GROUP,
},
{
name: 'pfx',
type: String,
describe: 'Path to a SSL pfx file.',
group: SSL_GROUP,
},
{
name: 'pfx-passphrase',
type: String,
describe: 'Passphrase for pfx file.',
group: SSL_GROUP,
},
{
name: 'content-base',
type: String,
Expand Down
35 changes: 0 additions & 35 deletions bin/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ const options = {
type: 'boolean',
describe: 'Broadcasts the server via ZeroConf networking on start',
},
lazy: {
type: 'boolean',
describe: 'Lazy',
},
liveReload: {
type: 'boolean',
describe: 'Enables/Disables live reloading on changing files',
Expand All @@ -30,12 +26,6 @@ const options = {
describe: 'Enables/Disables serveIndex middleware',
default: true,
},
inline: {
type: 'boolean',
default: true,
describe:
'Inline mode (set to false to disable including client scripts like livereload)',
},
profile: {
type: 'boolean',
describe: 'Print compilation profile data for progress steps',
Expand Down Expand Up @@ -106,31 +96,6 @@ const options = {
group: SSL_GROUP,
describe: 'HTTP/2, must be used with HTTPS',
},
key: {
type: 'string',
describe: 'Path to a SSL key.',
group: SSL_GROUP,
},
cert: {
type: 'string',
describe: 'Path to a SSL certificate.',
group: SSL_GROUP,
},
cacert: {
type: 'string',
describe: 'Path to a SSL CA certificate.',
group: SSL_GROUP,
},
pfx: {
type: 'string',
describe: 'Path to a SSL pfx file.',
group: SSL_GROUP,
},
'pfx-passphrase': {
type: 'string',
describe: 'Passphrase for pfx file.',
group: SSL_GROUP,
},
'content-base': {
type: 'string',
describe: 'A directory or URL to serve HTML content from.',
Expand Down
6 changes: 5 additions & 1 deletion client-src/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ const onSocketMessage = {
log.error(error);
},
close() {
log.error('[WDS] Disconnected!');
if (options.hot || options.liveReload) {
log.error('[WDS] Disconnected!');
} else {
log.error('[WDS] Hot Module Replacement & Live Reloading are disabled!');
}
sendMessage('Close');
},
};
Expand Down
8 changes: 3 additions & 5 deletions client-src/default/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ function clear() {
function showMessage(messages) {
ensureOverlayDivExists((div) => {
// Make it look similar to our terminal.
div.innerHTML = `<span style="color: #${
colors.red
}">Failed to compile.</span><br><br>${ansiHTML(
entities.encode(messages[0])
)}`;
const text = ansiHTML(entities.encode(messages[0]));

div.innerHTML = `<span style="color: #${colors.red}">Failed to compile.</span><br><br>${text}`;
});
}

Expand Down
11 changes: 3 additions & 8 deletions client-src/default/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
camelcase
*/

// this SockJSClient is here as a default fallback, in case inline mode
// is off or the client is not injected. This will be switched to
// WebsocketClient when it becomes the default

// important: the path to SockJSClient here is made to work in the 'client'
// directory, but is updated via the webpack compilation when compiled from
// the 'client-src' directory
// this WebsocketClient is here as a default fallback,
// in case the client is not injected
const Client =
typeof __webpack_dev_server_client__ !== 'undefined'
? __webpack_dev_server_client__
: // eslint-disable-next-line import/no-unresolved
require('./clients/SockJSClient');
require('../clients/WebsocketClient');

let retries = 0;
let client = null;
Expand Down
2 changes: 1 addition & 1 deletion client-src/default/utils/createSocketUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function getSocketUrl(urlParts, loc) {
// resourceQuery, so we need to fall back to the default if
// they are not provided
const sockHost = query.sockHost || hostname;
const sockPath = query.sockPath || '/sockjs-node';
const sockPath = query.sockPath || '/ws';
let sockPort = query.sockPort || port;

if (sockPort === 'location') {
Expand Down
20 changes: 6 additions & 14 deletions client-src/default/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
'use strict';

const webpack = require('webpack');
const path = require('path');

module.exports = {
mode: 'production',
entry: path.join(__dirname, 'index.js'),
output: {
path: path.resolve(__dirname, '../../client/default'),
filename: 'index.bundle.js',
},
module: {
rules: [
{
Expand All @@ -17,17 +22,4 @@ module.exports = {
},
],
},
plugins: [
new webpack.NormalModuleReplacementPlugin(
/^\.\/clients\/SockJSClient$/,
(resource) => {
if (resource.context.startsWith(process.cwd())) {
resource.request = resource.request.replace(
/^\.\/clients\/SockJSClient$/,
'../clients/SockJSClient'
);
}
}
),
],
};
Loading