Skip to content

Commit

Permalink
more tests and fixes for webworker
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Mar 26, 2018
1 parent 06e9a57 commit b018bc7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 19 deletions.
38 changes: 19 additions & 19 deletions lib/webworker/WebWorkerMainTemplatePlugin.js
Expand Up @@ -51,27 +51,27 @@ class WebWorkerMainTemplatePlugin {
length
)} + "`,
chunk: {
id: '" + chunkId + "'
},
contentHash: {
javascript: `" + ${JSON.stringify(
chunkMaps.contentHash.javascript
)}[chunkId] + "`
},
contentHashWithLength: {
javascript: length => {
const shortContentHashMap = {};
const contentHash = chunkMaps.contentHash.javascript;
for (const chunkId of Object.keys(contentHash)) {
if (typeof contentHash[chunkId] === "string") {
shortContentHashMap[chunkId] = contentHash[
chunkId
].substr(0, length);
id: '" + chunkId + "',
contentHash: {
javascript: `" + ${JSON.stringify(
chunkMaps.contentHash.javascript
)}[chunkId] + "`
},
contentHashWithLength: {
javascript: length => {
const shortContentHashMap = {};
const contentHash = chunkMaps.contentHash.javascript;
for (const chunkId of Object.keys(contentHash)) {
if (typeof contentHash[chunkId] === "string") {
shortContentHashMap[chunkId] = contentHash[
chunkId
].substr(0, length);
}
}
return `" + ${JSON.stringify(
shortContentHashMap
)}[chunkId] + "`;
}
return `" + ${JSON.stringify(
shortContentHashMap
)}[chunkId] + "`;
}
},
contentHashType: "javascript"
Expand Down
Expand Up @@ -47,5 +47,6 @@ module.exports = {
},
afterExecute: () => {
delete global.webpackJsonp;
delete global.webpackChunk;
}
};
28 changes: 28 additions & 0 deletions test/configCases/hash-length/output-filename/webpack.config.js
Expand Up @@ -191,6 +191,34 @@ module.exports = [
expectedFilenameLength: 9 + 7 + 3,
expectedChunkFilenameLength: 2 + 9 + 7 + 3
}
},
{
name: "contenthash in webpack",
entry: "./no-async",
output: {
filename: "bundle16.[contenthash].js",
chunkFilename: "[id].bundle16.[contenthash].js",
globalObject: "this"
},
target: "webworker",
amd: {
expectedFilenameLength: 32,
expectedChunkFilenameLength: 34
}
},
{
name: "contenthash in async-node with length",
entry: "./no-async",
output: {
filename: "bundle17.[contenthash:7].js",
chunkFilename: "[id].bundle17.[contenthash:7].js",
globalObject: "this"
},
target: "webworker",
amd: {
expectedFilenameLength: 9 + 7 + 3,
expectedChunkFilenameLength: 2 + 9 + 7 + 3
}
}
];

Expand Down

0 comments on commit b018bc7

Please sign in to comment.