Skip to content

Commit

Permalink
⚙ Update compiled files
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Dec 13, 2021
1 parent 5024ee7 commit 95dbcac
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 100 deletions.
72 changes: 36 additions & 36 deletions packages/next/bundles/webpack/packages/lazy-compilation-node.js
@@ -1,40 +1,40 @@
/* global __resourceQuery */

'use strict'
"use strict";

var urlBase = decodeURIComponent(__resourceQuery.slice(1))
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
exports.keepAlive = function (options) {
var data = options.data
var onError = options.onError
var active = options.active
var module = options.module
var response
var request = (
urlBase.startsWith('https') ? require('https') : require('http')
).request(
urlBase + data,
{
agent: false,
headers: { accept: 'text/event-stream' },
},
function (res) {
response = res
response.on('error', errorHandler)
if (!active && !module.hot) {
console.log(
'Hot Module Replacement is not enabled. Waiting for process restart...'
)
}
}
)
function errorHandler(err) {
err.message =
'Problem communicating active modules to the server: ' + err.message
onError(err)
}
request.on('error', errorHandler)
request.end()
return function () {
response.destroy()
}
}
var data = options.data;
var onError = options.onError;
var active = options.active;
var module = options.module;
var response;
var request = (
urlBase.startsWith("https") ? require("https") : require("http")
).request(
urlBase + data,
{
agent: false,
headers: { accept: "text/event-stream" }
},
function (res) {
response = res;
response.on("error", errorHandler);
if (!active && !module.hot) {
console.log(
"Hot Module Replacement is not enabled. Waiting for process restart..."
);
}
}
);
function errorHandler(err) {
err.message =
"Problem communicating active modules to the server: " + err.message;
onError(err);
}
request.on("error", errorHandler);
request.end();
return function () {
response.destroy();
};
};
128 changes: 64 additions & 64 deletions packages/next/bundles/webpack/packages/lazy-compilation-web.js
@@ -1,74 +1,74 @@
/* global __resourceQuery */

'use strict'
"use strict";

if (typeof EventSource !== 'function') {
throw new Error(
"Environment doesn't support lazy compilation (requires EventSource)"
)
if (typeof EventSource !== "function") {
throw new Error(
"Environment doesn't support lazy compilation (requires EventSource)"
);
}

var urlBase = decodeURIComponent(__resourceQuery.slice(1))
var activeEventSource
var activeKeys = new Map()
var errorHandlers = new Set()
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
var activeEventSource;
var activeKeys = new Map();
var errorHandlers = new Set();

var updateEventSource = function updateEventSource() {
if (activeEventSource) activeEventSource.close()
if (activeKeys.size) {
activeEventSource = new EventSource(
urlBase + Array.from(activeKeys.keys()).join('@')
)
activeEventSource.onerror = function (event) {
errorHandlers.forEach(function (onError) {
onError(
new Error(
'Problem communicating active modules to the server: ' +
event.message +
' ' +
event.filename +
':' +
event.lineno +
':' +
event.colno +
' ' +
event.error
)
)
})
}
} else {
activeEventSource = undefined
}
}
if (activeEventSource) activeEventSource.close();
if (activeKeys.size) {
activeEventSource = new EventSource(
urlBase + Array.from(activeKeys.keys()).join("@")
);
activeEventSource.onerror = function (event) {
errorHandlers.forEach(function (onError) {
onError(
new Error(
"Problem communicating active modules to the server: " +
event.message +
" " +
event.filename +
":" +
event.lineno +
":" +
event.colno +
" " +
event.error
)
);
});
};
} else {
activeEventSource = undefined;
}
};

exports.keepAlive = function (options) {
var data = options.data
var onError = options.onError
var active = options.active
var module = options.module
errorHandlers.add(onError)
var value = activeKeys.get(data) || 0
activeKeys.set(data, value + 1)
if (value === 0) {
updateEventSource()
}
if (!active && !module.hot) {
console.log(
'Hot Module Replacement is not enabled. Waiting for process restart...'
)
}
var data = options.data;
var onError = options.onError;
var active = options.active;
var module = options.module;
errorHandlers.add(onError);
var value = activeKeys.get(data) || 0;
activeKeys.set(data, value + 1);
if (value === 0) {
updateEventSource();
}
if (!active && !module.hot) {
console.log(
"Hot Module Replacement is not enabled. Waiting for process restart..."
);
}

return function () {
errorHandlers.delete(onError)
setTimeout(function () {
var value = activeKeys.get(data)
if (value === 1) {
activeKeys.delete(data)
updateEventSource()
} else {
activeKeys.set(data, value - 1)
}
}, 1000)
}
}
return function () {
errorHandlers.delete(onError);
setTimeout(function () {
var value = activeKeys.get(data);
if (value === 1) {
activeKeys.delete(data);
updateEventSource();
} else {
activeKeys.set(data, value - 1);
}
}, 1000);
};
};

0 comments on commit 95dbcac

Please sign in to comment.