Skip to content

Commit a2eada1

Browse files
committed
Merge branch 'master' into next
# Conflicts: # lib/BannerPlugin.js
2 parents ebab3e0 + 33f518b commit a2eada1

File tree

36 files changed

+152
-44
lines changed

36 files changed

+152
-44
lines changed

lib/BannerPlugin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ class BannerPlugin {
5353
query = filename.substr(querySplit);
5454
filename = filename.substr(0, querySplit);
5555
}
56-
basename = filename.includes("/") ?
57-
filename.substr(filename.lastIndexOf("/") + 1) :
58-
filename;
56+
57+
const lastSlashIndex = filename.lastIndexOf("/");
58+
59+
if(lastSlashIndex === -1) {
60+
basename = filename;
61+
} else {
62+
basename = filename.substr(lastSlashIndex + 1);
63+
}
5964

6065
const comment = compilation.getPath(banner, {
6166
hash,

lib/TemplatedPathPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ class TemplatedPathPlugin {
104104
const outputOptions = mainTemplate.outputOptions;
105105
const chunkFilename = outputOptions.chunkFilename || outputOptions.filename;
106106
if(REGEXP_CHUNKHASH_FOR_TEST.test(chunkFilename))
107-
hash.update(JSON.stringify(chunk.getChunkMaps(true, true).hash));
107+
hash.update(JSON.stringify(chunk.getChunkMaps(false, true).hash));
108108
if(REGEXP_NAME_FOR_TEST.test(chunkFilename))
109-
hash.update(JSON.stringify(chunk.getChunkMaps(true, true).name));
109+
hash.update(JSON.stringify(chunk.getChunkMaps(false, true).name));
110110
});
111111
});
112112
}

test/WatchTestCases.test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ describe("WatchTestCases", () => {
163163
return test;
164164
}
165165

166+
const globalContext = {
167+
console: console
168+
};
169+
166170
function _require(currentDirectory, module) {
167171
if(Array.isArray(module) || /^\.\.?\//.test(module)) {
168172
let fn;
@@ -178,11 +182,15 @@ describe("WatchTestCases", () => {
178182
p = path.join(currentDirectory, module);
179183
content = fs.readFileSync(p, "utf-8");
180184
}
181-
fn = vm.runInThisContext("(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE) {" + content + "\n})", p);
185+
if(options.target === "web" || options.target === "webworker") {
186+
fn = vm.runInNewContext("(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE, window) {" + content + "\n})", globalContext, p);
187+
} else {
188+
fn = vm.runInThisContext("(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE) {" + content + "\n})", p);
189+
}
182190
const m = {
183191
exports: {}
184192
};
185-
fn.call(m.exports, _require.bind(null, path.dirname(p)), m, m.exports, path.dirname(p), p, _it, run.name, jsonStats, state);
193+
fn.call(m.exports, _require.bind(null, path.dirname(p)), m, m.exports, path.dirname(p), p, _it, run.name, jsonStats, state, globalContext);
186194
return module.exports;
187195
} else if(testConfig.modules && module in testConfig.modules) {
188196
return testConfig.modules[module];
@@ -196,7 +204,7 @@ describe("WatchTestCases", () => {
196204
} catch(e) {}
197205

198206
if(testConfig.noTests) return process.nextTick(done);
199-
_require(outputDirectory, "./bundle.js");
207+
_require(outputDirectory, testConfig.bundlePath || "./bundle.js");
200208

201209
if(exportedTests < 1) return done(new Error("No tests exported by test case"));
202210
runIdx++;

test/statsCases/aggressive-splitting-entry/expected.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
Hash: e3da7f19fc8db8fea5d9e3da7f19fc8db8fea5d9
1+
Hash: 1d3bfcee111df03fa6251d3bfcee111df03fa625
22
Child fitting:
3-
Hash: e3da7f19fc8db8fea5d9
3+
Hash: 1d3bfcee111df03fa625
44
Time: Xms
55
Asset Size Chunks Chunk Names
66
706f97eb6a2b8fb1a17e.js 1.05 KiB 0 [emitted]
7-
3e99eb0cb296524693dd.js 9.92 KiB 1 [emitted]
7+
a65f8652fd07c12d0049.js 9.92 KiB 1 [emitted]
88
4c485a9e1dc58eedfbd1.js 1.94 KiB 2 [emitted]
99
337c857e3e34cc5ef72d.js 1.94 KiB 3 [emitted]
10-
Entrypoint main = 4c485a9e1dc58eedfbd1.js 337c857e3e34cc5ef72d.js 3e99eb0cb296524693dd.js
10+
Entrypoint main = 4c485a9e1dc58eedfbd1.js 337c857e3e34cc5ef72d.js a65f8652fd07c12d0049.js
1111
chunk {0} 706f97eb6a2b8fb1a17e.js 916 bytes <{2}> <{3}> <{1}>
1212
> ./g [4] ./index.js 7:0-13
1313
[7] ./g.js 916 bytes {0} [built]
14-
chunk {1} 3e99eb0cb296524693dd.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
14+
chunk {1} a65f8652fd07c12d0049.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
1515
> ./index main
1616
[3] ./e.js 899 bytes {1} [built]
1717
[4] ./index.js 111 bytes {1} [built]
@@ -25,18 +25,18 @@ Child fitting:
2525
[1] ./c.js 899 bytes {3} [built]
2626
[2] ./d.js 899 bytes {3} [built]
2727
Child content-change:
28-
Hash: e3da7f19fc8db8fea5d9
28+
Hash: 1d3bfcee111df03fa625
2929
Time: Xms
3030
Asset Size Chunks Chunk Names
3131
706f97eb6a2b8fb1a17e.js 1.05 KiB 0 [emitted]
32-
3e99eb0cb296524693dd.js 9.92 KiB 1 [emitted]
32+
a65f8652fd07c12d0049.js 9.92 KiB 1 [emitted]
3333
4c485a9e1dc58eedfbd1.js 1.94 KiB 2 [emitted]
3434
337c857e3e34cc5ef72d.js 1.94 KiB 3 [emitted]
35-
Entrypoint main = 4c485a9e1dc58eedfbd1.js 337c857e3e34cc5ef72d.js 3e99eb0cb296524693dd.js
35+
Entrypoint main = 4c485a9e1dc58eedfbd1.js 337c857e3e34cc5ef72d.js a65f8652fd07c12d0049.js
3636
chunk {0} 706f97eb6a2b8fb1a17e.js 916 bytes <{2}> <{3}> <{1}>
3737
> ./g [4] ./index.js 7:0-13
3838
[7] ./g.js 916 bytes {0} [built]
39-
chunk {1} 3e99eb0cb296524693dd.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
39+
chunk {1} a65f8652fd07c12d0049.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
4040
> ./index main
4141
[3] ./e.js 899 bytes {1} [built]
4242
[4] ./index.js 111 bytes {1} [built]

test/statsCases/color-disabled/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hash: 8a0ebb916aaf99067211
1+
Hash: 5ebdffcace96139575ac
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
main.js 2.61 KiB 0 [emitted] main

test/statsCases/color-enabled-custom/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hash: <CLR=BOLD>8a0ebb916aaf99067211</CLR>
1+
Hash: <CLR=BOLD>5ebdffcace96139575ac</CLR>
22
Time: <CLR=BOLD>X</CLR>ms
33
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=39,BOLD><CLR=22><CLR=BOLD>Chunk Names</CLR>
44
<CLR=32>main.js</CLR> 2.61 KiB <CLR=BOLD>0</CLR> <CLR=32>[emitted]</CLR> main

test/statsCases/color-enabled/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hash: <CLR=BOLD>8a0ebb916aaf99067211</CLR>
1+
Hash: <CLR=BOLD>5ebdffcace96139575ac</CLR>
22
Time: <CLR=BOLD>X</CLR>ms
33
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=39,BOLD><CLR=22><CLR=BOLD>Chunk Names</CLR>
44
<CLR=32,BOLD>main.js</CLR> 2.61 KiB <CLR=BOLD>0</CLR> <CLR=32,BOLD>[emitted]</CLR> main

test/statsCases/commons-chunk-min-size-0/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hash: d7afa670e5077df305a3
1+
Hash: 2a374ac6d98475951384
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
entry-1.js 5.49 KiB 0 [emitted] entry-1

test/statsCases/commons-chunk-min-size-Infinity/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hash: 0ffa64fb9bd6d9e9dce0
1+
Hash: d86d9e4d7a615c762442
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
entry-1.js 5.49 KiB 0 [emitted] entry-1

test/statsCases/commons-plugin-issue-4980/expected.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Hash: aa788836a27320e9e2c82a1426a570619ab0713a
1+
Hash: cdd753ac70c5ff3b74bedd7e476c27a1777b4d27
22
Child
3-
Hash: aa788836a27320e9e2c8
3+
Hash: cdd753ac70c5ff3b74be
44
Time: Xms
55
Asset Size Chunks Chunk Names
66
app.js 5.58 KiB 0 [emitted] app
@@ -12,7 +12,7 @@ Child
1212
| ./submodule-a.js 59 bytes [built]
1313
| ./submodule-b.js 59 bytes [built]
1414
Child
15-
Hash: 2a1426a570619ab0713a
15+
Hash: dd7e476c27a1777b4d27
1616
Time: Xms
1717
Asset Size Chunks Chunk Names
1818
app.js 5.6 KiB 0 [emitted] app

0 commit comments

Comments
 (0)