forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
208 additions
and
22 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
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 = "a"; |
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 = "b"; |
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 = "c"; |
33 changes: 33 additions & 0 deletions
33
test/configCases/async-commons-chunk/existing-name/index.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,33 @@ | ||
require("should"); | ||
const sinon = require("sinon"); | ||
const chunkLoadingSpy = sinon.spy(__webpack_require__, 'e'); | ||
|
||
it("should not have duplicate chunks in blocks", function(done) { | ||
// This split point should contain: a | ||
require.ensure([], function(require) { | ||
require("./a").should.be.eql("a"); | ||
}, 'a'); | ||
|
||
// This split point should contain: a and b - we use CommonsChunksPlugin to | ||
// have it only contain b and make chunk a be an async dependency. | ||
require.ensure([], function(require) { | ||
require("./a").should.be.eql("a"); | ||
require("./b").should.be.eql("b"); | ||
}, 'a+b'); | ||
|
||
// This split point should contain: a, b and c - we use CommonsChunksPlugin to | ||
// have it only contain c and make chunks a and a+b be async dependencies. | ||
require.ensure([], function(require) { | ||
require("./a").should.be.eql("a"); | ||
require("./b").should.be.eql("b"); | ||
require("./c").should.be.eql("c"); | ||
}, 'a+b+c'); | ||
|
||
// Each of the require.ensures above should end up resolving chunks: | ||
// - a | ||
// - a, a+b | ||
// - a, a+b, a+b+c | ||
chunkLoadingSpy.callCount.should.be.eql(6); | ||
chunkLoadingSpy.args.should.be.eql([[0], [0], [1], [0], [1], [2]]); | ||
done(); | ||
}); |
14 changes: 14 additions & 0 deletions
14
test/configCases/async-commons-chunk/existing-name/webpack.config.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 webpack = require("../../../../"); | ||
|
||
module.exports = { | ||
plugins: [ | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
chunks: ["a+b", "a+b+c"], | ||
async: "a+b", | ||
}), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
chunks: ["a", "a+b"], | ||
async: "a", | ||
}), | ||
] | ||
}; |
6 changes: 6 additions & 0 deletions
6
test/configCases/source-map/source-map-filename-contenthash/index.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,6 @@ | ||
it("should contain contenthash as query parameter and path", function() { | ||
var fs = require("fs"); | ||
var source = fs.readFileSync(__filename, "utf-8"); | ||
var match = /sourceMappingURL\s*=.*-([A-Fa-f0-9]{32})\.map\?([A-Fa-f0-9]{32})-([A-Fa-f0-9]{32})/.exec(source); | ||
match.length.should.be.eql(4); | ||
}); |
16 changes: 16 additions & 0 deletions
16
test/configCases/source-map/source-map-filename-contenthash/webpack.config.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,16 @@ | ||
var webpack = require("../../../../"); | ||
module.exports = { | ||
node: { | ||
__dirname: false, | ||
__filename: false | ||
}, | ||
devtool: "source-map", | ||
output: { | ||
sourceMapFilename: "[file]-[contenthash].map?[contenthash]-[contenthash]", | ||
}, | ||
plugins: [ | ||
new webpack.optimize.UglifyJsPlugin({ | ||
sourceMap: 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,5 @@ | ||
export const a = "a"; | ||
export const b = "b"; | ||
export const c = "c"; | ||
|
||
export default "d"; |
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,2 @@ | ||
import subA from './submodule-a'; | ||
import subB from './submodule-b' |
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,2 @@ | ||
import subB from './submodule-a' | ||
import subC from './submodule-c'; |
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,29 @@ | ||
Hash: 7d3a56317b2e339b1d822897fe6052020598632c | ||
Child | ||
Hash: 7d3a56317b2e339b1d82 | ||
Time: Xms | ||
Asset Size Chunks Chunk Names | ||
app.js 1.27 kB 0 [emitted] app | ||
vendor.bd2b4219dfda1a951495.js 443 bytes 1 [emitted] vendor | ||
runtime.js 5.94 kB 2 [emitted] runtime | ||
chunk {0} app.js (app) 185 bytes {1} [initial] [rendered] | ||
[./entry-1.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-1.js 67 bytes {0} [built] | ||
[./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] | ||
[./submodule-b.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-b.js 59 bytes {0} [built] | ||
chunk {1} vendor.bd2b4219dfda1a951495.js (vendor) 87 bytes {2} [initial] [rendered] | ||
[./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] | ||
chunk {2} runtime.js (runtime) 0 bytes [entry] [rendered] | ||
Child | ||
Hash: 2897fe6052020598632c | ||
Time: Xms | ||
Asset Size Chunks Chunk Names | ||
app.js 1.32 kB 0 [emitted] app | ||
vendor.bd2b4219dfda1a951495.js 443 bytes 1 [emitted] vendor | ||
runtime.js 5.94 kB 2 [emitted] runtime | ||
chunk {0} app.js (app) 192 bytes {1} [initial] [rendered] | ||
[./entry-2.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-2.js 67 bytes {0} [built] | ||
[./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] | ||
[./submodule-c.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-c.js 66 bytes {0} [built] | ||
chunk {1} vendor.bd2b4219dfda1a951495.js (vendor) 87 bytes {2} [initial] [rendered] | ||
[./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] | ||
chunk {2} runtime.js (runtime) 0 bytes [entry] [rendered] |
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,3 @@ | ||
import d, { a } from './constants'; | ||
|
||
export default d + a; |
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,3 @@ | ||
import { b, c } from './constants'; | ||
|
||
export default b + c; |
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,3 @@ | ||
import { a, b, c } from './constants'; | ||
|
||
export default a + b + c; |
35 changes: 35 additions & 0 deletions
35
test/statsCases/commons-plugin-issue-4980/webpack.config.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,35 @@ | ||
var CommonsChunkPlugin = require("../../../lib/optimize/CommonsChunkPlugin"); | ||
var NamedModulesPlugin = require("../../../lib/NamedModulesPlugin"); | ||
|
||
// should generate vendor chunk with the same chunkhash for both entries | ||
module.exports = [{ | ||
entry: { | ||
app: "./entry-1.js" | ||
}, | ||
plugins: [ | ||
new NamedModulesPlugin(), | ||
new CommonsChunkPlugin({ | ||
name: "vendor", | ||
filename: "[name].[chunkhash].js", | ||
minChunks: m => /constants/.test(m.resource) | ||
}), | ||
new CommonsChunkPlugin({ | ||
name: "runtime" | ||
}) | ||
] | ||
},{ | ||
entry: { | ||
app: "./entry-2.js" | ||
}, | ||
plugins: [ | ||
new NamedModulesPlugin(), | ||
new CommonsChunkPlugin({ | ||
name: "vendor", | ||
filename: "[name].[chunkhash].js", | ||
minChunks: m => /constants/.test(m.resource) | ||
}), | ||
new CommonsChunkPlugin({ | ||
name: "runtime" | ||
}) | ||
] | ||
}]; |
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 |
---|---|---|
|
@@ -1029,7 +1029,7 @@ destroy@~1.0.4: | |
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" | ||
|
||
[email protected]: | ||
[email protected], diff@^3.1.0: | ||
version "3.2.0" | ||
resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" | ||
|
||
|
@@ -1500,11 +1500,11 @@ form-data@~2.1.1: | |
combined-stream "^1.0.5" | ||
mime-types "^2.1.12" | ||
|
||
formatio@1.1.1: | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" | ||
formatio@1.2.0: | ||
version "1.2.0" | ||
resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.2.0.tgz#f3b2167d9068c4698a8d51f4f760a39a54d818eb" | ||
dependencies: | ||
samsam "~1.1" | ||
samsam "1.x" | ||
|
||
forwarded@~0.1.0: | ||
version "0.1.0" | ||
|
@@ -2371,9 +2371,9 @@ [email protected], log-driver@^1.x: | |
version "1.2.5" | ||
resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" | ||
|
||
lolex@1.3.2: | ||
version "1.3.2" | ||
resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" | ||
lolex@^1.6.0: | ||
version "1.6.0" | ||
resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.6.0.tgz#3a9a0283452a47d7439e72731b9e07d7386e49f6" | ||
|
||
longest@^1.0.1: | ||
version "1.0.1" | ||
|
@@ -2541,6 +2541,10 @@ nan@^2.3.0: | |
version "2.6.2" | ||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" | ||
|
||
native-promise-only@^0.8.1: | ||
version "0.8.1" | ||
resolved "https://registry.yarnpkg.com/native-promise-only/-/native-promise-only-0.8.1.tgz#20a318c30cb45f71fe7adfbf7b21c99c1472ef11" | ||
|
||
natural-compare@^1.4.0: | ||
version "1.4.0" | ||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" | ||
|
@@ -2823,6 +2827,12 @@ [email protected]: | |
version "0.1.7" | ||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" | ||
|
||
path-to-regexp@^1.7.0: | ||
version "1.7.0" | ||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d" | ||
dependencies: | ||
isarray "0.0.1" | ||
|
||
path-type@^1.0.0: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" | ||
|
@@ -3551,9 +3561,9 @@ safe-buffer@^5.0.1: | |
version "5.0.1" | ||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" | ||
|
||
samsam@1.1.2, samsam@~1.1: | ||
version "1.1.2" | ||
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" | ||
samsam@1.x, samsam@^1.1.3: | ||
version "1.2.1" | ||
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.2.1.tgz#edd39093a3184370cb859243b2bdf255e7d8ea67" | ||
|
||
sax@~1.2.1: | ||
version "1.2.2" | ||
|
@@ -3693,14 +3703,18 @@ simple-git@^1.65.0: | |
dependencies: | ||
debug "^2.6.7" | ||
|
||
sinon@^1.17.7: | ||
version "1.17.7" | ||
resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" | ||
sinon@^2.3.2: | ||
version "2.3.2" | ||
resolved "https://registry.yarnpkg.com/sinon/-/sinon-2.3.2.tgz#c43a9c570f32baac1159505cfeed19108855df89" | ||
dependencies: | ||
formatio "1.1.1" | ||
lolex "1.3.2" | ||
samsam "1.1.2" | ||
util ">=0.10.3 <1" | ||
diff "^3.1.0" | ||
formatio "1.2.0" | ||
lolex "^1.6.0" | ||
native-promise-only "^0.8.1" | ||
path-to-regexp "^1.7.0" | ||
samsam "^1.1.3" | ||
text-encoding "0.6.4" | ||
type-detect "^4.0.0" | ||
|
||
[email protected]: | ||
version "0.0.4" | ||
|
@@ -3969,6 +3983,10 @@ tar@^2.2.1: | |
fstream "^1.0.2" | ||
inherits "2" | ||
|
||
[email protected]: | ||
version "0.6.4" | ||
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" | ||
|
||
text-table@~0.2.0: | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" | ||
|
@@ -4035,6 +4053,10 @@ type-check@~0.3.2: | |
dependencies: | ||
prelude-ls "~1.1.2" | ||
|
||
type-detect@^4.0.0: | ||
version "4.0.3" | ||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.3.tgz#0e3f2670b44099b0b46c284d136a7ef49c74c2ea" | ||
|
||
type-is@~1.6.6: | ||
version "1.6.15" | ||
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" | ||
|
@@ -4122,7 +4144,7 @@ util-deprecate@~1.0.1: | |
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" | ||
|
||
[email protected], "util@>=0.10.3 <1", util@^0.10.3: | ||
[email protected], util@^0.10.3: | ||
version "0.10.3" | ||
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" | ||
dependencies: | ||
|