Skip to content

Commit

Permalink
fix(hot): enable hot option as a default
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Apr 28, 2020
1 parent 023c194 commit 1da4986
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
3 changes: 1 addition & 2 deletions client-src/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const status = {
currentHash: '',
};
const options = {
hot: false,
hot: true,
hotReload: true,
liveReload: false,
initial: true,
Expand All @@ -36,7 +36,6 @@ if (typeof window !== 'undefined') {

const onSocketMessage = {
hot() {
options.hot = true;
log.info('[WDS] Hot Module Replacement enabled.');
},
liveReload() {
Expand Down
12 changes: 11 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ class Server {

normalizeOptions(this.compiler, this.options);

// don't move this position because addEntries called by updateCompiler checks this.options.hot|hotOnly
this.hot =
typeof this.options.hot === 'boolean' ||
typeof this.options.hotOnly === 'boolean'
? this.options.hot || this.options.hotOnly
: true;

if (this.hot) {
this.options.hot = true;
}

updateCompiler(this.compiler, this.options);

this.heartbeatInterval = 30000;
Expand All @@ -86,7 +97,6 @@ class Server {
this.contentBaseWatchers = [];

// TODO this.<property> is deprecated (remove them in next major release.) in favor this.options.<property>
this.hot = this.options.hot || this.options.hotOnly;
this.headers = this.options.headers;
this.progress = this.options.progress;

Expand Down
2 changes: 1 addition & 1 deletion test/client/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`index should run onSocketMessage.ok 1`] = `"Ok"`;

exports[`index should run onSocketMessage.ok 2`] = `
Object {
"hot": false,
"hot": true,
"hotReload": true,
"initial": false,
"liveReload": false,
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/__snapshots__/ClientOptions.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ Array [
exports[`Client console.log liveReload disabled 1`] = `
Array [
"Hey.",
"[HMR] Waiting for update signal from WDS...",
"[WDS] Hot Module Replacement enabled.",
]
`;

exports[`Client console.log liveReload enabled 1`] = `
Array [
"Hey.",
"[HMR] Waiting for update signal from WDS...",
"[WDS] Hot Module Replacement enabled.",
"[WDS] Live Reloading enabled.",
]
`;
4 changes: 4 additions & 0 deletions test/e2e/__snapshots__/Iframe.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ Array [
exports[`Client iframe console.log liveReload disabled 1`] = `
Array [
"Hey.",
"[HMR] Waiting for update signal from WDS...",
"[WDS] Hot Module Replacement enabled.",
]
`;

exports[`Client iframe console.log liveReload enabled 1`] = `
Array [
"Hey.",
"[HMR] Waiting for update signal from WDS...",
"[WDS] Hot Module Replacement enabled.",
"[WDS] Live Reloading enabled.",
]
`;
7 changes: 7 additions & 0 deletions test/e2e/__snapshots__/TransportMode.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

exports[`transportMode client custom client on browser client logs correctly 1`] = `
Array [
"[HMR] Waiting for update signal from WDS...",
"Hey.",
"open",
"hot",
"[WDS] Hot Module Replacement enabled.",
"liveReload",
"[WDS] Live Reloading enabled.",
"hash",
Expand All @@ -15,15 +18,19 @@ Array [

exports[`transportMode client sockjs on browser client logs correctly 1`] = `
Array [
"[HMR] Waiting for update signal from WDS...",
"Hey.",
"[WDS] Hot Module Replacement enabled.",
"[WDS] Live Reloading enabled.",
"[WDS] Disconnected!",
]
`;

exports[`transportMode client ws on browser client logs correctly 1`] = `
Array [
"[HMR] Waiting for update signal from WDS...",
"Hey.",
"[WDS] Hot Module Replacement enabled.",
"[WDS] Live Reloading enabled.",
"[WDS] Disconnected!",
]
Expand Down
4 changes: 0 additions & 4 deletions test/server/hot-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('hot option', () => {
const options = {
port,
inline: true,
hot: true,
watchOptions: {
poll: true,
},
Expand All @@ -36,7 +35,6 @@ describe('hot option', () => {
const options = {
port,
inline: true,
hot: true,
watchOptions: {
poll: true,
},
Expand Down Expand Up @@ -92,7 +90,6 @@ describe('hot option', () => {
const options = {
port,
inline: true,
hot: true,
watchOptions: {
poll: true,
},
Expand Down Expand Up @@ -126,7 +123,6 @@ describe('hot option', () => {
const options = {
port,
inline: true,
hot: true,
watchOptions: {
poll: true,
},
Expand Down
2 changes: 1 addition & 1 deletion test/server/transportMode-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ describe('transportMode', () => {
expect(MockSockJSServer.mock.calls[0][0].options.port).toEqual(port);

expect(mockServerInstance.onConnection.mock.calls).toMatchSnapshot();
expect(mockServerInstance.send.mock.calls.length).toEqual(3);
expect(mockServerInstance.send.mock.calls.length).toEqual(4);
// call 0 to the send() method is liveReload
expect(mockServerInstance.send.mock.calls[0]).toMatchSnapshot();
// call 1 to the send() method is hash data, so we skip it
Expand Down

0 comments on commit 1da4986

Please sign in to comment.