-
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to enable/disable HMR (
options.hmr
) (#264)
- Loading branch information
1 parent
67120f8
commit 378e906
Showing
12 changed files
with
266 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
{ | ||
"type": "object", | ||
"properties": { | ||
"hmr": { | ||
"type": "boolean" | ||
}, | ||
"base": { | ||
"type": "number" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Node v4 requires "use strict" to allow block scoped let & const | ||
"use strict"; | ||
|
||
var assert = require("assert"); | ||
var sinon = require('sinon'); | ||
var loaderUtils = require('loader-utils'); | ||
|
||
var url = require("../url"); | ||
|
||
describe("url tests", function () { | ||
var sandbox = sinon.sandbox.create(); | ||
var getOptions; | ||
|
||
beforeEach(() => { | ||
// Mock loaderUtils to override options | ||
getOptions = sandbox.stub(loaderUtils, 'getOptions'); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it("should output HMR code by default", function () { | ||
assert.equal(/Hot Module Replacement/g.test(url.pitch()), true); | ||
}); | ||
|
||
it("should NOT output HMR code when options.hmr is false", function () { | ||
getOptions.returns({hmr: false}); | ||
assert.equal(/Hot Module Replacement/g.test(url.pitch()), false); | ||
}); | ||
|
||
it("should output HMR code when options.hmr is true", function () { | ||
getOptions.returns({hmr: true}); | ||
assert.equal(/Hot Module Replacement/g.test(url.pitch()), true); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Node v4 requires "use strict" to allow block scoped let & const | ||
"use strict"; | ||
|
||
var assert = require("assert"); | ||
var sinon = require('sinon'); | ||
var loaderUtils = require('loader-utils'); | ||
|
||
var useable = require("../useable"); | ||
|
||
describe("useable tests", function () { | ||
var sandbox = sinon.sandbox.create(); | ||
var getOptions; | ||
|
||
beforeEach(() => { | ||
// Mock loaderUtils to override options | ||
getOptions = sandbox.stub(loaderUtils, 'getOptions'); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it("should output HMR code by default", function () { | ||
assert.equal(/Hot Module Replacement/g.test(useable.pitch()), true); | ||
}); | ||
|
||
it("should NOT output HMR code when options.hmr is false", function () { | ||
getOptions.returns({hmr: false}); | ||
assert.equal(/Hot Module Replacement/g.test(useable.pitch()), false); | ||
}); | ||
|
||
it("should output HMR code when options.hmr is true", function () { | ||
getOptions.returns({hmr: true}); | ||
assert.equal(/Hot Module Replacement/g.test(useable.pitch()), true); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.