Skip to content

Commit c9d32f8

Browse files
authored
fixes #1084: template literals causing errors on IE (#1089)
* fixes #1084: template literals causing errors on IE * regressing back to [email protected] to prevent IE errors cleaning up erroneous ES6 in client for IE updating client eslintrc to prevent es6 errors in IE
1 parent 6e18fa6 commit c9d32f8

File tree

7 files changed

+96
-48
lines changed

7 files changed

+96
-48
lines changed

client/.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"rules": {
3+
"object-shorthand": ["error", "never"],
4+
"prefer-arrow-callback": ["off"],
5+
"prefer-template": ["off"]
6+
}
7+
}

client/index.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ function sendMsg(type, data) {
6565
!(self instanceof WorkerGlobalScope))
6666
) {
6767
self.postMessage({
68-
type: `webpack${type}`,
69-
data
68+
type: 'webpack' + type,
69+
data: data
7070
}, '*');
7171
}
7272
}
7373

7474
const onSocketMsg = {
75-
hot() {
75+
hot: function msgHot() {
7676
hot = true;
7777
log.info('[WDS] Hot Module Replacement enabled.');
7878
},
79-
invalid() {
79+
invalid: function msgInvalid() {
8080
log.info('[WDS] App updated. Recompiling...');
8181
// fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
8282
if (useWarningOverlay || useErrorOverlay) overlay.clear();
8383
sendMsg('Invalid');
8484
},
85-
hash(hash) {
85+
hash: function msgHash(hash) {
8686
currentHash = hash;
8787
},
8888
'still-ok': function stillOk() {
@@ -109,10 +109,10 @@ const onSocketMsg = {
109109
log.disableAll();
110110
break;
111111
default:
112-
log.error(`[WDS] Unknown clientLogLevel '${level}'`);
112+
log.error('[WDS] Unknown clientLogLevel \'' + level + '\'');
113113
}
114114
},
115-
overlay(value) {
115+
overlay: function msgOverlay(value) {
116116
if (typeof document !== 'undefined') {
117117
if (typeof (value) === 'boolean') {
118118
useWarningOverlay = false;
@@ -123,15 +123,15 @@ const onSocketMsg = {
123123
}
124124
}
125125
},
126-
progress(progress) {
126+
progress: function msgProgress(progress) {
127127
if (typeof document !== 'undefined') {
128128
useProgress = progress;
129129
}
130130
},
131131
'progress-update': function progressUpdate(data) {
132-
if (useProgress) log.info(`[WDS] ${data.percent}% - ${data.msg}.`);
132+
if (useProgress) log.info('[WDS] ' + data.percent + '% - ' + data.msg + '.');
133133
},
134-
ok() {
134+
ok: function msgOk() {
135135
sendMsg('Ok');
136136
if (useWarningOverlay || useErrorOverlay) overlay.clear();
137137
if (initial) return initial = false; // eslint-disable-line no-return-assign
@@ -141,27 +141,27 @@ const onSocketMsg = {
141141
log.info('[WDS] Content base changed. Reloading...');
142142
self.location.reload();
143143
},
144-
warnings(warnings) {
144+
warnings: function msgWarnings(warnings) {
145145
log.warn('[WDS] Warnings while compiling.');
146-
const strippedWarnings = warnings.map(warning => stripAnsi(warning));
146+
const strippedWarnings = warnings.map(function map(warning) { return stripAnsi(warning); });
147147
sendMsg('Warnings', strippedWarnings);
148148
for (let i = 0; i < strippedWarnings.length; i++) { log.warn(strippedWarnings[i]); }
149149
if (useWarningOverlay) overlay.showMessage(warnings);
150150

151151
if (initial) return initial = false; // eslint-disable-line no-return-assign
152152
reloadApp();
153153
},
154-
errors(errors) {
154+
errors: function msgErrors(errors) {
155155
log.error('[WDS] Errors while compiling. Reload prevented.');
156-
const strippedErrors = errors.map(error => stripAnsi(error));
156+
const strippedErrors = errors.map(function map(error) { return stripAnsi(error); });
157157
sendMsg('Errors', strippedErrors);
158158
for (let i = 0; i < strippedErrors.length; i++) { log.error(strippedErrors[i]); }
159159
if (useErrorOverlay) overlay.showMessage(errors);
160160
},
161-
error(error) {
161+
error: function msgError(error) {
162162
log.error(error);
163163
},
164-
close() {
164+
close: function msgClose() {
165165
log.error('[WDS] Disconnected!');
166166
sendMsg('Close');
167167
}
@@ -191,17 +191,17 @@ if (hostname && (self.location.protocol === 'https:' || urlParts.hostname === '0
191191
}
192192

193193
const socketUrl = url.format({
194-
protocol,
194+
protocol: protocol,
195195
auth: urlParts.auth,
196-
hostname,
196+
hostname: hostname,
197197
port: urlParts.port,
198198
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : urlParts.path
199199
});
200200

201201
socket(socketUrl, onSocketMsg);
202202

203203
let isUnloading = false;
204-
self.addEventListener('beforeunload', () => {
204+
self.addEventListener('beforeunload', function beforeUnload() {
205205
isUnloading = true;
206206
});
207207

@@ -216,7 +216,7 @@ function reloadApp() {
216216
hotEmitter.emit('webpackHotUpdate', currentHash);
217217
if (typeof self !== 'undefined' && self.window) {
218218
// broadcast update to window
219-
self.postMessage(`webpackHotUpdate${currentHash}`, '*');
219+
self.postMessage('webpackHotUpdate' + currentHash, '*');
220220
}
221221
} else {
222222
log.info('[WDS] App updated. Reloading...');

client/live.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require('./style.css');
1010
let hot = false;
1111
let currentHash = '';
1212

13-
$(() => {
13+
$(function ready() {
1414
$('body').html(require('./page.pug')());
1515
const status = $('#status');
1616
const okness = $('#okness');
@@ -28,11 +28,11 @@ $(() => {
2828
});
2929

3030
const onSocketMsg = {
31-
hot() {
31+
hot: function msgHot() {
3232
hot = true;
3333
iframe.attr('src', contentPage + window.location.hash);
3434
},
35-
invalid() {
35+
invalid: function msgInvalid() {
3636
okness.text('');
3737
status.text('App updated. Recompiling...');
3838
header.css({
@@ -41,7 +41,7 @@ $(() => {
4141
$errors.hide();
4242
if (!hot) iframe.hide();
4343
},
44-
hash(hash) {
44+
hash: function msgHash(hash) {
4545
currentHash = hash;
4646
},
4747
'still-ok': function stillOk() {
@@ -53,27 +53,27 @@ $(() => {
5353
$errors.hide();
5454
if (!hot) iframe.show();
5555
},
56-
ok() {
56+
ok: function msgOk() {
5757
okness.text('');
5858
$errors.hide();
5959
reloadApp();
6060
},
61-
warnings() {
61+
warnings: function msgWarnings() {
6262
okness.text('Warnings while compiling.');
6363
$errors.hide();
6464
reloadApp();
6565
},
66-
errors(errors) {
66+
errors: function msgErrors(errors) {
6767
status.text('App updated with errors. No reload!');
6868
okness.text('Errors while compiling.');
69-
$errors.text(`\n${stripAnsi(errors.join('\n\n\n'))}\n\n`);
69+
$errors.text('\n' + stripAnsi(errors.join('\n\n\n')) + '\n\n');
7070
header.css({
7171
borderColor: '#ebcb8b'
7272
});
7373
$errors.show();
7474
iframe.hide();
7575
},
76-
close() {
76+
close: function msgClose() {
7777
status.text('');
7878
okness.text('Disconnected.');
7979
$errors.text('\n\n\n Lost connection to webpack-dev-server.\n Please restart the server to reestablish connection...\n\n\n\n');
@@ -87,7 +87,7 @@ $(() => {
8787

8888
socket('/sockjs-node', onSocketMsg);
8989

90-
iframe.on('load', () => {
90+
iframe.on('load', function load() {
9191
status.text('App ready.');
9292
header.css({
9393
borderColor: ''
@@ -99,7 +99,7 @@ $(() => {
9999
if (hot) {
100100
status.text('App hot update.');
101101
try {
102-
iframe[0].contentWindow.postMessage(`webpackHotUpdate${currentHash}`, '*');
102+
iframe[0].contentWindow.postMessage('webpackHotUpdate' + currentHash, '*');
103103
} catch (e) {
104104
console.warn(e); // eslint-disable-line
105105
}
@@ -110,7 +110,7 @@ $(() => {
110110
borderColor: '#96b5b4'
111111
});
112112
try {
113-
let old = `${iframe[0].contentWindow.location}`;
113+
let old = iframe[0].contentWindow.location + '';
114114
if (old.indexOf('about') === 0) old = null;
115115
iframe.attr('src', old || (contentPage + window.location.hash));
116116
if (old) {

client/overlay.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function ensureOverlayDivExists(onOverlayDivReady) {
8383
}
8484

8585
// Create iframe and, when it is ready, a div inside it.
86-
overlayIframe = createOverlayIframe(() => {
86+
overlayIframe = createOverlayIframe(function cb() {
8787
overlayDiv = addOverlayDivTo(overlayIframe);
8888
// Now we can talk!
8989
lastOnOverlayDivReady(overlayDiv);
@@ -96,13 +96,11 @@ function ensureOverlayDivExists(onOverlayDivReady) {
9696
}
9797

9898
function showMessageOverlay(message) {
99-
ensureOverlayDivExists((div) => {
99+
ensureOverlayDivExists(function cb(div) {
100100
// Make it look similar to our terminal.
101-
div.innerHTML =
102-
`<span style="color: #${
103-
colors.red
104-
}">Failed to compile.</span><br><br>${
105-
ansiHTML(entities.encode(message))}`;
101+
div.innerHTML = '<span style="color: #' + colors.red +
102+
'">Failed to compile.</span><br><br>' +
103+
ansiHTML(entities.encode(message));
106104
});
107105
}
108106

client/socket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function socket(url, handlers) {
2626
const retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
2727
retries += 1;
2828

29-
setTimeout(() => {
29+
setTimeout(function cb() {
3030
socket(url, handlers);
3131
}, retryInMs);
3232
}

package-lock.json

Lines changed: 50 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"sockjs": "0.3.18",
6161
"sockjs-client": "1.1.4",
6262
"spdy": "^3.4.1",
63-
"strip-ansi": "^4.0.0",
63+
"strip-ansi": "^3.0.1",
6464
"supports-color": "^4.2.1",
6565
"webpack-dev-middleware": "^1.11.0",
6666
"yargs": "^8.0.2"

0 commit comments

Comments
 (0)