Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tests checking chunkhash of runtime chunk only changes if needed
- Loading branch information
Showing
12 changed files
with
114 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = "Normal"; |
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,28 @@ | ||
it("should change chunkhash of main chunk", function () { | ||
const mainChunk = STATS_JSON.chunks.find((chunk) => chunk.names.indexOf("main") !== -1); | ||
(!mainChunk).should.be.false("Main chunk not found"); | ||
switch (WATCH_STEP) { | ||
case "0": | ||
STATE.hash = mainChunk.hash; | ||
break; | ||
case "1": | ||
mainChunk.hash.should.be.not.eql(STATE.hash); | ||
break; | ||
} | ||
}); | ||
|
||
it("should load additional chunk", function (done) { | ||
const step = WATCH_STEP; | ||
import(/* webpackChunkName: "dynamic" */ './dynamic') | ||
.then((dynamic) => { | ||
switch (step) { | ||
case "0": | ||
dynamic.should.be.eql("Normal"); | ||
break; | ||
case "1": | ||
dynamic.should.be.eql("Changed"); | ||
break; | ||
} | ||
done(); | ||
}); | ||
}); |
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 @@ | ||
module.exports = "Changed"; |
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,5 @@ | ||
module.exports = { | ||
output: { | ||
chunkFilename: "[name].[chunkhash].js" | ||
} | ||
}; |
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 @@ | ||
module.exports = "Normal"; |
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,44 @@ | ||
require("should"); | ||
|
||
import * as both from './dynamic-and-static' | ||
import * as staticModule from './static' | ||
|
||
it("should not change chunkhash of manifest chunk", function () { | ||
const manifestChunk = STATS_JSON.chunks.find((chunk) => chunk.names.indexOf("manifest") !== -1); | ||
(!manifestChunk).should.be.false("Main chunk not found"); | ||
switch (WATCH_STEP) { | ||
case "0": | ||
STATE.hash = manifestChunk.hash; | ||
staticModule.should.be.eql("Normal"); | ||
both.should.be.eql("Normal"); | ||
break; | ||
case "1": | ||
manifestChunk.hash.should.be.eql(STATE.hash); | ||
staticModule.should.be.eql("Changed"); | ||
both.should.be.eql("Normal"); | ||
break; | ||
case "2": | ||
manifestChunk.hash.should.be.eql(STATE.hash); | ||
staticModule.should.be.eql("Changed"); | ||
both.should.be.eql("Changed"); | ||
break; | ||
} | ||
}); | ||
|
||
it("should load additional chunk", function (done) { | ||
const step = WATCH_STEP; | ||
import(/* webpackChunkName: "dynamic-and-static" */ './dynamic-and-static') | ||
.then((dynamic) => { | ||
switch (step) { | ||
case "0": | ||
case "1": | ||
dynamic.should.be.eql("Normal"); | ||
break; | ||
case "2": | ||
dynamic.should.be.eql("Changed"); | ||
break; | ||
} | ||
done(); | ||
}) | ||
.catch(done);; | ||
}); |
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 @@ | ||
module.exports = "Normal"; |
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 @@ | ||
module.exports = "Changed"; |
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 @@ | ||
module.exports = "Changed"; |
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,6 @@ | ||
module.exports = { | ||
bundlePath: [ | ||
"./manifest.bundle.js", | ||
"./main.bundle.js" | ||
] | ||
} |
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,14 @@ | ||
var CommonsChunkPlugin = require("../../../../lib/optimize/CommonsChunkPlugin"); | ||
module.exports = { | ||
output: { | ||
filename: "[name].bundle.js", | ||
chunkFilename: "[name].[chunkhash].js" | ||
}, | ||
target: "web", | ||
plugins: [ | ||
new CommonsChunkPlugin({ | ||
name: ["manifest"], | ||
minChunks: Infinity | ||
}) | ||
] | ||
}; |