Skip to content
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

fix: multi compiler mode with multiple web targets #3840

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion client-src/utils/reloadApp.js
Expand Up @@ -15,7 +15,7 @@ function reloadApp({ hot, liveReload }, status) {
? // eslint-disable-next-line camelcase
__webpack_hash__
: status.previousHash || "";
const isInitial = status.currentHash.indexOf(webpackHash) === 0;
const isInitial = status.currentHash.indexOf(webpackHash) >= 0;

if (isInitial) {
const isLegacyInitial =
Expand Down
30 changes: 11 additions & 19 deletions lib/Server.js
Expand Up @@ -1150,26 +1150,18 @@ class Server {
}

setupHooks() {
const addHooks = (compiler) => {
compiler.hooks.invalid.tap("webpack-dev-server", () => {
if (this.webSocketServer) {
this.sendMessage(this.webSocketServer.clients, "invalid");
}
});
compiler.hooks.done.tap("webpack-dev-server", (stats) => {
if (this.webSocketServer) {
this.sendStats(this.webSocketServer.clients, this.getStats(stats));
}

this.stats = stats;
});
};
this.compiler.hooks.invalid.tap("webpack-dev-server", () => {
if (this.webSocketServer) {
this.sendMessage(this.webSocketServer.clients, "invalid");
}
});
this.compiler.hooks.done.tap("webpack-dev-server", (stats) => {
if (this.webSocketServer) {
this.sendStats(this.webSocketServer.clients, this.getStats(stats));
}

if (this.compiler.compilers) {
this.compiler.compilers.forEach(addHooks);
} else {
addHooks(this.compiler);
}
this.stats = stats;
});
}

setupHostHeaderCheck() {
Expand Down
4 changes: 2 additions & 2 deletions test/client/utils/reloadApp.test.js
Expand Up @@ -86,7 +86,7 @@ describe("'reloadApp' function", () => {

reloadApp(
{ hot: false, hotReload: true, liveReload: true },
{ isUnloading: false, currentHash: "other-mock-hash" }
{ isUnloading: false, currentHash: "changed-mock" }
);

setTimeout(() => {
Expand All @@ -101,7 +101,7 @@ describe("'reloadApp' function", () => {
test("should run liveReload when protocol is http:", (done) => {
reloadApp(
{ hot: false, hotReload: true, liveReload: true },
{ isUnloading: false, currentHash: "other-mock-hash" }
{ isUnloading: false, currentHash: "changed-mock" }
);

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/module-federation.test.js
Expand Up @@ -8,7 +8,7 @@ const objectEntryConfig = require("../fixtures/module-federation-config/webpack.
const multiConfig = require("../fixtures/module-federation-config/webpack.multi.config");
const runBrowser = require("../helpers/run-browser");
const isWebpack5 = require("../helpers/isWebpack5");
const port = require("../ports-map")["universal-compiler"];
const port = require("../ports-map")["module-federation"];

const describeOnlyWebpack5 = isWebpack5 ? describe : describe.skip;

Expand Down